String.prototype.parseColor=function(){var A="#";if(this.slice(0,4)=="rgb("){var C=this.slice(4,this.length-1).split(",");var B=0;do{A+=parseInt(C[B]).toColorPart()}while(++B<3)}else{if(this.slice(0,1)=="#"){if(this.length==4){for(var B=1;
B<4;B++){A+=(this.charAt(B)+this.charAt(B)).toLowerCase()}}if(this.length==7){A=this.toLowerCase()}}}return(A.length==7?A:(arguments[0]||this))};Element.collectTextNodes=function(A){return $A($(A).childNodes).collect(function(B){return(B.nodeType==3?B.nodeValue:(B.hasChildNodes()?Element.collectTextNodes(B):""))
}).flatten().join("")};Element.collectTextNodesIgnoreClass=function(A,B){return $A($(A).childNodes).collect(function(C){return(C.nodeType==3?C.nodeValue:((C.hasChildNodes()&&!Element.hasClassName(C,B))?Element.collectTextNodesIgnoreClass(C,B):""))
}).flatten().join("")};Element.setContentZoom=function(A,B){A=$(A);A.setStyle({fontSize:(B/100)+"em"});if(Prototype.Browser.WebKit){window.scrollBy(0,0)}return A};Element.getInlineOpacity=function(A){return $(A).style.opacity||""
};Element.forceRerendering=function(A){try{A=$(A);var C=document.createTextNode(" ");A.appendChild(C);A.removeChild(C)}catch(B){}};var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},Transitions:{linear:Prototype.K,sinoidal:function(A){return(-Math.cos(A*Math.PI)/2)+0.5
},reverse:function(A){return 1-A},flicker:function(A){var A=((-Math.cos(A*Math.PI)/4)+0.75)+Math.random()/4;return A>1?1:A},wobble:function(A){return(-Math.cos(A*Math.PI*(9*A))/2)+0.5},pulse:function(B,A){return(-Math.cos((B*((A||5)-0.5)*2)*Math.PI)/2)+0.5
},spring:function(A){return 1-(Math.cos(A*4.5*Math.PI)*Math.exp(-A*6))},none:function(A){return 0},full:function(A){return 1}},DefaultOptions:{duration:1,fps:100,sync:false,from:0,to:1,delay:0,queue:"parallel"},tagifyText:function(A){var B="position:relative";
if(Prototype.Browser.IE){B+=";zoom:1"}A=$(A);$A(A.childNodes).each(function(C){if(C.nodeType==3){C.nodeValue.toArray().each(function(D){A.insertBefore(new Element("span",{style:B}).update(D==" "?String.fromCharCode(160):D),C)
});Element.remove(C)}})},multiple:function(B,C){var E;if(((typeof B=="object")||Object.isFunction(B))&&(B.length)){E=B}else{E=$(B).childNodes}var A=Object.extend({speed:0.1,delay:0},arguments[2]||{});var D=A.delay;
$A(E).each(function(G,F){new C(G,Object.extend(A,{delay:F*A.speed+D}))})},PAIRS:{slide:["SlideDown","SlideUp"],blind:["BlindDown","BlindUp"],appear:["Appear","Fade"]},toggle:function(B,C,A){B=$(B);C=(C||"appear").toLowerCase();
return Effect[Effect.PAIRS[C][B.visible()?1:0]](B,Object.extend({queue:{position:"end",scope:(B.id||"global"),limit:1}},A||{}))}};Effect.DefaultOptions.transition=Effect.Transitions.sinoidal;Effect.ScopedQueue=Class.create(Enumerable,{initialize:function(){this.effects=[];
this.interval=null},_each:function(A){this.effects._each(A)},add:function(B){var C=new Date().getTime();var A=Object.isString(B.options.queue)?B.options.queue:B.options.queue.position;switch(A){case"front":this.effects.findAll(function(D){return D.state=="idle"
}).each(function(D){D.startOn+=B.finishOn;D.finishOn+=B.finishOn});break;case"with-last":C=this.effects.pluck("startOn").max()||C;break;case"end":C=this.effects.pluck("finishOn").max()||C;break}B.startOn+=C;
B.finishOn+=C;if(!B.options.queue.limit||(this.effects.length<B.options.queue.limit)){this.effects.push(B)}if(!this.interval){this.interval=setInterval(this.loop.bind(this),15)}},remove:function(A){this.effects=this.effects.reject(function(B){return B==A
});if(this.effects.length==0){clearInterval(this.interval);this.interval=null}},loop:function(){var C=new Date().getTime();for(var B=0,A=this.effects.length;B<A;B++){this.effects[B]&&this.effects[B].loop(C)
}}});Effect.Queues={instances:$H(),get:function(A){if(!Object.isString(A)){return A}return this.instances.get(A)||this.instances.set(A,new Effect.ScopedQueue())}};Effect.Queue=Effect.Queues.get("global");
Effect.Base=Class.create({position:null,start:function(A){if(A&&A.transition===false){A.transition=Effect.Transitions.linear}this.options=Object.extend(Object.extend({},Effect.DefaultOptions),A||{});this.currentFrame=0;
this.state="idle";this.startOn=this.options.delay*1000;this.finishOn=this.startOn+(this.options.duration*1000);this.fromToDelta=this.options.to-this.options.from;this.totalTime=this.finishOn-this.startOn;
this.totalFrames=this.options.fps*this.options.duration;this.render=(function(){function B(D,C){if(D.options[C+"Internal"]){D.options[C+"Internal"](D)}if(D.options[C]){D.options[C](D)}}return function(C){if(this.state==="idle"){this.state="running";
B(this,"beforeSetup");if(this.setup){this.setup()}B(this,"afterSetup")}if(this.state==="running"){C=(this.options.transition(C)*this.fromToDelta)+this.options.from;this.position=C;B(this,"beforeUpdate");
if(this.update){this.update(C)}B(this,"afterUpdate")}}})();this.event("beforeStart");if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).add(this)
}},loop:function(C){if(C>=this.startOn){if(C>=this.finishOn){this.render(1);this.cancel();this.event("beforeFinish");if(this.finish){this.finish()}this.event("afterFinish");return }var B=(C-this.startOn)/this.totalTime,A=(B*this.totalFrames).round();
if(A>this.currentFrame){this.render(B);this.currentFrame=A}}},cancel:function(){if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).remove(this)
}this.state="finished"},event:function(A){if(this.options[A+"Internal"]){this.options[A+"Internal"](this)}if(this.options[A]){this.options[A](this)}},inspect:function(){var A=$H();for(property in this){if(!Object.isFunction(this[property])){A.set(property,this[property])
}}return"#<Effect:"+A.inspect()+",options:"+$H(this.options).inspect()+">"}});Effect.Parallel=Class.create(Effect.Base,{initialize:function(A){this.effects=A||[];this.start(arguments[1])},update:function(A){this.effects.invoke("render",A)
},finish:function(A){this.effects.each(function(B){B.render(1);B.cancel();B.event("beforeFinish");if(B.finish){B.finish(A)}B.event("afterFinish")})}});Effect.Tween=Class.create(Effect.Base,{initialize:function(C,F,E){C=Object.isString(C)?$(C):C;
var B=$A(arguments),D=B.last(),A=B.length==5?B[3]:null;this.method=Object.isFunction(D)?D.bind(C):Object.isFunction(C[D])?C[D].bind(C):function(G){C[D]=G};this.start(Object.extend({from:F,to:E},A||{}))
},update:function(A){this.method(A)}});Effect.Event=Class.create(Effect.Base,{initialize:function(){this.start(Object.extend({duration:0},arguments[0]||{}))},update:Prototype.emptyFunction});Effect.Opacity=Class.create(Effect.Base,{initialize:function(B){this.element=$(B);
if(!this.element){throw (Effect._elementDoesNotExistError)}if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}var A=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});
this.start(A)},update:function(A){this.element.setOpacity(A)}});Effect.Move=Class.create(Effect.Base,{initialize:function(B){this.element=$(B);if(!this.element){throw (Effect._elementDoesNotExistError)
}var A=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});this.start(A)},setup:function(){this.element.makePositioned();this.originalLeft=parseFloat(this.element.getStyle("left")||"0");this.originalTop=parseFloat(this.element.getStyle("top")||"0");
if(this.options.mode=="absolute"){this.options.x=this.options.x-this.originalLeft;this.options.y=this.options.y-this.originalTop}},update:function(A){this.element.setStyle({left:(this.options.x*A+this.originalLeft).round()+"px",top:(this.options.y*A+this.originalTop).round()+"px"})
}});Effect.MoveBy=function(B,A,C){return new Effect.Move(B,Object.extend({x:C,y:A},arguments[3]||{}))};Effect.Scale=Class.create(Effect.Base,{initialize:function(B,C){this.element=$(B);if(!this.element){throw (Effect._elementDoesNotExistError)
}var A=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:C},arguments[2]||{});this.start(A)},setup:function(){this.restoreAfterFinish=this.options.restoreAfterFinish||false;
this.elementPositioning=this.element.getStyle("position");this.originalStyle={};["top","left","width","height","fontSize"].each(function(B){this.originalStyle[B]=this.element.style[B]}.bind(this));this.originalTop=this.element.offsetTop;
this.originalLeft=this.element.offsetLeft;var A=this.element.getStyle("font-size")||"100%";["em","px","%","pt"].each(function(B){if(A.indexOf(B)>0){this.fontSize=parseFloat(A);this.fontSizeType=B}}.bind(this));
this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;this.dims=null;if(this.options.scaleMode=="box"){this.dims=[this.element.offsetHeight,this.element.offsetWidth]}if(/^content/.test(this.options.scaleMode)){this.dims=[this.element.scrollHeight,this.element.scrollWidth]
}if(!this.dims){this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth]}},update:function(A){var B=(this.options.scaleFrom/100)+(this.factor*A);if(this.options.scaleContent&&this.fontSize){this.element.setStyle({fontSize:this.fontSize*B+this.fontSizeType})
}this.setDimensions(this.dims[0]*B,this.dims[1]*B)},finish:function(A){if(this.restoreAfterFinish){this.element.setStyle(this.originalStyle)}},setDimensions:function(A,D){var E={};if(this.options.scaleX){E.width=D.round()+"px"
}if(this.options.scaleY){E.height=A.round()+"px"}if(this.options.scaleFromCenter){var C=(A-this.dims[0])/2;var B=(D-this.dims[1])/2;if(this.elementPositioning=="absolute"){if(this.options.scaleY){E.top=this.originalTop-C+"px"
}if(this.options.scaleX){E.left=this.originalLeft-B+"px"}}else{if(this.options.scaleY){E.top=-C+"px"}if(this.options.scaleX){E.left=-B+"px"}}}this.element.setStyle(E)}});Effect.Highlight=Class.create(Effect.Base,{initialize:function(B){this.element=$(B);
if(!this.element){throw (Effect._elementDoesNotExistError)}var A=Object.extend({startcolor:"#ffff99"},arguments[1]||{});this.start(A)},setup:function(){if(this.element.getStyle("display")=="none"){this.cancel();
return }this.oldStyle={};if(!this.options.keepBackgroundImage){this.oldStyle.backgroundImage=this.element.getStyle("background-image");this.element.setStyle({backgroundImage:"none"})}if(!this.options.endcolor){this.options.endcolor=this.element.getStyle("background-color").parseColor("#ffffff")
}if(!this.options.restorecolor){this.options.restorecolor=this.element.getStyle("background-color")}this._base=$R(0,2).map(function(A){return parseInt(this.options.startcolor.slice(A*2+1,A*2+3),16)}.bind(this));
this._delta=$R(0,2).map(function(A){return parseInt(this.options.endcolor.slice(A*2+1,A*2+3),16)-this._base[A]}.bind(this))},update:function(A){this.element.setStyle({backgroundColor:$R(0,2).inject("#",function(B,C,D){return B+((this._base[D]+(this._delta[D]*A)).round().toColorPart())
}.bind(this))})},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}))}});Effect.ScrollTo=function(C){var B=arguments[1]||{},A=document.viewport.getScrollOffsets(),D=$(C).cumulativeOffset();
if(B.offset){D[1]+=B.offset}return new Effect.Tween(null,A.top,D[1],B,function(E){scrollTo(A.left,E.round())})};Effect.Fade=function(C){C=$(C);var A=C.getInlineOpacity();var B=Object.extend({from:C.getOpacity()||1,to:0,afterFinishInternal:function(D){if(D.options.to!=0){return 
}D.element.hide().setStyle({opacity:A})}},arguments[1]||{});return new Effect.Opacity(C,B)};Effect.Appear=function(B){B=$(B);var A=Object.extend({from:(B.getStyle("display")=="none"?0:B.getOpacity()||0),to:1,afterFinishInternal:function(C){C.element.forceRerendering()
},beforeSetup:function(C){C.element.setOpacity(C.options.from).show()}},arguments[1]||{});return new Effect.Opacity(B,A)};Effect.Puff=function(B){B=$(B);var A={opacity:B.getInlineOpacity(),position:B.getStyle("position"),top:B.style.top,left:B.style.left,width:B.style.width,height:B.style.height};
return new Effect.Parallel([new Effect.Scale(B,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(B,{sync:true,to:0})],Object.extend({duration:1,beforeSetupInternal:function(C){Position.absolutize(C.effects[0].element)
},afterFinishInternal:function(C){C.effects[0].element.hide().setStyle(A)}},arguments[1]||{}))};Effect.BlindUp=function(A){A=$(A);A.makeClipping();return new Effect.Scale(A,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(B){B.element.hide().undoClipping()
}},arguments[1]||{}))};Effect.BlindDown=function(B){B=$(B);var A=B.getDimensions();return new Effect.Scale(B,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:A.height,originalWidth:A.width},restoreAfterFinish:true,afterSetup:function(C){C.element.makeClipping().setStyle({height:"0px"}).show()
},afterFinishInternal:function(C){C.element.undoClipping()}},arguments[1]||{}))};Effect.SwitchOff=function(B){B=$(B);var A=B.getInlineOpacity();return new Effect.Appear(B,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(C){new Effect.Scale(C.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(D){D.element.makePositioned().makeClipping()
},afterFinishInternal:function(D){D.element.hide().undoClipping().undoPositioned().setStyle({opacity:A})}})}},arguments[1]||{}))};Effect.DropOut=function(B){B=$(B);var A={top:B.getStyle("top"),left:B.getStyle("left"),opacity:B.getInlineOpacity()};
return new Effect.Parallel([new Effect.Move(B,{x:0,y:100,sync:true}),new Effect.Opacity(B,{sync:true,to:0})],Object.extend({duration:0.5,beforeSetup:function(C){C.effects[0].element.makePositioned()},afterFinishInternal:function(C){C.effects[0].element.hide().undoPositioned().setStyle(A)
}},arguments[1]||{}))};Effect.Shake=function(D){D=$(D);var B=Object.extend({distance:20,duration:0.5},arguments[1]||{});var E=parseFloat(B.distance);var C=parseFloat(B.duration)/10;var A={top:D.getStyle("top"),left:D.getStyle("left")};
return new Effect.Move(D,{x:E,y:0,duration:C,afterFinishInternal:function(F){new Effect.Move(F.element,{x:-E*2,y:0,duration:C*2,afterFinishInternal:function(G){new Effect.Move(G.element,{x:E*2,y:0,duration:C*2,afterFinishInternal:function(H){new Effect.Move(H.element,{x:-E*2,y:0,duration:C*2,afterFinishInternal:function(I){new Effect.Move(I.element,{x:E*2,y:0,duration:C*2,afterFinishInternal:function(J){new Effect.Move(J.element,{x:-E,y:0,duration:C,afterFinishInternal:function(K){K.element.undoPositioned().setStyle(A)
}})}})}})}})}})}})};Effect.SlideDown=function(C){C=$(C).cleanWhitespace();var A=C.down().getStyle("bottom");var B=C.getDimensions();return new Effect.Scale(C,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:B.height,originalWidth:B.width},restoreAfterFinish:true,afterSetup:function(D){D.element.makePositioned();
D.element.down().makePositioned();if(window.opera){D.element.setStyle({top:""})}D.element.makeClipping().setStyle({height:"0px"}).show()},afterUpdateInternal:function(D){D.element.down().setStyle({bottom:(D.dims[0]-D.element.clientHeight)+"px"})
},afterFinishInternal:function(D){D.element.undoClipping().undoPositioned();D.element.down().undoPositioned().setStyle({bottom:A})}},arguments[1]||{}))};Effect.SlideUp=function(C){C=$(C).cleanWhitespace();
var A=C.down().getStyle("bottom");var B=C.getDimensions();return new Effect.Scale(C,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,scaleMode:{originalHeight:B.height,originalWidth:B.width},restoreAfterFinish:true,afterSetup:function(D){D.element.makePositioned();
D.element.down().makePositioned();if(window.opera){D.element.setStyle({top:""})}D.element.makeClipping().show()},afterUpdateInternal:function(D){D.element.down().setStyle({bottom:(D.dims[0]-D.element.clientHeight)+"px"})
},afterFinishInternal:function(D){D.element.hide().undoClipping().undoPositioned();D.element.down().undoPositioned().setStyle({bottom:A})}},arguments[1]||{}))};Effect.Squish=function(A){return new Effect.Scale(A,window.opera?1:0,{restoreAfterFinish:true,beforeSetup:function(B){B.element.makeClipping()
},afterFinishInternal:function(B){B.element.hide().undoClipping()}})};Effect.Grow=function(C){C=$(C);var B=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});
var A={top:C.style.top,left:C.style.left,height:C.style.height,width:C.style.width,opacity:C.getInlineOpacity()};var G=C.getDimensions();var H,F;var E,D;switch(B.direction){case"top-left":H=F=E=D=0;break;
case"top-right":H=G.width;F=D=0;E=-G.width;break;case"bottom-left":H=E=0;F=G.height;D=-G.height;break;case"bottom-right":H=G.width;F=G.height;E=-G.width;D=-G.height;break;case"center":H=G.width/2;F=G.height/2;
E=-G.width/2;D=-G.height/2;break}return new Effect.Move(C,{x:H,y:F,duration:0.01,beforeSetup:function(I){I.element.hide().makeClipping().makePositioned()},afterFinishInternal:function(I){new Effect.Parallel([new Effect.Opacity(I.element,{sync:true,to:1,from:0,transition:B.opacityTransition}),new Effect.Move(I.element,{x:E,y:D,sync:true,transition:B.moveTransition}),new Effect.Scale(I.element,100,{scaleMode:{originalHeight:G.height,originalWidth:G.width},sync:true,scaleFrom:window.opera?1:0,transition:B.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(J){J.effects[0].element.setStyle({height:"0px"}).show()
},afterFinishInternal:function(J){J.effects[0].element.undoClipping().undoPositioned().setStyle(A)}},B))}})};Effect.Shrink=function(C){C=$(C);var B=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});
var A={top:C.style.top,left:C.style.left,height:C.style.height,width:C.style.width,opacity:C.getInlineOpacity()};var F=C.getDimensions();var E,D;switch(B.direction){case"top-left":E=D=0;break;case"top-right":E=F.width;
D=0;break;case"bottom-left":E=0;D=F.height;break;case"bottom-right":E=F.width;D=F.height;break;case"center":E=F.width/2;D=F.height/2;break}return new Effect.Parallel([new Effect.Opacity(C,{sync:true,to:0,from:1,transition:B.opacityTransition}),new Effect.Scale(C,window.opera?1:0,{sync:true,transition:B.scaleTransition,restoreAfterFinish:true}),new Effect.Move(C,{x:E,y:D,sync:true,transition:B.moveTransition})],Object.extend({beforeStartInternal:function(G){G.effects[0].element.makePositioned().makeClipping()
},afterFinishInternal:function(G){G.effects[0].element.hide().undoClipping().undoPositioned().setStyle(A)}},B))};Effect.Pulsate=function(C){C=$(C);var B=arguments[1]||{},A=C.getInlineOpacity(),E=B.transition||Effect.Transitions.linear,D=function(F){return 1-E((-Math.cos((F*(B.pulses||5)*2)*Math.PI)/2)+0.5)
};return new Effect.Opacity(C,Object.extend(Object.extend({duration:2,from:0,afterFinishInternal:function(F){F.element.setStyle({opacity:A})}},B),{transition:D}))};Effect.Fold=function(B){B=$(B);var A={top:B.style.top,left:B.style.left,width:B.style.width,height:B.style.height};
B.makeClipping();return new Effect.Scale(B,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(C){new Effect.Scale(B,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(D){D.element.hide().undoClipping().setStyle(A)
}})}},arguments[1]||{}))};Effect.Morph=Class.create(Effect.Base,{initialize:function(C){this.element=$(C);if(!this.element){throw (Effect._elementDoesNotExistError)}var A=Object.extend({style:{}},arguments[1]||{});
if(!Object.isString(A.style)){this.style=$H(A.style)}else{if(A.style.include(":")){this.style=A.style.parseStyle()}else{this.element.addClassName(A.style);this.style=$H(this.element.getStyles());this.element.removeClassName(A.style);
var B=this.element.getStyles();this.style=this.style.reject(function(D){return D.value==B[D.key]});A.afterFinishInternal=function(D){D.element.addClassName(D.options.style);D.transforms.each(function(E){D.element.style[E.style]=""
})}}}this.start(A)},setup:function(){function A(B){if(!B||["rgba(0, 0, 0, 0)","transparent"].include(B)){B="#ffffff"}B=B.parseColor();return $R(0,2).map(function(C){return parseInt(B.slice(C*2+1,C*2+3),16)
})}this.transforms=this.style.map(function(G){var F=G[0],E=G[1],D=null;if(E.parseColor("#zzzzzz")!="#zzzzzz"){E=E.parseColor();D="color"}else{if(F=="opacity"){E=parseFloat(E);if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})
}}else{if(Element.CSS_LENGTH.test(E)){var C=E.match(/^([\+\-]?[0-9\.]+)(.*)$/);E=parseFloat(C[1]);D=(C.length==3)?C[2]:null}}}var B=this.element.getStyle(F);return{style:F.camelize(),originalValue:D=="color"?A(B):parseFloat(B||0),targetValue:D=="color"?A(E):E,unit:D}
}.bind(this)).reject(function(B){return((B.originalValue==B.targetValue)||(B.unit!="color"&&(isNaN(B.originalValue)||isNaN(B.targetValue))))})},update:function(A){var D={},B,C=this.transforms.length;while(C--){D[(B=this.transforms[C]).style]=B.unit=="color"?"#"+(Math.round(B.originalValue[0]+(B.targetValue[0]-B.originalValue[0])*A)).toColorPart()+(Math.round(B.originalValue[1]+(B.targetValue[1]-B.originalValue[1])*A)).toColorPart()+(Math.round(B.originalValue[2]+(B.targetValue[2]-B.originalValue[2])*A)).toColorPart():(B.originalValue+(B.targetValue-B.originalValue)*A).toFixed(3)+(B.unit===null?"":B.unit)
}this.element.setStyle(D,true)}});Effect.Transform=Class.create({initialize:function(A){this.tracks=[];this.options=arguments[1]||{};this.addTracks(A)},addTracks:function(A){A.each(function(B){B=$H(B);
var C=B.values().first();this.tracks.push($H({ids:B.keys().first(),effect:Effect.Morph,options:{style:C}}))}.bind(this));return this},play:function(){return new Effect.Parallel(this.tracks.map(function(A){var D=A.get("ids"),C=A.get("effect"),B=A.get("options");
var E=[$(D)||$$(D)].flatten();return E.map(function(F){return new C(F,Object.extend({sync:true},B))})}).flatten(),this.options)}});Element.CSS_PROPERTIES=$w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex");
Element.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;String.__parseStyleElement=document.createElement("div");String.prototype.parseStyle=function(){var B,A=$H();if(Prototype.Browser.WebKit){B=new Element("div",{style:this}).style
}else{String.__parseStyleElement.innerHTML='<div style="'+this+'"></div>';B=String.__parseStyleElement.childNodes[0].style}Element.CSS_PROPERTIES.each(function(C){if(B[C]){A.set(C,B[C])}});if(Prototype.Browser.IE&&this.include("opacity")){A.set("opacity",this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1])
}return A};if(document.defaultView&&document.defaultView.getComputedStyle){Element.getStyles=function(B){var A=document.defaultView.getComputedStyle($(B),null);return Element.CSS_PROPERTIES.inject({},function(C,D){C[D]=A[D];
return C})}}else{Element.getStyles=function(B){B=$(B);var A=B.currentStyle,C;C=Element.CSS_PROPERTIES.inject({},function(D,E){D[E]=A[E];return D});if(!C.opacity){C.opacity=B.getOpacity()}return C}}Effect.Methods={morph:function(A,B){A=$(A);
new Effect.Morph(A,Object.extend({style:B},arguments[2]||{}));return A},visualEffect:function(C,E,B){C=$(C);var D=E.dasherize().camelize(),A=D.charAt(0).toUpperCase()+D.substring(1);new Effect[A](C,B);
return C},highlight:function(B,A){B=$(B);new Effect.Highlight(B,A);return B}};$w("fade appear grow shrink fold blindUp blindDown slideUp slideDown pulsate shake puff squish switchOff dropOut").each(function(A){Effect.Methods[A]=function(C,B){C=$(C);
Effect[A.charAt(0).toUpperCase()+A.substring(1)](C,B);return C}});$w("getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles").each(function(A){Effect.Methods[A]=Element[A]
});Element.addMethods(Effect.Methods);if(Object.isUndefined(Effect)){throw ("dragdrop.js requires including script.aculo.us' effects.js library")}var Droppables={drops:[],remove:function(A){this.drops=this.drops.reject(function(B){return B.element==$(A)
})},add:function(B){B=$(B);var A=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});if(A.containment){A._containers=[];var C=A.containment;if(Object.isArray(C)){C.each(function(D){A._containers.push($(D))
})}else{A._containers.push($(C))}}if(A.accept){A.accept=[A.accept].flatten()}Element.makePositioned(B);A.element=B;this.drops.push(A)},findDeepestChild:function(A){deepest=A[0];for(i=1;i<A.length;++i){if(Element.isParent(A[i].element,deepest.element)){deepest=A[i]
}}return deepest},isContained:function(B,A){var C;if(A.tree){C=B.treeNode}else{C=B.parentNode}return A._containers.detect(function(D){return C==D})},isAffected:function(A,C,B){return((B.element!=C)&&((!B._containers)||this.isContained(C,B))&&((!B.accept)||(Element.classNames(C).detect(function(D){return B.accept.include(D)
})))&&Position.within(B.element,A[0],A[1]))},deactivate:function(A){if(A.hoverclass){Element.removeClassName(A.element,A.hoverclass)}this.last_active=null},activate:function(A){if(A.hoverclass){Element.addClassName(A.element,A.hoverclass)
}this.last_active=A},show:function(A,C){if(!this.drops.length){return }var B,D=[];this.drops.each(function(E){if(Droppables.isAffected(A,C,E)){D.push(E)}});if(D.length>0){B=Droppables.findDeepestChild(D)
}if(this.last_active&&this.last_active!=B){this.deactivate(this.last_active)}if(B){Position.within(B.element,A[0],A[1]);if(B.onHover){B.onHover(C,B.element,Position.overlap(B.overlap,B.element))}if(B!=this.last_active){Droppables.activate(B)
}}},fire:function(B,A){if(!this.last_active){return }Position.prepare();if(this.isAffected([Event.pointerX(B),Event.pointerY(B)],A,this.last_active)){if(this.last_active.onDrop){this.last_active.onDrop(A,this.last_active.element,B);
return true}}},reset:function(){if(this.last_active){this.deactivate(this.last_active)}}};var Draggables={drags:[],observers:[],register:function(A){if(this.drags.length==0){this.eventMouseUp=this.endDrag.bindAsEventListener(this);
this.eventMouseMove=this.updateDrag.bindAsEventListener(this);this.eventKeypress=this.keyPress.bindAsEventListener(this);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove);
Event.observe(document,"keypress",this.eventKeypress)}this.drags.push(A)},unregister:function(A){this.drags=this.drags.reject(function(B){return B==A});if(this.drags.length==0){Event.stopObserving(document,"mouseup",this.eventMouseUp);
Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress)}},activate:function(A){if(A.options.delay){this._timeout=setTimeout(function(){Draggables._timeout=null;
window.focus();Draggables.activeDraggable=A}.bind(this),A.options.delay)}else{window.focus();this.activeDraggable=A}},deactivate:function(){this.activeDraggable=null},updateDrag:function(A){if(!this.activeDraggable){return 
}var B=[Event.pointerX(A),Event.pointerY(A)];if(this._lastPointer&&(this._lastPointer.inspect()==B.inspect())){return }this._lastPointer=B;this.activeDraggable.updateDrag(A,B)},endDrag:function(A){if(this._timeout){clearTimeout(this._timeout);
this._timeout=null}if(!this.activeDraggable){return }this._lastPointer=null;this.activeDraggable.endDrag(A);this.activeDraggable=null},keyPress:function(A){if(this.activeDraggable){this.activeDraggable.keyPress(A)
}},addObserver:function(A){this.observers.push(A);this._cacheObserverCallbacks()},removeObserver:function(A){this.observers=this.observers.reject(function(B){return B.element==A});this._cacheObserverCallbacks()
},notify:function(B,A,C){if(this[B+"Count"]>0){this.observers.each(function(D){if(D[B]){D[B](B,A,C)}})}if(A.options[B]){A.options[B](A,C)}},_cacheObserverCallbacks:function(){["onStart","onEnd","onDrag"].each(function(A){Draggables[A+"Count"]=Draggables.observers.select(function(B){return B[A]
}).length})}};var Draggable=Class.create({initialize:function(B){var C={handle:false,reverteffect:function(F,E,D){var G=Math.sqrt(Math.abs(E^2)+Math.abs(D^2))*0.02;new Effect.Move(F,{x:-D,y:-E,duration:G,queue:{scope:"_draggable",position:"end"}})
},endeffect:function(E){var D=Object.isNumber(E._opacity)?E._opacity:1;new Effect.Opacity(E,{duration:0.2,from:0.7,to:D,queue:{scope:"_draggable",position:"end"},afterFinish:function(){Draggable._dragging[E]=false
}})},zindex:1000,revert:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false,delay:0};if(!arguments[1]||Object.isUndefined(arguments[1].endeffect)){Object.extend(C,{starteffect:function(D){D._opacity=Element.getOpacity(D);
Draggable._dragging[D]=true;new Effect.Opacity(D,{duration:0.2,from:D._opacity,to:0.7})}})}var A=Object.extend(C,arguments[1]||{});this.element=$(B);if(A.handle&&Object.isString(A.handle)){this.handle=this.element.down("."+A.handle,0)
}if(!this.handle){this.handle=$(A.handle)}if(!this.handle){this.handle=this.element}if(A.scroll&&!A.scroll.scrollTo&&!A.scroll.outerHTML){A.scroll=$(A.scroll);this._isScrollChild=Element.childOf(this.element,A.scroll)
}Element.makePositioned(this.element);this.options=A;this.dragging=false;this.eventMouseDown=this.initDrag.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);Draggables.register(this)
},destroy:function(){Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);Draggables.unregister(this)},currentDelta:function(){return([parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")])
},initDrag:function(A){if(!Object.isUndefined(Draggable._dragging[this.element])&&Draggable._dragging[this.element]){return }if(Event.isLeftClick(A)){var C=Event.element(A);if((tag_name=C.tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){return 
}var B=[Event.pointerX(A),Event.pointerY(A)];var D=this.element.cumulativeOffset();this.offset=[0,1].map(function(E){return(B[E]-D[E])});Draggables.activate(this);Event.stop(A)}},startDrag:function(B){this.dragging=true;
if(!this.delta){this.delta=this.currentDelta()}if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);this.element.style.zIndex=this.options.zindex}if(this.options.ghosting){this._clone=this.element.cloneNode(true);
this._originallyAbsolute=(this.element.getStyle("position")=="absolute");if(!this._originallyAbsolute){Position.absolutize(this.element)}this.element.parentNode.insertBefore(this._clone,this.element)}if(this.options.scroll){if(this.options.scroll==window){var A=this._getWindowScroll(this.options.scroll);
this.originalScrollLeft=A.left;this.originalScrollTop=A.top}else{this.originalScrollLeft=this.options.scroll.scrollLeft;this.originalScrollTop=this.options.scroll.scrollTop}}Draggables.notify("onStart",this,B);
if(this.options.starteffect){this.options.starteffect(this.element)}},updateDrag:function(event,pointer){if(!this.dragging){this.startDrag(event)}if(!this.options.quiet){Position.prepare();Droppables.show(pointer,this.element)
}Draggables.notify("onDrag",this,event);this.draw(pointer);if(this.options.change){this.options.change(this)}if(this.options.scroll){this.stopScrolling();var p;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){p=[left,top,left+width,top+height]
}}else{p=Position.page(this.options.scroll);p[0]+=this.options.scroll.scrollLeft+Position.deltaX;p[1]+=this.options.scroll.scrollTop+Position.deltaY;p.push(p[0]+this.options.scroll.offsetWidth);p.push(p[1]+this.options.scroll.offsetHeight)
}var speed=[0,0];if(pointer[0]<(p[0]+this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[0]+this.options.scrollSensitivity)}if(pointer[1]<(p[1]+this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[1]+this.options.scrollSensitivity)
}if(pointer[0]>(p[2]-this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[2]-this.options.scrollSensitivity)}if(pointer[1]>(p[3]-this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[3]-this.options.scrollSensitivity)
}this.startScrolling(speed)}if(Prototype.Browser.WebKit){window.scrollBy(0,0)}Event.stop(event)},finishDrag:function(B,E){this.dragging=false;if(this.options.quiet){Position.prepare();var D=[Event.pointerX(B),Event.pointerY(B)];
Droppables.show(D,this.element)}if(this.options.ghosting){if(!this._originallyAbsolute){Position.relativize(this.element)}delete this._originallyAbsolute;Element.remove(this._clone);this._clone=null}var F=false;
if(E){F=Droppables.fire(B,this.element);if(!F){F=false}}if(F&&this.options.onDropped){this.options.onDropped(this.element)}Draggables.notify("onEnd",this,B);var A=this.options.revert;if(A&&Object.isFunction(A)){A=A(this.element)
}var C=this.currentDelta();if(A&&this.options.reverteffect){if(F==0||A!="failure"){this.options.reverteffect(this.element,C[1]-this.delta[1],C[0]-this.delta[0])}}else{this.delta=C}if(this.options.zindex){this.element.style.zIndex=this.originalZ
}if(this.options.endeffect){this.options.endeffect(this.element)}Draggables.deactivate(this);Droppables.reset()},keyPress:function(A){if(A.keyCode!=Event.KEY_ESC){return }this.finishDrag(A,false);Event.stop(A)
},endDrag:function(A){if(!this.dragging){return }this.stopScrolling();this.finishDrag(A,true);Event.stop(A)},draw:function(A){var F=this.element.cumulativeOffset();if(this.options.ghosting){var C=Position.realOffset(this.element);
F[0]+=C[0]-Position.deltaX;F[1]+=C[1]-Position.deltaY}var E=this.currentDelta();F[0]-=E[0];F[1]-=E[1];if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){F[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;
F[1]-=this.options.scroll.scrollTop-this.originalScrollTop}var D=[0,1].map(function(G){return(A[G]-F[G]-this.offset[G])}.bind(this));if(this.options.snap){if(Object.isFunction(this.options.snap)){D=this.options.snap(D[0],D[1],this)
}else{if(Object.isArray(this.options.snap)){D=D.map(function(G,H){return(G/this.options.snap[H]).round()*this.options.snap[H]}.bind(this))}else{D=D.map(function(G){return(G/this.options.snap).round()*this.options.snap
}.bind(this))}}}var B=this.element.style;if((!this.options.constraint)||(this.options.constraint=="horizontal")){B.left=D[0]+"px"}if((!this.options.constraint)||(this.options.constraint=="vertical")){B.top=D[1]+"px"
}if(B.visibility=="hidden"){B.visibility=""}},stopScrolling:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;Draggables._lastScrollPointer=null}},startScrolling:function(A){if(!(A[0]||A[1])){return 
}this.scrollSpeed=[A[0]*this.options.scrollSpeed,A[1]*this.options.scrollSpeed];this.lastScrolled=new Date();this.scrollInterval=setInterval(this.scroll.bind(this),10)},scroll:function(){var current=new Date();
var delta=current-this.lastScrolled;this.lastScrolled=current;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){if(this.scrollSpeed[0]||this.scrollSpeed[1]){var d=delta/1000;
this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1])}}}else{this.options.scroll.scrollLeft+=this.scrollSpeed[0]*delta/1000;this.options.scroll.scrollTop+=this.scrollSpeed[1]*delta/1000
}Position.prepare();Droppables.show(Draggables._lastPointer,this.element);Draggables.notify("onDrag",this);if(this._isScrollChild){Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);
Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*delta/1000;Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*delta/1000;if(Draggables._lastScrollPointer[0]<0){Draggables._lastScrollPointer[0]=0
}if(Draggables._lastScrollPointer[1]<0){Draggables._lastScrollPointer[1]=0}this.draw(Draggables._lastScrollPointer)}if(this.options.change){this.options.change(this)}},_getWindowScroll:function(w){var T,L,W,H;
with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else{if(w.document.body){T=body.scrollTop;L=body.scrollLeft}}if(w.innerWidth){W=w.innerWidth;
H=w.innerHeight}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}}return{top:T,left:L,width:W,height:H}
}});Draggable._dragging={};var SortableObserver=Class.create({initialize:function(B,A){this.element=$(B);this.observer=A;this.lastValue=Sortable.serialize(this.element)},onStart:function(){this.lastValue=Sortable.serialize(this.element)
},onEnd:function(){Sortable.unmark();if(this.lastValue!=Sortable.serialize(this.element)){this.observer(this.element)}}});var Sortable={SERIALIZE_RULE:/^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,sortables:{},_findRootElement:function(A){while(A.tagName.toUpperCase()!="BODY"){if(A.id&&Sortable.sortables[A.id]){return A
}A=A.parentNode}},options:function(A){A=Sortable._findRootElement($(A));if(!A){return }return Sortable.sortables[A.id]},destroy:function(A){A=$(A);var B=Sortable.sortables[A.id];if(B){Draggables.removeObserver(B.element);
B.droppables.each(function(C){Droppables.remove(C)});B.draggables.invoke("destroy");delete Sortable.sortables[B.element.id]}},create:function(C){C=$(C);var B=Object.extend({element:C,tag:"li",dropOnEmpty:false,tree:false,treeTag:"ul",overlap:"vertical",constraint:"vertical",containment:C,handle:false,only:false,delay:0,hoverclass:null,ghosting:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,format:this.SERIALIZE_RULE,elements:false,handles:false,onChange:Prototype.emptyFunction,onUpdate:Prototype.emptyFunction},arguments[1]||{});
this.destroy(C);var A={revert:true,quiet:B.quiet,scroll:B.scroll,scrollSpeed:B.scrollSpeed,scrollSensitivity:B.scrollSensitivity,delay:B.delay,ghosting:B.ghosting,constraint:B.constraint,handle:B.handle};
if(B.starteffect){A.starteffect=B.starteffect}if(B.reverteffect){A.reverteffect=B.reverteffect}else{if(B.ghosting){A.reverteffect=function(F){F.style.top=0;F.style.left=0}}}if(B.endeffect){A.endeffect=B.endeffect
}if(B.zindex){A.zindex=B.zindex}var D={overlap:B.overlap,containment:B.containment,tree:B.tree,hoverclass:B.hoverclass,onHover:Sortable.onHover};var E={onHover:Sortable.onEmptyHover,overlap:B.overlap,containment:B.containment,hoverclass:B.hoverclass};
Element.cleanWhitespace(C);B.draggables=[];B.droppables=[];if(B.dropOnEmpty||B.tree){Droppables.add(C,E);B.droppables.push(C)}(B.elements||this.findElements(C,B)||[]).each(function(H,F){var G=B.handles?$(B.handles[F]):(B.handle?$(H).select("."+B.handle)[0]:H);
B.draggables.push(new Draggable(H,Object.extend(A,{handle:G})));Droppables.add(H,D);if(B.tree){H.treeNode=C}B.droppables.push(H)});if(B.tree){(Sortable.findTreeElements(C,B)||[]).each(function(F){Droppables.add(F,E);
F.treeNode=C;B.droppables.push(F)})}this.sortables[C.identify()]=B;Draggables.addObserver(new SortableObserver(C,B.onUpdate))},findElements:function(B,A){return Element.findChildren(B,A.only,A.tree?true:false,A.tag)
},findTreeElements:function(B,A){return Element.findChildren(B,A.only,A.tree?true:false,A.treeTag)},onHover:function(E,D,A){if(Element.isParent(D,E)){return }if(A>0.33&&A<0.66&&Sortable.options(D).tree){return 
}else{if(A>0.5){Sortable.mark(D,"before");if(D.previousSibling!=E){var B=E.parentNode;E.style.visibility="hidden";D.parentNode.insertBefore(E,D);if(D.parentNode!=B){Sortable.options(B).onChange(E)}Sortable.options(D.parentNode).onChange(E)
}}else{Sortable.mark(D,"after");var C=D.nextSibling||null;if(C!=E){var B=E.parentNode;E.style.visibility="hidden";D.parentNode.insertBefore(E,C);if(D.parentNode!=B){Sortable.options(B).onChange(E)}Sortable.options(D.parentNode).onChange(E)
}}}},onEmptyHover:function(E,G,H){var I=E.parentNode;var A=Sortable.options(G);if(!Element.isParent(G,E)){var F;var C=Sortable.findElements(G,{tag:A.tag,only:A.only});var B=null;if(C){var D=Element.offsetSize(G,A.overlap)*(1-H);
for(F=0;F<C.length;F+=1){if(D-Element.offsetSize(C[F],A.overlap)>=0){D-=Element.offsetSize(C[F],A.overlap)}else{if(D-(Element.offsetSize(C[F],A.overlap)/2)>=0){B=F+1<C.length?C[F+1]:null;break}else{B=C[F];
break}}}}G.insertBefore(E,B);Sortable.options(I).onChange(E);A.onChange(E)}},unmark:function(){if(Sortable._marker){Sortable._marker.hide()}},mark:function(B,A){var D=Sortable.options(B.parentNode);if(D&&!D.ghosting){return 
}if(!Sortable._marker){Sortable._marker=($("dropmarker")||Element.extend(document.createElement("DIV"))).hide().addClassName("dropmarker").setStyle({position:"absolute"});document.getElementsByTagName("body").item(0).appendChild(Sortable._marker)
}var C=B.cumulativeOffset();Sortable._marker.setStyle({left:C[0]+"px",top:C[1]+"px"});if(A=="after"){if(D.overlap=="horizontal"){Sortable._marker.setStyle({left:(C[0]+B.clientWidth)+"px"})}else{Sortable._marker.setStyle({top:(C[1]+B.clientHeight)+"px"})
}}Sortable._marker.show()},_tree:function(E,B,F){var D=Sortable.findElements(E,B)||[];for(var C=0;C<D.length;++C){var A=D[C].id.match(B.format);if(!A){continue}var G={id:encodeURIComponent(A?A[1]:null),element:E,parent:F,children:[],position:F.children.length,container:$(D[C]).down(B.treeTag)};
if(G.container){this._tree(G.container,B,G)}F.children.push(G)}return F},tree:function(D){D=$(D);var C=this.options(D);var B=Object.extend({tag:C.tag,treeTag:C.treeTag,only:C.only,name:D.id,format:C.format},arguments[1]||{});
var A={id:null,parent:null,children:[],container:D,position:0};return Sortable._tree(D,B,A)},_constructIndex:function(B){var A="";do{if(B.id){A="["+B.position+"]"+A}}while((B=B.parent)!=null);return A},sequence:function(B){B=$(B);
var A=Object.extend(this.options(B),arguments[1]||{});return $(this.findElements(B,A)||[]).map(function(C){return C.id.match(A.format)?C.id.match(A.format)[1]:""})},setSequence:function(B,C){B=$(B);var A=Object.extend(this.options(B),arguments[2]||{});
var D={};this.findElements(B,A).each(function(E){if(E.id.match(A.format)){D[E.id.match(A.format)[1]]=[E,E.parentNode]}E.parentNode.removeChild(E)});C.each(function(E){var F=D[E];if(F){F[1].appendChild(F[0]);
delete D[E]}})},serialize:function(C){C=$(C);var B=Object.extend(Sortable.options(C),arguments[1]||{});var A=encodeURIComponent((arguments[1]&&arguments[1].name)?arguments[1].name:C.id);if(B.tree){return Sortable.tree(C,arguments[1]).children.map(function(D){return[A+Sortable._constructIndex(D)+"[id]="+encodeURIComponent(D.id)].concat(D.children.map(arguments.callee))
}).flatten().join("&")}else{return Sortable.sequence(C,arguments[1]).map(function(D){return A+"[]="+encodeURIComponent(D)}).join("&")}}};Element.isParent=function(B,A){if(!B.parentNode||B==A){return false
}if(B.parentNode==A){return true}return Element.isParent(B.parentNode,A)};Element.findChildren=function(D,B,A,C){if(!D.hasChildNodes()){return null}C=C.toUpperCase();if(B){B=[B].flatten()}var E=[];$A(D.childNodes).each(function(G){if(G.tagName&&G.tagName.toUpperCase()==C&&(!B||(Element.classNames(G).detect(function(H){return B.include(H)
})))){E.push(G)}if(A){var F=Element.findChildren(G,B,A,C);if(F){E.push(F)}}});return(E.length>0?E.flatten():[])};Element.offsetSize=function(A,B){return A["offset"+((B=="vertical"||B=="height")?"Height":"Width")]
};try{console.log("init console... done")}catch(e){console={log:function(){}}}var SL={utils:{},effects:{},ui:{},browser:{IE6:Prototype.Browser.IE&&parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5))==6},storage:$H()};
Hash.prototype.setDefault=function(A,B){if(this.get(A)==undefined){this.set(A,B)}};Hash.prototype.ensureHash=function(A){if(this.get(A)==undefined){this.set(A,$H())}return this.get(A)};Element.addMethods({setStyle:function(B,C){B=$(B);
var F=B.style,A;if(Object.isString(C)){B.style.cssText+=";"+C;return C.include("opacity")?B.setOpacity(C.match(/opacity:\s*(\d?\.?\d*)/)[1]):B}for(var E in C){var D=C[E];if(D&&(D.toLowerCase().startsWith("nan")||D.toLowerCase().startsWith("infinity"))){continue
}if(E=="opacity"){B.setOpacity(D)}else{F[(E=="float"||E=="cssFloat")?(Object.isUndefined(F.styleFloat)?"cssFloat":"styleFloat"):E]=D}}return B},getStorage:function(A){A=$(A);var B=A._slStorage;if(!B){B=$H();
A._slStorage=B}return B}});SL.utils.removeAMP=function(B){while(true){var A=B.indexOf("&amp;");if(A==-1){break}B=B.substring(0,A)+"&"+B.substring(A+"&amp;".length)}return B};SL.utils.addOrReplaceArg=function(D,A,E){D=this.removeAMP(D);
var C="&args."+A+"=";var B=D.indexOf(C);if(B==-1){return E==null?D:(D+C+E)}var F=D.substring(B+C.length);return D.substring(0,B)+(E==null?"":(C+E))+(F.indexOf("&")==-1?"":F.substring(F.indexOf("&")))};
SL.utils.createBodyElement=function(B,A){var C=new Element(B,A);$$("body")[0].appendChild(C);return C};SL.utils.reparentToBody=function(B){B.remove();var A=document.getElementsByTagName("body").item(0);
A.appendChild(B)};SL.utils._domReady=false;SL.utils._domReadyFunctions=$A();document.observe("dom:loaded",function(){SL.utils._domReady=true;SL.utils._domReadyFunctions.each(function(A){A()});SL.utils._domReadyFunctions=undefined
});SL.utils.onDomReady=function(A){if(SL.utils._domReady){A()}else{SL.utils._domReadyFunctions.push(A)}};SL.utils.isDomReady=function(){return SL.utils._domReady};SL.events={};SL.events.pushKeyboardObserver=function(A){if(!SL.events._keyboardObservers){SL.events._keyboardObservers=$A();
SL.events._keyboard={shift:false};document.observe("keydown",function(E,D){var C=D.keyCode;if(C!=Event.KEY_ESC&&SL.events._checkForm()){return }if(C==16){if(!E.shift){E.shift=true;for(var B=SL.events._keyboardObservers.length-1;
B>=0;B--){o=SL.events._keyboardObservers[B];if(o.shiftdown){if(o.shiftdown(E)){D.stop();return }}if(o.modal){return }}}return }E.code=C;E.key=String.fromCharCode(C).toLowerCase();for(var B=SL.events._keyboardObservers.length-1;
B>=0;B--){o=SL.events._keyboardObservers[B];if(o.keydown){if(o.keydown(E)){D.stop();return }}if(o.modal){return }}}.curry(SL.events._keyboard));document.observe("keyup",function(E,D){if(SL.events._checkForm()){return 
}var C=D.keyCode;if(C==16){E.shift=false;for(var B=SL.events._keyboardObservers.length-1;B>=0;B--){o=SL.events._keyboardObservers[B];if(o.shiftup){if(o.shiftup(E)){D.stop();return }}if(o.modal){return 
}}return }E.code=C;E.key=String.fromCharCode(C).toLowerCase();for(var B=SL.events._keyboardObservers.length-1;B>=0;B--){o=SL.events._keyboardObservers[B];if(o.keyup){if(o.keyup(E)){D.stop();return }if(o.modal){return 
}}}E.code=undefined;E.key=undefined}.curry(SL.events._keyboard))}SL.events._keyboardObservers.push(A);return A};SL.events.removeKeyboardObserver=function(A){if(A.modal){var B=SL.events._keyboardObservers.indexOf(A);
if(B>=0){SL.events._keyboardObservers=SL.events._keyboardObservers.slice(0,B)}}else{SL.events._keyboardObservers=SL.events._keyboardObservers.without(A)}};SL.events._checkForm=function(){var B=document.activeElement;
if(!B){return false}var A=B.tagName.toLowerCase();if(A=="body"){return false}if(A=="input"||B.up("form")){return true}return false};SL.elements={};SL.elements.createBlindRow=function(A){var E=0;var D=new Element("tr");
var C=A.childElements();for(var B=0;B<C.length;B++){var G=C[B].readAttribute("colspan");E+=G?parseInt(G):1}var D=new Element("tr");var F=new Element("td",{colspan:E});F.setStyle({margin:"0",padding:"0"});
D.appendChild(F);return D};SL.Element=Class.create({isElement:true,initialize:function(B,A){this.e=$(B);this.id=B.identify();this.config=$H(A);this.init()},init:function(){},destroy:function(){this.cleanup()
},cleanup:function(){}});SL.byID=function(C){var B=$(C);if(!B){console.log("SL.byID: unable to find element with id '"+C+"'");return }var A=B.retrieve("sl_component");if(A){return A}if(!SL.legacy){console.log("SL.byID: element '"+C+"' has no component")
}return SL.legacy.initWidget(B)};SL.getCC=function(B){var C=B;while(C){var A=C.retrieve("sl_component");if(A){return A}C=C.up()}};SL.initDefered=function(C,B,A){SL.utils.onDomReady(function(F,E,D){new F(E,D)
}.curry(C,B,A))};SL.initOnEvent=function(J,A,H,G,C,B){var I=$(J);var E=I.retrieve("sl_init_events");if(!E){E=$H();I.store("sl_init_events",E)}var K=E.get(A);if(!K){K=$A();E.set(A,K);var D=function(O,L,N){var M=O.retrieve("sl_init_events");
M.get(L).each(function(Q,P){P(N)}.curry(O));O.stopObserving(L,M.get("_f_"+L));M.set("_f_"+L,undefined);M.set(L,undefined)}.curry(I,A);E.set("_f_"+A,D);I.observe(A,D)}var F=function(R,P,L,Q,O){var N=$(P);
if(N&&N.retrieve("sl_component")){return }var M=new R(P,L);M.connectDestroy(Q);M.notifyInitEvent(O)}.curry(H,G,C,B?J:null);K.push(F)};SL.ensureComponent=function(E,D,B){var C=$(D);if(!C){return new E(D,B)
}var A=C.retrieve("sl_component");if(A){return A}return new E(D,B)};SL.Component=Class.create({initialize:function(C,B){if(arguments.length==1&&(typeof C)!="string"&&!$(C)){B=C;this.e=undefined}else{this.e=$(C)
}if(!this.e){console.log("create new element:",C);this.e=SL.utils.createBodyElement("div");this.e.setStyle({display:"none"});if(C){this.e.writeAttribute("id",C)}}else{if(!this.e.up()){var A=document.getElementsByTagName("body").item(0);
A.appendChild(this.e)}}this.id=this.e.identify();this.e.store("sl_component",this);this.e.addClassName("sljs__component__");this.config=$H(B);this.version=1;this.config.setDefault("spinner_class","gui_busy_img");
if(this.config.get("add_css")){this.e.addClassName(this.config.get("add_css"))}this.url=this.config.get("url");this.init();if(this.config.get("after_init")){this.config.get("after_init")(this)}},init:function(){},notifyInitEvent:function(A){},setUrl:function(A){this.url=A
},setLoading:function(A){A.update(this._getLoadingContent())},_getLoadingContent:function(){return'<div class="'+this.config.get("spinner_class")+'"></div>'},_onSuccess:function(A){this._onSuccessContent(A.request.options.slVersion,A.responseText)
},_onSuccessContent:function(A,B){if(SL.legacy){slCloseTooltips()}if(A!=undefined&&A!=this.version){return }this._setContent(B);this.onSuccess();this._emitContentChanged()},onFailure:function(A){console.log("SL.Component failure: "+A)
},onError:function(A){console.log("SL.Component error: "+A)},_setContent:function(A){this._cleanup(true);try{this.e.update(A);if(SL.legacy){SL.legacy.autoInitWidgets(this.e)}}catch(B){this.onError(B)}},_emitContentChanged:function(){var B=this.e.up();
while(B){if(B.tagName=="BODY"){break}var A=B.retrieve("sl_component");if(A){A.onChildComponentChanged(this)}B=B.up()}},_getReloadURL:function(A){if(!A){A=this.url}if(this.reloadArgs){$H(this.reloadArgs).each(function(B){A=SL.utils.addOrReplaceArg(A,B.key,B.value)
})}return A},load:function(B,A){if(A){this.setLoadingSpinner(A)}else{if(this.config.get("load_shaded")){this.setLoadingSpinner(this.id)}else{this.setLoading(this.e)}}this.version++;this.url=B;new Ajax.Request(this.getReloadURL(B),{method:"post",onSuccess:this._onSuccess.bind(this),onFailure:this.onFailure.bind(this),slVersion:this.version})
},loadPost:function(C,B,A){if(A){this.setLoadingSpinner(A)}else{if(this.config.get("load_shaded")){this.setLoadingSpinner(this.id)}else{this.setLoading(this.e)}}if(this.reloadArgs){$H(this.reloadArgs).each(function(D){B=addOrReplaceArg(B,D.key,D.value)
})}new Ajax.Request(this.getReloadURL(C,true),{method:"post",parameters:B,onSuccess:this._onSuccess.bind(this),onFailure:this.onFailure.bind(this)})},setReloadArg:function(A,B){if(!this.reloadArgs){this.reloadArgs=$H({})
}this.reloadArgs.set(A,B)},onSuccess:function(){},onChildComponentChanged:function(A){},setDimension:function(B,A){this.e.setStyle({width:B+"px",height:A+"px"})},setLoadingSpinner:function(A){var E=$(A);
if(E&&!E.down("#__"+this.id+"__loading")){var C=E.childElements();var F=new Element("div");for(var B=0;B<C.length;B++){var D=C[B]}E.insert({top:'<div id="__'+this.id+'__loading" style="position:absolute" class="gui_busy_img"></div>'});
E.insert(F);F.setOpacity(0.3);for(var B=0;B<C.length;B++){var D=C[B];F.insert(D)}}},loadBackground:function(A){this.url=A;this.version++;new Ajax.Request(this.getReloadURL(A),{method:"get",onSuccess:this._onSuccess.bind(this),onFailure:this.onFailure.bind(this),slVersion:this.version})
},replaceArgs:function(C,D,B){var A=this.url;$H(C).each(function(E){A=addOrReplaceArg(A,E.key,E.value)});if(D){this.loadBackground(this.getReloadURL(A))}else{this.load(this.getReloadURL(A),B)}},updateArgs:function(A){$H(A).each(function(B){this.url=addOrReplaceArg(this.url,B.key,B.value)
}.bind(this))},refresh:function(E,B){if(!this.url){var F=this.getParentComponent();if(F!=null){F.refresh(E,B)}return }if(B){var G=this.url.split("?");if(G.length>1){this.url=G[0]+"?";G=G[1].split("&");
var H=true;for(var D=0;D<G.length;D++){var A=false;for(var C=0;C<B.length;C++){if(G[D].startsWith("args."+B[C])){A=true}}if(!A){if(H){H=false}else{this.url+="&"}this.url+=G[D]}}}}if(E){this.loadBackground(this.getReloadURL())
}else{this.load(this.getReloadURL())}},refreshDelay:function(B,A){this.version++;if(this.e&&this.e.parentNode){setTimeout(this._delayedRefresh.bind(this,B,this.version),A)}},_delayedRefresh:function(A,B){if(this.version==B){this.refresh(A)
}},getParentComponent:function(){var B=this.e.up();while(B){if(B.tagName=="BODY"){return null}var A=B.retrieve("sl_component");if(A){return A}B=B.up()}return null},getReloadURL:function(A,B){if(!A){A=this.url
}if(!B&&this.reloadArgs){$H(this.reloadArgs).each(function(C){A=addOrReplaceArg(A,C.key,C.value)})}return A},_destroy:function(){console.log("Destroying component:",this.id);this._cleanup();this.e.store("sl_component",undefined);
if(this.e.parentNode){this.e.remove()}(function(B){var A=$(B);if(A&&A.parentNode){A.remove()}}.curry(this.id).defer())},uploadForm:function(F,D){this.version++;try{var C=this.e.select(".sljs__component__");
if(C){C.each(function(H){var I=H.retrieve("sl_component");if(I){I.updateForPost()}})}slUpdateEditors(this.e,true)}catch(E){console.log(E)}var E=SL.utils.createBodyElement("div");var G=E.identify()+"_iframe";
var A=new Element("iframe",{id:G,name:G,stlye:"display:none",src:"about:blank"});E.appendChild(A);A.observe("load",this._iframeLoaded.bind(this,E,G,this.version));var B=$(F);B.writeAttribute("target",G);
if(D){B.submit()}return true},updateForPost:function(){},_iframeLoaded:function(D,E,A){if(this.version!=A){console.log("Old version:",this.version," ",A);return }console.log("Update for form upload:",this.id);
var B=$(E).contentWindow.sl_reload_url;if(B){this.url=B}var C=$(E).contentWindow.sl_reload_content;this._onSuccessContent(A,C);(function(F){F.remove()}.curry(D).defer())},submitUploadForm:function(D,A,C){var B=$(D);
if(A&&C){B.appendChild(new Element("input",{type:"hidden",name:A,value:C}))}this.uploadForm(D,true)},_cleanup:function(A){if(!A){if(this.isCleanedUp){return }this.isCleanedUp=true;try{this.cleanup()}catch(D){console.log(D)
}var B=this.e.retrieve("sl_delete_notify");if(B){B.each(function(F){try{F.value._destroy(D)}catch(E){console.log(E)}});this.e.store("sl_delete_notify",undefined)}}try{var C=this.e.select(".sljs__component__");
if(C){C.each(function(E){var F=E.retrieve("sl_component");if(F){F._cleanup()}})}C=this.e.select(".sljs__delete_notify__");if(C){C.each(function(F){var E=F.retrieve("sl_delete_notify");if(E){E.each(function(H){try{H.value._destroy()
}catch(G){console.log(G)}})}F.store("sl_delete_notify",undefined)})}}catch(D){console.log(D)}},connectDestroy:function(C){if(!C){return }var B=$(C);var A=B.retrieve("sl_delete_notify");if(!A){A=$H();B.store("sl_delete_notify",A);
B.addClassName("sljs__delete_notify__")}if(!A.get(this.id)){A.set(this.id,this)}},cleanup:function(){}});SL.effects.hideEmbededObjects=function(){$$("object","embed").each(function(A){A.style.display="none"
})};SL.effects.showEmbededObjects=function(){$$("object","embed").each(function(A){A.style.display="block"})};SL.effects.resetStyles=function(A){A.setOpacity(1);A.setStyle({height:"auto",overflow:"visible"})
};SL.effects.resetCurrent=function(B){var A=B.retrieve("effect");if(A){A.cancel();this.resetStyles(B);if(A.options.slAfterFinish){A.options.slAfterFinish()}B.store("effect",undefined);return true}return false
};SL.effects.registerCurrent=function(A){if(A.options.afterFinish){A.options.slAfterFinish=A.options.afterFinish}A.options.afterFinish=function(C){var B=C.retrieve("effect");if(B&&B.options.slAfterFinish){B.options.slAfterFinish()
}C.store("effect",undefined)}.curry(A.element);A.element.store("effect",A)};SL.effects.registerHover=function(B,A){if(!A){A="hover"}B.observe("mouseenter",function(){B.addClassName(A)});B.observe("mouseleave",function(){B.removeClassName(A)
})};SL.effects.reparentToOffscreen=function(B){B.remove();var A=document.getElementsByTagName("body").item(0);A.appendChild(B);B.setStyle({position:"absolute",top:"0px",left:"-999em"});B.show()};SL.effects.reparentAndReset=function(B,A){A.remove();
B.appendChild(A);A.setStyle({position:"static",top:"auto",left:"auto"});A.show()};SL.effects.getBodyHeight=function(){var B=$$("body")[0];var A=B.getHeight();var C=document.viewport.getHeight()+document.viewport.getScrollOffsets().top;
if(C>A){A=C}if(A<=0){A=1000}return A};SL.effects.Preloader=Class.create({initialize:function(B,A){this.element=B;this.finishCallback=A;this.run.bind(this).defer()},run:function(){if(this.element.retrieve("sl_preloaded")){this._emitFinished();
return }var A=this.element.select("img");if(A.length==0){this._emitFinished();return }this.remaining=A.length;A.each(function(D){if(D.readAttribute("width")&&D.readAttribute("height")){this.remaining--;
return }var C=D.readAttribute("src");if(!C){this.remaining--;return }var B=new Image();B.onload=this._onLoad.bind(this);B.onerror=this._onLoad.bind(this);B.onabort=this._onLoad.bind(this);B.src=C}.bind(this));
if(this.remaining<=0){this._emitFinished()}else{setTimeout(this._emitFinished.bind(this),20000)}},_onLoad:function(){this.remaining--;if(this.remaining<=0){this._emitFinished()}},_emitFinished:function(){if(!this.finished){this.finished=true;
this.element.store("sl_preloaded",true);if(this.finishCallback){this.finishCallback.defer()}}}});SL.effects.Queue=Class.create({initialize:function(A){this.config=$H(A);this.effects=$H();this.steps=$A(["first","last"]);
this.currentStep=-1},add:function(B,A){var C=this.effects.get(B);if(C==undefined){C=$A();this.effects.set(B,C)}C.push(A);this.effects.set(B,C)},start:function(){if(this.steps.length==0){_finished();return 
}this._iter()},isEmpty:function(){return this.effects.size()<=0},_iter:function(){this.currentStep++;console.log("Step:",this.currentStep);if(this.currentStep>=this.steps.length){this._finished();return 
}var A=this.effects.get(this.steps[this.currentStep]);if(!A||A.length==0){this._iter();return }var B=0;A.each(function(C){if(B<C.options.duration){B=C.options.duration}});if(B<=0){console.log("No duration:",this.effects.get(this.steps[this.currentStep]));
this._iter();return }new Effect.Parallel(A,{duration:B,afterFinish:this._iter.bind(this)})},_finished:function(){console.log("Queue finished:",this.config);if(this.config.get("afterFinish")){this.config.get("afterFinish")(this)
}}});SL.ui.MenuHorizontal=Class.create(SL.Component,{init:function(){this.config.setDefault("hide_delay",500);this.config.setDefault("show_effect","blind_down");this.config.setDefault("show_duration",200);
this.config.setDefault("hide_effect","fade");this.config.setDefault("hide_duration",200);this.config.setDefault("css_prefix","dropdown_menu");this.cssPrefix=this.config.get("css_prefix");this.e.select("li."+this.cssPrefix+"_horizontal").each(this.initElement.bind(this,true));
this.e.select("li."+this.cssPrefix).each(this.initElement.bind(this,false))},initElement:function(A,B){if(A&&SL.browser.IE6){B.down().setStyle({width:"1%"})}B.observe("mouseenter",this.onMouseEnter.bind(this,B));
B.observe("mouseleave",this.onMouseLeave.bind(this,B))},onMouseEnter:function(D){var C=D.up();C.childElements().each(this._resetChild.bind(this,D));var A=D.down("div."+this.cssPrefix);if(!A){return }if(A.retrieve("visible")){if(A.retrieve("status")!="visible"){A.store("status","visible")
}return }A.store("visible",true);if(!SL.effects.resetCurrent(A)){SL.effects.resetStyles(D);var B=this.config.get("show_effect");if(B=="appear"){A.hide();SL.effects.registerCurrent(Effect.Appear(A,{duration:this.config.get("show_duration")/1000}))
}else{if(B=="blind_down"){A.hide();SL.effects.registerCurrent(Effect.BlindDown(A,{duration:this.config.get("show_duration")/1000}))}}}D.addClassName("active");this._getNavItem(D).addClassName("active")
},_resetChild:function(B,A){if(B==A){return }var C=A.down("div."+this.cssPrefix);if(C==null){return }SL.effects.resetCurrent(C);SL.effects.resetStyles(C);C.store("visible",false);C.store("status","hidden");
A.removeClassName("active");this._getNavItem(A).removeClassName("active");C.hide()},onMouseLeave:function(B){var A=B.down("div."+this.cssPrefix);if(!A){return }A.store("status","delayed_hide");setTimeout(this.delayedHide.bind(this,B,A),this.config.get("hide_delay"))
},delayedHide:function(C,A){if(A.retrieve("status")!="delayed_hide"){return }SL.effects.resetCurrent(A);var B=this.config.get("hide_effect");if(B=="blind_up"){SL.effects.registerCurrent(Effect.BlindUp(A,{duration:this.config.get("hide_duration")/1000,afterFinish:this._clearHover.bind(this,C)}))
}else{if(B=="fade"){SL.effects.registerCurrent(Effect.Fade(A,{duration:this.config.get("hide_duration")/1000,afterFinish:this._clearHover.bind(this,C)}))}else{C.removeClassName("hover")}}A.store("visible",false);
A.store("status","hidden")},_clearHover:function(A){A.removeClassName("active");this._getNavItem(A).removeClassName("active")},_getNavItem:function(A){return A.down()}});SL.ui.Expandable=Class.create(SL.Component,{init:function(){this.config.setDefault("duration",0);
this.config.setDefault("state_url",null);this.config.setDefault("css_prefix","expandable");this.config.setDefault("button_class",this.config.get("css_prefix")+"_btn");var A=this.e.down();var C=this.e.select("."+this.config.get("button_class"));
this.img=C?C[0].down():false;this.body=A.next().down();var B=this.body.getStyle("display");this.expanded=!B||B=="block"},toggle:function(){if(this.expanded){this.hide()}else{this.show()}var B=this.config.get("state_url");
if(B){var A=B+"&args.state=";if(this.expanded){A+="true"}else{A+="false"}new Ajax.Request(A,{method:"get"})}},_getImgURL:function(A){if(!this.img){return }var C=this.img.src.lastIndexOf("/");var B=this.img.src.lastIndexOf("_");
if(B>C){C=B}if(C<0){return }return this.img.src.substring(0,C+1)+A+".png"},show:function(){var A=this.config.get("duration");if(A<=0){this.body.setStyle("display:block")}else{this.body.blindDown({duration:A/1000})
}this.img.src=this._getImgURL("up");this.expanded=true},hide:function(){var A=this.config.get("duration");if(A<=0){this.body.setStyle("display:none")}else{this.body.blindUp({duration:A/1000})}this.img.src=this._getImgURL("down");
this.expanded=false}});SL.ui.Accordion=Class.create(SL.Component,{init:function(){this.config.setDefault("duration",0);this.config.setDefault("on_mouse_over",false);this.config.setDefault("css_prefix","accordion");
this.config.setDefault("button_class",this.config.get("css_prefix")+"_btn");this.config.setDefault("mode","complex"),this.cssPrefix=this.config.get("css_prefix");this.mode=this.config.get("mode");this.duration=this.config.get("duration");
this.onMouseOver=this.config.get("on_mouse_over");this.active=-1;if(this.mode=="list"){this.list=this.e.down("ul");var C=this.list.childElements();for(var B=0;B<C.length;B++){var E=C[B];if(E.hasClassName("selected")){this.active=B
}if(!E.down("ul")){continue}if(this.onMouseOver){E.observe("mouseenter",this._onMouseOver.bind(this,B))}else{E.observe("click",this._onMouseClicked.bind(this,B))}}}else{this.inner=this.e.select("."+this.cssPrefix+"_inner")[0];
var C=this.inner.childElements();for(var B=1;B<C.length;B+=2){var E=C[B];var A=E.down();var D=A.getStyle("display");if(D==null||D=="block"){this.active=(B-1)/2}}if(this.onMouseOver){for(var B=0;B<C.length/2;
B++){C[B*2].observe("mouseenter",this._onMouseOver.bind(this,B))}}}},_onMouseOver:function(B,A){this.setActive(B)},_toggleBtn:function(D,F){var E=D.select("."+this.config.get("button_class"));if(!E){return 
}for(var C=0;C<E.length;C++){var A=E[C].down();if(!A){continue}var G=A.src.lastIndexOf("/");var B=A.src.lastIndexOf("_");if(B>G){G=B}if(G<0){continue}A.src=A.src.substring(0,G+1)+F+".png"}},getElement:function(A){if(this.mode=="list"){return this.list.childElements()[A].down("ul")
}return this.inner.childElements()[(A*2)+1].down()},setActive:function(B){if(this.onMouseOver&&this.active==B){return }if(this.active>=0){var A=this.getElement(this.active);if(this.duration<=0){A.setStyle("display:none")
}else{SL.effects.resetCurrent(A);SL.effects.registerCurrent(Effect.BlindUp(A,{duration:this.duration/1000}))}if(this.mode!="list"){this._toggleBtn(this.inner.childElements()[(this.active*2)],"down")}}if(this.active==B){this.active=-1;
return }var A=this.getElement(B);if(this.duration<=0){A.setStyle("display:block")}else{SL.effects.resetCurrent(A);SL.effects.registerCurrent(Effect.BlindDown(A,{duration:this.duration/1000}))}this.active=B;
if(this.mode!="list"){this._toggleBtn(this.inner.childElements()[(this.active*2)],"up")}}});SL.ui._overlayIndex=50;SL.ui._getNewOverlayIndex=function(){SL.ui._overlayIndex=SL.ui._overlayIndex+10;return SL.ui._overlayIndex
};SL.ui.Overlay=Class.create(SL.Component,{init:function(){this.config.setDefault("backdrop_opacity",0.7);this.config.setDefault("backdrop_duration",300);this.config.setDefault("delete_on_hide",false);
this.config.setDefault("background-color","#ffffff");this.config.setDefault("load_shaded",true);this.e.setStyle({position:"absolute"});if(this.config.get("background-color")!="auto"){this.e.setStyle({backgroundColor:this.config.get("background-color")})
}if(this.config.get("show")){this.show.bind(this).defer()}},show:function(){SL.effects.hideEmbededObjects();this.zIndex=SL.ui._getNewOverlayIndex();this.exKB=SL.events.pushKeyboardObserver({modal:true,keydown:this.onKeyDown.bind(this)});
this._showBackdrop();this.beforeShowOverlay();this.centerToViewport(this.e);this.zIndex=SL.ui._getNewOverlayIndex();this.e.setStyle({zIndex:(this.zIndex+1)+""});this.e.appear({duration:0.1,afterFinish:this.afterShow.bind(this)})
},setCloseJS:function(A){this.closeJS=A},beforeShowOverlay:function(){},afterShow:function(){},afterHideOverlay:function(){},beforeHide:function(){},hide:function(B){if(!B){B="abort"}this.beforeHide();
SL.events.removeKeyboardObserver(this.exKB);this.e.hide();this._hideBackdrop();if(this.onClose){var A=this.onClose.get(B)||this.onClose.get("all");if(A){try{A(B)}catch(C){console.log(C)}}}if(this.closeJS){this.closeJS(this)
}},getTopLeftForCenter:function(D,A){var C=document.viewport.getWidth();var B=document.viewport.getHeight();var G=0;var F=0;if(D<C){F=(C-D)/2}if(A<B){G=(B-A)/2}var E=document.viewport.getScrollOffsets();
return{top:G+E.top,left:F+E.left}},centerToViewport:function(B){if(!B){B=this.e}var A=this.getTopLeftForCenter(B.getWidth(),B.getHeight());this.e.setStyle({top:A.top+"px",left:A.left+"px"});this.afterCentered()
},afterCentered:function(){},_getBackdrop:function(){var B=this.id+"_g_backdrop";var A=$(B);if(!A){A=SL.utils.createBodyElement("div",{id:B});A.setStyle({position:"absolute",top:"0",left:"0",width:"100%",height:SL.effects.getBodyHeight()+"px",backgroundColor:"#000000"});
A.hide();A.observe("click",this.hide.bind(this))}A.setStyle({zIndex:this.zIndex+""});return A},_showBackdrop:function(){var A=this._getBackdrop();A.setStyle({height:SL.effects.getBodyHeight()+"px"});A.appear({duration:this.config.get("backdrop_duration")/1000,from:0,to:this.config.get("backdrop_opacity")})
},_hideBackdrop:function(){var A=this._getBackdrop();A.fade({duration:this.config.get("backdrop_duration")/1000,afterFinish:this._afterHideOverlay.bind(this,A)})},onKeyDown:function(A){if(A.code==Event.KEY_ESC||A.key=="q"){this.hide();
return true}return false},_afterHideOverlay:function(A){this.afterHideOverlay();if(this.config.get("delete_on_hide")){A.remove();this._destroy()}},cleanup:function($super){SL.events.removeKeyboardObserver(this.exKB);
$super()},addOnClose:function(A){this.onClose=$H(A)}});SL.ui.Dialog=Class.create(SL.ui.Overlay,{isDialog:true,init:function($super){this.config.setDefault("backdrop_opacity",0.4);this.config.setDefault("static_height",false);
$super();this.config.setDefault("dialog_class","gui_dialog");this.config.setDefault("add_class","gui_overlay");this.css=this.config.get("dialog_class");this.e.addClassName(this.css);this.e.addClassName(this.config.get("add_class"))
},onDragStart:function(){this.dragged=true},onChildComponentChanged:function(){this._updateOverlay.bind(this).defer()},onSuccess:function(){if(this.draggable){this.draggable.destroy()}if(this.e.select("."+this.css+"_head").size()>0){this.draggable=new SL.dnd.Draggable(this.e,{grip_class:this.css+"_head",cb:{dragStart:this.onDragStart.bind(this),moved:this.afterCentered.bind(this)}})
}if(this.config.get("size")){this._updateOverlay(true)}else{this._updateOverlay.bind(this,true).defer()}},showAndLoad:function(A){this.show();this.load(A)},afterCentered:function(){},beforeHide:function(){},setSize:function(A,B){this.config.set("size",A);
this.config.set("static_height",B);this._updateOverlay.bind(this).defer()},_updateOverlay:function(C){var F=this.e.down("."+this.css+"_content_outer");if(!F){var D=this.config.get("size");if(D){this.e.setStyle({width:D.width>0?(D.width+"px"):"auto",height:D.height>0?(D.height+"px"):"auto"})
}this.centerToViewport();if(C){new SL.effects.Preloader(this.e,this._updateOverlay.bind(this)).run()}return }var B=F.down();var E="auto";var A="auto";D=this.config.get("size");if(!D){if(B.getWidth()>document.viewport.getWidth()-60){E=document.viewport.getWidth()-60+"px"
}if(B.getHeight()>document.viewport.getHeight()-60){A=document.viewport.getHeight()-60+"px"}}else{E=(D.width>0?D.width:B.getWidth()+2)+"px";if(this.config.get("static_height")){A=(D.height>0?D.height:B.getHeight()+2)+"px"
}else{if(D.height>0){A=B.getHeight()>D.height?D.height:B.getHeight();if(A>document.viewport.getHeight()-60){A=document.viewport.getHeight()-60+"px"}else{A=A+"px"}}else{if(B.getHeight()>document.viewport.getHeight()-60){A=document.viewport.getHeight()-60+"px"
}else{A="auto"}}}}F.setStyle({width:E,height:A});this.centerToViewport();if(C){new SL.effects.Preloader(this.e,this._updateOverlay.bind(this)).run()}},cleanup:function($super){if(this.draggable){this.draggable.destroy()
}}});SL.ui.Lightbox=Class.create(SL.ui.Overlay,{init:function($super){$super();this.config.setDefault("resize_duration",500);this.config.setDefault("counter_template",new Template("#{index} of #{total}"));
this.config.setDefault("content_dimension",null);this.config.setDefault("mode","auto");this.config.setDefault("show_bottom",true);this.config.setDefault("bottom_duration",100);this.config.setDefault("hide_on_click","auto");
this.config.setDefault("counter_top",false);this.config.setDefault("switch_duration",1000);this.e.addClassName("lightbox");this.currentImage=0;this.mode=this.config.get("mode");this.diaTimeout=this.config.get("dia_timeout");
this.contentDimension=this.config.get("content_dimension");if(this.mode=="auto"){var A=$(this.config.get("gallery_id"));this.images=$A();A.select("a").each(function(C){this.images.push({url:C.readAttribute("href"),text:C.readAttribute("title")});
C.observe("click",function(D,E){E.stop();this.showImage(D)}.bind(this,this.images.length-1))}.bind(this))}else{if(this.mode=="json"){this.images=$A(this.config.get("data"))}else{if(this.mode=="html"){var A=$(this.config.get("gallery_id"));
var B=this.config.get("content_dimension");this._switchImage(this.currentImage+1);this.images=$A();A.childElements().each(function(C){this.images.push({e:C,text:C.readAttribute("title")});SL.effects.reparentToOffscreen(C);
if(B){C.setStyle({maxWidth:B.width+"px"})}}.bind(this))}else{console.log("Unknown mode:",this.mode)}}}},beforeShowOverlay:function(){this._initDefaultLayout()},afterShow:function(){this._updateForImage()
},showImage:function(A){this.currentImage=A;this.show()},showImageWithID:function(C){for(var A=0;A<this.images.length;A++){var B=this.images[A];if(B.id==C){this.currentImage=A;this.show();return }}console.log("Lightbox: No image with id ",C)
},next:function(){this._switchImage(this.currentImage+1)},prev:function(){this._switchImage(this.currentImage-1)},_initDefaultLayout:function(){if(this.e.childElements().length>0){return }var F;if(this.mode=="html"){F=""
}else{if(!this.config.get("content_dimension")||!this.diaTimeout){F='<img src="" />'}else{F="";for(i=0;i<this.images.length;i++){F+='<img style="position:absolute;top:0;left:0;display:none;" src="" />'
}}}var C;if(this.config.get("show_bottom")){var E='<div class="lightbox_details">';if(this.config.get("counter_top")){E+='<div class="lightbox_counter"></div><div class="lightbox_text"></div>'}else{E+='<div class="lightbox_text"></div><div class="lightbox_counter"></div>'
}if(this.config.get("add_content")){E=E+'<div class="lightbox_add_content">'+this.config.get("add_content")+"</div>"}if(this.config.get("print_img")){E=E+'<div class="lightbox_print"><img src="'+this.config.get("print_img")+'" /></div>'
}E=E+"</div>";C='<div class="lightbox_bottom" style="display:none">'+E+'<div class="lightbox_close"></div></div>'}else{C=""}var H;if(this.images.length>1&&!this.config.get("dia_timeout")){H='<div class="lightbox_hnav"><a href="#" class="lightbox_hnav_next"></a><a href="#" class="lightbox_hnav_prev"></a></div>';
this.hasHoverNav=true}else{H=""}var D='<div class="lightbox_content">'+H+'<div id="'+this.id+'_content_inner" class="lightbox_content_inner">'+F+"</div></div>"+C;this.e.insert({top:D});this.hoverNext=this.e.down(".lightbox_hnav_next");
this.hoverPrev=this.e.down(".lightbox_hnav_prev");this.content=this.e.down(".lightbox_content");this.contentInner=this.e.down(".lightbox_content_inner");this.close=this.e.down(".lightbox_close");this.text=this.e.down(".lightbox_text");
this.counter=this.e.down(".lightbox_counter");this.bottom=this.e.down(".lightbox_bottom");this.addContent=this.e.down(".lightbox_add_content");if(this.hasHoverNav){this.hoverNext.observe("click",this.next.bind(this));
this.hoverPrev.observe("click",this.prev.bind(this));SL.effects.registerHover(this.hoverNext);SL.effects.registerHover(this.hoverPrev)}if(this.close){this.close.observe("click",this.hide.bind(this))}var G=this.config.get("content_dimension");
if(G){this.content.setStyle({width:G.width+"px",height:G.height+"px",overflow:"hidden",position:"relative"});this.contentInner.setStyle({position:"relative"});if(this.bottom){this.bottom.show()}}else{this.content.setStyle({width:"200px",height:"200px",overflow:"hidden"})
}this.contentInner.setStyle({overflow:"hidden",width:"100%"});var B=this.config.get("hide_on_click");if(B=="auto"&&this.images.length<=1){this.e.observe("click",this.hide.bind(this))}else{if(B==true){this.e.observe("click",this.hide.bind(this))
}}var A=this.e.down(".lightbox_print");if(A){A.observe("click",slPrintElement.curry(this.id+"_content_inner"))}},_updateForImage:function(){this.inAnimation=true;var C=this.images[this.currentImage];if(!this.diaTimeout||!this.config.get("content_dimension")){this.content.addClassName("loading");
this.contentInner.hide();this.e.setOpacity(0.8)}if(this.mode=="html"){new SL.effects.Preloader(C.e,this._updateForHTML.bind(this));return }var B;if(!this.config.get("content_dimension")||!this.diaTimeout){B=this.contentInner.down("img")
}else{B=this.contentInner.children[this.currentImage];B.hide()}var A=new Image();A.onload=function(){B.writeAttribute("src",C.url);this._resizeTo.bind(this,A.width,A.height,B).defer()}.bind(this);A.src=C.url
},_updateForHTML:function(){var C=this.images[this.currentImage];var B=C.e.getWidth();var A=C.e.getHeight();this.contentInner.childElements().each(function(D){SL.effects.reparentToOffscreen(D)});SL.effects.reparentAndReset(this.contentInner,C.e);
dimension=this.config.get("content_dimension");if(dimension){if(B>dimension.width){B=dimension.width;C.e.setStyle({width:B+"px"});A=dimension.height}}this._resizeTo(B,A)},_resizeTo:function(G,A,I){var H=this.content;
dimension=this.config.get("content_dimension");if(dimension!=null){var J=0;var E=0;if(G!=dimension.width){E=(dimension.width-G)/2}if(A!=dimension.height){J=(dimension.height-A)/2}if(!I||!this.diaTimeout){this.contentInner.setStyle({top:J+"px",left:E+"px",width:G+"px",height:A+"px"});
this._afterUpdateFinished(dimension.width,dimension.height)}else{this.contentInner.setStyle({width:"100%",height:dimension.height+"px"});if(!this.currentIE){if(I){I.show()}this.currentIE=I;this._afterUpdateFinished(dimension.width,dimension.height)
}else{console.log("appear:"+I.src);I.appear({duration:this.config.get("switch_duration")/1000,from:0,to:1,afterFinish:this._afterUpdateFinished.bind(this,G,A)});this.currentIE.fade({duration:this.config.get("switch_duration")/1000,from:1,to:0});
this.currentIE=I}this.currentIE.setStyle({top:J+"px",left:E+"px"})}this.centerToViewport.bind(this,this.e).defer();return }var C=H.getWidth();var D=H.getHeight();var E=parseFloat(this.e.getStyle("left")||"0");
var K=this.getTopLeftForCenter(G,A);var F=this.config.get("resize_duration")/2000;if(F<=0){H.setStyle({width:G+"px",height:A+"px"});this.e.setStyle({top:K.top+"px",left:K.left+"px"});this._afterUpdateFinished(G,A);
return }var B=new SL.effects.Queue({afterFinish:this._afterUpdateFinished.bind(this,G,A)});hScale=A*100/D;wScale=G*100/C;console.log("Animate resize:",C,":",D,":",G,":",A,":",wScale,":",hScale);if(D!=A){B.add("first",new Effect.Scale(H,hScale,{sync:true,scaleX:false,scaleContent:false,duration:F}));
B.add("first",new Effect.Move(this.e,{sync:true,y:K.top,x:E,duration:F,mode:"absolute"}))}if(C!=G){B.add("last",new Effect.Scale(H,wScale,{sync:true,scaleY:false,scaleContent:false,duration:F}));B.add("last",new Effect.Move(this.e,{sync:true,y:K.top,x:K.left,duration:F,mode:"absolute"}))
}if(!this.contentDimension&&this.bottom){SL.effects.resetCurrent(this.bottom);this.bottom.hide()}if(B.isEmpty()){this._afterUpdateFinished(G,A);return }B.start()},_switchImage:function(A){if(this.inAnimation){return 
}if(A<0){A=this.images.length-1}else{if(A>=this.images.length){A=0}}this.currentImage=A;this._updateForImage()},_afterUpdateFinished:function(C,A){if(this.diaTimeout){if(this.currentTimeout){clearTimeout(this.currentTimeout)
}this.currentTimeout=setTimeout(function(){this._switchImage(this.currentImage+1)}.bind(this),this.diaTimeout)}this.images[this.currentImage].loaded=true;var B=(this.currentImage>=this.images.length-1)?0:this.currentImage+1;
if(!this.images[B].loaded){if(this.mode=="html"){new SL.effects.Preloader(this.images[B].e)}else{new Image().src=this.images[B].url}}if(this.hasHoverNav){if(this.currentImage>=this.images.length-1){this.hoverNext.hide()
}else{this.hoverNext.show();this.hoverNext.setStyle({height:A+"px",width:(C/2)-1+"px"})}if(this.currentImage<=0){this.hoverPrev.hide()}else{this.hoverPrev.show();this.hoverPrev.setStyle({height:A+"px",width:(C/2)-1+"px"})
}}this.content.removeClassName("loading");this.contentInner.show();this.e.setOpacity(1);if(this.bottom){var D=this.images[this.currentImage];if(D.text){this.text.show();this.text.update(D.text)}else{this.text.hide()
}if(this.images.length>1){this.counter.update(this.config.get("counter_template").evaluate({total:this.images.length,index:this.currentImage+1}))}if(!this.contentDimension){this.bottom.setStyle({width:C+"px"});
SL.effects.registerCurrent(new Effect.BlindDown(this.bottom,{duration:this.config.get("bottom_duration")/1000}))}}setTimeout(function(){this.inAnimation=false}.bind(this),50)},afterHideOverlay:function(){SL.effects.showEmbededObjects()
},onKeyDown:function($super,A){if($super(A)){return true}if(this.inAnimation||this.images.length<2){return }if(A.code==Event.KEY_LEFT){this._switchImage(this.currentImage-1)}else{if(A.code==Event.KEY_RIGHT){this._switchImage(this.currentImage+1)
}}}});SL.ui.showSimpleLightbox=function(H,E,D,C,A,G,F,B){new SL.ui.Lightbox(H,{counter_template:F,mode:"json",hide_on_click:B,delete_on_hide:true,content_dimension:D,print_img:C,dia_timeout:A,switch_duration:G,data:E}).showImage(0)
};SL.ui.getDialog=function(B){var A=SL.byID(B);while(A){if(A.isDialog){return A}A=A.getParentComponent()}};SL.ui.TreeTable=Class.create(SL.Component,{init:function(){this.config.setDefault("selectable",false);
this.config.setDefault("keyboard_editing",false);this.rows=this.config.get("rows");if(this.config.get("selectable")&&this.rows){this.selected=false;this.config.get("rows").each(function(C){var B=$(C.id);
B.observe("click",this.onRowClicked.bind(this,B))}.bind(this));var A=this.config.get("selected");if(A){SL.storage.ensureHash("tree_selection").set(this.id,A)}else{A=SL.storage.ensureHash("tree_selection").get(this.id)
}if(A){this.selected=$(A);if(this.selected){this.selected.addClassName("selected")}}else{if(this.config.get("select_first")){console.log(this.rows[0].id);this.onRowClicked.bind(this,$(this.rows[0].id)).defer()
}}this.dndActionURL=this.config.get("dnd_action_url");this.dndActionComponent=this.config.get("dnd_action_component");if(this.dndActionURL){this.dnd=new SL.dnd.SortableTable(this.e.down("table"),{cb:{dragStart:this.onDragStart.bind(this),dragStop:this.onDragStop.bind(this)},grip_class:this.config.get("grip_class")})
}if(this.config.get("keyboard_editing")){this.keyObserver=SL.events.pushKeyboardObserver({keydown:this.onKey.bind(this)})}}},onDragStart:function(A,B){this.rows.each(function(E){if(!E.last){return }var D=$(E.id);
var C=SL.elements.createBlindRow(D);C.setStyle({backgroundColor:"#cccccc",height:"10px"});C.addClassName("sljs__tree_table_dnd_marker");C.id=E.id+"__last_child";D.insert({after:C})}.bind(this))},onDragStop:function(B,F,E){var D=F.next();
var C=F.previous();this.e.select(".sljs__tree_table_dnd_marker").each(function(J){J.remove()});if(this.dndActionURL){var G;var I;if(D){G=D.id;if(G.endsWith("__last_child")){G=G.substring(0,G.length-12);
I=false}else{I=true}}else{if(C){G=C.id;I=false}else{console.log("No target found");return }}var A=this.dndActionURL+"&args.dnd_action_source_id="+F.id+"&args.dnd_action_target_id="+G+"&args.dnd_action_above="+I;
var H=SL.byID(this.dndActionComponent);H.loadBackground(A)}},onKey:function(C){if(!this.selected||this.disabled){return }if(C.shift){var A=$H(this.getActions(this.selected.id));var B;switch(C.code){case Event.KEY_DOWN:B=A.get("down");
break;case Event.KEY_UP:B=A.get("up");break;case Event.KEY_LEFT:B=A.get("left");break;case Event.KEY_RIGHT:B=A.get("right");break;default:if(C.key=="n"){B=A.get("add")}else{if(C.key=="e"){B=A.get("edit")
}else{if(C.key=="m"){B=A.get("move")}}}}if(B){this._disableTemp();B()}return true}if(C.code==Event.KEY_DOWN){var D=this.selected.next();if(D){this.onRowClicked(D)}return true}if(C.code==Event.KEY_UP){var D=this.selected.previous();
if(D){this.onRowClicked(D)}return true}if(C.code==Event.KEY_ESC){this.onRowClicked(null);return true}if(C.code==Event.KEY_LEFT||C.code==Event.KEY_RIGHT){var A=$H(this.getActions(this.selected.id)).get("toggle");
if(A){this._disableTemp();A()}return true}},toggle:function(C){var B=$(C);if(!B){return }var A=B.down(".gtvlm");if(!A){A=B.down(".gtvtm")}if(!A){A=B.down(".gtvlp")}if(!A){A=B.down(".gtvtp")}if(!A){A=B.down(".gtvtn")
}if(!A){A=B.down(".gtvln")}if(!A){return }A.update(this._getLoadingContent())},onRowClicked:function(A){if(!A){if(this.selected){this.selected.removeClassName("selected");this.setSelected();this.selected=undefined
}return }if(this.selected){if(this.selected==A){return }this.selected.removeClassName("selected")}A.addClassName("selected");this.selected=A;this.setSelected(A.id)},setSelected:function(C){var A=SL.storage.ensureHash("tree_selection");
A.set(this.id,C);if(this.selectionNotifyHandler){if(C){this.selectionNotifyHandler($(C),this.getActions(C))}else{this.selectionNotifyHandler(null,{})}}var B=$H(this.getActions(this.selected.id)).get("select");
if(B){B()}},getActions:function(C){for(var A=0;A<this.rows.length;A++){var B=this.rows[A];if(B&&B.id==C){return B.actions}}console.log("TreeTable: No actions for id "+C);return $H()},connectSelectionNotify:function(A,B){this.selectionNotifyHandler=A;
if(B&&this.selected){this.selectionNotifyHandler($(this.selected),this.getActions(this.selected.id))}},cleanup:function(){SL.events.removeKeyboardObserver(this.keyObserver)},_disableTemp:function(){if(!this.disabled){this.disabled=true;
setTimeout(function(){this.disabled=false}.bind(this),5000)}},onSuccess:function(){this.disabled=undefined}});SL.ui.TreeTableActions=Class.create(SL.Component,{init:function(){this.tree=SL.byID(this.config.get("tree_id"));
this.actions=$H(this.config.get("actions"));this.actions.each(function(B){var A=B.value;$(A.image).observe("click",this._clicked.bind(this,B.key))}.bind(this));this.tree.connectSelectionNotify(this.onChanged.bind(this),true)
},_clicked:function(C){var A=this.actions.get(C);if(!this.currentActions){if(A.fallback){A.fallback()}return }var B=this.currentActions.get(C);if(B){B()}else{if(A.fallback){A.fallback()}}},setActions:function(A){this.currentActions=A;
this.actions.each(function(C,G){var E=G.key;var B=G.value;var F=$(B.image);var D;if(F.tagName.toLowerCase()=="img"){D=F}else{D=F.down("img")}if(C.get(E)||B.fallback){if(D&&D.src.endsWith("_i.png")){D.src=D.src.substring(0,D.src.length-6)+".png"
}F.setStyle({cursor:"pointer"})}else{if(D&&!D.src.endsWith("_i.png")){D.src=D.src.substring(0,D.src.length-4)+"_i.png"}F.setStyle({pointer:"default"})}}.curry(A))},onChanged:function(A,B){this.setActions($H(B))
}});SL.dnd={};SL.dnd.SortableTable=Class.create(SL.Component,{init:function(){this.config.setDefault("callbacks",{});this.config.setDefault("grip_class",null);this.cb=this.config.ensureHash("cb");this.gripClass=this.config.get("grip_class");
this.root=this.e.down("tbody");if(!this.root){this.root=this.e}this._initObservedElements()},_initObservedElements:function(){if(this.observed){this.observed.each(function(B){var A=$(B.key);if(A){A.stopObserving("mousedown",B.value)
}}.bind(this))}this.observed=$H();this.root.childElements().each(function(A){if(this.gripClass){A.select("."+this.gripClass).each(function(C,B){this._observeElement(C,B)}.bind(this,A))}else{this._observeElement(A)
}}.bind(this))},_observeElement:function(C,B){if(!this.observed.get(B)&&!B.down("form")){var A=this.onMouseDown.bind(this,C);B.observe("mousedown",A);this.observed.set(B.identify(),A)}},onChildComponentChanged:function(A){this._initObservedElements()
},onMouseDown:function(B,A){if(this.mouseMoveEvent||!A.isLeftClick()){return }this.mouseMoveEvent=this.onMouseMove.bind(this,B);this.mouseUpEvent=this.onMouseUp.bind(this,B);document.observe("mousemove",this.mouseMoveEvent);
document.observe("mouseup",this.mouseUpEvent);var C=B.cumulativeOffset();this.xOffset=A.pageX-C.left;A.stop()},onMouseUp:function(C,B){document.stopObserving("mousemove",this.mouseMoveEvent);document.stopObserving("mouseup",this.mouseUpEvent);
this.mouseMoveEvent=undefined;this.mouseUpEvent=undefined;if(this.marker){var A=this.marker.up().childElements().indexOf(this.marker);if(this.ghost){this.marker.replace(this.ghost.down("tr"));this.ghost.remove()
}else{this.ghost.remove()}this.marker=undefined;this.ghost=undefined;if(this.cb.dragStop){this.cb.dragStop(this,C,A)}}this.previousIndex=undefined},onMouseMove:function(C,B){if(!this.marker){if(this.cb.dragStart){this.cb.dragStart(this,C)
}this.previousIndex=C.up().childElements().indexOf(C);this.marker=this.createMarker(C);this.ghost=SL.utils.createBodyElement("table",{"class":this.e.readAttribute("class")});this.ghost.setStyle({width:this.e.getWidth()+"px"});
this.ghost.hide();var A=new Element("tbody");this.ghost.appendChild(A);A.appendChild(C.replace(this.marker));this.ghost.setStyle({position:"absolute",cursor:"move",zIndex:"1000"});this.ghost.setOpacity("0.8");
this.ghost.show()}this.ghost.setStyle({left:B.pageX-this.xOffset+"px",top:B.pageY-(C.getHeight()/2)+"px"});var D=this.findRowAt(B.pageX,B.pageY);if(D){if(D.e==this.marker){return }if(D.overlap<0.5){D.e.insert({after:this.marker})
}else{D.e.insert({before:this.marker})}}B.stop()},findRowAt:function(A,G){var D=this.root.childElements();for(var C=0;C<D.length;C++){var E=D[C];var F=E.cumulativeOffset();if(A<F.left||G<F.top){continue
}if(A>F.left+E.getWidth()){continue}if(G>F.top+E.getHeight()){continue}var B=1-((G-F.top)/E.getHeight());return{e:E,overlap:B}}return false},createMarker:function(A){var C=SL.elements.createBlindRow(A);
var B=new Element("div");B.setStyle({margin:"0",padding:"0",height:A.getHeight()-4+"px",border:"dotted #777 2px"});C.down("td").appendChild(B);return C},cleanup:function(){if(this.mouseMoveEvent){document.stopObserving("mousemove",this.mouseMoveEvent);
document.stopObserving("mouseup",this.mouseUpEvent)}if(this.ghost){this.ghost.remove()}}});SL.dnd.Draggable=Class.create(SL.Element,{init:function(){this.config.setDefault("grip_class",null);this.config.setDefault("orientation","both");
this.cb=this.config.ensureHash("cb");this.orientation=this.config.get("orientation");var A=this.config.get("grip_class");this.handle=A?this.e.down("."+A):this.e;if(!this.handle){console.log("Handle not found:"+A);
return }this.mouseDownHandler=this.onMouseDown.bind(this,this.e);this.handle.observe("mousedown",this.mouseDownHandler);this.handle.setStyle({cursor:"move"});console.log("Create draggable:",this.e)},onMouseDown:function(B,A){if(this.mouseMoveEvent||!A.isLeftClick()){return 
}this.mouseMoveEvent=this.onMouseMove.bind(this,B);this.mouseUpEvent=this.onMouseUp.bind(this,B);document.observe("mousemove",this.mouseMoveEvent);document.observe("mouseup",this.mouseUpEvent);this.xOffset=A.pageX-this.e.offsetLeft;
this.yOffset=A.pageY-this.e.offsetTop;A.stop()},onMouseUp:function(B,A){document.stopObserving("mousemove",this.mouseMoveEvent);document.stopObserving("mouseup",this.mouseUpEvent);this.mouseMoveEvent=undefined;
this.mouseUpEvent=undefined;if(this.active){this.active=false;if(this.cb.dragStop){this.cb.dragStop(this)}}this.reenableIframes()},onMouseMove:function(E,B){if(!this.active){this.active=true;if(this.cb.dragStart){this.cb.dragStart(this)
}}var A=this.config.get("minX")||0;var F=this.config.get("minY")||0;var D=this.e.up().getWidth()-10-(this.config.get("maxX")||0);var C=this.e.up().getHeight()-10-(this.config.get("maxY")||9);if(this.orientation=="horizontal"){this.e.setStyle({left:Math.min(Math.max(A,B.pageX-this.xOffset),D)+"px"})
}else{if(this.orientation=="vertical"){this.e.setStyle({top:Math.min(Math.max(F,B.pageY-this.yOffset),C)+"px"})}else{this.e.setStyle({left:Math.min(Math.max(A,B.pageX-this.xOffset),D)+"px",top:Math.min(Math.max(F,B.pageY-this.yOffset),C)+"px"})
}}if(this.cb.moved){this.cb.moved(this)}this.updateIframes();B.stop()},updateIframes:function(){if(this.iframes){this.iframes.each(function(A){A.e.clonePosition(A.frame)})}else{this.iframes=$A();$$("iframe").each(function(B){var A=SL.utils.createBodyElement("div");
A.clonePosition(B);A.setStyle({position:"absolute",backgroundColor:"#ffffff"});A.setOpacity(0);this.iframes.push({e:A,frame:B})}.bind(this))}},reenableIframes:function(){if(this.iframes){this.iframes.each(function(A){A.e.remove()
});this.iframes=undefined}},cleanup:function(){this.handle.stopObserving("mousedown",this.mouseDownHandler);this.reenableIframes()}});SL.ui.SplitPane=Class.create(SL.Component,{init:function(){this.config.setDefault("spacer_width",7);
this.config.setDefault("orientation","horizontal");this.config.setDefault("spacer_class","gui_splitpane_"+this.config.get("orientation")+"_spacer");var B=this.config.get("spacer_width");this.div1=$(this.e.childElements()[0]);
this.div2=$(this.e.childElements()[1]);this.spacer=new Element("div",{"class":this.config.get("spacer_class")});this.e.setStyle({position:"relative"});this.div1.insert({after:this.spacer});if(this.config.get("orientation")=="horizontal"){var D=this.div1.getWidth();
var A=this.div2.getWidth();this.spacer.setStyle({position:"absolute",left:D+"px",top:"0",width:B+"px",bottom:"0",zIndex:"1"});this.div1.setStyle({"float":"none",position:"absolute",left:"0",top:"0",width:D+"px"});
this.div2.setStyle({"float":"none",position:"absolute",left:(D+B)+"px",top:"0",right:"0",marginLeft:"0"});this.currentHeight=Math.max(this.div1.getHeight(),this.div2.getHeight())+5;this.e.setStyle({height:this.currentHeight+"px"});
this.updateEvent=this.update.bind(this);this.actionURL=this.config.get("action_url");this.draggable=new SL.dnd.Draggable(this.spacer,{orientation:"horizontal",minX:this.config.get("min_left"),maxX:this.config.get("min_right"),cb:{moved:this.updateEvent,dragStop:this.onDragStop.bind(this)}})
}else{var E=this.div1.getHeight();var C=this.div2.getHeight();this.spacer.setStyle({position:"absolute",left:"0",top:E+"px",height:B+"px",right:"0",zIndex:"1"});this.div1.setStyle({position:"absolute",left:"0",top:"0"});
this.div2.setStyle({position:"absolute",top:(E+B)+"px",left:"0",right:"0",bottom:"0"});this.updateEvent=this.update.bind(this);this.actionURL=this.config.get("action_url");this.draggable=new SL.dnd.Draggable(this.spacer,{orientation:"vertical",minY:this.config.get("min_left"),maxY:this.config.get("min_right"),cb:{moved:this.updateEvent,dragStop:this.onDragStop.bind(this)}})
}Event.observe(document.onresize?document:window,"resize",this.updateEvent);setTimeout(this.onCheckLayout.bind(this),500)},onCheckLayout:function(){if(this.isCleanedUp){return }if(this.config.get("orientation")=="horizontal"){var A=Math.max(this.div1.getHeight(),this.div2.getHeight())+5;
if(this.currentHeight!=A){this.currentHeight=A;this.e.setStyle({height:A+"px"})}this.spacer.setStyle({height:this.currentHeight+"px"}),setTimeout(this.onCheckLayout.bind(this),500)}},update:function(){var B=this.config.get("spacer_width");
if(this.config.get("orientation")=="horizontal"){var F=this.spacer.offsetLeft;var D=F;var A=this.e.getWidth()-F-B;this.spacer.setStyle({left:D+"px"});this.div1.setStyle({width:D+"px"});this.div2.setStyle({left:(D+B)+"px"});
this.currentHeight=Math.max(this.div1.getHeight(),this.div2.getHeight());this.e.setStyle({height:this.currentHeight+"px"});this.spacer.setStyle({height:this.currentHeight+"px"})}else{var F=this.spacer.offsetTop;
var E=F;var C=this.e.getHeight()-F-B;this.spacer.setStyle({top:E+"px"});this.div1.setStyle({height:E+"px"});this.div2.setStyle({top:(E+B)+"px"})}},onChildComponentChanged:function(){this.update()},onDragStop:function(){if(this.actionURL){var A=this.spacer.offsetLeft;
new Ajax.Request(this.actionURL+"&args._sp_offset="+A)}},cleanup:function(){this.draggable.destroy();Event.stopObserving(document.onresize?document:window,"resize",this.updateEvent)}});SL.ui.Tooltip=Class.create(SL.Component,{init:function(){this.config.setDefault("hide_delay",500);
this.config.setDefault("follow_mouse",false);this.trigger=$(this.config.get("connect_id"));this.followMouse=this.config.get("follow_mouse");SL.utils.reparentToBody(this.e);this.e.setStyle({display:"block",position:"absolute",zIndex:"999"});
this.e.hide();this.onTriggerEnterEvent=this.onTriggerEnter.bind(this);this.onTriggerLeaveEvent=this.onTriggerLeave.bind(this);this.trigger.observe("mouseenter",this.onTriggerEnterEvent);this.trigger.observe("mouseleave",this.onTriggerLeaveEvent);
this.initURL=this.config.get("url")},notifyInitEvent:function(A){this.onTriggerEnter(A)},onTriggerEnter:function(A){this.onTrigger=true;if(this.timeout){clearTimeout(this.timeout);this.timeout=undefined
}if(this.shown){return }SL.ui._registerActiveTooltip(this);if(this.initURL){this.load(this.initURL);this.initURL=undefined}this.onTooltipEnterEvent=this.onTooltipEnter.bind(this);this.onTooltipLeaveEvent=this.onTooltipLeave.bind(this);
this.e.observe("mouseenter",this.onTooltipEnterEvent);this.e.observe("mouseleave",this.onTooltipLeaveEvent);this._showDefered.bind(this).defer();this.triggerPosition={left:A.pageX,top:A.pageY};this.shown=true
},onTriggerLeave:function(A){this.onTrigger=false;if(!this.shown){return }if(this.timeout){clearTimeout(this.timeout)}if(!this.onTooltip){this.timeout=setTimeout(this._hide.bind(this),this.config.get("hide_delay"))
}},onTooltipEnter:function(A){if(this.timeout){clearTimeout(this.timeout);this.timeout=undefined}this.onTooltip=true},onTooltipLeave:function(A){this.onTooltip=false;if(!this.onTrigger){this.timeout=setTimeout(this._hide.bind(this),this.config.get("hide_delay"))
}},_showDefered:function(){if(!this.onTrigger&&!this.onTooltip){return }if(this.followMouse){this.onMouseMoveEvent=this.onMouseMove.bind(this);this.trigger.observe("mousemove",this.onMouseMoveEvent);this.e.observe("mousemove",this.onMouseMoveEvent)
}this._update()},onSuccess:function(){this._update()},onChildComponentChanged:function(){this._update()},onMouseMove:function(B){var A=this.trigger.cumulativeOffset();if(B.pageX<A.left){return }if(B.pageX>A.left+this.trigger.getWidth()){return 
}if(B.pageY<A.top){return }if(B.pageY>A.top+this.trigger.getHeight()){return }this.triggerPosition={left:B.pageX,top:B.pageY};this._updatePositions()},_update:function(){new SL.effects.Preloader(this.e,this._updatePositions.bind(this)).run()
},_updatePositions:function(){if(this.followMouse){if(!this.triggerPosition){console.log("No trigger position");return }var C=this.triggerPosition.left+2;var K=this.triggerPosition.top+2;var H=document.viewport.getScrollOffsets();
var J=document.viewport.getDimensions();var G=H.left+J.width;var D=C+this.e.getWidth()-G;if(D>0){var I=H.left-(C-this.e.getWidth());if(I<D){C=C-this.e.getWidth()-2}}var B=H.top+J.height;var A=K+this.e.getHeight()-B;
if(A>0){var F=H.top-(K-this.e.getHeight());if(F<A){K=K-this.e.getHeight()-2}}this.e.setStyle({left:C+"px",top:K+"px"});if((this.onTrigger||this.onTooltip)&&this.shown){this.e.show()}return }var E=this.trigger.cumulativeOffset();
var H=document.viewport.getScrollOffsets();var J=document.viewport.getDimensions();var C;if(this.triggerPosition){C=this.triggerPosition.left}else{C=E.left+this.trigger.getWidth()}if(C+this.e.getWidth()>H.left+J.width){C=Math.max(E.left-this.e.getWidth(),H.left)
}var K=E.top+this.trigger.getHeight();if(K+this.e.getHeight()>H.top+J.height){K=Math.max(E.top-this.e.getHeight(),H.top)}this.e.setStyle({left:C+"px",top:K+"px"});if((this.onTrigger||this.onTooltip)&&this.shown){this.e.show()
}},_hide:function(A){if(!A&&(this.onTrigger||this.onTooltip)){return }if(this.timeout){clearTimeout(this.timeout);this.timeout=undefined}this.e.hide();this.shown=false;this.timeout=undefined;if(this.onTooltipEnterEvent){this.e.stopObserving("mouseenter",this.onTooltipEnterEvent);
this.e.stopObserving("mouseleave",this.onTooltipLeaveEvent)}if(this.onMouseMoveEvent){this.trigger.stopObserving("mousemove",this.onMouseMoveEvent);this.e.stopObserving("mousemove",this.onMouseMoveEvent)
}this.onTrigger=false;this.onTooltip=false;this.triggerPosition=undefined;if(!A){SL.ui._registerActiveTooltip(null)}},cleanup:function(){this.trigger.stopObserving("mouseenter",this.onTriggerEnterEvent);
this.trigger.stopObserving("mouseleave",this.onTriggerLeaveEvent);if(this.onTooltipEnterEvent){this.e.stopObserving("mouseenter",this.onTooltipEnterEvent);this.e.stopObserving("mouseleave",this.onTooltipLeaveEvent)
}this.e.hide();this.e.remove()}});SL.ui._registerActiveTooltip=function(A){if(SL.ui._activeTooltip){if(SL.ui._activeTooltip==A){return }SL.ui._activeTooltip._hide(true)}SL.ui._activeTooltip=A};SL.effects.ContentChanger=Class.create(SL.Component,{init:function(){this.config.setDefault("timeout",5000);
this.config.setDefault("duration",1500);this.content=this.config.get("content");this.current=0;if(this.content.length>1){this.currentElement=$(this.content[0].id);setTimeout(this.next.bind(this),this.content[0].timeout||this.config.get("timeout"))
}},next:function(){this.current++;if(this.current>=this.content.length){this.current=0}new SL.effects.Preloader($(this.content[this.current].id),this.switchToCurrent.bind(this)).run()},switchToCurrent:function(){new Effect.Fade(this.currentElement,{from:1,to:0,duration:this.config.get("duration")/1000});
this.currentElement=$(this.content[this.current].id);this.currentElement.setOpacity(0);this.currentElement.setStyle({visibility:"visible"});new Effect.Appear(this.currentElement,{from:0,to:1,duration:this.config.get("duration")/1000,afterFinish:this.activateTimeout.bind(this)})
},activateTimeout:function(){setTimeout(this.next.bind(this),this.content[this.current].timeout||this.config.get("timeout"))}});SL.ui.HTMLEditor=Class.create(SL.Component,{init:function(){this.config.setDefault("textarea",this.id+"_t");
this.config.setDefault("toolbar","Basic");this._init.bind(this).defer()},_init:function(){this.editor=CKEDITOR.replace($(this.config.get("textarea")),{toolbar:this.config.get("toolbar")});this.editor.on("instanceReady",this._instanceReady.bind(this))
},_instanceReady:function(){console.log("CKEditor: Ready");this._emitContentChanged.bind(this).defer()},updateForPost:function(){if(this.editor){this.editor.updateElement();this.editor.destroy();this.editor=undefined
}}});