Function.prototype.beforeHook=function(object,method){if(typeof(object)=='function'){object=object.prototype;}
var __original=object[method];var __hook=this;object[method]=function(){var result=__hook.apply(this,$A(arguments));if((typeof(result)=='undefined')||((typeof(result)=='boolean')&&result)){return(__original.apply(this,$A(arguments)));}else if((typeof(result)=='boolean')&&!result){return;}else{if(!result.shift)result=[result];var exec=result.shift();if(exec){return(__original.apply(this,$A(result.shift())));}else{return(result.shift());};};};};Function.prototype.afterHook=function(object,method){if(typeof(object)=='function'){object=object.prototype;}
var __original=object[method];var __hook=this;object[method]=function(){var result=__original.apply(this,$A(arguments));return(__hook.apply(this,$A(arguments).concat([result])));};};MethodSpy=Class.create();MethodSpy.argumentToString=function(argument){switch(typeof(argument)){case'string':return("'"+argument+"'");case'object':if(argument===null){return('null');}else if(argument.constructor==Array){var result='[';for(var i=0;i<argument.length;i++){result+=MethodSpy.argumentToString(argument[i])+',';}
if(argument.length>0){result=result.slice(0,-1)}
return(result+']');}else{return(argument.toSource());}
default:return(argument);}};MethodSpy.prototype={initialize:function(klass,options){if(arguments.length<2){options={};}
for(var key in klass.prototype){if(typeof(klass.prototype[key])=='function'){var closure=function(){var shallowKey=key;var realFunction=klass.prototype[shallowKey];klass.prototype[key]=function(){var argumentString='(';for(var i=0;i<arguments.length;i++){argumentString+=MethodSpy.argumentToString(arguments[i])+',';}
if(arguments.length>0){argumentString=argumentString.slice(0,-1);}
argumentString+=')';console.log('Entering method: %s%s',shallowKey,argumentString);return(realFunction.apply(this,$A(arguments)));}}
closure.call();}}}};Event.Group=Class.create();Event.Group.prototype={initialize:function(){this.events=[];},add:function(){this.events.push($A(arguments));},remove:function(){for(var i=0;i<this.events.length;i++){var eventArguments=this.events[i];var match=true;for(var j=0;j<eventArguments.length;j++){var savedArgument=eventArguments[j];var suppliedArgument=arguments[j];if(suppliedArgument!=savedArgument){match=false;break;}}
if(match){var newEventsStart=this.events.slice(0,i);var newEventsEnd=this.events.slice(i+1);this.events=newEventsStart.concat(newEventsEnd);break;}}},start:function(){for(var i=0;i<this.events.length;i++){var eventArguments=this.events[i];Event.observe.apply(Event,eventArguments);}},stop:function(){for(var i=0;i<this.events.length;i++){var eventArguments=this.events[i];Event.stopObserving.apply(Event,eventArguments);}}}
window.EditableAttributes={functionStore:{after:{}}};var EditableAttributes={functionStore:{after:{}},hooks:{inPlaceEditor:{before:{onComplete:function(transport){if(this.originalDisplayStates){for(var i=0;i<this.originalDisplayStates.length;i++){var id=this.originalDisplayStates[i][0];var styleValue=this.originalDisplayStates[i][1];$(id).style.display=styleValue;}}
return(!this.options.exitHook||this.options.exitHook(this,transport));},enterEditMode:function(evt){var force=((arguments.length>1)&&arguments[1]);if(!force&&this.options.hide){this.originalDisplayStates=[];for(var i=0;i<this.options.hide.length;i++){var id=this.options.hide[i];var element=$(id);this.originalDisplayStates.push([id,Element.getStyle(id,'display')]);element.style.display='none';}}
return(force||!this.options.enterHook||this.options.enterHook(this,evt));},initialize:function(element,url,options){if(options.disableHoverEffects&&!options.onComplete){options.onComplete=function(transport,element){return(true);};}},onSubmit:function(){if(this.options.changesURL&&this.element.innerHTML.substr(0,9)!='Untitled '){var ok=confirm('If you continue with this change, at least one site URL will be modified. This could have serious consequences for any SEO campaign being conducted for your site. Are you sure you want to continue?');if(ok){return(true);}else{this.onclickCancel();return(false);};}},enterHover:function(){return(!(Draggables.activeDraggable||this.options.disableHoverEffects));},leaveHover:function(){return(!(Draggables.activeDraggable||this.options.disableHoverEffects));}}}}};EditableAttributes.hooks.inPlaceEditor.before.onComplete.beforeHook(Ajax.InPlaceCollectionEditor,'onComplete');EditableAttributes.hooks.inPlaceEditor.before.onComplete.beforeHook(Ajax.InPlaceEditor,'onComplete');EditableAttributes.hooks.inPlaceEditor.before.enterEditMode.beforeHook(Ajax.InPlaceCollectionEditor,'enterEditMode');EditableAttributes.hooks.inPlaceEditor.before.enterEditMode.beforeHook(Ajax.InPlaceEditor,'enterEditMode');EditableAttributes.hooks.inPlaceEditor.before.onSubmit.beforeHook(Ajax.InPlaceCollectionEditor,'onSubmit');EditableAttributes.hooks.inPlaceEditor.before.onSubmit.beforeHook(Ajax.InPlaceEditor,'onSubmit');EditableAttributes.hooks.inPlaceEditor.before.initialize.beforeHook(Ajax.InPlaceCollectionEditor,'initialize');EditableAttributes.hooks.inPlaceEditor.before.initialize.beforeHook(Ajax.InPlaceEditor,'initialize');EditableAttributes.hooks.inPlaceEditor.before.enterHover.beforeHook(Ajax.InPlaceCollectionEditor,'enterHover');EditableAttributes.hooks.inPlaceEditor.before.enterHover.beforeHook(Ajax.InPlaceEditor,'enterHover');EditableAttributes.hooks.inPlaceEditor.before.leaveHover.beforeHook(Ajax.InPlaceEditor,'leaveHover');EditableAttributes.hooks.inPlaceEditor.before.leaveHover.beforeHook(Ajax.InPlaceCollectionEditor,'leaveHover');afterEnterHook=function(transport,result){if(this.options.afterEnterHook){this.options.afterEnterHook.call(this);}
return(result);}
afterEnterHook.afterHook(Ajax.InPlaceEditor,'enterEditMode');beforeSubmittingHtmlHook=function(){if(this.options.beforeSubmitHook){this.options.beforeSubmitHook.call(this);}
return true}
beforeSubmittingHtmlHook.beforeHook(Ajax.InPlaceEditor,'onSubmit');(function(){if(this.options.confirmCancel){return(confirm('WARNING! Are you sure you want to cancel this edit? This cannot be undone!'));}else{return(true);}}).beforeHook(Ajax.InPlaceEditor,'onclickCancel');Field.scrollFreeActivate=function(field){setTimeout(function(){if(field&&!field.style.display=='none'&&!field.style.visibility=='hidden')Field.activate(field);},1);}
dontStripTags=function(transport,result){this.editField.value=transport.responseText;return result;}
dontStripTags.afterHook(Ajax.InPlaceEditor,'onLoadedExternalText');EditableAttributes.WidgetMethods={createEventListeners:function(){this.eventListeners={};for(var i=0;i<arguments.length;i++){var methodName=arguments[i];this.eventListeners[methodName]=this[methodName].bindAsEventListener(this);}},createBoundMethods:function(){this.boundMethods={};for(var i=0;i<arguments.length;i++){var methodName=arguments[i];this.boundMethods[methodName]=this[methodName].bind(this);}}}
EditableLink={set:function(url,id,attribute,passBack){passBack=passBack||{}
var href=prompt('Please enter a URL to link to:');if(href===null)
return(false);if((href.length>0)&&!(/^https?:\/\//.test(href))){href="http://"+href;}
postBody='id='+escape(id)+'&attribute='+escape(attribute)+'&value='+escape(href);for(var key in passBack){if(typeof(key)!='string')
continue;var value=passBack[key];if(typeof(value)=='string'){postBody+='&'+escape(key)+'='+escape(value);}}
new Ajax.Request(url,{evalScripts:true,method:'post',postBody:postBody});return(false);}};EditableCollection={postSortOrder:function(element,url,key){var sequence=Sortable.sequence(element,{format:/^.*_(\d+)$/});var postData='type=collection&key='+encodeURIComponent(key)+'&value='+encodeURIComponent(sequence.join('-'));new Ajax.Request(url,{asynchronous:true,evalScripts:true,onFailure:function(transport){if(Rails.development){alert("(JS) EditableCollection.postSortOrder failed:\nURL: "+url
+"\npostBody: "+decodeURIComponent(postData)+"\nResponse:\n"+
transport.responseText.stripTags());}else{alert('Currently unavailable');};},method:'post',postBody:postData})},addToCollection:function(collection,member){Sortable.addToCollection(collection,member);}};Sortable.addToCollection=function(collection,member){options=Sortable.sortables[$(collection).id];member=$(member);var options_for_draggable={revert:true,scroll:options.scroll,scrollSpeed:options.scrollSpeed,scrollSensitivity:options.scrollSensitivity,ghosting:options.ghosting,constraint:options.constraint,handle:options.handle};if(options.starteffect){options_for_draggable.starteffect=options.starteffect;}
if(options.reverteffect){options_for_draggable.reverteffect=options.reverteffect;}else{if(options.ghosting)options_for_draggable.reverteffect=function(element){element.style.top=0;element.style.left=0;};};if(options.endeffect){options_for_draggable.endeffect=options.endeffect;}
if(options.zindex){options_for_draggable.zindex=options.zindex;}
var options_for_droppable={overlap:options.overlap,containment:options.containment,tree:options.tree,hoverclass:options.hoverclass,onHover:Sortable.onHover};var options_for_tree={onHover:Sortable.onEmptyHover,overlap:options.overlap,containment:options.containment,hoverclass:options.hoverclass};var handle=options.handle?Element.childrenWithClassName(e,options.handle)[0]:member;options.draggables.push(new Draggable(member,Object.extend(options_for_draggable,{handle:handle})));Droppables.add(member,options_for_droppable);if(options.tree){member.treeNode=collection;}
options.droppables.push(member);if(options.tree){(Sortable.findTreeElements(member,options)||[]).each(function(e){Droppables.add(e,options_for_tree);e.treeNode=collection;options.droppables.push(e);});};Sortable.sortables[collection.id]=options;};Slideshow=Class.create();Slideshow.prototype={initialize:function(options){if(!options)options={};this.slides=options.slides||[];if(options.titleElement){this.titleElement=$(options.titleElement);}else{this.titleElement=false;}
this.current=0;if(options.timeout){this.timeout=options.timeout+850;setTimeout((function(){this.play();}).bind(this),this.timeout);this.paused=false;}else{this.paused=true;this.timeout=false;}
this.baseName=options.name||'sshow';},lastSlide:function(){if(this.slides){return this.slides.length-1;}else{return 0}},addSlide:function(slideEl){for(var i=0;i<this.slides.length;i++)if(this.slides[i]==slideEl)return;this.slides.push(slideEl);slideEl.style.zIndex=999-this.lastSlide();img=slideEl.getElementsByTagName('img')[0];img.style.display='inline';if(this.slides.length==1&&this.titleElement){this.titleElement.innerHTML=img.alt;}
controlsElement=$(this.baseName+'_scontrols');if(controlsElement){this.slides.length<2?Element.hide(controlsElement):Element.show(controlsElement);}},loadSlides:function(elementId){this.paused=true;this.slides=[];slideDivs=$(elementId).getElementsByTagName('div');for(var i=0;i<slideDivs.length;i++)
if(slideDivs[i].className.indexOf('controls')<0)
this.addSlide(slideDivs[i]);},go:function(advance){if(this.slides.length<2)
return false;nextSlide=this.current+advance;if(advance>0&&nextSlide>this.lastSlide()){nextSlide=0;}else if(advance<0&&nextSlide<0){nextSlide=this.lastSlide();}
this.showSlide(nextSlide);},playForward:function(){this.go(1);setTimeout((function(){if(!this.paused)this.playForward();}).bind(this),this.timeout);},playReverse:function(){this.go(-1);setTimeout((function(){if(!this.paused)this.playReverse();}).bind(this),this.timeout);},play:function(){this.playForward();},pause:function(){this.paused=true;},unPause:function(){this.paused=false;},togglePlayPause:function(){if(this.paused){this.unPause();this.play();}else{this.pause();}},next:function(){this.pause();this.go(1);},prev:function(){this.pause();this.go(-1);},showSlide:function(index){if(this.slides.length>1){for(var i=0;i<this.slides.length;i++){if(this.current==i){zDex=3;}else if(index==i){zDex=2;}else{zDex=1;}
this.slides[i].style.zIndex=zDex;}
Effect.Fade(this.slides[this.current],{afterFinish:function(effect){effect.element.style.zIndex=0;Element.show(effect.element);Element.setOpacity(effect.element,1);}});}
this.current=index;if(this.titleElement){this.titleElement.innerHTML=this.slides[this.current].getElementsByTagName('img')[0].alt;}},showLast:function(){this.pause();this.showSlide(this.lastSlide());}}
CssGraph=Class.create();CssGraph.prototype={initialize:function(elementId,initOptions){this.element=$(elementId);this.width=initOptions.width||500;this.height=initOptions.height||300;this.type=initOptions.type||'bar';this.labelX=initOptions.labelX||'';this.labelY=initOptions.labelY||'';this.data=initOptions.data||[];},render:function(){this.render_bar();},render_bar:function(){xLabelHeight=18;margin=1;border=0;padding=0;barHeight=this.height-xLabelHeight;barWidth=this.barWidth()-margin-(padding*2);innerBarWidth=barWidth;barChartHtml='';for(var i=0;i<this.data.length;i++){xVal=this.data[i][0];yVal=this.data[i][1];yPercent=yVal/this.maxDataFor(1)*100;innerBarHeight=barHeight/100*yPercent-8;xVal=xVal.replace(' ','<br />');barChartHtml='<div class="bar" style="float:left; margin-right:'+margin+'px; height:'+this.height+'px; width:'+this.barWidth+'px;">  <div class="barframe" style="position:relative; border:'+border+'px solid black; padding:'+padding+'px; width:'+barWidth+'; height:'+barHeight+'px;">     <div class="bardata" style="position:absolute; bottom:'+padding+'px; height:'+innerBarHeight+'px; background:url(/gradient/magick_draw.png?size=50x80&color1=87b71f&color2=eeeeee); width:'+innerBarWidth+'px;">      <span class="barY" style="position:relative; top:0; left:0; font-size:10px; font-weight:bold; color:#fff;">'+yVal+'</span>     </div>    </div>    <div class="barX" style="text-align:center; width:'+this.barWidth+'px; height:'+xLabelHeight+'">'+xVal+'</div>   </div>'+barChartHtml;}
this.element.innerHTML=barChartHtml;},barWidth:function(){return this.width/this.data.length;},maxDataFor:function(index){var dataVal=this.data[0][index];for(var i=1;i<this.data.length;i++){if(dataVal<this.data[i][index])
dataVal=this.data[i][index];}
return dataVal;},update:function(new_data){this.data=new_data;this.render();}};XhrBox=Class.create();XhrBox.prototype={initialize:function(options){if(options)this.setOptions(options);},setOptions:function(options){this.width=options.width||this.width;this.height=options.width||this.height;this.okButton=options.okButton||this.okButton;this.cancelButton=options.cancelButton||this.cancelButton;this.onOk=options.onOk||function(){};this.onCancel=options.onCancel||function(){};this.duration=options.duration||0.4;this.url=options.url||false},open:function(options){if(options)this.setOptions(options);this.showOverlay().showChrome();if(this.url)this.load(this.url);return this;},close:function(){this.hideChrome().hideOverlay();return this;},showOverlay:function(){this.dimElement=this.findOrCreateElement('DimElement');this.dimElement.style.display='block';return this;},hideOverlay:function(){if(this.dimElement)Element.hide(this.dimElement);return this;},load:function(uri){this.contentElement.innerHTML='';this.hideOk();this.showCancel();Element.addClassName(this.chromeElement,'loading')
new Ajax.Updater(this.contentElement,uri,{asynchronous:true,evalScripts:true,onComplete:this.onLoaded.bind(this)});return this;},onLoaded:function(){Element.removeClassName(this.chromeElement,'loading');if(this.okButton)this.showOk();if(this.cancelButton==false)this.hideCancel();},showChrome:function(){this.chromeWrapperElement=this.findOrCreateElement('ChromeWrapperElement');Element.show(this.chromeWrapperElement);this.chromeElement=this.findOrCreateElement('ChromeElement',this.chromeWrapperElement);Element.show(this.chromeElement);this.resize();this.contentElement=this.findOrCreateElement('ContentElement',this.chromeElement);this.contentElement.innerHTML=' ';Element.show(this.contentElement);this.controlsElement=this.findOrCreateElement('ControlsElement',this.chromeElement);Element.show(this.controlsElement);this.statusElement=this.findOrCreateElement('StatusElement',this.controlsElement);Element.show(this.statusElement);this.showCancel();return this;},showCancel:function(){if(!this.cancelElement){this.cancelElement=this.findOrCreateElement('CancelElement',this.controlsElement);Element.show(this.cancelElement);this.cancelAnchor=this.findOrCreateElement('CancelAnchor',this.cancelElement,'a');this.cancelAnchor.href='#CANCEL';this.cancelAnchor.innerHTML='<span>Cancel</span>';this.cancelAnchor.onclick=this.clickCancel.bind(this);}
Element.show(this.cancelAnchor);return this;},hideCancel:function(){if(this.cancelElement)Element.hide(this.cancelElement);return this;},showOk:function(){if(!this.okElement){this.okElement=this.findOrCreateElement('OkElement',this.controlsElement);Element.show(this.okElement);this.okAnchor=this.findOrCreateElement('OkAnchor',this.okElement,'a');this.okAnchor.href='#OK';this.okAnchor.innerHTML='Ok';this.okAnchor.onclick=this.clickOk.bind(this);}
Element.show(this.okAnchor);return this;},hideOk:function(){if(this.okElement)Element.hide(this.okElement);return this;},resize:function(options){if(!this.chromeElement.style.width){this.chromeElement.style.width='90px';this.chromeElement.style.height='90px';}
if(!options)options={};imgWidth=options.width||this.width
imgHeight=options.height||this.height
this.refreshPageSize();if(imgWidth>this.pageWidth)imgWidth=this.pageWidth-20;if(imgHeight>this.windowHeight)imgHeight=this.windowHeight-50;new Effect.Scale(this.chromeElement,((imgHeight/this.height)*100),{duration:this.duration,scaleContent:false,scaleX:false,scaleMode:{originalHeight:imgHeight}});new Effect.Scale(this.chromeElement,((imgWidth/this.width)*100),{delay:this.duration,duration:this.duration,scaleContent:false,scaleY:false,scaleMode:{originalWidth:imgWidth}});this.chromeElement.style.marginTop=''+((this.pageHeight/2)-(imgHeight/2))+'px';this.width=imgWidth;this.height=imgHeight;return this;},hideChrome:function(){Element.hide(this.chromeWrapperElement);return this;},clickOk:function(){this.onOk();this.close();return this;},clickCancel:function(){this.onCancel();this.close();return this;},findOrCreateElement:function(divId,parentElement,elementTag){divId='XhrBox'+divId;if(!elementTag)elementTag='div';elly=document.getElementById(divId);if(!elly){newChromeElement=document.createElement(elementTag);newChromeElement.setAttribute('id',divId);newChromeElement.style.display='none';if(!parentElement)parentElement=document.getElementsByTagName('body')[0];parentElement.appendChild(newChromeElement);elly=document.getElementById(divId);}
return elly},refreshPageSize:function(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}
var windowWidth,windowHeight;if(self.innerHeight){this.windowWidth=self.innerWidth;this.windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){this.windowWidth=document.documentElement.clientWidth;this.windowHeight=document.documentElement.clientHeight;}else if(document.body){this.windowWidth=document.body.clientWidth;this.windowHeight=document.body.clientHeight;}
if(yScroll<windowHeight){this.pageHeight=windowHeight;}else{this.pageHeight=yScroll;}
if(xScroll<windowWidth){this.pageWidth=windowWidth;}else{this.pageWidth=xScroll;}}};xhrBox=new XhrBox;var EditableTrees={};var EditableTree=Class.create();EditableTree.prototype={initialize:function(elementOrId,options){this.outerList=$(elementOrId);this.boundClickNew=this.__onClickNew__.bindAsEventListener(this);this.boundMouseDown=this.__onMouseDown__.bindAsEventListener(this);this.boundMouseUp=this.__onMouseUp__.bindAsEventListener(this);this.boundMouseMove=this.__onMouseMove__.bindAsEventListener(this);this.boundOnClickCapture=this.__onClickCapture__.bindAsEventListener(this);this.boundOnClickDirect=this.__onClickDirect__.bindAsEventListener(this);this.options=Object.extend({domItemClass:'editable_tree_item',domListClass:'editable_tree_list',selfActuating:true,add:true,minimumMoveDistance:5,notifyPreProcessor:function(s){return(s);}},options)
this.mouseDown=false;this.active=false;this.elementsWithOnClick={};this.selfActuate();EditableTrees[this.outerList.id]=this;if(this.options.onUpdated&&this.options.onUpdated.length>0){this.onUpdatedCallback=function(){eval(this.options.onUpdated)};}},selfActuate:function(){if(this.options.selfActuating)
this.actuateInterface();},actuateInterface:function(){this.actuated=[];var elements=this.outerList.getElementsByTagName('li');for(var i=0;i<elements.length;i++){var element=elements[i];if(!Element.hasClassName(element,this.options.domItemClass))
continue;this.actuateElement(element);}
if(this.options.add){Event.observe($(this.outerList.id+'_new'),"click",this.boundClickNew);}
var anchors=this.outerList.getElementsByTagName('a');for(var i=0;i<anchors.length;i++){if(anchors[i].onclick){this.elementsWithOnClick[anchors[i]]=anchors[i].onclick;}
anchors[i].onclick=this.boundOnClickDirect;}},actuateElement:function(element){Droppables.add(element,{overlap:'horizontal',onHover:this.__onHover__.bind(this),onDrop:this.__beforeOnDrop__.bind(this)});var dragObject=new Draggable(element,{ghosting:true,revert:false,starteffect:function(element){},endeffect:function(element){this.lastActiveState=this.active;if(!this.active){this.returnToOrigin(element);return;}
if(!this.dropped){this.changeHoverState(null,element,null);this.__onRemove__(element);}else{var dragged=this.dragged;var dropped=this.dropped;delete this.dragged;delete this.dropped;this.__onDrop__(dragged,dropped);}
this.active=false;delete this.dropped;}.bind(this)});Event.observe(element,"mousedown",this.boundMouseDown);Event.observe(document,"mousemove",this.boundMouseMove);Event.observe(element,"mouseup",this.boundMouseUp);Event.observe(element,"click",this.boundOnClickCapture,true);this.actuated.push([element,dragObject]);},deactuateInterface:function(){for(var i=0;i<this.actuated.length;i++){this.actuated[i][1].destroy();var element=this.actuated[i][0];Droppables.remove(element);Event.stopObserving(element,"mousedown",this.boundMouseDown);Event.stopObserving(element,"mouseup",this.boundMouseUp);Event.stopObserving(element,"click",this.boundOnClick);}
Event.stopObserving($(this.outerList.id+'_new'),"click",this.boundClickNew);this.elementsWithOnClick={};},__onHover__:function(draggable,droppable,overlap){if(!this.active)
return;var type=(overlap>0.5)?-1:1;var li=droppable;if(((droppable!=this.lastHover)||(this.lastHoverType!=type))&&(li.id!=draggable.id)){if(type<0){this.__onHoverLeftStart__(draggable,droppable);}else{this.__onHoverRightStart__(draggable,droppable);}}},__beforeOnDrop__:function(draggable,droppable){if(!this.active)
return;this.dropped=droppable;this.dragged=draggable;},__onDrop__:function(draggable,droppable){if(!this.active)
return;if(draggable.id==droppable.id){this.changeHoverState(null,draggable,droppable);return;}
this.onDrop(draggable,droppable);this.changeHoverState(null,draggable,droppable);},__onHoverLeftStart__:function(draggable,droppable){this.changeHoverState(-1,draggable,droppable);this.onHoverLeftStart(draggable,droppable);},__onHoverLeftStop__:function(draggable,droppable){this.onHoverLeftStop(draggable,droppable);},__onHoverRightStart__:function(draggable,droppable){this.changeHoverState(1,draggable,droppable);this.onHoverRightStart(draggable,droppable);},__onHoverRightStop__:function(draggable,droppable){this.onHoverRightStop(draggable,droppable);},changeHoverState:function(type,draggable,droppable){var savedLast=this.lastHover;var savedLastType=this.lastHoverType;if(type){this.lastHover=droppable;this.lastHoverType=type;}else{delete this.lastHover;delete this.lastHoverType;}
if(savedLast){if(savedLastType<1){this.__onHoverLeftStop__(draggable,savedLast);}else{this.__onHoverRightStop__(draggable,savedLast);}}},__onDragStop__:function(dragged,dropped){this.onDragStop(dragged,dropped);},__onRemove__:function(dragged){setTimeout(function(){this.onRemove(dragged);}.bind(this),1);},__onMouseDown__:function(event){this.mouseDown=true;this.lastActiveState=this.active=false;this.moveCount=0;return(false);},__onMouseUp__:function(event){delete this.moveCount;this.mouseDown=false;if(!this.active)
return;if(this.topBubble(Event.element(event))){this.__onDragStop__(Event.element(event));}
return(false);},__onMouseMove__:function(event){if(!this.mouseDown||this.active)
return;if(++this.moveCount>this.options.minimumMoveDistance){this.active=true;this.onDragStart(Event.element(event));}},__onClickCapture__:function(event){if(this.active)
Event.stop(event);},__onClickDirect__:function(event){var savedFunction=this.elementsWithOnClick[Event.element(event)];if(!this.lastActiveState&&savedFunction)
savedFunction(event);return(!this.lastActiveState);},__onClickNew__:function(event){var element=Event.element(event);this.deactuateInterface();new Ajax.Request(this.options.notify,{asynchronous:true,method:'post',postBody:this.options.notifyPreProcessor('list='+escape(this.outerList.id)+'&new=1'),onSuccess:function(t){this.__onNotifySuccess__(t,function(){this.onAddSuccess(element,t);});}.bind(this),onFailure:function(t){this.onAddFailure(element,t);}.bind(this)});return(false);},__onNotifySuccess__:function(response,unlessRJSFunction){if((response.getResponseHeader('Content-type')||'').match(/^text\/javascript/i)){return;}
unlessRJSFunction.bind(this)();},returnToOrigin:function(element){element.style.opacity='';element.style.zIndex='';var top=parseInt(element.style.top.slice(0,-2))*-1;var left=parseInt(element.style.left.slice(0,-2))*-1;var dur=Math.sqrt(Math.abs(((top<0)?top*-1:top)^2)+Math.abs(((left<0)?left*-1:left)^2))*0.02;new Effect.Move(element,{x:left,y:top,duration:dur});return(dur);},topBubble:function(element){if(!this.mouseUpTriggerCount){this.mouseUpTriggerCount=1;this.mouseUpTriggerTotal=0;var pointer=element;while(true){if((pointer.nodeName.toLowerCase()=='li')&&Element.hasClassName(pointer,this.options.domItemClass)){this.mouseUpTriggerTotal++;if(pointer.parentNode.id==this.outerList.id)
break;}
pointer=pointer.parentNode;}}else{this.mouseUpTriggerCount++;}
if(this.mouseUpTriggerCount>=this.mouseUpTriggerTotal){delete this.mouseUpTriggerCount;return(true);}else{return(false);}},findOrCreateUL:function(li){var ul=li.firstChild;var hasList=false;do{hasList=((ul.nodeName.toLowerCase()=='ul')&&Element.hasClassName(ul,this.options.domListClass));if(hasList)
break;}while(ul=ul.nextSibling);if(!hasList){ul=document.createElement('ul');ul.setAttribute('class',this.options.domListClass);li.appendChild(ul);this.newListForHover=ul;}else{this.oldListForHover=ul;}
return(this.oldListForHover||this.newListForHover);},onHoverLeftStart:function(dragged,dropped){if(dropped.id==dragged.id)
return;var li=dropped;Element.addClassName(li,'ea_tree_hover_left');},onHoverLeftStop:function(dragged,dropped){var li=dropped;Element.removeClassName(li,'ea_tree_hover_left');},onHoverRightStart:function(dragged,dropped){var ul=this.findOrCreateUL(dropped);var couldBe=document.createElement('li');ul.appendChild(couldBe);Element.addClassName(couldBe,'ea_tree_hover_right');this.couldBe=couldBe;},onHoverRightStop:function(dragged,dropped){if(this.newListForHover){this.newListForHover.removeChild(this.couldBe);this.newListForHover.parentNode.removeChild(this.newListForHover);delete this.newListForHover;}
if(this.oldListForHover){this.oldListForHover.removeChild(this.couldBe);delete this.oldListForHover;}},onDragStart:function(dragged){delete this.oldListForHover;delete this.newListForHover;},onDragStop:function(dragged){if(this.newListForHover){this.newListForHover.removeChild(this.couldBe);this.newListForHover.parentNode.removeChild(this.newListForHover);delete this.newListForHover;}
if(this.oldListForHover){this.oldListForHover.removeChild(this.couldBe);delete this.oldListForHover;}},onDrop:function(draggable,droppable){this.savedParent=draggable.parentNode;this.savedSibling=draggable.nextSibling;draggable.parentNode.removeChild(draggable);var postBody='list='+escape(this.outerList.id)+'&dragged='+escape(draggable.id)+'&dropped='+
escape(droppable.id)+'&side='+this.convertSideFormat(this.lastHoverType);var side=this.lastHoverType;this.deactuateInterface();new Ajax.Request(this.options.notify,{asynchronous:true,method:'post',postBody:this.options.notifyPreProcessor(postBody),onSuccess:function(t){this.draggable=draggable;this.droppable=droppable;this.__onNotifySuccess__(t,function(){this.onMoveSuccess(draggable,droppable,side,t);});}.bind(this),onFailure:function(t){this.onMoveFailure(draggable,droppable,side,t);}.bind(this)});},onRemove:function(dragged){dragged.style.opacity='';dragged.style.zIndex='';if(confirm('Are you sure you wish to delete this?'))
{this.deactuateInterface();new Ajax.Request(this.options.notify,{asynchronous:true,method:'post',postBody:this.options.notifyPreProcessor('list='+escape(this.outerList.id)+'&removed='+escape(dragged.id)),onSuccess:function(t){this.__onNotifySuccess__(t,function(){this.onRemoveSuccess(dragged,t);});}.bind(this),onFailure:function(t){this.onRemoveFailure(dragged,t);}.bind(this)});}else{this.returnToOrigin(dragged);}},onRemoveSuccess:function(element,response){if(response.responseText!='OK'){this.onRemoveFailure(element,response);return;}
this.resetDraggableStyle(element);element.parentNode.removeChild(element);element.style.opacity='';element.style.zIndex='';Effect.Puff(element);if(this.onUpdatedCallback)this.onUpdatedCallback();this.selfActuate();},onRemoveFailure:function(element,response){element.style.display='';setTimeout(function(){Effect.Pulsate(element);},Math.round(this.returnToOrigin(element)*1000));this.selfActuate();},onAddSuccess:function(element,response){var li=document.createElement('li');var domID=response.getResponseHeader('DOM-ID');if(!domID){alert('Incorrect HTTP headers. Sorry, cannot continue.');return;};li.setAttribute('id',domID);li.setAttribute('class',this.options.domItemClass+' level_1');this.outerList.appendChild(li);li.innerHTML=response.responseText;li.style.display='none';Effect.Appear(li);if(this.onUpdatedCallback)this.onUpdatedCallback();this.selfActuate();},onAddFailure:function(element,response){alert('There is a problem communicating with the server, sorry! Our technical team has been notified.');this.selfActuate();},onMoveSuccess:function(dragged,dropped,side,response){if(response.responseText!='OK'){this.onMoveFailure(dragged,dropped,side,response);return;}
this.positionDraggedElementAfterMove(side);new Effect.Appear(dragged);this.selfActuate();},positionDraggedElementAfterMove:function(side){var dragged=this.draggable;var dropped=this.droppable;this.resetDraggableStyle(dragged);if(side<1){var pointer=dropped;while(true){pointer=pointer.nextSibling;if(!pointer)
break;if((pointer.nodeName.toLowerCase()=='li')&&(Element.hasClassName(pointer,this.options.domItemClass))){break;}}
if(pointer)
dropped.parentNode.insertBefore(dragged,pointer);else
dropped.parentNode.appendChild(dragged);}else{var ul=this.findOrCreateUL(dropped);delete this.oldListForHover;delete this.newListForHover;ul.appendChild(dragged);}
var level=1;var pointer=dragged;while(pointer.id!=this.outerList.id){pointer=pointer.parentNode;if((pointer.nodeName.toLowerCase()=='li')&&(Element.hasClassName(pointer,this.options.domItemClass)))
level++;}
dragged.className=dragged.className.replace(/(^|\s)(level_)\d+/,'$1$2'+level);dragged.style.display='none';if(this.onUpdatedCallback)this.onUpdatedCallback();},onMoveFailure:function(dragged,dropped,side,response){this.resetDraggableStyle(dragged);this.savedParent.insertBefore(dragged,this.savedSibling);Effect.Pulsate(dragged);this.selfActuate();},resetDraggableStyle:function(element){element.style.top='';element.style.left='';element.style.opacity='';element.style.zIndex='';},convertSideFormat:function(side){if(typeof(side)=='number')
return((side<1)?'left':'right');else
return((side=='left')?-1:1);}};var SingletonTimeout=Class.create();SingletonTimeout.prototype={initialize:function(callback,delay){this.callback=callback;this.delay=delay;this.passThrough=$A(arguments).slice(2);if(arguments.length<3)
delete this.passThrough;this.boundExecuteCallback=this.executeCallback.bind(this);},start:function(){this.stop();this.timer=setTimeout(this.boundExecuteCallback,this.delay);},stop:function(){if(this.timer){clearTimeout(this.timer);this.timer=false;}},executeCallback:function(){this.timer=false;if(this.passThrough){this.callback.apply(this,this.passThrough);}else{this.callback();}}}
var FormElementChangeObserver=Class.create();FormElementChangeObserver.prototype={initialize:function(element,options){this.options=options;this.options.delay=this.options.delay||750;this.element=$(element);this.createBoundMethods('onKeyPressTimeout')
this.actuate();this.onKeyPressSingletonTimeout=new SingletonTimeout(this.boundMethods.onKeyPressTimeout,this.options.delay);},createEventGroups:function(){this.createEventListeners('onKeyPress');this.eventGroups={};this.eventGroups.watching=new Event.Group;this.eventGroups.watching.add(this.element,'keypress',this.eventListeners.onKeyPress);},actuate:function(){this.createEventGroups();this.eventGroups.watching.start();},onKeyPress:function(event){this.onKeyPressSingletonTimeout.start();},onKeyPressTimeout:function(){this.options.callback(this.element);}}
Object.extend(FormElementChangeObserver.prototype,EditableAttributes.WidgetMethods);StarVoter=Class.create();StarVoter.prototype={initialize:function(options){this.options=Object.extend({vote:0,resumeVotedModeDelay:2000},options);this.container=$(this.options.containerId);var cssSelector='#'+this.options.containerId+' .star';this.stars=$$(cssSelector);this.createEventGroups();this.createBoundMethods('resumeVotedMode');this.resumeVoteSingletonTimeout=new SingletonTimeout(this.boundMethods.resumeVotedMode,this.options.resumeVotedModeDelay);this.actuateInterface();},createEventGroups:function(){this.eventGroups={};this.createEventListeners('onStartVoteHoverStar','onStopVoteHoverStar','onClickVoteStar','onStartVotedHoverStar','onStopVotedHoverStar','onClickVotedStar');this.eventGroups.voting=new Event.Group;this.eventGroups.voted=new Event.Group;for(var i=0;i<this.stars.length;i++){var star=this.stars[i];this.eventGroups.voting.add(star,'mouseover',this.eventListeners.onStartVoteHoverStar);this.eventGroups.voting.add(star,'mouseout',this.eventListeners.onStopVoteHoverStar);this.eventGroups.voting.add(star,'click',this.eventListeners.onClickVoteStar);this.eventGroups.voted.add(star,'mouseover',this.eventListeners.onStartVotedHoverStar);this.eventGroups.voted.add(star,'mouseout',this.eventListeners.onStopVotedHoverStar);this.eventGroups.voted.add(star,'click',this.eventListeners.onClickVotedStar);}},actuateInterface:function(){this.showCommonVote();if(this.options.voter){if(this.options.votersVote){this.actuateVoted();}else{this.actuateVoting();}}},actuateVoting:function(){this.eventGroups.voting.start();},deactuateVoting:function(){this.eventGroups.voting.stop();},actuateVoted:function(){this.eventGroups.voted.start();},deactuateVoted:function(){this.hideOwnVote();this.eventGroups.voted.stop();},showCommonVote:function(){if(this.commonVote)
return;this.commonVote=true;var pivot=(this.options.vote<1)?null:this.stars[this.options.vote-1];this.changeStarClasses(pivot,'common_vote','unvoted_common','add');},hideCommonVote:function(){if(!this.commonVote)
return;this.commonVote=false;var pivot=this.stars[this.options.vote-1];this.changeStarClasses(pivot,'common_vote','unvoted_common','remove');},showOwnVote:function(){if(this.ownVote)
return;this.ownVote=true;var pivot=this.stars[this.options.votersVote-1];this.changeStarClasses(pivot,'own_vote','unvoted_own','add');},hideOwnVote:function(){if(!this.ownVote)
return;this.ownVote=false;var pivot=this.stars[this.options.votersVote-1];this.changeStarClasses(pivot,'own_vote','unvoted_own','remove');},showPossibleVote:function(pivot){this.changeStarClasses(pivot,'possible_vote','unvoted_possible','add');},hidePossibleVote:function(pivot){this.changeStarClasses(pivot,'possible_vote','unvoted_possible','remove');},onStartVoteHoverStar:function(event){var pivot=Event.element(event);this.resumeVoteSingletonTimeout.stop();this.hideCommonVote();this.showPossibleVote(pivot);},onStopVoteHoverStar:function(event){var pivot=Event.element(event);this.hidePossibleVote(pivot);this.showCommonVote();if(this.options.votersVote){this.resumeVoteSingletonTimeout.start();}},onClickVoteStar:function(event){var star=Event.element(event);var starNumber=star.id.match('_([^_]+)$')[1];var parameters='vote='+escape(starNumber);parameters+='&voter='+escape(this.options.voter);parameters+='&subject='+escape(this.options.subject);if(this.options.key){parameters+='&key='+escape(this.options.key);}
new Ajax.Request(this.options.url,{evalScripts:true,method:'post',postBody:parameters});},onStartVotedHoverStar:function(event){this.hideCommonVote();this.showOwnVote();},onStopVotedHoverStar:function(event){this.hideOwnVote();this.showCommonVote();},onClickVotedStar:function(event){this.deactuateVoted();this.actuateVoting();this.showPossibleVote(Event.element(event));},resumeVotedMode:function(){this.resumeVoteTimer=false;this.deactuateVoting();this.actuateVoted();},forAllStarsUntil:function(star,block){if(!star)
return;for(var i=0;i<this.stars.length;i++){var iStar=this.stars[i];block.call(this,iStar);if(iStar==star){break;}}},forAllStarsAfter:function(star,block){var matched=!star;for(var i=0;i<this.stars.length;i++){var iStar=this.stars[i];if(iStar==star){matched=true;continue;}
if(matched){block.call(this,iStar);}}},changeStarClasses:function(pivot,firstClass,secondClass,addOrRemove){method=Element[addOrRemove+'ClassName'];this.forAllStarsUntil(pivot,function(star){method.apply(Element,[star,firstClass]);});this.forAllStarsAfter(pivot,function(star){method.apply(Element,[star,secondClass]);});}}
Object.extend(StarVoter.prototype,EditableAttributes.WidgetMethods);function reloadCSS(){var links=document.getElementsByTagName('link');for(var i=0;i<links.length;i++){var link=links[i];if(links[i].type=='text/css'){var href=link.href;href=href.replace(/\?\d+$/,'');href+='?'+Math.floor(Math.random()*Math.pow(10,8));var clone=link.cloneNode(true);clone.href=href;var nextSibling=link.nextSibling;var parentNode=link.parentNode;parentNode.removeChild(link);parentNode.insertBefore(clone,nextSibling);}}
setTimeout(function(){for(var i=0;i<document.styleSheets.length;i++){var styleSheet=document.styleSheets[i];for(var j=0;j<styleSheet.cssRules.length;j++){var rule=styleSheet.cssRules[j];if(rule.constructor==CSSImportRule){var cssText=rule.cssText.replace(/^(@import url\(['"]*[^?\)]+)(\?[^\)]*)?(\).*)/,'$1'+'?'+Math.floor(Math.random()*Math.pow(10,8))+'$3');styleSheet.deleteRule(j);styleSheet.insertRule(cssText,j);}}}},500);void(0);}
(function(){return(!(this.options.evalScripts===false));}).beforeHook(Ajax.Request,'evalResponse');(function(event){if(!this.options.mustGainFocus||(this.suggestionsHaveFocus&&event.keyCode!=Event.KEY_TAB&&event.keyCode!=Event.KEY_RETURN)){return(true);}else{switch(event.keyCode){case Event.KEY_TAB:Event.stop(event);this.suggestionsHaveFocus=!this.suggestionsHaveFocus;this.element.focus();return(false);case Event.KEY_UP:case Event.KEY_DOWN:this.suggestionsHaveFocus=true;return(true);case Event.KEY_RETURN:if(this.suggestionsHaveFocus){var ptr=this.getCurrentEntry();this.selectEntry();ptr=ptr.childNodes[0];var stack=[];var offset=0;var acted=false;while(true){if(ptr.childNodes[offset]){stack.push(ptr,offset);ptr=ptr.childNodes[offset];offset=0;continue;}else{if(ptr.tagName){if(acted=(ptr.tagName.toLowerCase().indexOf("input")>-1&&ptr.type=="button"))
ptr.click();else if(acted=(ptr.tagName.toLowerCase().indexOf("a")>-1))
document.location=ptr.href;else if(acted=(ptr.onclick))
ptr.onclick();}
ptr=ptr.parentNode.childNodes[offset++];if(!ptr){if(stack.length<1)
break;var pair=stack.pop();ptr=stack.shift();offset=stack.shift();continue;}}}
if(acted)
Event.stop(event);return(false);}
return(false);}
return(true);}}).beforeHook(Ajax.Autocompleter,'onKeyPress');