
if(typeof(SK)=='undefined')SK={};var sk_namespaces=["SK.Env","SK.Obj","SK.Singletons","SK.UI","SK.UI.Arrangement","SK.UI.Help","SK.Util","SK.Const","SK.Actions.Common"];for(var i=0;i<sk_namespaces.length;i++){var nsp=sk_namespaces[i];var nsp_elements=nsp.split('.');var nsp_prefix_arr=[];for(var j=0;j<nsp_elements.length;j++){var nsp_element=nsp_elements[j];var prefix=this.nsp_prefix_arr.length>0?this.nsp_prefix_arr.join(".")+".":"";var nsp_str=prefix+nsp_element;if(typeof(eval(nsp_str))=='undefined'){eval(nsp_str+' = {};');}
nsp_prefix_arr.push(nsp_element);}}


SK.Env=function(options){this.options=options;this.get=function(key){if(typeof this.options[key]=='undefined')return"";return this.options[key];}
this.set=function(key,value){this.options[key]=value;}
this.setMultiple=function(options){for(var i in options){if($defined(this.options[i])){this.options[i]=SK.Util.merge(this.options[i],options[i]);}else{this.options[i]=options[i];}}}}
SK.Singletons.env=new SK.Env({});


var MooTools={'version':'1.2.5','build':'008d8f0f2fcc2044e54fdd3635341aaab274e757'};var Native=function(options){options=options||{};var name=options.name;var legacy=options.legacy;var protect=options.protect;var methods=options.implement;var generics=options.generics;var initialize=options.initialize;var afterImplement=options.afterImplement||function(){};var object=initialize||legacy;generics=generics!==false;object.constructor=Native;object.$family={name:'native'};if(legacy&&initialize)object.prototype=legacy.prototype;object.prototype.constructor=object;if(name){var family=name.toLowerCase();object.prototype.$family={name:family};Native.typize(object,family);}
var add=function(obj,name,method,force){if(!protect||force||!obj.prototype[name])obj.prototype[name]=method;if(generics)Native.genericize(obj,name,protect);afterImplement.call(obj,name,method);return obj;};object.alias=function(a1,a2,a3){if(typeof a1=='string'){var pa1=this.prototype[a1];if((a1=pa1))return add(this,a2,a1,a3);}
for(var a in a1)this.alias(a,a1[a],a2);return this;};object.implement=function(a1,a2,a3){if(typeof a1=='string')return add(this,a1,a2,a3);for(var p in a1)add(this,p,a1[p],a2);return this;};if(methods)object.implement(methods);return object;};Native.genericize=function(object,property,check){if((!check||!object[property])&&typeof object.prototype[property]=='function')object[property]=function(){var args=Array.prototype.slice.call(arguments);return object.prototype[property].apply(args.shift(),args);};};Native.implement=function(objects,properties){for(var i=0,l=objects.length;i<l;i++)objects[i].implement(properties);};Native.typize=function(object,family){if(!object.type)object.type=function(item){return($type(item)===family);};};(function(){var natives={'Array':Array,'Date':Date,'Function':Function,'Number':Number,'RegExp':RegExp,'String':String};for(var n in natives)new Native({name:n,initialize:natives[n],protect:true});var types={'boolean':Boolean,'native':Native,'object':Object};for(var t in types)Native.typize(types[t],t);var generics={'Array':["concat","indexOf","join","lastIndexOf","pop","push","reverse","shift","slice","sort","splice","toString","unshift","valueOf"],'String':["charAt","charCodeAt","concat","indexOf","lastIndexOf","match","replace","search","slice","split","substr","substring","toLowerCase","toUpperCase","valueOf"]};for(var g in generics){for(var i=generics[g].length;i--;)Native.genericize(natives[g],generics[g][i],true);}})();var Hash=new Native({name:'Hash',initialize:function(object){if($type(object)=='hash')object=$unlink(object.getClean());for(var key in object)this[key]=object[key];return this;}});Hash.implement({forEach:function(fn,bind){for(var key in this){if(this.hasOwnProperty(key))fn.call(bind,this[key],key,this);}},getClean:function(){var clean={};for(var key in this){if(this.hasOwnProperty(key))clean[key]=this[key];}
return clean;},getLength:function(){var length=0;for(var key in this){if(this.hasOwnProperty(key))length++;}
return length;}});Hash.alias('forEach','each');Array.implement({forEach:function(fn,bind){for(var i=0,l=this.length;i<l;i++)fn.call(bind,this[i],i,this);}});Array.alias('forEach','each');function $A(iterable){if(iterable.item){var l=iterable.length,array=new Array(l);while(l--)array[l]=iterable[l];return array;}
return Array.prototype.slice.call(iterable);};function $arguments(i){return function(){return arguments[i];};};function $chk(obj){return!!(obj||obj===0);};function $clear(timer){clearTimeout(timer);clearInterval(timer);return null;};function $defined(obj){return(obj!=undefined);};function $each(iterable,fn,bind){var type=$type(iterable);((type=='arguments'||type=='collection'||type=='array')?Array:Hash).each(iterable,fn,bind);};function $empty(){};function $extend(original,extended){for(var key in(extended||{}))original[key]=extended[key];return original;};function $H(object){return new Hash(object);};function $lambda(value){return($type(value)=='function')?value:function(){return value;};};function $merge(){var args=Array.slice(arguments);args.unshift({});return $mixin.apply(null,args);};function $mixin(mix){for(var i=1,l=arguments.length;i<l;i++){var object=arguments[i];if($type(object)!='object')continue;for(var key in object){var op=object[key],mp=mix[key];mix[key]=(mp&&$type(op)=='object'&&$type(mp)=='object')?$mixin(mp,op):$unlink(op);}}
return mix;};function $pick(){for(var i=0,l=arguments.length;i<l;i++){if(arguments[i]!=undefined)return arguments[i];}
return null;};function $random(min,max){return Math.floor(Math.random()*(max-min+1)+min);};function $splat(obj){var type=$type(obj);return(type)?((type!='array'&&type!='arguments')?[obj]:obj):[];};var $time=Date.now||function(){return+new Date;};function $try(){for(var i=0,l=arguments.length;i<l;i++){try{return arguments[i]();}catch(e){}}
return null;};function $type(obj){if(obj==undefined)return false;if(obj.$family)return(obj.$family.name=='number'&&!isFinite(obj))?false:obj.$family.name;if(obj.nodeName){switch(obj.nodeType){case 1:return'element';case 3:return(/\S/).test(obj.nodeValue)?'textnode':'whitespace';}}else if(typeof obj.length=='number'){if(obj.callee)return'arguments';else if(obj.item)return'collection';}
return typeof obj;};function $unlink(object){var unlinked;switch($type(object)){case'object':unlinked={};for(var p in object)unlinked[p]=$unlink(object[p]);break;case'hash':unlinked=new Hash(object);break;case'array':unlinked=[];for(var i=0,l=object.length;i<l;i++)unlinked[i]=$unlink(object[i]);break;default:return object;}
return unlinked;};Array.implement({every:function(fn,bind){for(var i=0,l=this.length;i<l;i++){if(!fn.call(bind,this[i],i,this))return false;}
return true;},filter:function(fn,bind){var results=[];for(var i=0,l=this.length;i<l;i++){if(fn.call(bind,this[i],i,this))results.push(this[i]);}
return results;},clean:function(){return this.filter($defined);},indexOf:function(item,from){var len=this.length;for(var i=(from<0)?Math.max(0,len+from):from||0;i<len;i++){if(this[i]===item)return i;}
return-1;},map:function(fn,bind){var results=[];for(var i=0,l=this.length;i<l;i++)results[i]=fn.call(bind,this[i],i,this);return results;},some:function(fn,bind){for(var i=0,l=this.length;i<l;i++){if(fn.call(bind,this[i],i,this))return true;}
return false;},associate:function(keys){var obj={},length=Math.min(this.length,keys.length);for(var i=0;i<length;i++)obj[keys[i]]=this[i];return obj;},link:function(object){var result={};for(var i=0,l=this.length;i<l;i++){for(var key in object){if(object[key](this[i])){result[key]=this[i];delete object[key];break;}}}
return result;},contains:function(item,from){return this.indexOf(item,from)!=-1;},extend:function(array){for(var i=0,j=array.length;i<j;i++)this.push(array[i]);return this;},getLast:function(){return(this.length)?this[this.length-1]:null;},getRandom:function(){return(this.length)?this[$random(0,this.length-1)]:null;},include:function(item){if(!this.contains(item))this.push(item);return this;},combine:function(array){for(var i=0,l=array.length;i<l;i++)this.include(array[i]);return this;},erase:function(item){for(var i=this.length;i--;i){if(this[i]===item)this.splice(i,1);}
return this;},empty:function(){this.length=0;return this;},flatten:function(){var array=[];for(var i=0,l=this.length;i<l;i++){var type=$type(this[i]);if(!type)continue;array=array.concat((type=='array'||type=='collection'||type=='arguments')?Array.flatten(this[i]):this[i]);}
return array;},hexToRgb:function(array){if(this.length!=3)return null;var rgb=this.map(function(value){if(value.length==1)value+=value;return value.toInt(16);});return(array)?rgb:'rgb('+rgb+')';},rgbToHex:function(array){if(this.length<3)return null;if(this.length==4&&this[3]==0&&!array)return'transparent';var hex=[];for(var i=0;i<3;i++){var bit=(this[i]-0).toString(16);hex.push((bit.length==1)?'0'+bit:bit);}
return(array)?hex:'#'+hex.join('');}});String.implement({test:function(regex,params){return((typeof regex=='string')?new RegExp(regex,params):regex).test(this);},contains:function(string,separator){return(separator)?(separator+this+separator).indexOf(separator+string+separator)>-1:this.indexOf(string)>-1;},trim:function(){return this.replace(/^\s+|\s+$/g,'');},clean:function(){return this.replace(/\s+/g,' ').trim();},camelCase:function(){return this.replace(/-\D/g,function(match){return match.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(match){return('-'+match.charAt(0).toLowerCase());});},capitalize:function(){return this.replace(/\b[a-z]/g,function(match){return match.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,'\\$1');},toInt:function(base){return parseInt(this,base||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(array){var hex=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);return(hex)?hex.slice(1).hexToRgb(array):null;},rgbToHex:function(array){var rgb=this.match(/\d{1,3}/g);return(rgb)?rgb.rgbToHex(array):null;},stripScripts:function(option){var scripts='';var text=this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi,function(){scripts+=arguments[1]+'\n';return'';});if(option===true)$exec(scripts);else if($type(option)=='function')option(scripts,text);return text;},substitute:function(object,regexp){return this.replace(regexp||(/\\?\{([^{}]+)\}/g),function(match,name){if(match.charAt(0)=='\\')return match.slice(1);return(object[name]!=undefined)?object[name]:'';});}});try{delete Function.prototype.bind;}catch(e){}
Function.implement({extend:function(properties){for(var property in properties)this[property]=properties[property];return this;},create:function(options){var self=this;options=options||{};return function(event){var args=options.arguments;args=(args!=undefined)?$splat(args):Array.slice(arguments,(options.event)?1:0);if(options.event)args=[event||window.event].extend(args);var returns=function(){return self.apply(options.bind||null,args);};if(options.delay)return setTimeout(returns,options.delay);if(options.periodical)return setInterval(returns,options.periodical);if(options.attempt)return $try(returns);return returns();};},run:function(args,bind){return this.apply(bind,$splat(args));},pass:function(args,bind){return this.create({bind:bind,arguments:args});},bind:function(bind,args){return this.create({bind:bind,arguments:args});},bindWithEvent:function(bind,args){return this.create({bind:bind,arguments:args,event:true});},attempt:function(args,bind){return this.create({bind:bind,arguments:args,attempt:true})();},delay:function(delay,bind,args){return this.create({bind:bind,arguments:args,delay:delay})();},periodical:function(periodical,bind,args){return this.create({bind:bind,arguments:args,periodical:periodical})();}});Number.implement({limit:function(min,max){return Math.min(max,Math.max(min,this));},round:function(precision){precision=Math.pow(10,precision||0);return Math.round(this*precision)/precision;},times:function(fn,bind){for(var i=0;i<this;i++)fn.call(bind,i,this);},toFloat:function(){return parseFloat(this);},toInt:function(base){return parseInt(this,base||10);}});Number.alias('times','each');(function(math){var methods={};math.each(function(name){if(!Number[name])methods[name]=function(){return Math[name].apply(null,[this].concat($A(arguments)));};});Number.implement(methods);})(['abs','acos','asin','atan','atan2','ceil','cos','exp','floor','log','max','min','pow','sin','sqrt','tan']);Hash.implement({has:Object.prototype.hasOwnProperty,keyOf:function(value){for(var key in this){if(this.hasOwnProperty(key)&&this[key]===value)return key;}
return null;},hasValue:function(value){return(Hash.keyOf(this,value)!==null);},extend:function(properties){Hash.each(properties||{},function(value,key){Hash.set(this,key,value);},this);return this;},combine:function(properties){Hash.each(properties||{},function(value,key){Hash.include(this,key,value);},this);return this;},erase:function(key){if(this.hasOwnProperty(key))delete this[key];return this;},get:function(key){return(this.hasOwnProperty(key))?this[key]:null;},set:function(key,value){if(!this[key]||this.hasOwnProperty(key))this[key]=value;return this;},empty:function(){Hash.each(this,function(value,key){delete this[key];},this);return this;},include:function(key,value){if(this[key]==undefined)this[key]=value;return this;},map:function(fn,bind){var results=new Hash;Hash.each(this,function(value,key){results.set(key,fn.call(bind,value,key,this));},this);return results;},filter:function(fn,bind){var results=new Hash;Hash.each(this,function(value,key){if(fn.call(bind,value,key,this))results.set(key,value);},this);return results;},every:function(fn,bind){for(var key in this){if(this.hasOwnProperty(key)&&!fn.call(bind,this[key],key))return false;}
return true;},some:function(fn,bind){for(var key in this){if(this.hasOwnProperty(key)&&fn.call(bind,this[key],key))return true;}
return false;},getKeys:function(){var keys=[];Hash.each(this,function(value,key){keys.push(key);});return keys;},getValues:function(){var values=[];Hash.each(this,function(value){values.push(value);});return values;},toQueryString:function(base){var queryString=[];Hash.each(this,function(value,key){if(base)key=base+'['+key+']';var result;switch($type(value)){case'object':result=Hash.toQueryString(value,key);break;case'array':var qs={};value.each(function(val,i){qs[i]=val;});result=Hash.toQueryString(qs,key);break;default:result=key+'='+encodeURIComponent(value);}
if(value!=undefined)queryString.push(result);});return queryString.join('&');}});Hash.alias({keyOf:'indexOf',hasValue:'contains'});function Class(params){if(params instanceof Function)params={initialize:params};var newClass=function(){Object.reset(this);if(newClass._prototyping)return this;this._current=$empty;var value=(this.initialize)?this.initialize.apply(this,arguments):this;delete this._current;delete this.caller;return value;}.extend(this);newClass.implement(params);newClass.constructor=Class;newClass.prototype.constructor=newClass;return newClass;};Function.prototype.protect=function(){this._protected=true;return this;};Object.reset=function(object,key){if(key==null){for(var p in object)Object.reset(object,p);return object;}
delete object[key];switch($type(object[key])){case'object':var F=function(){};F.prototype=object[key];var i=new F;object[key]=Object.reset(i);break;case'array':object[key]=$unlink(object[key]);break;}
return object;};new Native({name:'Class',initialize:Class}).extend({instantiate:function(F){F._prototyping=true;var proto=new F;delete F._prototyping;return proto;},wrap:function(self,key,method){if(method._origin)method=method._origin;return function(){if(method._protected&&this._current==null)throw new Error('The method "'+key+'" cannot be called.');var caller=this.caller,current=this._current;this.caller=current;this._current=arguments.callee;var result=method.apply(this,arguments);this._current=current;this.caller=caller;return result;}.extend({_owner:self,_origin:method,_name:key});}});Class.implement({implement:function(key,value){if($type(key)=='object'){for(var p in key)this.implement(p,key[p]);return this;}
var mutator=Class.Mutators[key];if(mutator){value=mutator.call(this,value);if(value==null)return this;}
var proto=this.prototype;switch($type(value)){case'function':if(value._hidden)return this;proto[key]=Class.wrap(this,key,value);break;case'object':var previous=proto[key];if($type(previous)=='object')$mixin(previous,value);else proto[key]=$unlink(value);break;case'array':proto[key]=$unlink(value);break;default:proto[key]=value;}
return this;}});Class.Mutators={Extends:function(parent){this.parent=parent;this.prototype=Class.instantiate(parent);this.implement('parent',function(){var name=this.caller._name,previous=this.caller._owner.parent.prototype[name];if(!previous)throw new Error('The method "'+name+'" has no parent.');return previous.apply(this,arguments);}.protect());},Implements:function(items){$splat(items).each(function(item){if(item instanceof Function)item=Class.instantiate(item);this.implement(item);},this);}};var Chain=new Class({$chain:[],chain:function(){this.$chain.extend(Array.flatten(arguments));return this;},callChain:function(){return(this.$chain.length)?this.$chain.shift().apply(this,arguments):false;},clearChain:function(){this.$chain.empty();return this;}});var Events=new Class({$events:{},addEvent:function(type,fn,internal){type=Events.removeOn(type);if(fn!=$empty){this.$events[type]=this.$events[type]||[];this.$events[type].include(fn);if(internal)fn.internal=true;}
return this;},addEvents:function(events){for(var type in events)this.addEvent(type,events[type]);return this;},fireEvent:function(type,args,delay){type=Events.removeOn(type);if(!this.$events||!this.$events[type])return this;this.$events[type].each(function(fn){fn.create({'bind':this,'delay':delay,'arguments':args})();},this);return this;},removeEvent:function(type,fn){type=Events.removeOn(type);if(!this.$events[type])return this;if(!fn.internal)this.$events[type].erase(fn);return this;},removeEvents:function(events){var type;if($type(events)=='object'){for(type in events)this.removeEvent(type,events[type]);return this;}
if(events)events=Events.removeOn(events);for(type in this.$events){if(events&&events!=type)continue;var fns=this.$events[type];for(var i=fns.length;i--;i)this.removeEvent(type,fns[i]);}
return this;}});Events.removeOn=function(string){return string.replace(/^on([A-Z])/,function(full,first){return first.toLowerCase();});};var Options=new Class({setOptions:function(){this.options=$merge.run([this.options].extend(arguments));if(!this.addEvent)return this;for(var option in this.options){if($type(this.options[option])!='function'||!(/^on[A-Z]/).test(option))continue;this.addEvent(option,this.options[option]);delete this.options[option];}
return this;}});var Browser=$merge({Engine:{name:'unknown',version:0},Platform:{name:(window.orientation!=undefined)?'ipod':(navigator.platform.match(/mac|win|linux/i)||['other'])[0].toLowerCase()},Features:{xpath:!!(document.evaluate),air:!!(window.runtime),query:!!(document.querySelector)},Plugins:{},Engines:{presto:function(){return(!window.opera)?false:((arguments.callee.caller)?960:((document.getElementsByClassName)?950:925));},trident:function(){return(!window.ActiveXObject)?false:((window.XMLHttpRequest)?((document.querySelectorAll)?6:5):4);},webkit:function(){return(navigator.taintEnabled)?false:((Browser.Features.xpath)?((Browser.Features.query)?525:420):419);},gecko:function(){return(!document.getBoxObjectFor&&window.mozInnerScreenX==null)?false:((document.getElementsByClassName)?19:18);}}},Browser||{});Browser.Platform[Browser.Platform.name]=true;Browser.detect=function(){for(var engine in this.Engines){var version=this.Engines[engine]();if(version){this.Engine={name:engine,version:version};this.Engine[engine]=this.Engine[engine+version]=true;break;}}
return{name:engine,version:version};};Browser.detect();Browser.Request=function(){return $try(function(){return new XMLHttpRequest();},function(){return new ActiveXObject('MSXML2.XMLHTTP');},function(){return new ActiveXObject('Microsoft.XMLHTTP');});};Browser.Features.xhr=!!(Browser.Request());Browser.Plugins.Flash=(function(){var version=($try(function(){return navigator.plugins['Shockwave Flash'].description;},function(){return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');})||'0 r0').match(/\d+/g);return{version:parseInt(version[0]||0+'.'+version[1],10)||0,build:parseInt(version[2],10)||0};})();function $exec(text){if(!text)return text;if(window.execScript){window.execScript(text);}else{var script=document.createElement('script');script.setAttribute('type','text/javascript');script[(Browser.Engine.webkit&&Browser.Engine.version<420)?'innerText':'text']=text;document.head.appendChild(script);document.head.removeChild(script);}
return text;};Native.UID=1;var $uid=(Browser.Engine.trident)?function(item){return(item.uid||(item.uid=[Native.UID++]))[0];}:function(item){return item.uid||(item.uid=Native.UID++);};var Window=new Native({name:'Window',legacy:(Browser.Engine.trident)?null:window.Window,initialize:function(win){$uid(win);if(!win.Element){win.Element=$empty;if(Browser.Engine.webkit)win.document.createElement("iframe");win.Element.prototype=(Browser.Engine.webkit)?window["[[DOMElement.prototype]]"]:{};}
win.document.window=win;return $extend(win,Window.Prototype);},afterImplement:function(property,value){window[property]=Window.Prototype[property]=value;}});Window.Prototype={$family:{name:'window'}};new Window(window);var Document=new Native({name:'Document',legacy:(Browser.Engine.trident)?null:window.Document,initialize:function(doc){$uid(doc);doc.head=doc.getElementsByTagName('head')[0];doc.html=doc.getElementsByTagName('html')[0];if(Browser.Engine.trident&&Browser.Engine.version<=4)$try(function(){doc.execCommand("BackgroundImageCache",false,true);});if(Browser.Engine.trident)doc.window.attachEvent('onunload',function(){doc.window.detachEvent('onunload',arguments.callee);doc.head=doc.html=doc.window=null;});return $extend(doc,Document.Prototype);},afterImplement:function(property,value){document[property]=Document.Prototype[property]=value;}});Document.Prototype={$family:{name:'document'}};new Document(document);var Element=new Native({name:'Element',legacy:window.Element,initialize:function(tag,props){var konstructor=Element.Constructors.get(tag);if(konstructor)return konstructor(props);if(typeof tag=='string')return document.newElement(tag,props);return document.id(tag).set(props);},afterImplement:function(key,value){Element.Prototype[key]=value;if(Array[key])return;Elements.implement(key,function(){var items=[],elements=true;for(var i=0,j=this.length;i<j;i++){var returns=this[i][key].apply(this[i],arguments);items.push(returns);if(elements)elements=($type(returns)=='element');}
return(elements)?new Elements(items):items;});}});Element.Prototype={$family:{name:'element'}};Element.Constructors=new Hash;var IFrame=new Native({name:'IFrame',generics:false,initialize:function(){var params=Array.link(arguments,{properties:Object.type,iframe:$defined});var props=params.properties||{};var iframe=document.id(params.iframe);var onload=props.onload||$empty;delete props.onload;props.id=props.name=$pick(props.id,props.name,iframe?(iframe.id||iframe.name):'IFrame_'+$time());iframe=new Element(iframe||'iframe',props);var onFrameLoad=function(){var host=$try(function(){return iframe.contentWindow.location.host;});if(!host||host==window.location.host){var win=new Window(iframe.contentWindow);new Document(iframe.contentWindow.document);$extend(win.Element.prototype,Element.Prototype);}
onload.call(iframe.contentWindow,iframe.contentWindow.document);};var contentWindow=$try(function(){return iframe.contentWindow;});((contentWindow&&contentWindow.document.body)||window.frames[props.id])?onFrameLoad():iframe.addListener('load',onFrameLoad);return iframe;}});var Elements=new Native({initialize:function(elements,options){options=$extend({ddup:true,cash:true},options);elements=elements||[];if(options.ddup||options.cash){var uniques={},returned=[];for(var i=0,l=elements.length;i<l;i++){var el=document.id(elements[i],!options.cash);if(options.ddup){if(uniques[el.uid])continue;uniques[el.uid]=true;}
if(el)returned.push(el);}
elements=returned;}
return(options.cash)?$extend(elements,this):elements;}});Elements.implement({filter:function(filter,bind){if(!filter)return this;return new Elements(Array.filter(this,(typeof filter=='string')?function(item){return item.match(filter);}:filter,bind));}});(function(){var createElementAcceptsHTML;try{var x=document.createElement('<input name=x>');createElementAcceptsHTML=(x.name=='x');}catch(e){}
var escapeQuotes=function(html){return(''+html).replace(/&/g,'&amp;').replace(/"/g,'&quot;');};Document.implement({newElement:function(tag,props){if(props&&props.checked!=null)props.defaultChecked=props.checked;if(createElementAcceptsHTML&&props){tag='<'+tag;if(props.name)tag+=' name="'+escapeQuotes(props.name)+'"';if(props.type)tag+=' type="'+escapeQuotes(props.type)+'"';tag+='>';delete props.name;delete props.type;}
return this.id(this.createElement(tag)).set(props);},newTextNode:function(text){return this.createTextNode(text);},getDocument:function(){return this;},getWindow:function(){return this.window;},id:(function(){var types={string:function(id,nocash,doc){id=doc.getElementById(id);return(id)?types.element(id,nocash):null;},element:function(el,nocash){$uid(el);if(!nocash&&!el.$family&&!(/^object|embed$/i).test(el.tagName)){var proto=Element.Prototype;for(var p in proto)el[p]=proto[p];};return el;},object:function(obj,nocash,doc){if(obj.toElement)return types.element(obj.toElement(doc),nocash);return null;}};types.textnode=types.whitespace=types.window=types.document=$arguments(0);return function(el,nocash,doc){if(el&&el.$family&&el.uid)return el;var type=$type(el);return(types[type])?types[type](el,nocash,doc||document):null;};})()});})();if(window.$==null)Window.implement({$:function(el,nc){return document.id(el,nc,this.document);}});Window.implement({$$:function(selector){if(arguments.length==1&&typeof selector=='string')return this.document.getElements(selector);var elements=[];var args=Array.flatten(arguments);for(var i=0,l=args.length;i<l;i++){var item=args[i];switch($type(item)){case'element':elements.push(item);break;case'string':elements.extend(this.document.getElements(item,true));}}
return new Elements(elements);},getDocument:function(){return this.document;},getWindow:function(){return this;}});Native.implement([Element,Document],{getElement:function(selector,nocash){return document.id(this.getElements(selector,true)[0]||null,nocash);},getElements:function(tags,nocash){tags=tags.split(',');var elements=[];var ddup=(tags.length>1);tags.each(function(tag){var partial=this.getElementsByTagName(tag.trim());(ddup)?elements.extend(partial):elements=partial;},this);return new Elements(elements,{ddup:ddup,cash:!nocash});}});(function(){var collected={},storage={};var props={input:'checked',option:'selected',textarea:(Browser.Engine.webkit&&Browser.Engine.version<420)?'innerHTML':'value'};var get=function(uid){if(!storage){storage={};}
return(storage[uid]||(storage[uid]={}));};var clean=function(item,retain){if(!item)return;var uid=item.uid;if(retain!==true)retain=false;if(Browser.Engine.trident){if(item.clearAttributes){var clone=retain&&item.cloneNode(false);item.clearAttributes();if(clone)item.mergeAttributes(clone);}else if(item.removeEvents){item.removeEvents();}
if((/object/i).test(item.tagName)){for(var p in item){if(typeof item[p]=='function')item[p]=$empty;}
Element.dispose(item);}}
if(!uid)return;collected[uid]=storage[uid]=null;};var purge=function(){Hash.each(collected,clean);if(Browser.Engine.trident)$A(document.getElementsByTagName('object')).each(clean);if(window.CollectGarbage)CollectGarbage();collected=storage=null;};var walk=function(element,walk,start,match,all,nocash){var el=element[start||walk];var elements=[];while(el){if(el.nodeType==1&&(!match||Element.match(el,match))){if(!all)return document.id(el,nocash);elements.push(el);}
el=el[walk];}
return(all)?new Elements(elements,{ddup:false,cash:!nocash}):null;};var attributes={'html':'innerHTML','class':'className','for':'htmlFor','defaultValue':'defaultValue','text':(Browser.Engine.trident||(Browser.Engine.webkit&&Browser.Engine.version<420))?'innerText':'textContent'};var bools=['compact','nowrap','ismap','declare','noshade','checked','disabled','readonly','multiple','selected','noresize','defer'];var camels=['value','type','defaultValue','accessKey','cellPadding','cellSpacing','colSpan','frameBorder','maxLength','readOnly','rowSpan','tabIndex','useMap'];bools=bools.associate(bools);Hash.extend(attributes,bools);Hash.extend(attributes,camels.associate(camels.map(String.toLowerCase)));var inserters={before:function(context,element){if(element.parentNode)element.parentNode.insertBefore(context,element);},after:function(context,element){if(!element.parentNode)return;var next=element.nextSibling;(next)?element.parentNode.insertBefore(context,next):element.parentNode.appendChild(context);},bottom:function(context,element){element.appendChild(context);},top:function(context,element){var first=element.firstChild;(first)?element.insertBefore(context,first):element.appendChild(context);}};inserters.inside=inserters.bottom;Hash.each(inserters,function(inserter,where){where=where.capitalize();Element.implement('inject'+where,function(el){inserter(this,document.id(el,true));return this;});Element.implement('grab'+where,function(el){inserter(document.id(el,true),this);return this;});});Element.implement({set:function(prop,value){switch($type(prop)){case'object':for(var p in prop)this.set(p,prop[p]);break;case'string':var property=Element.Properties.get(prop);(property&&property.set)?property.set.apply(this,Array.slice(arguments,1)):this.setProperty(prop,value);}
return this;},get:function(prop){var property=Element.Properties.get(prop);return(property&&property.get)?property.get.apply(this,Array.slice(arguments,1)):this.getProperty(prop);},erase:function(prop){var property=Element.Properties.get(prop);(property&&property.erase)?property.erase.apply(this):this.removeProperty(prop);return this;},setProperty:function(attribute,value){var key=attributes[attribute];if(value==undefined)return this.removeProperty(attribute);if(key&&bools[attribute])value=!!value;(key)?this[key]=value:this.setAttribute(attribute,''+value);return this;},setProperties:function(attributes){for(var attribute in attributes)this.setProperty(attribute,attributes[attribute]);return this;},getProperty:function(attribute){var key=attributes[attribute];var value=(key)?this[key]:this.getAttribute(attribute,2);return(bools[attribute])?!!value:(key)?value:value||null;},getProperties:function(){var args=$A(arguments);return args.map(this.getProperty,this).associate(args);},removeProperty:function(attribute){var key=attributes[attribute];(key)?this[key]=(key&&bools[attribute])?false:'':this.removeAttribute(attribute);return this;},removeProperties:function(){Array.each(arguments,this.removeProperty,this);return this;},hasClass:function(className){return this.className.contains(className,' ');},addClass:function(className){if(!this.hasClass(className))this.className=(this.className+' '+className).clean();return this;},removeClass:function(className){this.className=this.className.replace(new RegExp('(^|\\s)'+className+'(?:\\s|$)'),'$1');return this;},toggleClass:function(className){return this.hasClass(className)?this.removeClass(className):this.addClass(className);},adopt:function(){Array.flatten(arguments).each(function(element){element=document.id(element,true);if(element)this.appendChild(element);},this);return this;},appendText:function(text,where){return this.grab(this.getDocument().newTextNode(text),where);},grab:function(el,where){inserters[where||'bottom'](document.id(el,true),this);return this;},inject:function(el,where){inserters[where||'bottom'](this,document.id(el,true));return this;},replaces:function(el){el=document.id(el,true);el.parentNode.replaceChild(this,el);return this;},wraps:function(el,where){el=document.id(el,true);return this.replaces(el).grab(el,where);},getPrevious:function(match,nocash){return walk(this,'previousSibling',null,match,false,nocash);},getAllPrevious:function(match,nocash){return walk(this,'previousSibling',null,match,true,nocash);},getNext:function(match,nocash){return walk(this,'nextSibling',null,match,false,nocash);},getAllNext:function(match,nocash){return walk(this,'nextSibling',null,match,true,nocash);},getFirst:function(match,nocash){return walk(this,'nextSibling','firstChild',match,false,nocash);},getLast:function(match,nocash){return walk(this,'previousSibling','lastChild',match,false,nocash);},getParent:function(match,nocash){return walk(this,'parentNode',null,match,false,nocash);},getParents:function(match,nocash){return walk(this,'parentNode',null,match,true,nocash);},getSiblings:function(match,nocash){return this.getParent().getChildren(match,nocash).erase(this);},getChildren:function(match,nocash){return walk(this,'nextSibling','firstChild',match,true,nocash);},getWindow:function(){return this.ownerDocument.window;},getDocument:function(){return this.ownerDocument;},getElementById:function(id,nocash){var el=this.ownerDocument.getElementById(id);if(!el)return null;for(var parent=el.parentNode;parent!=this;parent=parent.parentNode){if(!parent)return null;}
return document.id(el,nocash);},getSelected:function(){return new Elements($A(this.options).filter(function(option){return option.selected;}));},getComputedStyle:function(property){if(this.currentStyle)return this.currentStyle[property.camelCase()];var computed=this.getDocument().defaultView.getComputedStyle(this,null);return(computed)?computed.getPropertyValue([property.hyphenate()]):null;},toQueryString:function(){var queryString=[];this.getElements('input, select, textarea',true).each(function(el){if(!el.name||el.disabled||el.type=='submit'||el.type=='reset'||el.type=='file')return;var value=(el.tagName.toLowerCase()=='select')?Element.getSelected(el).map(function(opt){return opt.value;}):((el.type=='radio'||el.type=='checkbox')&&!el.checked)?null:el.value;$splat(value).each(function(val){if(typeof val!='undefined')queryString.push(el.name+'='+encodeURIComponent(val));});});return queryString.join('&');},clone:function(contents,keepid){contents=contents!==false;var clone=this.cloneNode(contents);var clean=function(node,element){if(!keepid)node.removeAttribute('id');if(Browser.Engine.trident){node.clearAttributes();node.mergeAttributes(element);node.removeAttribute('uid');if(node.options){var no=node.options,eo=element.options;for(var j=no.length;j--;)no[j].selected=eo[j].selected;}}
var prop=props[element.tagName.toLowerCase()];if(prop&&element[prop])node[prop]=element[prop];};if(contents){var ce=clone.getElementsByTagName('*'),te=this.getElementsByTagName('*');for(var i=ce.length;i--;)clean(ce[i],te[i]);}
clean(clone,this);return document.id(clone);},destroy:function(){Element.empty(this);Element.dispose(this);clean(this,true);return null;},empty:function(){$A(this.childNodes).each(function(node){Element.destroy(node);});return this;},dispose:function(){return(this.parentNode)?this.parentNode.removeChild(this):this;},hasChild:function(el){el=document.id(el,true);if(!el)return false;if(Browser.Engine.webkit&&Browser.Engine.version<420)return $A(this.getElementsByTagName(el.tagName)).contains(el);return(this.contains)?(this!=el&&this.contains(el)):!!(this.compareDocumentPosition(el)&16);},match:function(tag){return(!tag||(tag==this)||(Element.get(this,'tag')==tag));}});Native.implement([Element,Window,Document],{addListener:function(type,fn){if(type=='unload'){var old=fn,self=this;fn=function(){self.removeListener('unload',fn);old();};}else{collected[this.uid]=this;}
if(this.addEventListener)this.addEventListener(type,fn,false);else this.attachEvent('on'+type,fn);return this;},removeListener:function(type,fn){if(this.removeEventListener)this.removeEventListener(type,fn,false);else this.detachEvent('on'+type,fn);return this;},retrieve:function(property,dflt){var storage=get(this.uid),prop=storage[property];if(dflt!=undefined&&prop==undefined)prop=storage[property]=dflt;return $pick(prop);},store:function(property,value){var storage=get(this.uid);storage[property]=value;return this;},eliminate:function(property){var storage=get(this.uid);delete storage[property];return this;}});window.addListener('unload',purge);})();Element.Properties=new Hash;Element.Properties.style={set:function(style){this.style.cssText=style;},get:function(){return this.style.cssText;},erase:function(){this.style.cssText='';}};Element.Properties.tag={get:function(){return this.tagName.toLowerCase();}};Element.Properties.html=(function(){var wrapper=document.createElement('div');var translations={table:[1,'<table>','</table>'],select:[1,'<select>','</select>'],tbody:[2,'<table><tbody>','</tbody></table>'],tr:[3,'<table><tbody><tr>','</tr></tbody></table>']};translations.thead=translations.tfoot=translations.tbody;var html={set:function(){var html=Array.flatten(arguments).join('');var wrap=Browser.Engine.trident&&translations[this.get('tag')];if(wrap){var first=wrapper;first.innerHTML=wrap[1]+html+wrap[2];for(var i=wrap[0];i--;)first=first.firstChild;this.empty().adopt(first.childNodes);}else{this.innerHTML=html;}}};html.erase=html.set;return html;})();if(Browser.Engine.webkit&&Browser.Engine.version<420)Element.Properties.text={get:function(){if(this.innerText)return this.innerText;var temp=this.ownerDocument.newElement('div',{html:this.innerHTML}).inject(this.ownerDocument.body);var text=temp.innerText;temp.destroy();return text;}};(function(){Element.implement({scrollTo:function(x,y){if(isBody(this)){this.getWindow().scrollTo(x,y);}else{this.scrollLeft=x;this.scrollTop=y;}
return this;},getSize:function(){if(isBody(this))return this.getWindow().getSize();return{x:this.offsetWidth,y:this.offsetHeight};},getScrollSize:function(){if(isBody(this))return this.getWindow().getScrollSize();return{x:this.scrollWidth,y:this.scrollHeight};},getScroll:function(){if(isBody(this))return this.getWindow().getScroll();return{x:this.scrollLeft,y:this.scrollTop};},getScrolls:function(){var element=this,position={x:0,y:0};while(element&&!isBody(element)){position.x+=element.scrollLeft;position.y+=element.scrollTop;element=element.parentNode;}
return position;},getOffsetParent:function(){var element=this;if(isBody(element))return null;if(!Browser.Engine.trident)return element.offsetParent;while((element=element.parentNode)&&!isBody(element)){if(styleString(element,'position')!='static')return element;}
return null;},getOffsets:function(){if(this.getBoundingClientRect){var bound=this.getBoundingClientRect(),html=document.id(this.getDocument().documentElement),htmlScroll=html.getScroll(),elemScrolls=this.getScrolls(),elemScroll=this.getScroll(),isFixed=(styleString(this,'position')=='fixed');return{x:bound.left.toInt()+elemScrolls.x-elemScroll.x+((isFixed)?0:htmlScroll.x)-html.clientLeft,y:bound.top.toInt()+elemScrolls.y-elemScroll.y+((isFixed)?0:htmlScroll.y)-html.clientTop};}
var element=this,position={x:0,y:0};if(isBody(this))return position;while(element&&!isBody(element)){position.x+=element.offsetLeft;position.y+=element.offsetTop;if(Browser.Engine.gecko){if(!borderBox(element)){position.x+=leftBorder(element);position.y+=topBorder(element);}
var parent=element.parentNode;if(parent&&styleString(parent,'overflow')!='visible'){position.x+=leftBorder(parent);position.y+=topBorder(parent);}}else if(element!=this&&Browser.Engine.webkit){position.x+=leftBorder(element);position.y+=topBorder(element);}
element=element.offsetParent;}
if(Browser.Engine.gecko&&!borderBox(this)){position.x-=leftBorder(this);position.y-=topBorder(this);}
return position;},getPosition:function(relative){if(isBody(this))return{x:0,y:0};var offset=this.getOffsets(),scroll=this.getScrolls();var position={x:offset.x-scroll.x,y:offset.y-scroll.y};var relativePosition=(relative&&(relative=document.id(relative)))?relative.getPosition():{x:0,y:0};return{x:position.x-relativePosition.x,y:position.y-relativePosition.y};},getCoordinates:function(element){if(isBody(this))return this.getWindow().getCoordinates();var position=this.getPosition(element),size=this.getSize();var obj={left:position.x,top:position.y,width:size.x,height:size.y};obj.right=obj.left+obj.width;obj.bottom=obj.top+obj.height;return obj;},computePosition:function(obj){return{left:obj.x-styleNumber(this,'margin-left'),top:obj.y-styleNumber(this,'margin-top')};},setPosition:function(obj){return this.setStyles(this.computePosition(obj));}});Native.implement([Document,Window],{getSize:function(){if(Browser.Engine.presto||Browser.Engine.webkit){var win=this.getWindow();return{x:win.innerWidth,y:win.innerHeight};}
var doc=getCompatElement(this);return{x:doc.clientWidth,y:doc.clientHeight};},getScroll:function(){var win=this.getWindow(),doc=getCompatElement(this);return{x:win.pageXOffset||doc.scrollLeft,y:win.pageYOffset||doc.scrollTop};},getScrollSize:function(){var doc=getCompatElement(this),min=this.getSize();return{x:Math.max(doc.scrollWidth,min.x),y:Math.max(doc.scrollHeight,min.y)};},getPosition:function(){return{x:0,y:0};},getCoordinates:function(){var size=this.getSize();return{top:0,left:0,bottom:size.y,right:size.x,height:size.y,width:size.x};}});var styleString=Element.getComputedStyle;function styleNumber(element,style){return styleString(element,style).toInt()||0;};function borderBox(element){return styleString(element,'-moz-box-sizing')=='border-box';};function topBorder(element){return styleNumber(element,'border-top-width');};function leftBorder(element){return styleNumber(element,'border-left-width');};function isBody(element){return(/^(?:body|html)$/i).test(element.tagName);};function getCompatElement(element){var doc=element.getDocument();return(!doc.compatMode||doc.compatMode=='CSS1Compat')?doc.html:doc.body;};})();Element.alias('setPosition','position');Native.implement([Window,Document,Element],{getHeight:function(){return this.getSize().y;},getWidth:function(){return this.getSize().x;},getScrollTop:function(){return this.getScroll().y;},getScrollLeft:function(){return this.getScroll().x;},getScrollHeight:function(){return this.getScrollSize().y;},getScrollWidth:function(){return this.getScrollSize().x;},getTop:function(){return this.getPosition().y;},getLeft:function(){return this.getPosition().x;}});var Event=new Native({name:'Event',initialize:function(event,win){win=win||window;var doc=win.document;event=event||win.event;if(event.$extended)return event;this.$extended=true;var type=event.type;var target=event.target||event.srcElement;while(target&&target.nodeType==3)target=target.parentNode;if(type.test(/key/)){var code=event.which||event.keyCode;var key=Event.Keys.keyOf(code);if(type=='keydown'){var fKey=code-111;if(fKey>0&&fKey<13)key='f'+fKey;}
key=key||String.fromCharCode(code).toLowerCase();}else if(type.match(/(click|mouse|menu)/i)){doc=(!doc.compatMode||doc.compatMode=='CSS1Compat')?doc.html:doc.body;var page={x:event.pageX||event.clientX+doc.scrollLeft,y:event.pageY||event.clientY+doc.scrollTop};var client={x:(event.pageX)?event.pageX-win.pageXOffset:event.clientX,y:(event.pageY)?event.pageY-win.pageYOffset:event.clientY};if(type.match(/DOMMouseScroll|mousewheel/)){var wheel=(event.wheelDelta)?event.wheelDelta/120:-(event.detail||0)/3;}
var rightClick=(event.which==3)||(event.button==2);var related=null;if(type.match(/over|out/)){switch(type){case'mouseover':related=event.relatedTarget||event.fromElement;break;case'mouseout':related=event.relatedTarget||event.toElement;}
if(!(function(){while(related&&related.nodeType==3)related=related.parentNode;return true;}).create({attempt:Browser.Engine.gecko})())related=false;}}
return $extend(this,{event:event,type:type,page:page,client:client,rightClick:rightClick,wheel:wheel,relatedTarget:related,target:target,code:code,key:key,shift:event.shiftKey,control:event.ctrlKey,alt:event.altKey,meta:event.metaKey});}});Event.Keys=new Hash({'enter':13,'up':38,'down':40,'left':37,'right':39,'esc':27,'space':32,'backspace':8,'tab':9,'delete':46});Event.implement({stop:function(){return this.stopPropagation().preventDefault();},stopPropagation:function(){if(this.event.stopPropagation)this.event.stopPropagation();else this.event.cancelBubble=true;return this;},preventDefault:function(){if(this.event.preventDefault)this.event.preventDefault();else this.event.returnValue=false;return this;}});Element.Properties.events={set:function(events){this.addEvents(events);}};Native.implement([Element,Window,Document],{addEvent:function(type,fn){var events=this.retrieve('events',{});events[type]=events[type]||{'keys':[],'values':[]};if(events[type].keys.contains(fn))return this;events[type].keys.push(fn);var realType=type,custom=Element.Events.get(type),condition=fn,self=this;if(custom){if(custom.onAdd)custom.onAdd.call(this,fn);if(custom.condition){condition=function(event){if(custom.condition.call(this,event))return fn.call(this,event);return true;};}
realType=custom.base||realType;}
var defn=function(){return fn.call(self);};var nativeEvent=Element.NativeEvents[realType];if(nativeEvent){if(nativeEvent==2){defn=function(event){event=new Event(event,self.getWindow());if(condition.call(self,event)===false)event.stop();};}
this.addListener(realType,defn);}
events[type].values.push(defn);return this;},removeEvent:function(type,fn){var events=this.retrieve('events');if(!events||!events[type])return this;var pos=events[type].keys.indexOf(fn);if(pos==-1)return this;events[type].keys.splice(pos,1);var value=events[type].values.splice(pos,1)[0];var custom=Element.Events.get(type);if(custom){if(custom.onRemove)custom.onRemove.call(this,fn);type=custom.base||type;}
return(Element.NativeEvents[type])?this.removeListener(type,value):this;},addEvents:function(events){for(var event in events)this.addEvent(event,events[event]);return this;},removeEvents:function(events){var type;if($type(events)=='object'){for(type in events)this.removeEvent(type,events[type]);return this;}
var attached=this.retrieve('events');if(!attached)return this;if(!events){for(type in attached)this.removeEvents(type);this.eliminate('events');}else if(attached[events]){while(attached[events].keys[0])this.removeEvent(events,attached[events].keys[0]);attached[events]=null;}
return this;},fireEvent:function(type,args,delay){var events=this.retrieve('events');if(!events||!events[type])return this;events[type].keys.each(function(fn){fn.create({'bind':this,'delay':delay,'arguments':args})();},this);return this;},cloneEvents:function(from,type){from=document.id(from);var fevents=from.retrieve('events');if(!fevents)return this;if(!type){for(var evType in fevents)this.cloneEvents(from,evType);}else if(fevents[type]){fevents[type].keys.each(function(fn){this.addEvent(type,fn);},this);}
return this;}});try{if(typeof HTMLElement!='undefined')
HTMLElement.prototype.fireEvent=Element.prototype.fireEvent;}catch(e){}
Element.NativeEvents={click:2,dblclick:2,mouseup:2,mousedown:2,contextmenu:2,mousewheel:2,DOMMouseScroll:2,mouseover:2,mouseout:2,mousemove:2,selectstart:2,selectend:2,keydown:2,keypress:2,keyup:2,focus:2,blur:2,change:2,reset:2,select:2,submit:2,load:1,unload:1,beforeunload:2,resize:1,move:1,DOMContentLoaded:1,readystatechange:1,error:1,abort:1,scroll:1};(function(){var $check=function(event){var related=event.relatedTarget;if(related==undefined)return true;if(related===false)return false;return($type(this)!='document'&&related!=this&&related.prefix!='xul'&&!this.hasChild(related));};Element.Events=new Hash({mouseenter:{base:'mouseover',condition:$check},mouseleave:{base:'mouseout',condition:$check},mousewheel:{base:(Browser.Engine.gecko)?'DOMMouseScroll':'mousewheel'}});})();Element.Properties.styles={set:function(styles){this.setStyles(styles);}};Element.Properties.opacity={set:function(opacity,novisibility){if(!novisibility){if(opacity==0){if(this.style.visibility!='hidden')this.style.visibility='hidden';}else{if(this.style.visibility!='visible')this.style.visibility='visible';}}
if(!this.currentStyle||!this.currentStyle.hasLayout)this.style.zoom=1;if(Browser.Engine.trident)this.style.filter=(opacity==1)?'':'alpha(opacity='+opacity*100+')';this.style.opacity=opacity;this.store('opacity',opacity);},get:function(){return this.retrieve('opacity',1);}};Element.implement({setOpacity:function(value){return this.set('opacity',value,true);},getOpacity:function(){return this.get('opacity');},setStyle:function(property,value){switch(property){case'opacity':return this.set('opacity',parseFloat(value));case'float':property=(Browser.Engine.trident)?'styleFloat':'cssFloat';}
property=property.camelCase();if($type(value)!='string'){var map=(Element.Styles.get(property)||'@').split(' ');value=$splat(value).map(function(val,i){if(!map[i])return'';return($type(val)=='number')?map[i].replace('@',Math.round(val)):val;}).join(' ');}else if(value==String(Number(value))){value=Math.round(value);}
this.style[property]=value;return this;},getStyle:function(property){switch(property){case'opacity':return this.get('opacity');case'float':property=(Browser.Engine.trident)?'styleFloat':'cssFloat';}
property=property.camelCase();var result=this.style[property];if(!$chk(result)){result=[];for(var style in Element.ShortStyles){if(property!=style)continue;for(var s in Element.ShortStyles[style])result.push(this.getStyle(s));return result.join(' ');}
result=this.getComputedStyle(property);}
if(result){result=String(result);var color=result.match(/rgba?\([\d\s,]+\)/);if(color)result=result.replace(color[0],color[0].rgbToHex());}
if(Browser.Engine.presto||(Browser.Engine.trident&&!$chk(parseInt(result,10)))){if(property.test(/^(height|width)$/)){var values=(property=='width')?['left','right']:['top','bottom'],size=0;values.each(function(value){size+=this.getStyle('border-'+value+'-width').toInt()+this.getStyle('padding-'+value).toInt();},this);return this['offset'+property.capitalize()]-size+'px';}
if((Browser.Engine.presto)&&String(result).test('px'))return result;if(property.test(/(border(.+)Width|margin|padding)/))return'0px';}
return result;},setStyles:function(styles){for(var style in styles)this.setStyle(style,styles[style]);return this;},getStyles:function(){var result={};Array.flatten(arguments).each(function(key){result[key]=this.getStyle(key);},this);return result;}});Element.Styles=new Hash({left:'@px',top:'@px',bottom:'@px',right:'@px',width:'@px',height:'@px',maxWidth:'@px',maxHeight:'@px',minWidth:'@px',minHeight:'@px',backgroundColor:'rgb(@, @, @)',backgroundPosition:'@px @px',color:'rgb(@, @, @)',fontSize:'@px',letterSpacing:'@px',lineHeight:'@px',clip:'rect(@px @px @px @px)',margin:'@px @px @px @px',padding:'@px @px @px @px',border:'@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)',borderWidth:'@px @px @px @px',borderStyle:'@ @ @ @',borderColor:'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)',zIndex:'@','zoom':'@',fontWeight:'@',textIndent:'@px',opacity:'@'});Element.ShortStyles={margin:{},padding:{},border:{},borderWidth:{},borderStyle:{},borderColor:{}};['Top','Right','Bottom','Left'].each(function(direction){var Short=Element.ShortStyles;var All=Element.Styles;['margin','padding'].each(function(style){var sd=style+direction;Short[style][sd]=All[sd]='@px';});var bd='border'+direction;Short.border[bd]=All[bd]='@px @ rgb(@, @, @)';var bdw=bd+'Width',bds=bd+'Style',bdc=bd+'Color';Short[bd]={};Short.borderWidth[bdw]=Short[bd][bdw]=All[bdw]='@px';Short.borderStyle[bds]=Short[bd][bds]=All[bds]='@';Short.borderColor[bdc]=Short[bd][bdc]=All[bdc]='rgb(@, @, @)';});var Fx=new Class({Implements:[Chain,Events,Options],options:{fps:50,unit:false,duration:500,link:'ignore'},initialize:function(options){this.subject=this.subject||this;this.setOptions(options);this.options.duration=Fx.Durations[this.options.duration]||this.options.duration.toInt();var wait=this.options.wait;if(wait===false)this.options.link='cancel';},getTransition:function(){return function(p){return-(Math.cos(Math.PI*p)-1)/2;};},step:function(){var time=$time();if(time<this.time+this.options.duration){var delta=this.transition((time-this.time)/this.options.duration);this.set(this.compute(this.from,this.to,delta));}else{this.set(this.compute(this.from,this.to,1));this.complete();}},set:function(now){return now;},compute:function(from,to,delta){return Fx.compute(from,to,delta);},check:function(){if(!this.timer)return true;switch(this.options.link){case'cancel':this.cancel();return true;case'chain':this.chain(this.caller.bind(this,arguments));return false;}
return false;},start:function(from,to){if(!this.check(from,to))return this;this.from=from;this.to=to;this.time=0;this.transition=this.getTransition();this.startTimer();this.onStart();return this;},complete:function(){if(this.stopTimer())this.onComplete();return this;},cancel:function(){if(this.stopTimer())this.onCancel();return this;},onStart:function(){this.fireEvent('start',this.subject);},onComplete:function(){this.fireEvent('complete',this.subject);if(!this.callChain())this.fireEvent('chainComplete',this.subject);},onCancel:function(){this.fireEvent('cancel',this.subject).clearChain();},pause:function(){this.stopTimer();return this;},resume:function(){this.startTimer();return this;},stopTimer:function(){if(!this.timer)return false;this.time=$time()-this.time;this.timer=$clear(this.timer);return true;},startTimer:function(){if(this.timer)return false;this.time=$time()-this.time;this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);return true;}});Fx.compute=function(from,to,delta){return(to-from)*delta+from;};Fx.Durations={'short':250,'normal':500,'long':1000};Fx.CSS=new Class({Extends:Fx,prepare:function(element,property,values){values=$splat(values);var values1=values[1];if(!$chk(values1)){values[1]=values[0];values[0]=element.getStyle(property);}
var parsed=values.map(this.parse);return{from:parsed[0],to:parsed[1]};},parse:function(value){value=$lambda(value)();value=(typeof value=='string')?value.split(' '):$splat(value);return value.map(function(val){val=String(val);var found=false;Fx.CSS.Parsers.each(function(parser,key){if(found)return;var parsed=parser.parse(val);if($chk(parsed))found={value:parsed,parser:parser};});found=found||{value:val,parser:Fx.CSS.Parsers.String};return found;});},compute:function(from,to,delta){var computed=[];(Math.min(from.length,to.length)).times(function(i){computed.push({value:from[i].parser.compute(from[i].value,to[i].value,delta),parser:from[i].parser});});computed.$family={name:'fx:css:value'};return computed;},serve:function(value,unit){if($type(value)!='fx:css:value')value=this.parse(value);var returned=[];value.each(function(bit){returned=returned.concat(bit.parser.serve(bit.value,unit));});return returned;},render:function(element,property,value,unit){element.setStyle(property,this.serve(value,unit));},search:function(selector){if(Fx.CSS.Cache[selector])return Fx.CSS.Cache[selector];var to={};Array.each(document.styleSheets,function(sheet,j){var href=sheet.href;if(href&&href.contains('://')&&!href.contains(document.domain))return;var rules=sheet.rules||sheet.cssRules;Array.each(rules,function(rule,i){if(!rule.style)return;var selectorText=(rule.selectorText)?rule.selectorText.replace(/^\w+/,function(m){return m.toLowerCase();}):null;if(!selectorText||!selectorText.test('^'+selector+'$'))return;Element.Styles.each(function(value,style){if(!rule.style[style]||Element.ShortStyles[style])return;value=String(rule.style[style]);to[style]=(value.test(/^rgb/))?value.rgbToHex():value;});});});return Fx.CSS.Cache[selector]=to;}});Fx.CSS.Cache={};Fx.CSS.Parsers=new Hash({Color:{parse:function(value){if(value.match(/^#[0-9a-f]{3,6}$/i))return value.hexToRgb(true);return((value=value.match(/(\d+),\s*(\d+),\s*(\d+)/)))?[value[1],value[2],value[3]]:false;},compute:function(from,to,delta){return from.map(function(value,i){return Math.round(Fx.compute(from[i],to[i],delta));});},serve:function(value){return value.map(Number);}},Number:{parse:parseFloat,compute:Fx.compute,serve:function(value,unit){return(unit)?value+unit:value;}},String:{parse:$lambda(false),compute:$arguments(1),serve:$arguments(0)}});Fx.Morph=new Class({Extends:Fx.CSS,initialize:function(element,options){this.element=this.subject=document.id(element);this.parent(options);},set:function(now){if(typeof now=='string')now=this.search(now);for(var p in now)this.render(this.element,p,now[p],this.options.unit);return this;},compute:function(from,to,delta){var now={};for(var p in from)now[p]=this.parent(from[p],to[p],delta);return now;},start:function(properties){if(!this.check(properties))return this;if(typeof properties=='string')properties=this.search(properties);var from={},to={};for(var p in properties){var parsed=this.prepare(this.element,p,properties[p]);from[p]=parsed.from;to[p]=parsed.to;}
return this.parent(from,to);}});Element.Properties.morph={set:function(options){var morph=this.retrieve('morph');if(morph)morph.cancel();return this.eliminate('morph').store('morph:options',$extend({link:'cancel'},options));},get:function(options){if(options||!this.retrieve('morph')){if(options||!this.retrieve('morph:options'))this.set('morph',options);this.store('morph',new Fx.Morph(this,this.retrieve('morph:options')));}
return this.retrieve('morph');}};Element.implement({morph:function(props){this.get('morph').start(props);return this;}});Fx.implement({getTransition:function(){var trans=this.options.transition||Fx.Transitions.Sine.easeInOut;if(typeof trans=='string'){var data=trans.split(':');trans=Fx.Transitions;trans=trans[data[0]]||trans[data[0].capitalize()];if(data[1])trans=trans['ease'+data[1].capitalize()+(data[2]?data[2].capitalize():'')];}
return trans;}});Fx.Transition=function(transition,params){params=$splat(params);return $extend(transition,{easeIn:function(pos){return transition(pos,params);},easeOut:function(pos){return 1-transition(1-pos,params);},easeInOut:function(pos){return(pos<=0.5)?transition(2*pos,params)/2:(2-transition(2*(1-pos),params))/2;}});};Fx.Transitions=new Hash({linear:$arguments(0)});Fx.Transitions.extend=function(transitions){for(var transition in transitions)Fx.Transitions[transition]=new Fx.Transition(transitions[transition]);};Fx.Transitions.extend({Pow:function(p,x){return Math.pow(p,x[0]||6);},Expo:function(p){return Math.pow(2,8*(p-1));},Circ:function(p){return 1-Math.sin(Math.acos(p));},Sine:function(p){return 1-Math.sin((1-p)*Math.PI/2);},Back:function(p,x){x=x[0]||1.618;return Math.pow(p,2)*((x+1)*p-x);},Bounce:function(p){var value;for(var a=0,b=1;1;a+=b,b/=2){if(p>=(7-4*a)/11){value=b*b-Math.pow((11-6*a-11*p)/4,2);break;}}
return value;},Elastic:function(p,x){return Math.pow(2,10*--p)*Math.cos(20*p*Math.PI*(x[0]||1)/3);}});['Quad','Cubic','Quart','Quint'].each(function(transition,i){Fx.Transitions[transition]=new Fx.Transition(function(p){return Math.pow(p,[i+2]);});});Fx.Tween=new Class({Extends:Fx.CSS,initialize:function(element,options){this.element=this.subject=document.id(element);this.parent(options);},set:function(property,now){if(arguments.length==1){now=property;property=this.property||this.options.property;}
this.render(this.element,property,now,this.options.unit);return this;},start:function(property,from,to){if(!this.check(property,from,to))return this;var args=Array.flatten(arguments);this.property=this.options.property||args.shift();var parsed=this.prepare(this.element,this.property,args);return this.parent(parsed.from,parsed.to);}});Element.Properties.tween={set:function(options){var tween=this.retrieve('tween');if(tween)tween.cancel();return this.eliminate('tween').store('tween:options',$extend({link:'cancel'},options));},get:function(options){if(options||!this.retrieve('tween')){if(options||!this.retrieve('tween:options'))this.set('tween',options);this.store('tween',new Fx.Tween(this,this.retrieve('tween:options')));}
return this.retrieve('tween');}};Element.implement({tween:function(property,from,to){this.get('tween').start(arguments);return this;},fade:function(how){var fade=this.get('tween'),o='opacity',toggle;how=$pick(how,'toggle');switch(how){case'in':fade.start(o,1);break;case'out':fade.start(o,0);break;case'show':fade.set(o,1);break;case'hide':fade.set(o,0);break;case'toggle':var flag=this.retrieve('fade:flag',this.get('opacity')==1);fade.start(o,(flag)?0:1);this.store('fade:flag',!flag);toggle=true;break;default:fade.start(o,arguments);}
if(!toggle)this.eliminate('fade:flag');return this;},highlight:function(start,end){if(!end){end=this.retrieve('highlight:original',this.getStyle('background-color'));end=(end=='transparent')?'#fff':end;}
var tween=this.get('tween');tween.start('background-color',start||'#ffff88',end).chain(function(){this.setStyle('background-color',this.retrieve('highlight:original'));tween.callChain();}.bind(this));return this;}});var Request=new Class({Implements:[Chain,Events,Options],options:{url:'',data:'',headers:{'X-Requested-With':'XMLHttpRequest','Accept':'text/javascript, text/html, application/xml, text/xml, */*'},async:true,format:false,method:'post',link:'ignore',isSuccess:null,emulation:true,urlEncoded:true,encoding:'utf-8',evalScripts:false,evalResponse:false,noCache:false},initialize:function(options){this.xhr=new Browser.Request();this.setOptions(options);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers=new Hash(this.options.headers);},onStateChange:function(){if(this.xhr.readyState!=4||!this.running)return;this.running=false;this.status=0;$try(function(){this.status=this.xhr.status;}.bind(this));this.xhr.onreadystatechange=$empty;if(this.options.isSuccess.call(this,this.status)){this.response={text:this.xhr.responseText,xml:this.xhr.responseXML};this.success(this.response.text,this.response.xml);}else{this.response={text:null,xml:null};this.failure();}},isSuccess:function(){return((this.status>=200)&&(this.status<300));},processScripts:function(text){if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader('Content-type')))return $exec(text);return text.stripScripts(this.options.evalScripts);},success:function(text,xml){this.onSuccess(this.processScripts(text),xml);},onSuccess:function(){this.fireEvent('complete',arguments).fireEvent('success',arguments).callChain();},failure:function(){this.onFailure();},onFailure:function(){this.fireEvent('complete').fireEvent('failure',this.xhr);},setHeader:function(name,value){this.headers.set(name,value);return this;},getHeader:function(name){return $try(function(){return this.xhr.getResponseHeader(name);}.bind(this));},check:function(){if(!this.running)return true;switch(this.options.link){case'cancel':this.cancel();return true;case'chain':this.chain(this.caller.bind(this,arguments));return false;}
return false;},send:function(options){if(!this.check(options))return this;this.running=true;var type=$type(options);if(type=='string'||type=='element')options={data:options};var old=this.options;options=$extend({data:old.data,url:old.url,method:old.method},options);var data=options.data,url=String(options.url),method=options.method.toLowerCase();switch($type(data)){case'element':data=document.id(data).toQueryString();break;case'object':case'hash':data=Hash.toQueryString(data);}
if(this.options.format){var format='format='+this.options.format;data=(data)?format+'&'+data:format;}
if(this.options.emulation&&!['get','post'].contains(method)){var _method='_method='+method;data=(data)?_method+'&'+data:_method;method='post';}
if(this.options.urlEncoded&&method=='post'){var encoding=(this.options.encoding)?'; charset='+this.options.encoding:'';this.headers.set('Content-type','application/x-www-form-urlencoded'+encoding);}
if(this.options.noCache){var noCache='noCache='+new Date().getTime();data=(data)?noCache+'&'+data:noCache;}
var trimPosition=url.lastIndexOf('/');if(trimPosition>-1&&(trimPosition=url.indexOf('#'))>-1)url=url.substr(0,trimPosition);if(data&&method=='get'){url=url+(url.contains('?')?'&':'?')+data;data=null;}
this.xhr.open(method.toUpperCase(),url,this.options.async);this.xhr.onreadystatechange=this.onStateChange.bind(this);this.headers.each(function(value,key){try{this.xhr.setRequestHeader(key,value);}catch(e){this.fireEvent('exception',[key,value]);}},this);this.fireEvent('request');this.xhr.send(data);if(!this.options.async)this.onStateChange();return this;},cancel:function(){if(!this.running)return this;this.running=false;this.xhr.abort();this.xhr.onreadystatechange=$empty;this.xhr=new Browser.Request();this.fireEvent('cancel');return this;}});(function(){var methods={};['get','post','put','delete','GET','POST','PUT','DELETE'].each(function(method){methods[method]=function(){var params=Array.link(arguments,{url:String.type,data:$defined});return this.send($extend(params,{method:method}));};});Request.implement(methods);})();Element.Properties.send={set:function(options){var send=this.retrieve('send');if(send)send.cancel();return this.eliminate('send').store('send:options',$extend({data:this,link:'cancel',method:this.get('method')||'post',url:this.get('action')},options));},get:function(options){if(options||!this.retrieve('send')){if(options||!this.retrieve('send:options'))this.set('send',options);this.store('send',new Request(this.retrieve('send:options')));}
return this.retrieve('send');}};Element.implement({send:function(url){var sender=this.get('send');sender.send({data:this,url:url||sender.options.url});return this;}});Request.HTML=new Class({Extends:Request,options:{update:false,append:false,evalScripts:true,filter:false},processHTML:function(text){var match=text.match(/<body[^>]*>([\s\S]*?)<\/body>/i);text=(match)?match[1]:text;var container=new Element('div');return $try(function(){var root='<root>'+text+'</root>',doc;if(Browser.Engine.trident){doc=new ActiveXObject('Microsoft.XMLDOM');doc.async=false;doc.loadXML(root);}else{doc=new DOMParser().parseFromString(root,'text/xml');}
root=doc.getElementsByTagName('root')[0];if(!root)return null;for(var i=0,k=root.childNodes.length;i<k;i++){var child=Element.clone(root.childNodes[i],true,true);if(child)container.grab(child);}
return container;})||container.set('html',text);},success:function(text){var options=this.options,response=this.response;response.html=text.stripScripts(function(script){response.javascript=script;});var temp=this.processHTML(response.html);response.tree=temp.childNodes;response.elements=temp.getElements('*');if(options.filter)response.tree=response.elements.filter(options.filter);if(options.update)document.id(options.update).empty().set('html',response.html);else if(options.append)document.id(options.append).adopt(temp.getChildren());if(options.evalScripts)$exec(response.javascript);this.onSuccess(response.tree,response.elements,response.html,response.javascript);}});Element.Properties.load={set:function(options){var load=this.retrieve('load');if(load)load.cancel();return this.eliminate('load').store('load:options',$extend({data:this,link:'cancel',update:this,method:'get'},options));},get:function(options){if(options||!this.retrieve('load')){if(options||!this.retrieve('load:options'))this.set('load',options);this.store('load',new Request.HTML(this.retrieve('load:options')));}
return this.retrieve('load');}};Element.implement({load:function(){this.get('load').send(Array.link(arguments,{data:Object.type,url:String.type}));return this;}});var JSON=new Hash(this.JSON&&{stringify:JSON.stringify,parse:JSON.parse}).extend({$specialChars:{'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},$replaceChars:function(chr){return JSON.$specialChars[chr]||'\\u00'+Math.floor(chr.charCodeAt()/16).toString(16)+(chr.charCodeAt()%16).toString(16);},encode:function(obj){switch($type(obj)){case'string':return'"'+obj.replace(/[\x00-\x1f\\"]/g,JSON.$replaceChars)+'"';case'array':return'['+String(obj.map(JSON.encode).clean())+']';case'object':case'hash':var string=[];Hash.each(obj,function(value,key){var json=JSON.encode(value);if(json)string.push(JSON.encode(key)+':'+json);});return'{'+string+'}';case'number':case'boolean':return String(obj);case false:return'null';}
return null;},decode:function(string,secure){if($type(string)!='string'||!string.length)return null;if(secure&&!(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"/g,'')))return null;return eval('('+string+')');}});Request.JSON=new Class({Extends:Request,options:{secure:true},initialize:function(options){this.parent(options);this.headers.extend({'Accept':'application/json','X-Request':'JSON'});},success:function(text){this.response.json=JSON.decode(text,this.options.secure);this.onSuccess(this.response.json,text);}});var Cookie=new Class({Implements:Options,options:{path:false,domain:false,duration:false,secure:false,document:document},initialize:function(key,options){this.key=key;this.setOptions(options);},write:function(value){value=encodeURIComponent(value);if(this.options.domain)value+='; domain='+this.options.domain;if(this.options.path)value+='; path='+this.options.path;if(this.options.duration){var date=new Date();date.setTime(date.getTime()+this.options.duration*24*60*60*1000);value+='; expires='+date.toGMTString();}
if(this.options.secure)value+='; secure';this.options.document.cookie=this.key+'='+value;return this;},read:function(){var value=this.options.document.cookie.match('(?:^|;)\\s*'+this.key.escapeRegExp()+'=([^;]*)');return(value)?decodeURIComponent(value[1]):null;},dispose:function(){new Cookie(this.key,$merge(this.options,{duration:-1})).write('');return this;}});Cookie.write=function(key,value,options){return new Cookie(key,options).write(value);};Cookie.read=function(key){return new Cookie(key).read();};Cookie.dispose=function(key,options){return new Cookie(key,options).dispose();};Element.Events.domready={onAdd:function(fn){if(Browser.loaded)fn.call(this);}};(function(){var domready=function(){if(Browser.loaded)return;Browser.loaded=true;window.fireEvent('domready');document.fireEvent('domready');};window.addEvent('load',domready);if(Browser.Engine.trident){var temp=document.createElement('div');(function(){($try(function(){temp.doScroll();return document.id(temp).inject(document.body).set('html','temp').dispose();}))?domready():arguments.callee.delay(50);})();}else if(Browser.Engine.webkit&&Browser.Engine.version<525){(function(){(['loaded','complete'].contains(document.readyState))?domready():arguments.callee.delay(50);})();}else{document.addEvent('DOMContentLoaded',domready);}})();Native.implement([Document,Element],{getElements:function(expression,nocash){expression=expression.split(',');var items,local={};for(var i=0,l=expression.length;i<l;i++){var selector=expression[i],elements=Selectors.Utils.search(this,selector,local);if(i!=0&&elements.item)elements=$A(elements);items=(i==0)?elements:(items.item)?$A(items).concat(elements):items.concat(elements);}
return new Elements(items,{ddup:(expression.length>1),cash:!nocash});}});Element.implement({match:function(selector){if(!selector||(selector==this))return true;var tagid=Selectors.Utils.parseTagAndID(selector);var tag=tagid[0],id=tagid[1];if(!Selectors.Filters.byID(this,id)||!Selectors.Filters.byTag(this,tag))return false;var parsed=Selectors.Utils.parseSelector(selector);return(parsed)?Selectors.Utils.filter(this,parsed,{}):true;}});var Selectors={Cache:{nth:{},parsed:{}}};Selectors.RegExps={id:(/#([\w-]+)/),tag:(/^(\w+|\*)/),quick:(/^(\w+|\*)$/),splitter:(/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),combined:(/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)};Selectors.Utils={chk:function(item,uniques){if(!uniques)return true;var uid=$uid(item);if(!uniques[uid])return uniques[uid]=true;return false;},parseNthArgument:function(argument){if(Selectors.Cache.nth[argument])return Selectors.Cache.nth[argument];var parsed=argument.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);if(!parsed)return false;var inta=parseInt(parsed[1],10);var a=(inta||inta===0)?inta:1;var special=parsed[2]||false;var b=parseInt(parsed[3],10)||0;if(a!=0){b--;while(b<1)b+=a;while(b>=a)b-=a;}else{a=b;special='index';}
switch(special){case'n':parsed={a:a,b:b,special:'n'};break;case'odd':parsed={a:2,b:0,special:'n'};break;case'even':parsed={a:2,b:1,special:'n'};break;case'first':parsed={a:0,special:'index'};break;case'last':parsed={special:'last-child'};break;case'only':parsed={special:'only-child'};break;default:parsed={a:(a-1),special:'index'};}
return Selectors.Cache.nth[argument]=parsed;},parseSelector:function(selector){if(Selectors.Cache.parsed[selector])return Selectors.Cache.parsed[selector];var m,parsed={classes:[],pseudos:[],attributes:[]};while((m=Selectors.RegExps.combined.exec(selector))){var cn=m[1],an=m[2],ao=m[3],av=m[5],pn=m[6],pa=m[7];if(cn){parsed.classes.push(cn);}else if(pn){var parser=Selectors.Pseudo.get(pn);if(parser)parsed.pseudos.push({parser:parser,argument:pa});else parsed.attributes.push({name:pn,operator:'=',value:pa});}else if(an){parsed.attributes.push({name:an,operator:ao,value:av});}}
if(!parsed.classes.length)delete parsed.classes;if(!parsed.attributes.length)delete parsed.attributes;if(!parsed.pseudos.length)delete parsed.pseudos;if(!parsed.classes&&!parsed.attributes&&!parsed.pseudos)parsed=null;return Selectors.Cache.parsed[selector]=parsed;},parseTagAndID:function(selector){var tag=selector.match(Selectors.RegExps.tag);var id=selector.match(Selectors.RegExps.id);return[(tag)?tag[1]:'*',(id)?id[1]:false];},filter:function(item,parsed,local){var i;if(parsed.classes){for(i=parsed.classes.length;i--;i){var cn=parsed.classes[i];if(!Selectors.Filters.byClass(item,cn))return false;}}
if(parsed.attributes){for(i=parsed.attributes.length;i--;i){var att=parsed.attributes[i];if(!Selectors.Filters.byAttribute(item,att.name,att.operator,att.value))return false;}}
if(parsed.pseudos){for(i=parsed.pseudos.length;i--;i){var psd=parsed.pseudos[i];if(!Selectors.Filters.byPseudo(item,psd.parser,psd.argument,local))return false;}}
return true;},getByTagAndID:function(ctx,tag,id){if(id){var item=(ctx.getElementById)?ctx.getElementById(id,true):Element.getElementById(ctx,id,true);return(item&&Selectors.Filters.byTag(item,tag))?[item]:[];}else{return ctx.getElementsByTagName(tag);}},search:function(self,expression,local){var splitters=[];var selectors=expression.trim().replace(Selectors.RegExps.splitter,function(m0,m1,m2){splitters.push(m1);return':)'+m2;}).split(':)');var items,filtered,item;for(var i=0,l=selectors.length;i<l;i++){var selector=selectors[i];if(i==0&&Selectors.RegExps.quick.test(selector)){items=self.getElementsByTagName(selector);continue;}
var splitter=splitters[i-1];var tagid=Selectors.Utils.parseTagAndID(selector);var tag=tagid[0],id=tagid[1];if(i==0){items=Selectors.Utils.getByTagAndID(self,tag,id);}else{var uniques={},found=[];for(var j=0,k=items.length;j<k;j++)found=Selectors.Getters[splitter](found,items[j],tag,id,uniques);items=found;}
var parsed=Selectors.Utils.parseSelector(selector);if(parsed){filtered=[];for(var m=0,n=items.length;m<n;m++){item=items[m];if(Selectors.Utils.filter(item,parsed,local))filtered.push(item);}
items=filtered;}}
return items;}};Selectors.Getters={' ':function(found,self,tag,id,uniques){var items=Selectors.Utils.getByTagAndID(self,tag,id);for(var i=0,l=items.length;i<l;i++){var item=items[i];if(Selectors.Utils.chk(item,uniques))found.push(item);}
return found;},'>':function(found,self,tag,id,uniques){var children=Selectors.Utils.getByTagAndID(self,tag,id);for(var i=0,l=children.length;i<l;i++){var child=children[i];if(child.parentNode==self&&Selectors.Utils.chk(child,uniques))found.push(child);}
return found;},'+':function(found,self,tag,id,uniques){while((self=self.nextSibling)){if(self.nodeType==1){if(Selectors.Utils.chk(self,uniques)&&Selectors.Filters.byTag(self,tag)&&Selectors.Filters.byID(self,id))found.push(self);break;}}
return found;},'~':function(found,self,tag,id,uniques){while((self=self.nextSibling)){if(self.nodeType==1){if(!Selectors.Utils.chk(self,uniques))break;if(Selectors.Filters.byTag(self,tag)&&Selectors.Filters.byID(self,id))found.push(self);}}
return found;}};Selectors.Filters={byTag:function(self,tag){return(tag=='*'||(self.tagName&&self.tagName.toLowerCase()==tag));},byID:function(self,id){return(!id||(self.id&&self.id==id));},byClass:function(self,klass){return(self.className&&self.className.contains&&self.className.contains(klass,' '));},byPseudo:function(self,parser,argument,local){return parser.call(self,argument,local);},byAttribute:function(self,name,operator,value){var result=Element.prototype.getProperty.call(self,name);if(!result)return(operator=='!=');if(!operator||value==undefined)return true;switch(operator){case'=':return(result==value);case'*=':return(result.contains(value));case'^=':return(result.substr(0,value.length)==value);case'$=':return(result.substr(result.length-value.length)==value);case'!=':return(result!=value);case'~=':return result.contains(value,' ');case'|=':return result.contains(value,'-');}
return false;}};Selectors.Pseudo=new Hash({checked:function(){return this.checked;},empty:function(){return!(this.innerText||this.textContent||'').length;},not:function(selector){return!Element.match(this,selector);},contains:function(text){return(this.innerText||this.textContent||'').contains(text);},'first-child':function(){return Selectors.Pseudo.index.call(this,0);},'last-child':function(){var element=this;while((element=element.nextSibling)){if(element.nodeType==1)return false;}
return true;},'only-child':function(){var prev=this;while((prev=prev.previousSibling)){if(prev.nodeType==1)return false;}
var next=this;while((next=next.nextSibling)){if(next.nodeType==1)return false;}
return true;},'nth-child':function(argument,local){argument=(argument==undefined)?'n':argument;var parsed=Selectors.Utils.parseNthArgument(argument);if(parsed.special!='n')return Selectors.Pseudo[parsed.special].call(this,parsed.a,local);var count=0;local.positions=local.positions||{};var uid=$uid(this);if(!local.positions[uid]){var self=this;while((self=self.previousSibling)){if(self.nodeType!=1)continue;count++;var position=local.positions[$uid(self)];if(position!=undefined){count=position+count;break;}}
local.positions[uid]=count;}
return(local.positions[uid]%parsed.a==parsed.b);},index:function(index){var element=this,count=0;while((element=element.previousSibling)){if(element.nodeType==1&&++count>index)return false;}
return(count==index);},even:function(argument,local){return Selectors.Pseudo['nth-child'].call(this,'2n+1',local);},odd:function(argument,local){return Selectors.Pseudo['nth-child'].call(this,'2n',local);},selected:function(){return this.selected;},enabled:function(){return(this.disabled===false);}});var Swiff=new Class({Implements:[Options],options:{id:null,height:1,width:1,container:null,properties:{},params:{quality:'high',allowScriptAccess:'always',wMode:'transparent',swLiveConnect:true},callBacks:{},vars:{}},toElement:function(){return this.object;},initialize:function(path,options){this.instance='Swiff_'+$time();this.setOptions(options);options=this.options;var id=this.id=options.id||this.instance;var container=document.id(options.container);Swiff.CallBacks[this.instance]={};var params=options.params,vars=options.vars,callBacks=options.callBacks;var properties=$extend({height:options.height,width:options.width},options.properties);var self=this;for(var callBack in callBacks){Swiff.CallBacks[this.instance][callBack]=(function(option){return function(){return option.apply(self.object,arguments);};})(callBacks[callBack]);vars[callBack]='Swiff.CallBacks.'+this.instance+'.'+callBack;}
params.flashVars=Hash.toQueryString(vars);if(Browser.Engine.trident){properties.classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';params.movie=path;}else{properties.type='application/x-shockwave-flash';properties.data=path;}
var build='<object id="'+id+'"';for(var property in properties)build+=' '+property+'="'+properties[property]+'"';build+='>';for(var param in params){if(params[param])build+='<param name="'+param+'" value="'+params[param]+'" />';}
build+='</object>';this.object=((container)?container.empty():new Element('div')).set('html',build).firstChild;},replaces:function(element){element=document.id(element,true);element.parentNode.replaceChild(this.toElement(),element);return this;},inject:function(element){document.id(element,true).appendChild(this.toElement());return this;},remote:function(){return Swiff.remote.apply(Swiff,[this.toElement()].extend(arguments));}});Swiff.CallBacks={};Swiff.remote=function(obj,fn){var rs=obj.CallFunction('<invoke name="'+fn+'" returntype="javascript">'+__flash__argumentsToXML(arguments,2)+'</invoke>');return eval(rs);};


var MooToolsPatched=true;Browser.Engines.webkit=function(){return(navigator.mozIsLocallyAvailable)?false:((Browser.Features.xpath)?((Browser.Features.query)?525:420):419);};Browser.detect();Element.Events.mousewheel={base:(Browser.Engine.gecko)?'DOMMouseScroll':'mousewheel'};


var THE_PAGE_IS_LOADED=false;if(navigator.userAgent.match(/MSIE.*Mac/)){Array.prototype.push=function(str_value){this[this.length]=str_value;}}
var ONLOAD_FUNCTIONS=new Array();function Goto(form_name,tmpl,pairs_to_set)
{var form=document.forms[form_name];form.template.value=tmpl;if(typeof(form.news_id)!='undefined')form.news_id.value='';if(typeof(pairs_to_set)!='undefined'){var array=pairs_to_set.split('&');for(var i=0;i<array.length;i++){var pair=array[i].split('=');var obj=eval('form.'+pair[0]);if(typeof(obj)!='undefined'){obj.value=pair[1];}}}
if(form.action.indexOf("javascript:Goto")!=-1){form.action=tmpl;}
form.submit();}
function GotoEx(window_obj,form_name,tmpl)
{window_obj.Goto(form_name,tmpl);}
function Trim(str)
{str=str.replace(/^\s*/,"");str=str.replace(/\s*$/,"");return str;}
function IsValidInteger(str)
{str=Trim(str);return str.length>0&&IsValid(str,'0123456789-');}
function IsValidNatural(str)
{str=Trim(str);return str.length>0&&str.indexOf('0')!=0&&IsValid(str,'1234567890');}
function IsValidReal(str)
{str=Trim(str);return str.length>0&&IsValid(str,'0123456789.-');}
function IsValid(str,alphabet)
{for(var i=0;i<str.length;i++){if(alphabet.indexOf(str.charAt(i))==-1)return false;}
return true;}
function IsValidIdentifier(str)
{str=Trim(str);return IsValid(str,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890-_');}
function IsValidEmail(strEmail)
{var validEmailRegExp=/^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]+)(\.[a-z]{2,6}(\.[a-z]{2,6}){0,2})$/i;return validEmailRegExp.test(strEmail);}
function IsValidSQLDate(sql_date)
{sql_date=Trim(sql_date);var parts=sql_date.split(' ');var time_str=parts.length>1?parts[1]:"";var date_str=parts.length>0?parts[0]:"";if(date_str==""){return false;}
if(time_str!=""){var time_parts=time_str.split(/:/);if(time_parts.length!=3)return false;var time_parts_valid=(time_parts[0]!=""&&time_parts[0]>=0&&time_parts[0]<=23&&time_parts[1]!=""&&time_parts[1]>=0&&time_parts[1]<=59&&time_parts[2]!=""&&time_parts[2]>=0&&time_parts[2]<=59);if(!time_parts_valid)return false;}
var date_parts=date_str.split(/-/);if(date_parts.length!=3)return false;var date_obj=new Date(date_parts[0],date_parts[1]-1,date_parts[2]);return date_parts[0]==date_obj.getFullYear()&&date_parts[1]==date_obj.getMonth()+1&&date_parts[2]==date_obj.getDate();}
function SKPopup(url,width,height,options)
{SKPopupHandle(url,width,height,options);}
function SKPopupHandle(url,width,height,options)
{var left=screen.width/2-width/2;var top=screen.height/2-height/2;var name='OpenedPopupWindow'+width+height;var resizable="yes";var scrollbars="yes";var status="no";var toolbar="no";var menubar="no";var modal="no";var location="no";if(typeof(options)!='undefined'){if(typeof(options['resizable'])!='undefined')
resizable=options['resizable'];if(typeof(options['scrollbars'])!='undefined')
scrollbars=options['scrollbars'];if(typeof(options['left'])!='undefined')
left=options['left'];if(typeof(options['top'])!='undefined')
top=options['top'];if(typeof(options['name'])!='undefined')
name=options['name'];if(typeof(options['status'])!='undefined')
status=options['status'];if(typeof(options['toolbar'])!='undefined'){toolbar=options['toolbar'];}
if(typeof(options['modal'])!='undefined'){modal=options['modal'];}
if(typeof(options['menubar'])!='undefined'){menubar=options['menubar'];}
if(typeof(options['location'])!='undefined'){location=options['location'];}}
var options='left='+left+',top='+top+',width='+width+',height='+height+',resizable='+resizable+',scrollbars='+scrollbars+',toolbar='+toolbar+',menubar='+menubar+',location='+location+',modal='+modal+',status='+status;try{document.body.style.cursor='wait';var handle=window.open(url,name,options);if(handle)
handle.focus();else
AlertSystemMessage("<font class=\"heading1\">Prosim, omogočite odpiranje novih oken</font>\n"+"<font class=\"plain\">Nastavitve tvojega brskalnika onemogočajo odpiranje novih oken. Za normalno delovanje administracije prosimo, da omogočiš odpiranje novih oken.<br><div class=\"popupBlockerImage\">&nbsp;</div></font>");document.body.style.cursor='default';return handle;}catch(e){document.body.style.cursor='default';return null;}}
function AreCookiesEnabled()
{var test_cookie_string="TestingIfCookiesAreEnabled=TestValue";document.cookie=test_cookie_string;if(document.cookie.indexOf(test_cookie_string)==-1){return false;}
document.cookie=test_cookie_string+'Expires: '+"; expires=Thu, 01-Jan-70 00:00:01 GMT";return true;}
function AlertNotEnabledCookiesMessage()
{AlertSystemMessage("<font class=\"heading1\">Piškotki so onemogočeni</font>\n"+"<font class=\"plain\">Piškotki v tvojem brskalniku so onemogočeni. Za administriranje strani morajo biti omogočeni.</font>");}
function AlertSystemMessage(message)
{var box=document.createElement('div');box.setAttribute('class','SystemAlertPlaceholder');box.className='SystemAlertPlaceholder';box.id='SystemAlertPlaceholderID';box.setAttribute('id','SystemAlertPlaceholderID');box.innerHTML='<div class="content"><div class="text">'+
message+'<div class="break"></div><a href="javascript:{}" class="plain" onclick="document.body.removeChild(document.getElementById(\'SystemAlertPlaceholderID\'));">Skrij to sporočilo</a><br>'+'</div></div>'+'<div class="bl"></div><div class="bm"></div><div class="br"></div>';document.body.appendChild(box);}
function RefreshCachedImages()
{}
function LoginToEdit(login,login_page,template_path)
{var options=new Array();options['resizable']='no';options['scrollbars']='no';if(typeof(template_path)=='undefined'||template_path==''){template_path=document.location.pathname;}
SKPopup(login_page+'?template_path='+escape(template_path)+'&domain='+document.location.host+'&target_window=top.opener'+'&login='+login,300,200,options);}
function ExecuteOnLoadFunctions()
{THE_PAGE_IS_LOADED=true;for(var i=0;i<ONLOAD_FUNCTIONS.length;i++){if(typeof ONLOAD_FUNCTIONS[i]=='function'){ONLOAD_FUNCTIONS[i]();}else{eval(ONLOAD_FUNCTIONS[i]);}}}
function IsPageLoaded()
{return THE_PAGE_IS_LOADED;}
function FixURL(url)
{url=Trim(url);url=url.replace(/\"/g,escape('"'));url=url.replace(/\'/g,escape("'"));url=url.replace(/ /g,escape(" "));if(url.toLowerCase().indexOf('://')==-1&&url.toLowerCase().indexOf('mailto:')!=0){if(url.indexOf('@')!=-1&&url.indexOf('.')!=-1){return'mailto:'+url;}else{return'http://'+url;}}
return url;}
function ScrollTop(){window.scrollTo(0,0);}
function GetCurrentLocationFileName(){var loc=document.location.pathname;return loc.substring(loc.lastIndexOf('/')+1,loc.length);}


function AddImagenEncoding(arrIDs){var sEncoding=SK.Singletons.env.get('encoding');for(var i=0;i<arrIDs.length;i++){var oImage=document.getElementById(arrIDs[i]);if(!oImage||typeof oImage=='undefined')return;oImage.src+='&encoding=%22'+escape(sEncoding)+'%22';}}
function LoadCSS(sUrl,oProps){var arrHead=document.getElementsByTagName('HEAD');var oHead=arrHead[0];var oLink=document.createElement('LINK');oLink.rel=(oProps&&typeof oProps.rel!='undefined')?oProps.rel:'stylesheet';oLink.type=(oProps&&typeof oProps.type!='undefined')?oProps.type:'text/css';if(oProps&&typeof oProps.title!='undefined'){oLink.title=oProps.title;}
oLink.href=sUrl;oHead.appendChild(oLink);}
function LoadScript(sUrl,oProps){var arrHead=document.getElementsByTagName('HEAD');var oHead=arrHead[0];var oScript=document.createElement('SCRIPT');oScript.type=(oProps&&typeof oProps.type!='undefined')?oProps.type:'text/javascript';oScript.src=sUrl;oHead.appendChild(oScript);}


var MOUSEOVERS={};var MOUSEOUTS={};var SK__PAGE_ID=new Array();function MouseOver(image_name,layer_name)
{if(!IsPageLoaded())
return;var _document=document;if(!document.all&&typeof(layer_name)!='undefined'){_document=(new Layer(layer_name)).Document;}
if(typeof _document.images[image_name]!='undefined'){if(typeof(MOUSEOVERS[image_name])!='undefined'){_document.images[image_name].src=MOUSEOVERS[image_name].src;}else{_document.images[image_name].src=eval(image_name+'_h').src;}}}
function MouseOut(image_name,layer_name)
{if(!IsPageLoaded())
return;var _document=document;if(!document.all&&typeof(layer_name)!='undefined'){_document=(new Layer(layer_name)).Document;}
if(typeof _document.images[image_name]!='undefined'){if(typeof(MOUSEOUTS[image_name])!='undefined'){_document.images[image_name].src=MOUSEOUTS[image_name].src;}else{_document.images[image_name].src=eval(image_name).src;}}}
function MouseClick(image_name,template)
{if(!IsPageLoaded())
return;document.ObjEditForm.current_highlighted_image_name.value=image_name;Goto('ObjEditForm',template);}
function SK__ImageHL(cfg)
{MOUSEOUTS[cfg.name]=new Image();MOUSEOUTS[cfg.name].src=cfg.base;MOUSEOVERS[cfg.name]=new Image();MOUSEOVERS[cfg.name].src=cfg.base+(cfg.base.charAt(cfg.base.length-1)=='/'?"":"/")+"over=1";}
function SK__CurrentItem(cfg)
{if(cfg.link==SK__PAGE_ID){MOUSEOUTS[cfg.name]=MOUSEOVERS[cfg.name];var old_onload=window.onload;window.onload=function(){if(old_onload){old_onload();}
MouseOver(cfg.name);};};}
function SK__SetPageID(id)
{SK__PAGE_ID=id;}
function SK__IsCurrentPage(link_id)
{return link_id==SK__PAGE_ID;}


var NN_4=(document.layers)?1:0;var IE=(document.all)?1:0;var NN_6=(!document.all&&document.getElementById)?1:0;var VISIBLE=NN_4?"show":"visible";var HIDDEN=NN_4?"hide":"hidden";var DISPLAY_ON="block";var DISPLAY_OFF="none";var LAYER__IS_NETSCAPE=(navigator.appName.indexOf("Explorer")==-1);var LAYER__NETSCAPE_TIME_PATCH_COEFFICIENT=NN_4?0:0;var inited_mouse_actions=false;var LAYERS_HASH={};var old_mouse_pos=new Object();old_mouse_pos.left=0;old_mouse_pos.top=0;var allow_default_dragging=false;var default_mousedown=null;var default_mousemove=null;var default_mouseup=null;function Layer(layer_name)
{NN_4=(document.layers)?1:0;IE=(document.all)?1:0;NN_6=(!document.all&&document.getElementById)?1:0;if(typeof(LAYERS_HASH)=='undefined')
LAYERS_HASH=new Array();this.LayerName=layer_name;this.Layer=Layer__GetLayerObj(layer_name);this.LayerStyle=Layer__GetLayerObjStyle(layer_name);this.Draggable=false;if(typeof(this.Layer)=='undefined'||typeof(this.LayerStyle)=='undefined'){this.Success=false;return null;}
this.SetPosition=Layer__SetLayerPosition;this.GetPosition=Layer__GetLayerPosition;this.SetVisible=Layer__SetLayerVisible;this.IsVisible=Layer__IsLayerVisible;this.SetDisplay=Layer__SetLayerDisplay;this.Move=Layer__Move;this.GetDimentions=IE||NN_6?Layer__GetLayerDimentions:Layer__GetLayerDimentions_NN;this.SetDimentions=IE||NN_6?Layer__SetLayerDimentions:Layer__SetLayerDimentions_NN;this.HTML=IE||NN_6?Layer__HTML:Layer__HTML_NN;this.DocumentMargins=IE||NN_6?Layer__GetDocumentMargins:Layer__GetDocumentMargins_NN;this.Document=IE?document:(NN_6?document:this.Layer.document);this.InitDrag=Layer__InitDrag;this.ReleaseDrag=Layer__ReleaseDrag;this.Maximize=Layer__Maximize;this.Center=Layer__Center;this.DocumentMargins();LAYERS_HASH[this.LayerName]=this;this.Success=true;return this;}
function Layer__DefaultDragging(func_handler_mousedown,func_handler_mousemove,func_handler_mouseup)
{default_mousedown=func_handler_mousedown;default_mousemove=func_handler_mousemove;default_mouseup=func_handler_mouseup;allow_default_dragging=true;}
function Layer__AllowDefaultDragging()
{allow_default_dragging=true;}
function Layer__ForbidDefaultDragging()
{allow_default_dragging=false;}
function Layer__GetLayerObj(layer_name,nested_ref){var layer;if(NN_6||IE){layer=document.getElementById(layer_name);}else if(NN_4){var layer_parent;if(typeof(nested_ref)!='undefined'){layer_parent=document.layers[nested_ref].document;}else{layer_parent=document;}
layer=layer_parent.layers[layer_name];}
return layer;}
function Layer__GetLayerObjStyle(layer_name,nested_ref){var layer=Layer__GetLayerObj(layer_name,nested_ref);if(!layer)return;if(NN_6){layer=layer.style;}else if(IE){layer=layer.style;}else if(NN_4){}
return layer;}
function Layer__SetLayerPosition(left,top)
{this.LayerStyle.left=left+((left+"").indexOf("px")==-1?"px":"");this.LayerStyle.top=top+((top+"").indexOf("px")==-1?"px":"");}
function Layer__GetLayerPosition()
{var pos=new Object();pos.left=parseInt(this.LayerStyle.left);pos.top=parseInt(this.LayerStyle.top);return pos;}
function Layer__SetLayerDimentions(width,height)
{this.LayerStyle.width=width+((width+"").indexOf("px")==-1?"px":"");this.LayerStyle.height=height+((height+"").indexOf("px")==-1?"px":"");}
function Layer__SetLayerDimentions_NN(width,height)
{this.LayerStyle.clip.width=width+((width+"").indexOf("px")==-1?"px":"");this.LayerStyle.clip.height=height+((height+"").indexOf("px")==-1?"px":"");}
function Layer__GetLayerDimentions()
{var dimentions=this.GetPosition();dimentions.width=parseInt(this.LayerStyle.width);dimentions.height=parseInt(this.LayerStyle.height);return dimentions;}
function Layer__GetLayerDimentions_NN()
{var dimentions=this.GetPosition();dimentions.width=parseInt(this.LayerStyle.clip.width);dimentions.height=parseInt(this.LayerStyle.clip.height);return dimentions;}
function Layer__Move(start_left,start_top,end_left,end_top,timeout,speed_coefficient,name)
{var layer=typeof(name)=='undefined'?this:new Layer(name);if(start_left==end_left&&start_top==end_top){layer.SetPosition(start_left,start_top);return;}
if(typeof(speed_coefficient)=='undefined'){speed_coefficient=1;}
var sign_left=__Layer__Sign(start_left,end_left);var sign_top=__Layer__Sign(start_top,end_top);var dleft=__Layer__Distance(start_left,end_left);var dtop=__Layer__Distance(start_top,end_top);var offset_left=1;var offset_top=1;if(dleft>dtop){if(dtop==0){offset_top=0;offset_left=1;}else{offset_top=1;offset_left=Math.floor(dleft/dtop);}}else{if(dleft==0){offset_top=1;offset_left=0;}else{offset_top=Math.floor(dtop/dleft);offset_left=1;}}
if(start_left!=end_left){start_left+=speed_coefficient*sign_left*offset_left+LAYER__NETSCAPE_TIME_PATCH_COEFFICIENT;}
if(start_top!=end_top){start_top+=speed_coefficient*sign_top*offset_top;}
layer.SetPosition(start_left,start_top);var new_sign_left=__Layer__Sign(start_left,end_left);var new_sign_top=__Layer__Sign(start_top,end_top);if(sign_left*new_sign_left<=0&&sign_top*new_sign_top<=0){return;}
var _name=typeof(name)=='undefined'?this.LayerName:name;if(timeout>0){window.setTimeout('Layer__Move('+start_left+', '+start_top+', '+end_left+', '+end_top+', '+timeout+', '+speed_coefficient+', "'+_name+'")',timeout);}else{Layer__Move(start_left,start_top,end_left,end_top,0,speed_coefficient,_name);}}
function __Layer__Distance(start,end)
{if(start>0&&end>0){return Math.abs(end-start);}
return Math.abs(start)+Math.abs(end);}
function __Layer__Sign(start,end)
{if(start<end)
return 1;if(start==end)
return 0;return-1;}
function Layer__SetLayerVisible(visible)
{this.LayerStyle.visibility=visible?VISIBLE:HIDDEN;}
function Layer__IsLayerVisible()
{return this.LayerStyle.visibility==VISIBLE;}
function Layer__SetLayerDisplay(visible)
{this.LayerStyle.display=visible?DISPLAY_ON:DISPLAY_OFF;}
function Layer__HTML(code)
{this.Layer.innerHTML=code;}
function Layer__HTML_NN(code)
{this.Document.open();this.Document.write(code);this.Document.close();}
function Layer__GetDocumentMargins()
{var d=document.body;if(document.documentElement&&document.compatMode!='BackCompat')d=document.documentElement;this.ScrollLeft=parseInt(d.scrollLeft);this.ScrollTop=parseInt(d.scrollTop);if(navigator.userAgent.toLowerCase().indexOf("safari")!=-1){this.ScrollLeft=parseInt(document.body.scrollLeft);this.ScrollTop=parseInt(document.body.scrollTop);}
this.WindowWidth=parseInt(d.clientWidth);this.WindowHeight=parseInt(d.clientHeight);this.DocumentWidth=parseInt(d.clientWidth)+parseInt(this.ScrollLeft);this.DocumentHeight=parseInt(d.clientHeight)+parseInt(this.ScrollTop);this.FullDocumentWidth=parseInt(d.scrollWidth);this.FullDocumentHeight=parseInt(d.scrollHeight);}
function Layer__GetDocumentMargins_NN()
{this.DocumentWidth=window.innerWidth+window.pageXOffset;this.DocumentHeight=window.innerHeight+window.pageYOffset;this.FullDocumentWidth=this.DocumentWidth;this.FullDocumentHeight=this.DocumentHeight;this.ScrollLeft=window.pageXOffset;this.ScrollTop=window.pageYOffset;this.WindowWidth=window.innerWidth;this.WindowHeight=window.innerHeight;}
function Layer__Maximize()
{this.DocumentMargins();this.SetDimentions(this.WindowWidth,this.WindowHeight);}
function Layer__Center(horizontally,vertically)
{var pos=this.GetPosition();var dimentions=this.GetDimentions();this.DocumentMargins();if(horizontally)
pos.left=this.WindowWidth/2-dimentions.width/2;if(vertically)
pos.top=this.WindowHeight/2-dimentions.height/2;this.SetPosition(pos.left,pos.top);}
function Layer__InitDrag()
{if(!inited_mouse_actions){if(IE){document.onmousedown=Layer__System__MOUSEDOWN;document.onclick=Layer__System__MOUSEUP;document.onmousemove=Layer__System__MOUSEMOVE;}else{document.onmousedown=Layer__System__MOUSEDOWN;document.captureEvents(Event.MOUSEDOWN);document.onmouseup=Layer__System__MOUSEUP;document.captureEvents(Event.MOUSEUP);document.onmousemove=Layer__System__MOUSEMOVE;document.captureEvents(Event.MOUSEMOVE);}
inited_mouse_actions=true;}
LAYERS_HASH[this.LayerName].Draggable=true;}
function Layer__ReleaseDrag()
{LAYERS_HASH[this.LayerName].Dragging=false;}
function Layer__System__MOUSEDOWN(event_obj)
{var dragged_some=false;for(var key in LAYERS_HASH){if(LAYERS_HASH[key].Draggable&&Layer__System__ClickedOverLayer(LAYERS_HASH[key],event_obj)){if(IE)
LAYERS_HASH[key].Dragging=true;else
LAYERS_HASH[key].Dragging=!LAYERS_HASH[key].Dragging;dragged_some=true;}}
if(!dragged_some&&allow_default_dragging){var current_pos=Layer__System__CurrentMousePosition(event_obj);default_mousedown(current_pos);}}
function Layer__System__MOUSEMOVE(event_obj)
{var old_pos=old_mouse_pos;var current_pos=Layer__System__CurrentMousePosition(event_obj);var dragged_some=false;for(var key in LAYERS_HASH){if(LAYERS_HASH[key].Draggable&&LAYERS_HASH[key].Dragging){LAYERS_HASH[key].LayerStyle.left=parseInt(LAYERS_HASH[key].LayerStyle.left)+(current_pos.left-old_pos.left);LAYERS_HASH[key].LayerStyle.top=parseInt(LAYERS_HASH[key].LayerStyle.top)+(current_pos.top-old_pos.top);dragged_some=true;}}
if(!dragged_some&&allow_default_dragging){default_mousemove(old_pos,current_pos);}}
function Layer__System__MOUSEUP(event_obj)
{var dragged_some=false;for(var key in LAYERS_HASH){if(LAYERS_HASH[key].Draggable&&LAYERS_HASH[key].Dragging){if(IE)
LAYERS_HASH[key].Dragging=false;dragged_some=true;}}
if(!dragged_some&&allow_default_dragging){var current_pos=Layer__System__CurrentMousePosition(event_obj);default_mouseup(current_pos);}}
function Layer__System__ClickedOverLayer(layer,event_obj)
{var pos=Layer__System__CurrentMousePosition(event_obj);var layer_pos=layer.GetDimentions();layer_pos.right=layer_pos.left+layer_pos.width;layer_pos.bottom=layer_pos.top+layer_pos.height;return(pos.left>=layer_pos.left&&pos.left<=layer_pos.right&&pos.top>=layer_pos.top&&pos.top<=layer_pos.bottom);}
function Layer__System__CurrentMousePosition(event_obj)
{var pos=new Object();if(IE){pos.left=event.clientX+document.body.scrollLeft;pos.top=event.clientY+document.body.scrollTop;}else{pos.left=event_obj.pageX+window.pageXOffset;pos.top=event_obj.pageY+window.pageYOffset;;}
old_mouse_pos=pos;return pos;}


if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";this.addParam("quality",q);this.addParam("allowscriptaccess","always");this.addParam("allownetworking","external");this.setAttribute("useExpressInstall",_7);this.setAttribute("doExpressInstall",false);var _d=(_9)?_9:window.location;this.setAttribute("xiRedirectUrl",_d);this.setAttribute("redirectUrl","");if(_a){this.setAttribute("redirectUrl",_a);}};deconcept.SWFObject.prototype={setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}
_19+="</object>";}
return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(_23,_24){var _25=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_25=new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");for(var i=15;i>6;i--){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);_25=new deconcept.PlayerVersion([i,0,0]);break;}
catch(e){}}}
catch(e){}
if(_23&&_25.major>_23.major){return _25;}
if(!_23||((_23.minor!=0||_23.rev!=0)&&_25.major==_23.major)||_25.major!=6||_24){try{_25=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}
catch(e){}}}
return _25;};deconcept.PlayerVersion=function(_29){this.major=parseInt(_29[0])!=null?parseInt(_29[0]):0;this.minor=parseInt(_29[1])||0;this.rev=parseInt(_29[2])||0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(q){var _2d=q.indexOf(_2b+"=");var _2e=(q.indexOf("&",_2d)>-1)?q.indexOf("&",_2d):q.length;if(q.length>1&&_2d>-1){return q.substring(q.indexOf("=",_2d)+1,_2e);}}return"";}};if(Array.prototype.push==null){Array.prototype.push=function(_2f){this[this.length]=_2f;return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;


var MEDIA_OBJECT_PROPS=['src','width','height','align','style','controller','uimode','showcontrols','scale','showlogo','autoplay','autostart','loop','playcount'];function MediaObject(src,width,height,align,controls,autoplay,loop,style){this.html=function(){var ebd=[];ebd.src=src;if(width)ebd.width=width;if(height)ebd.height=height;if(align)ebd.align=align;if(style)ebd.style=style;ebd.controller=(controls?'true':'false');ebd.uimode=(controls?'full':'none');ebd.showcontrols=(controls?1:0);ebd.scale='tofit';ebd.showlogo='false';ebd.autoplay=(autoplay?'true':'false');ebd.autostart=document.all?(autoplay?'true':'false'):(autoplay?1:0);ebd.loop=(loop?'true':'false');ebd.playcount=(loop?999999:1);var chunks=['<embed'];for(var idx=0;idx<MEDIA_OBJECT_PROPS.length;idx++){var prop=MEDIA_OBJECT_PROPS[idx];if(prop in ebd){chunks.push(prop+'="'+ebd[prop]+'"');}}
chunks.push('/>');return chunks.join(' ');}
this.write=function(){document.write(this.html());}}


var CVI_PENDING=[];var CVI_LOADED=false;var CVI_LOADER=null;var CVI_EFFECTS={reflex:function(image,options){cvi_reflex.add(image,options);},instant:function(image,options){cvi_instant.add(image,options);}};function ApplyImageEffect(image){if(image){var config=null;try{eval('config = '+image.getAttribute('options'));}catch(ex){}
CVI_PENDING.push([image,config]);}
if(CVI_LOADED){var curr;while(curr=CVI_PENDING.pop()){var image=curr[0];var config=curr[1];if(config&&config.name in CVI_EFFECTS){CVI_EFFECTS[config.name](curr[0],curr[1]);}}}else{if(!CVI_LOADER){CVI_LOADER=new Loader;CVI_LOADER.loadScript(CVI_LIBRARY_URL);CVI_LOADER.onload=function(){CVI_LOADED=true;if(document.all)
setTimeout(ApplyImageEffect,200);else
ApplyImageEffect();}
CVI_LOADER.load();}}}


var LOADER_SINK='image_sink';var LOADER_POOL=[];var LOADER_COUNT=0;function Loader(){this.id=LOADER_COUNT++;this.onerror=null;this.onload=null;this.onchange=null;this.loadScript=Loader__loadScript;this.loadImage=Loader__loadImage;this.loadElement=Loader__loadElement;this.clear=Loader__clear;this.load=Loader__load;this.ready=Loader__ready;this.merge=Loader__merge;this.addResource=Loader__addResource;this.getResource=Loader__getResource;this.setLoaded=Loader__setLoaded;this.setFailed=Loader__setFailed;this.notify=Loader__notify;this.clear();LOADER_POOL[this.id]=this;}
function Loader__clear(){this.resources={};this.pending=0;this.total=0;this.loaded=0;this.failed=0;this.preloaded=0;this.prefailed=0;this.loading=false;}
function Loader__load(){this.loading=true;this.loaded=this.preloaded;this.failed=this.prefailed;this.pending-=this.loaded;this.pending-=this.failed;this.preloaded=0;this.prefailed=0;this.notify();}
function Loader__loadElement(elem,url,sink){if(!this.addResource(url))return;elem.onload=LoadedHandler;elem.onerror=FailedHandler;elem.owner=this.id;elem.url=url;elem.src=url;if(!sink){sink=document.getElementById(LOADER_SINK);if(!sink){sink=document.createElement('DIV');sink.style.display='none';sink.id=LOADER_SINK;document.body.appendChild(sink);}}
sink.appendChild(elem);}
function Loader__loadScript(url){var scriptObj=document.createElement('SCRIPT');scriptObj.id="loader_gen_scr_"+this.id+"_"+genuid();scriptObj.onreadystatechange=function(){if(scriptObj.readyState=='loaded'||scriptObj.readyState=='complete'){this.onload();}}
this.loadElement(scriptObj,url,document.getElementsByTagName("head")[0]);}
function Loader__loadImage(url){var imageObj=document.createElement('IMG');imageObj.id="loader_gen_img_"+this.id+"_"+genuid();this.loadElement(imageObj,url);}
function Loader__ready(){return(this.loading==false);}
function Loader__merge(that){for(var url in that.resources){this.addResource(url);this.setLoaded(url,{id:that.resources[url]});}}
function Loader__addResource(url){if(url in this.resources||!url)return false;this.resources[url]=null;this.pending++;this.total++;this.notify();return true;}
function Loader__getResource(url){var resource=null;if(url in this.resources){resource=document.getElementById(this.resources[url]);if(resource){resource=resource.cloneNode(false);resource.id='resource_'+genuid();}}
return resource;}
function Loader__setLoaded(url,obj){if(this.resources[url])return;if(this.loading){this.pending--;this.loaded++;}else{this.preloaded++;}
this.resources[url]=obj.id;this.notify();}
function Loader__setFailed(url){if(this.loading){this.pending--;this.failed++;}else{this.prefailed++;}
this.resources[url]=null;this.notify();}
function Loader__notify(){if(!this.loading)return;if(this.onchange)this.onchange();if(this.pending==0){this.loading=false;if(this.failed==0){if(this.onload)this.onload();}else{if(this.onerror)this.onerror();}}}
function LoadedHandler(){var owner=LOADER_POOL[this.owner];if(owner){owner.setLoaded(this.url,this);}}
function FailedHandler(){var owner=LOADER_POOL[this.owner];if(owner){owner.setFailed(this.url);}}
function genuid(){return(new Date).getMilliseconds()+"_"+Math.floor(Math.random()*10000000000);}


function StripLocation(loc){var protocol_end='://';var protocol_end_pos=loc.indexOf(protocol_end);if(-1==protocol_end_pos){return"";}
var domain_start=protocol_end_pos+protocol_end.length;var last_occ_pos=loc.lastIndexOf('/');if(-1==last_occ_pos||last_occ_pos<=domain_start){return loc;}
return loc.substring(0,last_occ_pos);}
function RemoveWWW(loc){return loc.replace(':\/\/www\.','://');}
function ExtarctDomain(loc){var protocol_end='://'
var protocol_end_pos=loc.indexOf(protocol_end);if(-1==protocol_end_pos){return"";}
var domain_start=protocol_end_pos+protocol_end.length;var first_occ_pos=loc.indexOf('/',domain_start+1);if(-1==first_occ_pos){return loc.substring(domain_start);}
return loc.substring(domain_start,first_occ_pos);}
function GetReferrer(loc,referrer){if(referrer==''){return""}
var stripped_loc=StripLocation(loc);stripped_loc=RemoveWWW(stripped_loc);referrer=RemoveWWW(referrer);if(0==referrer.indexOf(stripped_loc)){return"";}
return ExtarctDomain(referrer);}
function StatsGetCookie(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return'';}else{begin+=2;}
var end=dc.indexOf(";",begin);if(end==-1)end=dc.length;return unescape(dc.substring(begin+prefix.length,end));}
function StatsDeleteCookie(name){document.cookie=name+"=; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT";}
function HitStats(script_url,site_id,page_id,sess_id_name,prof_info){var cur_referrer=StatsGetCookie('cur_referrer');if(cur_referrer!=''){StatsDeleteCookie('cur_referrer');}else{cur_referrer=document.referrer;}
var ref=GetReferrer(document.location.href,cur_referrer);var ref_pv=ref!=''?'&ref='+escape(ref):'';var sess_id=StatsGetCookie(sess_id_name);var url=script_url+"?__DCP_NO_SESS__=1&site_id="+site_id+"&page_id="+page_id+"&sess_id="+sess_id+ref_pv+
(prof_info?"&prof_time="+escape(prof_info.RawTime)+"&prof_text="+escape(prof_info.Message):"");var hit_frm=document.createElement('IFRAME');hit_frm.style.visibility='hidden';hit_frm.style.display='none';hit_frm.style.width=1;hit_frm.style.height=1;hit_frm.src=url;hit_frm.id="hit_frame";document.body.insertBefore(hit_frm,document.body.lastChild);}
function SSOpenPage(file_name)
{if(file_name!=""){var path_name=window.opener.location.pathname;var index=path_name.lastIndexOf('/');if(index==-1)return;path_name=path_name.substring(0,index+1)+file_name;window.opener.document.location.href=path_name;}}


if(typeof SK=='undefined')SK={};if(typeof SK.Utils=='undefined')SK.Utils={};SK.Utils.SiteReferrer=new Class({COOKIE_NAME:'site_referrer',initialize:function(){},store:function(){var referrer=document.referrer;var host=document.location.host;if(referrer=="")return;var ref_host=(referrer.split('/'))[2];if(host!=ref_host){Cookie.write(this.COOKIE_NAME,referrer,{duration:30,path:'/'});}},retrieve:function(){return Cookie.read(this.COOKIE_NAME);}});


if(typeof SK=='undefined')SK={};if(typeof SK.DB=='undefined')SK.DB={};SK.DB=new Class({db_cache:{},column_cache:{},initialize:function(token,api_options){this.token=token;this.api_options=$merge({encoding:SK.Util.getEncoding()},api_options||null);},execute:function(command,properties,callback){var api_properties={};for(var i in properties){var value=properties[i];if($type(properties[i])!='string'){value=JSON.encode(properties[i]);}
api_properties[i]=value;}
new SK.API(this.token,this.api_options).execute(command,api_properties,callback);},getDatabases:function(callback_ok,callback_failure){this.execute('db.get_all',{},function(success,message,data){if(success){data.databases.each(function(db){this.mgr.db_cache[db.id]=db;},this);this.callback_ok(data.databases.sort(function(a,b){var db1=a.name.toLowerCase();var db2=b.name.toLowerCase();return db1<db2?-1:db1>db2?1:0;}));}else{if(this.callback_failure)this.callback_failure(message);}}.bind({mgr:this,callback_ok:callback_ok,callback_failure:callback_failure}));},getDatabase:function(db_id,callback_ok,callback_failure){if(typeof(this.db_cache[db_id])!='undefined'){callback_ok(this.db_cache[db_id]);return;}
this.execute('db.get',{db_id:db_id},function(success,message,data){if(success){this.mgr.db_cache[data.id]=data;this.callback_ok(data);}else{this.callback_failure(message);}}.bind({mgr:this,callback_ok:callback_ok,callback_failure:callback_failure}));},getDatabaseID:function(db_name,callback_ok,callback_failure){this.getDatabases(function(databases){for(var i=0;i<databases.length;i++){if(databases[i].name==db_name){this.callback_ok(databases[i].id);return;}}
if(this.callback_failure)this.callback_failure("Database was not found");}.bind({callback_ok:callback_ok,callback_failure:callback_failure}),callback_failure);},addDatabase:function(db_meta,callback_ok,callback_failure){this.execute('db.add',db_meta,function(success,message,data){if(success){this.mgr.db_cache[data.id]=data;this.callback_ok(data);}else{this.callback_failure(message);}}.bind({mgr:this,callback_ok:callback_ok,callback_failure:callback_failure}));},getColumns:function(db_id,callback_ok,callback_failure){this.getColumnsUIProperties(db_id,function(columns_ui_properties){var callback_ok=this.callback_ok;var callback_failure=this.callback_failure;this.mgr.execute('db.column.get_all',{db_id:this.db_id},function(success,message,data){if(success){data.columns.each(function(column){this.mgr.column_cache[column.id]=column;},this);var columns_in_order_list=[];var columns_in_order_index={};var columns_hidden_index={};for(var i=0;i<columns_ui_properties.ordered.length;i++){var id=columns_ui_properties.ordered[i];var column=this.mgr.column_cache[id];if(typeof column=='undefined')continue;column.width=columns_ui_properties.width[id];column.sorted=false;if(id==columns_ui_properties.default_sort_column_id){column.sorted=true;column.sort_order=columns_ui_properties.default_sort_column_order.toLowerCase();}
columns_in_order_list.push(column);columns_in_order_index[columns_ui_properties.ordered[i]]=true;}
for(var i=0;i<columns_ui_properties.hidden.length;i++){columns_in_order_index[columns_ui_properties.hidden[i]]=true;}
for(var i=0;i<data.columns.length;i++){if(typeof columns_in_order_index[data.columns[i].id]=='undefined'&&typeof columns_hidden_index[data.columns[i].id]=='undefined'){columns_in_order_list.push(data.columns[i]);}}
this.callback_ok(columns_in_order_list);}else{if(this.callback_failure)this.callback_failure(message);}}.bind({mgr:this.mgr,callback_ok:callback_ok,callback_failure:callback_failure,ui_properties:columns_ui_properties}));}.bind({mgr:this,db_id:db_id,callback_ok:callback_ok,callback_failure:callback_failure}),function(message){if(this.callback_failure)this.callback_failure(message);}.bind({callback_failure:callback_failure}));},getColumnsUIProperties:function(db_id,callback_ok,callback_failure){this.getDatabase(db_id,function(db){var ordered_column_ids=[];var visible_column_ids=[];var hidden_column_ids=[];var widths_per_column=[];var default_sort_column_id=null;var default_sort_column_order=null;if(typeof db.extra.columns_order!='undefined'){ordered_column_ids=db.extra.columns_order;}
var column_types={"0":visible_column_ids,"1":hidden_column_ids};if(typeof db.extra.columns!='undefined'){for(var i=0;i<db.extra.columns.length;i++){var hidden=typeof db.extra.columns[i].hidden=='undefined'?0:db.extra.columns[i].hidden;column_types[hidden].push(db.extra.columns[i].id);var width=typeof db.extra.columns[i].width=='undefined'?'':db.extra.columns[i].width;widths_per_column[db.extra.columns[i].id]=width;}}
this.callback_ok({visible:visible_column_ids,hidden:hidden_column_ids,ordered:ordered_column_ids,width:widths_per_column,default_sort_column_id:$defined(db.extra.sort_on)?db.extra.sort_on:null,default_sort_column_order:$defined(db.extra.sort_by)?db.extra.sort_by:null});}.bind({callback_ok:callback_ok,callback_failure:callback_failure}),function(message){if(this.callback_failure)this.callback_failure(message);}.bind({callback_failure:callback_failure}));},getColumnsMeta:function(db_id,column_names,callback_ok,callback_failure){this.getColumns(db_id,function(columns){if(column_names==null){this.callback_ok(columns);}else{var only_columns=[];for(var i=0;i<column_names.length;i++){for(var j=0;j<columns.length;j++){if(column_names[i]==columns[j].name){only_columns.push(columns[j]);}}}
this.callback_ok(only_columns);}}.bind({callback_ok:callback_ok,callback_failure:callback_failure}),function(message){if(this.callback_failure)this.callback_failure(message);}.bind({callback_failure:callback_failure}));},addColumn:function(column_meta,callback_ok,callback_failure){this.execute('db.column.add',column_meta,function(success,message,data){if(success){this.callback_ok(data);}else{this.callback_failure(message);}}.bind({mgr:this,callback_ok:callback_ok,callback_failure:callback_failure}));},updateColumn:function(){alert("Not implemented yet");},removeColumn:function(){alert("Not implemented yet");},updateCells:function(db_id,cells,callback_ok,callback_failure){this.mapCellsByColumnID(db_id,cells,function(cells,columns){this.mgr.updateCellsByIDs(this.db_id,columns,cells,this.callback_ok,this.callback_failure),callback_failure}.bind({mgr:this,db_id:db_id,callback_ok:callback_ok,callback_failure:callback_failure}));},updateCellsByIDs:function(db_id,columns_meta,cells,callback_ok,callback_failure){this.execute('db.cell.update_multiple',{cells:cells.map(function(cell){return $extend(cell,{lock_id:'auto'});})},function(success,message,data){if(!success){this.callback_failure(message);}else{var new_cells={};var columns_map={};for(var i=0;i<this.columns.length;i++){columns_map[this.columns[i].id]=this.columns[i];}
for(var i=0;i<data.cells.length;i++){var column_name=typeof(columns_map[data.cells[i].col_id])=='undefined'?'('+data.cells[i].col_id+')':columns_map[data.cells[i].col_id].name;new_cells[column_name]=data.cells[i];}
this.callback_ok(columns_meta,new_cells);}}.bind({callback_ok:callback_ok,callback_failure:callback_failure,columns:columns_meta}));},mapCellsByColumnID:function(db_id,cells,callback_ok,callback_failure){this.getColumns(db_id,function(columns){var columns_map={};for(var i=0;i<columns.length;i++){columns_map[columns[i].name]=columns[i];}
var new_cells={};for(var col_name in this.cells){if(typeof columns_map[col_name]=='undefined'){this.callback_failure("Invalid column name: "+col_name);return;}
var column=columns_map[col_name];new_cells[column.id]=cells[col_name];}
this.callback_ok(new_cells,columns);}.bind({mgr:this,db_id:db_id,callback_ok:callback_ok,callback_failure:callback_failure,cells:cells}),function(message){this.callback_failure(message);}.bind({mgr:this,callback_ok:callback_ok,callback_failure:callback_failure}));},getRecords:function(db_id,column_names,filter,callback_ok,callback_failure){this.getColumnsMeta(db_id,column_names,function(columns_meta){if(this.filter==null){this.filter={where:null,sort:null,limit:null};}
var columns_map={};for(var i=0;i<columns_meta.length;i++){columns_map[columns_meta[i].name]=columns_meta[i];}
if(this.filter.where!=null){var processed_where=[];for(var i=0;i<this.filter.where.length;i++){if(typeof columns_map[this.filter.where[i][0]]!='undefined'){this.filter.where[i][0]=columns_map[this.filter.where[i][0]].id;processed_where.push(this.filter.where[i]);}}
if(processed_where.length==0){if(this.callback_failure)this.callback_failure("Invalid WHERE statement or column not found");return;}
this.filter.where=processed_where;}
if(this.filter.sort!=null){if(typeof(columns_map[filter.sort.column])=='undefined'){if(this.callback_failure)this.callback_failure("Invalid SORT statement or column not found");return;}
this.filter.sort.column=columns_map[filter.sort.column].id;}
this.mgr.getRecordsByIDs(this.db_id,columns_meta,this.filter,this.callback_ok,this.callback_failure);}.bind({mgr:this,db_id:db_id,filter:filter,callback_ok:callback_ok,callback_failure:callback_failure}),function(message){if(this.callback_failure)this.callback_failure(message);}.bind({callback_failure:callback_failure}));},getRecordsByIDs:function(db_id,columns_meta,filter,callback_ok,callback_failure){var index_only=(typeof filter!='undefined'&&filter.limit!='undefined'&&filter.limit!=null)?1:0;var original_filter=filter;if(filter!=null){var new_filter={};if(filter.sort!=null)new_filter.sort=filter.sort;if(filter.where!=null)new_filter.where=filter.where;if(new Hash(new_filter).getKeys().length>0){filter=$H(new_filter);}else{filter={};}}
var callback=function(success,message,data){if(success){var total_num_rows=data.rows.length;var rows_to_get=[];if(this.index_only==0){this.mgr.postProcessRows(this.columns_meta,data.rows,total_num_rows,this.callback_ok,this.callback_failure);return;}else{rows_to_get=data.rows.splice(this.filter.limit.from,this.filter.limit.count);}
this.mgr.getRowsData(rows_to_get,function(rows_data){this.mgr.postProcessRows(this.columns_meta,rows_data,this.total_num_rows,this.callback_ok,this.callback_failure);}.bind({mgr:this.mgr,total_num_rows:total_num_rows,callback_ok:this.callback_ok,callback_failure:this.callback_failure,columns_meta:this.columns_meta}),function(message){if(this.callback_failure)this.callback_failure(message);}.bind({callback_failure:callback_failure}));}else{if(this.callback_failure)this.callback_failure(message);}}.bind({mgr:this,filter:original_filter,index_only:index_only,callback_failure:callback_failure,callback_ok:callback_ok,columns_meta:columns_meta});if(typeof filter.where=='undefined'){this.execute('db.query.get_all_rows',{db_id:db_id,filter:filter,index_only:index_only},callback);}else{this.execute('db.query.get_filtered_rows',{filter:filter,index_only:index_only},callback);}},mapCellsByColumnName:function(columns_meta,cells){var columns_map={};var hr_cells={};for(var i=0;i<columns_meta.length;i++){columns_map[columns_meta[i].id]=columns_meta[i];}
for(var col_id in cells){var name="("+col_id+")";if(typeof columns_map[col_id]!='undefined'){name=columns_map[col_id].name;}
hr_cells[name]=cells[col_id];}
return hr_cells;},postProcessRows:function(columns_meta,rows_data,total_num_rows,callback_ok,callback_failure){var final_rows=[];for(var i=0;i<rows_data.length;i++){var cells=rows_data[i].cells;var hr_cells=this.mapCellsByColumnName(columns_meta,cells);final_rows.push({row_id:rows_data[i].row_id,cells:hr_cells});}
callback_ok(columns_meta,final_rows,total_num_rows);},getRowsData:function(rows,callback_ok,callback_failure){if(rows.length==0){callback_ok([]);return;}
this.execute('db.row.get_multiple',{rows:rows},function(success,message,data){if(success){this.callback_ok(data.rows);}else{if(this.callback_failure)this.callback_failure(message);}}.bind({callback_failure:callback_failure,callback_ok:callback_ok}))},addRecord:function(db_id,cells,callback_ok,callback_failure){this.mapCellsByColumnID(db_id,cells,function(cells,columns){this.mgr.addRecordByIDs(this.db_id,columns,cells,this.callback_ok,this.callback_failure),callback_failure}.bind({mgr:this,db_id:db_id,callback_ok:callback_ok,callback_failure:callback_failure}));},addRecordByIDs:function(db_id,columns_meta,cells,callback_ok,callback_failure){this.execute('db.row.add',{db_id:db_id,cells:cells},function(success,message,data){if(success){var hr_cells=this.mgr.mapCellsByColumnName(this.columns,data.cells);this.callback_ok(data.row_id,hr_cells,this.columns);}else{if(this.callback_failure)this.callback_failure(message);}}.bind({mgr:this,callback_failure:callback_failure,callback_ok:callback_ok,columns:columns_meta}));},updateRecord:function(db_id,row_id,cells,callback_ok,callback_failure){this.mapCellsByColumnID(db_id,cells,function(cells,columns){this.mgr.updateRecordByIDs(this.row_id,columns,cells,this.callback_ok,this.callback_failure),callback_failure}.bind({mgr:this,row_id:row_id,callback_ok:callback_ok,callback_failure:callback_failure}));},updateRecordByIDs:function(row_id,columns,cells,callback_ok,callback_failure){var cells_to_update=[];for(var col_id in cells){cells_to_update.push({row_id:row_id,col_id:col_id,value:cells[col_id],lock_id:'auto'});}
this.execute('db.cell.update_multiple',{cells:cells_to_update},function(success,message,data){if(success){var hr_cells=this.mgr.mapCellsByColumnName(this.columns,data.cells);this.callback_ok(data.row_id,hr_cells,this.columns);}else{if(this.callback_failure)this.callback_failure(message);}}.bind({mgr:this,callback_failure:callback_failure,callback_ok:callback_ok,columns:columns}));},removeRecord:function(){alert('Not implemented yet');},getTokens:function(callback_ok,callback_failure){this.execute('db.access.get_all',{},function(success,message,data){if(success){this.callback_ok(data.tokens);}else{if(this.callback_failure)this.callback_failure(message);}}.bind({callback_failure:callback_failure,callback_ok:callback_ok}));},addToken:function(properties,callback_ok,callback_failure){this.execute('db.access.add',properties,function(success,message,data){if(success){this.callback_ok(data);}else{if(this.callback_failure)this.callback_failure(message);}}.bind({callback_ok:callback_ok,callback_failure:callback_failure}));},updateToken:function(token_id,properties,callback_ok,callback_failure){this.execute('db.access.update',{token_id:token_id,meta:properties},function(success,message,data){if(success){this.callback_ok(data);}else{if(this.callback_failure)this.callback_failure(message);}}.bind({callback_ok:callback_ok,callback_failure:callback_failure}));},getTokenByName:function(name,callback_ok,callback_failure){this.getTokens(function(tokens){for(var i=0;i<tokens.length;i++){if(tokens[i].name==name){this.callback_ok(tokens[i]);return;}}
this.callback_failure("Token was not found");}.bind({mgr:this,callback_ok:callback_ok,callback_failure:callback_failure,name:name}),callback_failure)},getToken:function(id,callback_ok,callback_failure){this.execute('db.access.get',{id:id},function(success,message,data){if(success){this.callback_ok(data);}else{if(this.callback_failure)this.callback_failure(message);}}.bind({callback_ok:callback_ok,callback_failure:callback_failure}));},removeToken:function(){alert('Not implemented yet');}});SK.DB.Column={TEXT:0,NUMBER:1,DATE:2,RICH_TEXT:3,PASSWORD:4,FILE:5,ID:6,CHECKBOX:7,DROPDOWN:8,MULTICHOICE:9,COMBO:10,FLOAT:11};SK.DB.Format=new Class({column_handlers:{},initialize:function(){[{id:SK.DB.Column.TEXT,handler:SK.DB.Format.Text},{id:SK.DB.Column.NUMBER,handler:SK.DB.Format.Number},{id:SK.DB.Column.DATE,handler:SK.DB.Format.Date},{id:SK.DB.Column.RICH_TEXT,handler:SK.DB.Format.RichText},{id:SK.DB.Column.PASSWORD,handler:SK.DB.Format.Password},{id:SK.DB.Column.FILE,handler:SK.DB.Format.File},{id:SK.DB.Column.ID,handler:SK.DB.Format.ID},{id:SK.DB.Column.CHECKBOX,handler:SK.DB.Format.Checkbox},{id:SK.DB.Column.DROPDOWN,handler:SK.DB.Format.Dropdown},{id:SK.DB.Column.MULTICHOICE,handler:SK.DB.Format.Multichoice},{id:SK.DB.Column.COMBO,handler:SK.DB.Format.Combo},{id:SK.DB.Column.FLOAT,handler:SK.DB.Format.Float}].each(function(column_type){this.setColumnHandler(column_type.id,column_type.handler);},this);},setColumnHandler:function(col_type,callback){this.column_handlers[col_type]=callback;},getColumnHandler:function(col_type){return typeof this.column_handlers[col_type]=='undefined'?SK.DB.Format.Default:this.column_handlers[col_type];},toClient:function(column_meta,value){var handler_ref=this.getColumnHandler(column_meta.type);var handler=new handler_ref(column_meta);return handler.toClient(value);},toServer:function(column_meta,value){var handler_ref=this.getColumnHandler(column_meta.type);var handler=new handler_ref(column_meta);return handler.toServer(value);}});SK.DB.Format.Default=new Class({"type":"default",column_meta:{},initialize:function(column_meta){this.column_meta=column_meta;},generateColumnCSSClass:function(){return"db-column-type db-column-type-"+this.type;},getColumnMeta:function(){return this.column_meta;},preFormat:function(value){if(!$defined(value))return'';return value;},toClient:function(value){value=this.preFormat(value);if(value=='')return value;return'<span class="'+this.generateColumnCSSClass()+'">'+value+'</span>';},toServer:function(value){return value;}});SK.DB.Format.Text=new Class({Extends:SK.DB.Format.Default,"type":"text"});SK.DB.Format.Number=new Class({Extends:SK.DB.Format.Default,"type":"number"});SK.DB.Format.Date=new Class({Extends:SK.DB.Format.Default,"type":"date"});SK.DB.Format.RichText=new Class({Extends:SK.DB.Format.Default,"type":"rich-text"});SK.DB.Format.Password=new Class({Extends:SK.DB.Format.Default,"type":"password",toClient:function(value){return'<span class="'+this.generateColumnCSSClass()+'">**********</span>';}});SK.DB.Format.File=new Class({Extends:SK.DB.Format.Default,"type":"file",toClient:function(value){value=this.preFormat(value);if(value=='')return value;var parts=value.split('/');var file_name=parts[parts.length-1].split(/\?|\#/)[0];return'<a class="'+this.generateColumnCSSClass()+'" href="'+value+'" target="_blank">'+file_name+'</a>';}});SK.DB.Format.ID=new Class({Extends:SK.DB.Format.Default,"type":"id"});SK.DB.Format.Checkbox=new Class({Extends:SK.DB.Format.Default,"type":"checkbox"});SK.DB.Format.Dropdown=new Class({Extends:SK.DB.Format.Default,"type":"dropdown",toClient:function(value){var options=this.getColumnMeta().extra.options;if($defined(options)){for(var i=0;i<options.length;i++){var option=options[i];if(typeof option[value]!='undefined'){value=option[value];break;}}}
value=this.preFormat(value);if(value=='')return value;return'<span class="'+this.generateColumnCSSClass()+'">'+value+'</span>';}});SK.DB.Format.Multichoice=new Class({Extends:SK.DB.Format.Dropdown,"type":"multichoice",toClient:function(value){if(!$defined(value)||$type(value)!='array'){return'';}
var arr=[];for(var i=0;i<value.length;i++){var e=value[i];arr.push(this.parent(e));}
return arr.join(", ");}});SK.DB.Format.Combo=new Class({Extends:SK.DB.Format.Default,"type":"combo"});SK.DB.Format.Float=new Class({Extends:SK.DB.Format.Default,"type":"float"});SK.DB.Setup=new Class({database:{},columns:[],tokens:[],session_id:null,callback_ok:$empty(),callback_failure:$empty(),initialize:function(session_id,structure,callback_ok,callback_failure){this.session_id=session_id;this.database=$pick(structure.database,{});this.columns=$pick(structure.columns,[]);this.tokens=$pick(structure.tokens,[]);this.callback_ok=callback_ok;this.callback_failure=callback_failure;},create:function(){var sync=new SK.Sync([this.setupDatabase.bind(this),this.setupColumns.bind(this),this.setupTokens.bind(this)],function(){this.callback_ok({database:this.database,columns:this.columns,tokens:this.tokens});}.bind(this),this.callback_failure);sync.run();},setupDatabase:function(sync_obj){this.hasDatabase(this.database.name,function(db_id){this.mgr.database.id=db_id;this.sync.ready();}.bind({mgr:this,sync:sync_obj}),function(){this.mgr.addDatabase(this.sync);}.bind({mgr:this,sync:sync_obj}))},hasDatabase:function(name,callback_yes,callback_no){new SK.DB(this.session_id).getDatabaseID(name,callback_yes,callback_no);},addDatabase:function(sync_obj){new SK.DB(this.session_id).addDatabase(this.database,function(db_meta){this.mgr.database=db_meta;this.sync.ready();}.bind({mgr:this,sync:sync_obj}),function(message){this.sync.failure(message);}.bind({mgr:this,sync:sync_obj}));},setupColumns:function(sync_obj){var db_id=this.database.id;new SK.DB(this.session_id).getColumns(db_id,function(columns){var desired_columns=this.mgr.columns;var missing_columns=[];var available_columns=[];for(var i=0;i<desired_columns.length;i++){var found=false;for(var j=0;j<columns.length;j++){if(columns[j].name==desired_columns[i].name&&columns[j].type==desired_columns[i].type){desired_columns[i]=$H(columns[j]);found=true;break;}}
if(!found){missing_columns.push(desired_columns[i]);}else{available_columns.push(desired_columns[i]);}}
if(missing_columns.length>0){this.mgr.columns=available_columns;this.mgr.addColumns(this.sync,missing_columns);}else{this.sync.ready();}}.bind({mgr:this,sync:sync_obj}),function(message){this.sync.failure("There was a failure setting up the columns in the database: "+message);}.bind({sync:sync_obj}));},getColumns:function(){return this.columns;},addColumns:function(sync_obj,columns){var add_column_functions=[];for(var i=0;i<columns.length;i++){add_column_functions.push(function(sync_obj){new SK.DB(this.mgr.session_id).addColumn($extend(this.column,{db_id:this.mgr.database.id}),function(column_meta){this.mgr.columns.push($H(column_meta));this.sync.ready();}.bind({mgr:this.mgr,sync:sync_obj,column:this.column}),function(message){this.sync.failure(message);}.bind({mgr:this.mgr,sync:sync_obj}));}.bind({mgr:this,column:columns[i]}));}
var columns_sync=new SK.Sync(add_column_functions,function(){this.sync.ready();}.bind({mgr:this,sync:sync_obj}),function(message){this.sync.failure(message);}.bind({sync:sync_obj}));columns_sync.run();},setupTokens:function(sync_obj){new SK.DB(this.session_id).getTokens(function(tokens){var desired_tokens=this.mgr.tokens;for(var i=0;i<desired_tokens.length;i++){var found=false;for(var j=0;j<tokens.length;j++){if(tokens[j].name==desired_tokens[i].name){desired_tokens[i]=$H(tokens[j]);found=true;break;}}
if(!found){desired_tokens[i]._sync_mode='add';}else{desired_tokens[i]._sync_mode='update';}}
this.mgr.tokens=[];this.mgr.syncTokens(this.sync,desired_tokens);}.bind({mgr:this,sync:sync_obj}),function(message){this.sync.failure("There was a failure setting up the access to the database: "+message);}.bind({sync:sync_obj}));},syncTokens:function(sync_obj,tokens){var sync_token_functions=[];for(var i=0;i<tokens.length;i++){sync_token_functions.push(function(sync_obj){var token=this.token;for(var i=0;i<token.extra.db_permissions.length;i++){token.extra.db_permissions[i].databases=[this.mgr.database.id];}
var sync_token_callback_ok=function(token_meta){this.mgr.tokens.push($H(token_meta));this.sync.ready();}.bind({mgr:this.mgr,sync:sync_obj,token:this.token});var sync_token_callback_failure=function(message){this.sync.failure(message);}.bind({mgr:this.mgr,sync:sync_obj});if(token._sync_mode=='add'){new SK.DB(this.mgr.session_id).addToken(token,sync_token_callback_ok,sync_token_callback_failure);}else if(token._sync_mode=='update'){new SK.DB(this.mgr.session_id).updateToken(token.id,{name:token.name,extra:token.extra},sync_token_callback_ok,sync_token_callback_failure);}else{sync_obj.ready();}}.bind({mgr:this,token:tokens[i]}));}
var tokens_sync=new SK.Sync(sync_token_functions,function(){this.sync.ready();}.bind({mgr:this,sync:sync_obj}),function(message){this.sync.failure(message);}.bind({sync:sync_obj}));tokens_sync.run();}});SK.DB.QueryHelpers=new Class({generateEmptyResult:function(){return{"rows":[]};},validateResponse:function(success,message){if(!success){alert('Response error: '+message);}
return success;}});SK.DB.Query=new Class({Implements:[SK.DB.QueryHelpers],initialize:function(token,request_params){this.request=new SK.API(token,request_params);return this;},buildRequest:function(filter,columns,callback){var params={filter:JSON.encode(filter),index_only:1}
return this.request.buildRequest('db.query.get_filtered_rows',params,this.retrieveFilteredRows.bind({mgr:this,columns:columns,callback:callback}));},execute:function(filter,columns,callback){return this.buildRequest(filter,columns,callback).send();},retrieveFilteredRows:function(success,message,data){if(!this.mgr.validateResponse(success,message)){return;}
if(!data.rows.length){this.callback.apply(null,[this.mgr.generateEmptyResult()]);return;}
var cells=[];for(var i=0;i<data.rows.length;i++){for(var j=0;j<this.columns.length;j++){cells.push({"row_id":data.rows[i],"col_id":this.columns[j]});}}
this.mgr.request.execute('db.cell.get_multiple',{cells:JSON.encode(cells)},this.mgr.retrieveMultipleCells.bind({mgr:this.mgr,callback:this.callback}));},retrieveMultipleCells:function(success,message,data){if(!this.mgr.validateResponse(success,message)){return;}
var temp={};for(var i=0;i<data.cells.length;i++){var cell=data.cells[i];if(!temp[cell.row_id]){temp[cell.row_id]={};}
temp[cell.row_id][cell.col_id]=cell.value;}
var result=this.mgr.generateEmptyResult();for(var row_id in temp){result.rows.push({row_id:row_id,cells:temp[row_id]});delete temp[row_id];}
this.callback.apply(this,[result]);}});SK.DB.QueryAggregate=new Class({Implements:[SK.DB.QueryHelpers],columns:[],filters:[],callbacks:[],checks:[],requestId:0,completeCallbacks:[],initialize:function(token,request_params){this.request=new SK.API(token,request_params);return this;},buildRequest:function(filter,columns,callback){this.filters.push(filter);this.columns.push(columns);this.callbacks.push(this.createCallbackWrapper(callback));return this;},createCallbackWrapper:function(callback){this.checks.push(0);return function(){this.callback.apply(null,arguments);this.checks.pop();if(this.checks.length==0){this.mgr.completeCallbacks[this.requestId].call(null);}}.bind({mgr:this,callback:callback,requestId:this.requestId,checks:this.checks});},send:function(){this.execute.apply(this,arguments);},execute:function(callback){callback=$pick(callback,$empty);var filters=[];var index=0;while(this.filters.length){filters.push({id:index,filter:this.filters.shift()});index++;}
if(!filters.length){callback.call(null);return;}
this.completeCallbacks[this.requestId]=callback;var params={filters:JSON.encode(filters),index_only:1};this.request.execute('db.query.get_filtered_rows_multiple',params,this.retrieveFilteredRows.bind({mgr:this,callbacks:this.callbacks,columns:this.columns}));this.callbacks=[];this.columns=[];this.checks=[];this.requestId++;},retrieveFilteredRows:function(success,message,data){if(!this.mgr.validateResponse(success,message)){return;}
var results={};for(var index in data){var rows=data[index].rows;var columns=this.columns[index];var callback=this.callbacks[index];if(rows.length==0){callback.apply(null,[this.mgr.generateEmptyResult()]);continue;}
results[index]=[];for(var i=0;i<rows.length;i++){for(var j=0;j<columns.length;j++){results[index].push({"row_id":rows[i],"col_id":columns[j]});}}}
var cells=[];for(var index in results){cells=cells.concat(results[index]);}
if(!cells.length){return;}
this.mgr.request.execute('db.cell.get_multiple',{cells:JSON.encode(cells)},this.mgr.retrieveMultipleCells.bind({mgr:this.mgr,callbacks:this.callbacks,results:results}));},retrieveMultipleCells:function(success,message,data){if(!this.mgr.validateResponse(success,message)){return;}
var data_map={};for(var i=0;i<data.cells.length;i++){var cell=data.cells[i];if(!data_map[cell.row_id]){data_map[cell.row_id]={};}
data_map[cell.row_id][cell.col_id]=cell.value;}
for(var index in this.results){var temp={};for(var i=0;i<this.results[index].length;i++){var cell=this.results[index][i];if(!temp[cell.row_id]){temp[cell.row_id]={};}
temp[cell.row_id][cell.col_id]=data_map[cell.row_id][cell.col_id];}
var result=this.mgr.generateEmptyResult();for(var row_id in temp){result.rows.push({row_id:row_id,cells:temp[row_id]});delete temp[row_id];}
this.callbacks[index].apply(null,[result]);}}});


SK.Sync=new Class({initialize:function(functions,callback_ok,callback_failure){this.functions=$A(functions);this.callback_ok=callback_ok;this.callback_failure=callback_failure;},run:function(){this.runNextFunction();},runFunction:function(f){f(this);},runNextFunction:function(){if(this.functions.length==0){this.callback_ok();return;}
var f=this.functions[0];this.functions=this.functions.splice(1,this.functions.length-1);this.runFunction(f);},ready:function(){this.runNextFunction();},failure:function(message){this.callback_failure(message);}});SK.Async=new Class({initialize:function(functions,callback_ok,callback_failure){this.functions=$A(functions);this.num_functions=this.functions.length;this.callback_ok=callback_ok;this.callback_failure=callback_failure;},run:function(){for(var i=0;i<this.functions.length;i++){var f=this.functions[i];this.runFunction.delay(1,this,[f]);}},runFunction:function(f){f(this);},ready:function(){if(this.num_functions<=0){return this;}
this.num_functions--;if(this.num_functions==0){this.callback_ok();return;}},failure:function(message){this.callback_failure(message);}});


if(typeof SK=='undefined')SK={};if(typeof SK.Util=='undefined')SK.Util={};SK.Util.isSlowSystem=function(){return Browser.Engine.trident4==true||parseInt(SK.Singletons.env.get('system_type'))==SK.Util.SYSTEM_TYPE_SLOW;};SK.Util.getEncoding=function(){var charset_properties=['characterSet','charset','inputEncoding','defaultCharset'];for(var i=0;i<charset_properties.length;i++){if(typeof(document[charset_properties[i]])!='undefined'){return document[charset_properties[i]];}}
return"";};SK.Util.duplicate=function(json){var new_json={};if(typeof(json)!='object')return json;for(var i in json){new_json[i]=SK.Util.duplicate(json[i]);}
return new_json[i];};SK.Util.isScalar=function(a){if(!a)return false;return typeof(a)!='object'||typeof(a)=='function';};SK.Util.isArray=function(a){if(!a)return false;return typeof(a)=='object'&&typeof(a.length)!='undefined';};SK.Util.isHash=function(a){if(!a)return false;return!SK.Util.isScalar(a)&&!SK.Util.isArray(a);};SK.Util.merge=function(base_json,instance_json){var merged=null;if(typeof instance_json=='undefined')
instance_json=null;if(typeof base_json=='undefined')
base_json=null;if(instance_json==null&&base_json==null)return null;if($chk(instance_json)&&!$chk(base_json)&&(SK.Util.isScalar(instance_json)||SK.Util.isArray(instance_json))){return instance_json;}
if(!$chk(instance_json)&&$chk(base_json)&&(SK.Util.isScalar(base_json)||SK.Util.isArray(base_json))){return base_json;}
if(base_json){if(SK.Util.isHash(base_json)){merged=merged==null?{}:merged;for(var i in base_json){if(instance_json&&typeof instance_json[i]!='undefined'&&SK.Util.isScalar(instance_json[i])){merged[i]=instance_json[i];}else{var merged_stuct=SK.Util.merge(base_json[i],instance_json?instance_json[i]:null);if(merged_stuct)merged[i]=merged_stuct;}}}}
if(instance_json){if(SK.Util.isHash(instance_json)){merged=merged==null?{}:merged;for(var i in instance_json){if(instance_json[i]==null){delete merged[i];}else{var merged_stuct=SK.Util.merge(base_json?base_json[i]:null,instance_json[i]);if(merged_stuct)merged[i]=merged_stuct;}}}}
return merged;};


if(typeof SK=='undefined')SK={};if(typeof SK.Util=='undefined')SK.Util={};SK.Util.URL={parseQueryString:function(query){var query_str=query||document.location.href;var begin=query_str.indexOf("?");if(begin==-1){return{};}
var end=query_str.indexOf("#",begin);if(end==-1)end=query_str.length;var params_str=query_str.substring(begin+1,end);var params=params_str.split("&");var result={};for(var i=0;i<params.length;i++){var pair=params[i].split("=");if(pair.length==2){result[unescape(pair[0])]=unescape(pair[1]);}}
return result;}};


if(typeof(SK)=='undefined')SK={};if(typeof(SK.Util)=='undefined')SK.Util={};if(typeof(SK.Util.DateTime)=='undefined')SK.Util.DateTime={};if(typeof(SK.LocationFormats)=='undefined')SK.LocationFormats={};SK.LocationFormats.DateTime=new Class({months:['Januar','Februar','Marec','April','Maj','Junij','Julij','Avgust','September','Oktober','November','December'],days:['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],months_short:['Jan','Feb','Mar','Apr','Maj','Jun','Jul','Avg','Sep','Okt','Nov','Dec'],days_short:['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],env:null,default_format:'$YEAR$-$0M$-$0D$',regexp_subs:null,initialize:function(){this.getEnv();this.createRegExpSubs();},getEnv:function(){this.env=SK.Singletons&&SK.Singletons.env?SK.Singletons.env:null;if(!this.env||!this.env.get('locale')){var win=window;try{do{win=win.opener||win.parent;if(win.SK.Singletons&&win.SK.Singletons.env&&win.SK.Singletons.env.get('locale')){if(this.env){this.env.set('locale',win.SK.Singletons.env.get('locale'));}else{this.env=$extend({},win.SK.Singletons.env);}}}while((win.opener&&win!==win.opener)||win!==win.parent);}catch(e){}}},createRegExpSubs:function(){this.regexp_subs={$WEEKDAY$:'('+this.days.join('|')+')',$WD$:'('+this.days_short.join('|')+')',$YEAR$:'\\d{4}',$YR$:'\\d{2}',$MONTH$:'('+this.months.join('|')+')',$MNT$:'('+this.months_short.join('|')+')',$MN$:'(0\\d|1[0-2]|[1-9])',$0M$:'(0\\d|1[0-2])',$D$:'([0-2]\\d|3[0-1]|[1-9])',$0D$:'([0-2]\\d|3[0-1])',$H$:'(1[0-2]|[0-9])',$H24$:'([1-2]\\d|[0-9])',$M$:'[0-5]\\d',$S$:'[0-5]\\d',$AMPM$:'(AM|PM)','$AM.PM$':'(P\\.M\\.|A\\.M\\.)',$TZ$:null,$TIMEZONE$:null,$UTC$:null};this.regexp_subs.$H12$=this.regexp_subs.$H$;},getFormat:function(format){format=format||'';if(format.indexOf('$')>=0){return format;}
format=this.env?this.env.get('locale')[format]:this.default_format;return format||this.default_format;},addZero:function(num){return num<10?"0"+num:num;},parseDate:function(input){var date_obj;if(!input){date_obj=new Date();}
else if($type(input)=='date'){return input.toString()!=='Invalid Date'?input:null;}
else{if(/^[a-zA-Z]{3}, \d{2} [a-zA-Z]{3} \d{4} \d{2}:\d{2}:\d{2} (\+|\-)\d{4}$/.test(input)){return new Date(Date.parse(input));}
input=input.replace(/\-|\./g,'/');if(input.match(/^\d{1,2}:\d{2}/)){input='01/01/1970 '+input;}
date_obj=new Date(input);}
if(date_obj.toString()=='Invalid Date'){return null;}
return date_obj;},parseDateUTC:function(input){var date_obj=this.parseDate(input);if(!date_obj){return null;}
return new Date(Date.UTC(date_obj.getFullYear(),date_obj.getMonth(),date_obj.getDate(),date_obj.getHours(),date_obj.getMinutes(),date_obj.getSeconds()));},format:function(input,format){format=this.getFormat(format);var date_obj=this.parseDate(input);if(!date_obj){return input;}
var day=date_obj.getDay();var date=date_obj.getDate();var month=date_obj.getMonth();var year=date_obj.getFullYear();var hours=date_obj.getHours();var minutes=date_obj.getMinutes();var seconds=date_obj.getSeconds();var offset=this.getOffset(date_obj);var tz_match=date_obj.toString().match(Browser.Engine.trident?/(UTC(\+|\-)\d{4}|[A-Z]{3,4})/:/\(([\(\)a-zA-Z\s\,\.]+)\)$/);var timezone=tz_match?tz_match[1]:'';var subs={$WEEKDAY$:this.days[day],$WD$:this.days_short[day],$YEAR$:year,$YR$:String(year).substr(2),$MONTH$:this.months[month],$MNT$:this.months_short[month],$MN$:month+1,$0M$:this.addZero(month+1),$D$:date,$0D$:this.addZero(date),$H$:hours>12?hours-12:hours,$H24$:hours,$M$:this.addZero(minutes),$S$:this.addZero(seconds),$AMPM$:hours>=12?'PM':'AM','$AM.PM$':hours>=12?'P.M.':'A.M.',$TZ$:timezone,$UTC$:offset<0?offset:'+'+offset};subs.$H12$=subs.$H$;subs.$TIMEZONE$=subs.$TZ$;return format.replace(/\$[A-Z0-9\.]+\$/g,function(wildcard){var return_value=typeof(this.subs[wildcard])!='undefined'?this.subs[wildcard]:'';return return_value;}.bind({subs:subs}));},formatUTC:function(input,format){return this.format(this.parseDateUTC(input),format);},cache:{},validate:function(input,format){format=this.getFormat(format);var pattern;if(this.cache[format]){pattern=this.cache[format];}else{format=format.replace(/[\(\)\|\-\.\?\!\:\/\\]/g,function(c){return'\\'+c;});pattern=new RegExp('^'+format.replace(/\$[A-Z0-9\.]+\$/g,function(wildcard){return this.regexp_subs[wildcard];}.bind(this))+'$','i');this.cache[format]=pattern;}
return pattern.test(input);},setDefaultFormat:function(fmt){this.default_format=fmt;},parseInput:function(input,format){format=this.getFormat(format);var index_year=format.indexOf('$YEAR$');var index_m=format.indexOf('$MN$');index_m=index_m<0?format.indexOf('$0M$'):index_m;var index_d=format.indexOf('$D$');index_d=index_d<0?format.indexOf('$0D$'):index_d;if(index_year>index_m&&index_d<index_m){input=input.replace(/^(\d{1,2})(.{1})(\d{1,2})/,function(all,day,sep,month){return month+sep+day;});}
return this.parseDate(input)||new Date(input);},nowUTC:function(){var today=new Date();var offset=this.getOffset(today);today.setHours(today.getHours()-offset);return today;},getOffset:function(date_obj){return-(date_obj.getTimezoneOffset())/60;}});(function(SK){var mgr=new SK.LocationFormats.DateTime();SK.Util.DateTime.format=mgr.format.bind(mgr);SK.Util.DateTime.formatUTC=mgr.formatUTC.bind(mgr);SK.Util.DateTime.validate=mgr.validate.bind(mgr);SK.Util.DateTime.parseInput=mgr.parseInput.bind(mgr);SK.Util.DateTime.setDefaultFormat=mgr.setDefaultFormat.bind(mgr);SK.Util.DateTime.nowUTC=mgr.nowUTC.bind(mgr);})(SK);


