
if(typeof(Control)=='undefined')
Control={};var $proc=function(proc){return typeof(proc)=='function'?proc:function(){return proc};};var $value=function(value){return typeof(value)=='function'?value():value;};Object.Event={extend:function(object){object._objectEventSetup=function(event_name){this._observers=this._observers||{};this._observers[event_name]=this._observers[event_name]||[];};object.observe=function(event_name,observer){if(typeof(event_name)=='string'&&typeof(observer)!='undefined'){this._objectEventSetup(event_name);if(!this._observers[event_name].include(observer))
this._observers[event_name].push(observer);}else
for(var e in event_name)
this.observe(e,event_name[e]);};object.stopObserving=function(event_name,observer){this._objectEventSetup(event_name);if(event_name&&observer)
this._observers[event_name]=this._observers[event_name].without(observer);else if(event_name)
this._observers[event_name]=[];else
this._observers={};};object.observeOnce=function(event_name,outer_observer){var inner_observer=function(){outer_observer.apply(this,arguments);this.stopObserving(event_name,inner_observer);}.bind(this);this._objectEventSetup(event_name);this._observers[event_name].push(inner_observer);};object.notify=function(event_name){this._objectEventSetup(event_name);var collected_return_values=[];var args=$A(arguments).slice(1);try{for(var i=0;i<this._observers[event_name].length;++i)
collected_return_values.push(this._observers[event_name][i].apply(this._observers[event_name][i],args)||null);}catch(e){if(e==$break)
return false;else
throw e;}
return collected_return_values;};if(object.prototype){object.prototype._objectEventSetup=object._objectEventSetup;object.prototype.observe=object.observe;object.prototype.stopObserving=object.stopObserving;object.prototype.observeOnce=object.observeOnce;object.prototype.notify=function(event_name){if(object.notify){var args=$A(arguments).slice(1);args.unshift(this);args.unshift(event_name);object.notify.apply(object,args);}
this._objectEventSetup(event_name);var args=$A(arguments).slice(1);var collected_return_values=[];try{if(this.options&&this.options[event_name]&&typeof(this.options[event_name])=='function')
collected_return_values.push(this.options[event_name].apply(this,args)||null);for(var i=0;i<this._observers[event_name].length;++i)
collected_return_values.push(this._observers[event_name][i].apply(this._observers[event_name][i],args)||null);}catch(e){if(e==$break)
return false;else
throw e;}
return collected_return_values;};}}};Element.addMethods({observeOnce:function(element,event_name,outer_callback){var inner_callback=function(){outer_callback.apply(this,arguments);Element.stopObserving(element,event_name,inner_callback);};Element.observe(element,event_name,inner_callback);}});Object.extend(Event,(function(){var cache=Event.cache;function getEventID(element){if(element._prototypeEventID)return element._prototypeEventID[0];arguments.callee.id=arguments.callee.id||1;return element._prototypeEventID=[++arguments.callee.id];}
function getDOMEventName(eventName){if(eventName&&eventName.include(':'))return"dataavailable";if(!Prototype.Browser.IE){eventName={mouseenter:'mouseover',mouseleave:'mouseout'}[eventName]||eventName;}
return eventName;}
function getCacheForID(id){return cache[id]=cache[id]||{};}
function getWrappersForEventName(id,eventName){var c=getCacheForID(id);return c[eventName]=c[eventName]||[];}
function createWrapper(element,eventName,handler){var id=getEventID(element);var c=getWrappersForEventName(id,eventName);if(c.pluck("handler").include(handler))return false;var wrapper=function(event){if(!Event||!Event.extend||(event.eventName&&event.eventName!=eventName))
return false;Event.extend(event);handler.call(element,event);};if(!(Prototype.Browser.IE)&&['mouseenter','mouseleave'].include(eventName)){wrapper=wrapper.wrap(function(proceed,event){var rel=event.relatedTarget;var cur=event.currentTarget;if(rel&&rel.nodeType==Node.TEXT_NODE)
rel=rel.parentNode;if(rel&&rel!=cur&&!rel.descendantOf(cur))
return proceed(event);});}
wrapper.handler=handler;c.push(wrapper);return wrapper;}
function findWrapper(id,eventName,handler){var c=getWrappersForEventName(id,eventName);return c.find(function(wrapper){return wrapper.handler==handler});}
function destroyWrapper(id,eventName,handler){var c=getCacheForID(id);if(!c[eventName])return false;c[eventName]=c[eventName].without(findWrapper(id,eventName,handler));}
function destroyCache(){for(var id in cache)
for(var eventName in cache[id])
cache[id][eventName]=null;}
if(window.attachEvent){window.attachEvent("onunload",destroyCache);}
return{observe:function(element,eventName,handler){element=$(element);var name=getDOMEventName(eventName);var wrapper=createWrapper(element,eventName,handler);if(!wrapper)return element;if(element.addEventListener){element.addEventListener(name,wrapper,false);}else{element.attachEvent("on"+name,wrapper);}
return element;},stopObserving:function(element,eventName,handler){element=$(element);var id=getEventID(element),name=getDOMEventName(eventName);if(!handler&&eventName){getWrappersForEventName(id,eventName).each(function(wrapper){element.stopObserving(eventName,wrapper.handler);});return element;}else if(!eventName){Object.keys(getCacheForID(id)).each(function(eventName){element.stopObserving(eventName);});return element;}
var wrapper=findWrapper(id,eventName,handler);if(!wrapper)return element;if(element.removeEventListener){element.removeEventListener(name,wrapper,false);}else{element.detachEvent("on"+name,wrapper);}
destroyWrapper(id,eventName,handler);return element;},fire:function(element,eventName,memo){element=$(element);if(element==document&&document.createEvent&&!element.dispatchEvent)
element=document.documentElement;var event;if(document.createEvent){event=document.createEvent("HTMLEvents");event.initEvent("dataavailable",true,true);}else{event=document.createEventObject();event.eventType="ondataavailable";}
event.eventName=eventName;event.memo=memo||{};if(document.createEvent){element.dispatchEvent(event);}else{element.fireEvent(event.eventType,event);}
return Event.extend(event);}};})());Object.extend(Event,Event.Methods);Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize()});(function(){function wheel(event){var delta;if(event.wheelDelta)
delta=event.wheelDelta/120;else if(event.detail)
delta=-event.detail/3;if(!delta)
return;var custom_event=Event.element(event).fire('mouse:wheel',{delta:delta});if(custom_event.stopped){event.stop();return false;}}
document.observe('mousewheel',wheel);document.observe('DOMMouseScroll',wheel);})();var IframeShim=Class.create({initialize:function(){this.element=new Element('iframe',{style:'position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none',src:'javascript:void(0);',frameborder:0});$(document.body).insert(this.element);},hide:function(){this.element.hide();return this;},show:function(){this.element.show();return this;},positionUnder:function(element){var element=$(element);var offset=element.cumulativeOffset();var dimensions=element.getDimensions();this.element.setStyle({left:offset[0]+'px',top:offset[1]+'px',width:dimensions.width+'px',height:dimensions.height+'px',zIndex:element.getStyle('zIndex')-1}).show();return this;},setBounds:function(bounds){for(prop in bounds)
bounds[prop]+='px';this.element.setStyle(bounds);return this;},destroy:function(){if(this.element)
this.element.remove();return this;}});if(typeof(Prototype)=="undefined")
throw"Control.ProgressBar requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.ProgressBar requires Object.Event to be loaded.";Control.ProgressBar=Class.create({initialize:function(container,options){this.progress=0;this.executer=false;this.active=false;this.poller=false;this.container=$(container);this.containerWidth=this.container.getDimensions().width-(parseInt(this.container.getStyle('border-right-width').replace(/px/,''))+parseInt(this.container.getStyle('border-left-width').replace(/px/,'')));this.progressContainer=$(document.createElement('div'));this.progressContainer.setStyle({width:this.containerWidth+'px',height:'100%',position:'absolute',top:'0px',right:'0px'});this.container.appendChild(this.progressContainer);this.options={afterChange:Prototype.emptyFunction,interval:0.25,step:1,classNames:{active:'progress_bar_active',inactive:'progress_bar_inactive'}};Object.extend(this.options,options||{});this.container.addClassName(this.options.classNames.inactive);this.active=false;},setProgress:function(value){this.progress=value;this.draw();if(this.progress>=100)
this.stop(false);this.notify('afterChange',this.progress,this.active);},poll:function(url,interval){this.active=true;this.poller=new PeriodicalExecuter(function(){new Ajax.Request(url,{onSuccess:function(request){this.setProgress(parseInt(request.responseText));if(!this.active)
this.poller.stop();}.bind(this)});}.bind(this),interval||3);},start:function(){this.active=true;this.container.removeClassName(this.options.classNames.inactive);this.container.addClassName(this.options.classNames.active);this.executer=new PeriodicalExecuter(this.step.bind(this,this.options.step),this.options.interval);},stop:function(reset){this.active=false;if(this.executer)
this.executer.stop();this.container.removeClassName(this.options.classNames.active);this.container.addClassName(this.options.classNames.inactive);if(typeof(reset)=='undefined'||reset==true)
this.reset();},step:function(amount){this.active=true;this.setProgress(Math.min(100,this.progress+amount));},reset:function(){this.active=false;this.setProgress(0);},draw:function(){this.progressContainer.setStyle({width:(this.containerWidth-Math.floor((parseInt(this.progress)/100)*this.containerWidth))+'px'});},notify:function(event_name){if(this.options[event_name])
return[this.options[event_name].apply(this.options[event_name],$A(arguments).slice(1))];}});Object.Event.extend(Control.ProgressBar);String.prototype.parseColor=function(){var color='#';if(this.slice(0,4)=='rgb('){var cols=this.slice(4,this.length-1).split(',');var i=0;do{color+=parseInt(cols[i]).toColorPart()}while(++i<3);}else{if(this.slice(0,1)=='#'){if(this.length==4)for(var i=1;i<4;i++)color+=(this.charAt(i)+this.charAt(i)).toLowerCase();if(this.length==7)color=this.toLowerCase();}}
return(color.length==7?color:(arguments[0]||this));};Element.collectTextNodes=function(element){return $A($(element).childNodes).collect(function(node){return(node.nodeType==3?node.nodeValue:(node.hasChildNodes()?Element.collectTextNodes(node):''));}).flatten().join('');};Element.collectTextNodesIgnoreClass=function(element,className){return $A($(element).childNodes).collect(function(node){return(node.nodeType==3?node.nodeValue:((node.hasChildNodes()&&!Element.hasClassName(node,className))?Element.collectTextNodesIgnoreClass(node,className):''));}).flatten().join('');};Element.setContentZoom=function(element,percent){element=$(element);element.setStyle({fontSize:(percent/100)+'em'});if(Prototype.Browser.WebKit)window.scrollBy(0,0);return element;};Element.getInlineOpacity=function(element){return $(element).style.opacity||'';};Element.forceRerendering=function(element){try{element=$(element);var n=document.createTextNode(' ');element.appendChild(n);element.removeChild(n);}catch(e){}};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(pos){return(-Math.cos(pos*Math.PI)/2)+0.5;},reverse:function(pos){return 1-pos;},flicker:function(pos){var pos=((-Math.cos(pos*Math.PI)/4)+0.75)+Math.random()/4;return pos>1?1:pos;},wobble:function(pos){return(-Math.cos(pos*Math.PI*(9*pos))/2)+0.5;},pulse:function(pos,pulses){pulses=pulses||5;return(((pos%(1/pulses))*pulses).round()==0?((pos*pulses*2)-(pos*pulses*2).floor()):1-((pos*pulses*2)-(pos*pulses*2).floor()));},spring:function(pos){return 1-(Math.cos(pos*4.5*Math.PI)*Math.exp(-pos*6));},none:function(pos){return 0;},full:function(pos){return 1;}},DefaultOptions:{duration:1.0,fps:100,sync:false,from:0.0,to:1.0,delay:0.0,queue:'parallel'},tagifyText:function(element){var tagifyStyle='position:relative';if(Prototype.Browser.IE)tagifyStyle+=';zoom:1';element=$(element);$A(element.childNodes).each(function(child){if(child.nodeType==3){child.nodeValue.toArray().each(function(character){element.insertBefore(new Element('span',{style:tagifyStyle}).update(character==' '?String.fromCharCode(160):character),child);});Element.remove(child);}});},multiple:function(element,effect){var elements;if(((typeof element=='object')||Object.isFunction(element))&&(element.length))
elements=element;else
elements=$(element).childNodes;var options=Object.extend({speed:0.1,delay:0.0},arguments[2]||{});var masterDelay=options.delay;$A(elements).each(function(element,index){new effect(element,Object.extend(options,{delay:index*options.speed+masterDelay}));});},PAIRS:{'slide':['SlideDown','SlideUp'],'blind':['BlindDown','BlindUp'],'appear':['Appear','Fade']},toggle:function(element,effect){element=$(element);effect=(effect||'appear').toLowerCase();var options=Object.extend({queue:{position:'end',scope:(element.id||'global'),limit:1}},arguments[2]||{});Effect[element.visible()?Effect.PAIRS[effect][1]:Effect.PAIRS[effect][0]](element,options);}};Effect.DefaultOptions.transition=Effect.Transitions.sinoidal;Effect.ScopedQueue=Class.create(Enumerable,{initialize:function(){this.effects=[];this.interval=null;},_each:function(iterator){this.effects._each(iterator);},add:function(effect){var timestamp=new Date().getTime();var position=Object.isString(effect.options.queue)?effect.options.queue:effect.options.queue.position;switch(position){case'front':this.effects.findAll(function(e){return e.state=='idle'}).each(function(e){e.startOn+=effect.finishOn;e.finishOn+=effect.finishOn;});break;case'with-last':timestamp=this.effects.pluck('startOn').max()||timestamp;break;case'end':timestamp=this.effects.pluck('finishOn').max()||timestamp;break;}
effect.startOn+=timestamp;effect.finishOn+=timestamp;if(!effect.options.queue.limit||(this.effects.length<effect.options.queue.limit))
this.effects.push(effect);if(!this.interval)
this.interval=setInterval(this.loop.bind(this),15);},remove:function(effect){this.effects=this.effects.reject(function(e){return e==effect});if(this.effects.length==0){clearInterval(this.interval);this.interval=null;}},loop:function(){var timePos=new Date().getTime();for(var i=0,len=this.effects.length;i<len;i++)
this.effects[i]&&this.effects[i].loop(timePos);}});Effect.Queues={instances:$H(),get:function(queueName){if(!Object.isString(queueName))return queueName;return this.instances.get(queueName)||this.instances.set(queueName,new Effect.ScopedQueue());}};Effect.Queue=Effect.Queues.get('global');Effect.Base=Class.create({position:null,start:function(options){function codeForEvent(options,eventName){return((options[eventName+'Internal']?'this.options.'+eventName+'Internal(this);':'')+
(options[eventName]?'this.options.'+eventName+'(this);':''));}
if(options&&options.transition===false)options.transition=Effect.Transitions.linear;this.options=Object.extend(Object.extend({},Effect.DefaultOptions),options||{});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;eval('this.render = function(pos){ '+'if (this.state=="idle"){this.state="running";'+
codeForEvent(this.options,'beforeSetup')+
(this.setup?'this.setup();':'')+
codeForEvent(this.options,'afterSetup')+'};if (this.state=="running"){'+'pos=this.options.transition(pos)*'+this.fromToDelta+'+'+this.options.from+';'+'this.position=pos;'+
codeForEvent(this.options,'beforeUpdate')+
(this.update?'this.update(pos);':'')+
codeForEvent(this.options,'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(timePos){if(timePos>=this.startOn){if(timePos>=this.finishOn){this.render(1.0);this.cancel();this.event('beforeFinish');if(this.finish)this.finish();this.event('afterFinish');return;}
var pos=(timePos-this.startOn)/this.totalTime,frame=(pos*this.totalFrames).round();if(frame>this.currentFrame){this.render(pos);this.currentFrame=frame;}}},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(eventName){if(this.options[eventName+'Internal'])this.options[eventName+'Internal'](this);if(this.options[eventName])this.options[eventName](this);},inspect:function(){var data=$H();for(property in this)
if(!Object.isFunction(this[property]))data.set(property,this[property]);return'#<Effect:'+data.inspect()+',options:'+$H(this.options).inspect()+'>';}});Effect.Parallel=Class.create(Effect.Base,{initialize:function(effects){this.effects=effects||[];this.start(arguments[1]);},update:function(position){this.effects.invoke('render',position);},finish:function(position){this.effects.each(function(effect){effect.render(1.0);effect.cancel();effect.event('beforeFinish');if(effect.finish)effect.finish(position);effect.event('afterFinish');});}});Effect.Tween=Class.create(Effect.Base,{initialize:function(object,from,to){object=Object.isString(object)?$(object):object;var args=$A(arguments),method=args.last(),options=args.length==5?args[3]:null;this.method=Object.isFunction(method)?method.bind(object):Object.isFunction(object[method])?object[method].bind(object):function(value){object[method]=value};this.start(Object.extend({from:from,to:to},options||{}));},update:function(position){this.method(position);}});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(element){this.element=$(element);if(!this.element)throw(Effect._elementDoesNotExistError);if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout))
this.element.setStyle({zoom:1});var options=Object.extend({from:this.element.getOpacity()||0.0,to:1.0},arguments[1]||{});this.start(options);},update:function(position){this.element.setOpacity(position);}});Effect.Move=Class.create(Effect.Base,{initialize:function(element){this.element=$(element);if(!this.element)throw(Effect._elementDoesNotExistError);var options=Object.extend({x:0,y:0,mode:'relative'},arguments[1]||{});this.start(options);},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(position){this.element.setStyle({left:(this.options.x*position+this.originalLeft).round()+'px',top:(this.options.y*position+this.originalTop).round()+'px'});}});Effect.MoveBy=function(element,toTop,toLeft){return new Effect.Move(element,Object.extend({x:toLeft,y:toTop},arguments[3]||{}));};Effect.Scale=Class.create(Effect.Base,{initialize:function(element,percent){this.element=$(element);if(!this.element)throw(Effect._elementDoesNotExistError);var options=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:'box',scaleFrom:100.0,scaleTo:percent},arguments[2]||{});this.start(options);},setup:function(){this.restoreAfterFinish=this.options.restoreAfterFinish||false;this.elementPositioning=this.element.getStyle('position');this.originalStyle={};['top','left','width','height','fontSize'].each(function(k){this.originalStyle[k]=this.element.style[k];}.bind(this));this.originalTop=this.element.offsetTop;this.originalLeft=this.element.offsetLeft;var fontSize=this.element.getStyle('font-size')||'100%';['em','px','%','pt'].each(function(fontSizeType){if(fontSize.indexOf(fontSizeType)>0){this.fontSize=parseFloat(fontSize);this.fontSizeType=fontSizeType;}}.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(position){var currentScale=(this.options.scaleFrom/100.0)+(this.factor*position);if(this.options.scaleContent&&this.fontSize)
this.element.setStyle({fontSize:this.fontSize*currentScale+this.fontSizeType});this.setDimensions(this.dims[0]*currentScale,this.dims[1]*currentScale);},finish:function(position){if(this.restoreAfterFinish)this.element.setStyle(this.originalStyle);},setDimensions:function(height,width){var d={};if(this.options.scaleX)d.width=width.round()+'px';if(this.options.scaleY)d.height=height.round()+'px';if(this.options.scaleFromCenter){var topd=(height-this.dims[0])/2;var leftd=(width-this.dims[1])/2;if(this.elementPositioning=='absolute'){if(this.options.scaleY)d.top=this.originalTop-topd+'px';if(this.options.scaleX)d.left=this.originalLeft-leftd+'px';}else{if(this.options.scaleY)d.top=-topd+'px';if(this.options.scaleX)d.left=-leftd+'px';}}
this.element.setStyle(d);}});Effect.Highlight=Class.create(Effect.Base,{initialize:function(element){this.element=$(element);if(!this.element)throw(Effect._elementDoesNotExistError);var options=Object.extend({startcolor:'#ffff99'},arguments[1]||{});this.start(options);},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(i){return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16)}.bind(this));this._delta=$R(0,2).map(function(i){return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i]}.bind(this));},update:function(position){this.element.setStyle({backgroundColor:$R(0,2).inject('#',function(m,v,i){return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart());}.bind(this))});},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}));}});Effect.ScrollTo=function(element){var options=arguments[1]||{},scrollOffsets=document.viewport.getScrollOffsets(),elementOffsets=$(element).cumulativeOffset(),max=(window.height||document.body.scrollHeight)-document.viewport.getHeight();if(options.offset)elementOffsets[1]+=options.offset;return new Effect.Tween(null,scrollOffsets.top,elementOffsets[1]>max?max:elementOffsets[1],options,function(p){scrollTo(scrollOffsets.left,p.round())});};Effect.Fade=function(element){element=$(element);var oldOpacity=element.getInlineOpacity();var options=Object.extend({from:element.getOpacity()||1.0,to:0.0,afterFinishInternal:function(effect){if(effect.options.to!=0)return;effect.element.hide().setStyle({opacity:oldOpacity});}},arguments[1]||{});return new Effect.Opacity(element,options);};Effect.Appear=function(element){element=$(element);var options=Object.extend({from:(element.getStyle('display')=='none'?0.0:element.getOpacity()||0.0),to:1.0,afterFinishInternal:function(effect){effect.element.forceRerendering();},beforeSetup:function(effect){effect.element.setOpacity(effect.options.from).show();}},arguments[1]||{});return new Effect.Opacity(element,options);};Effect.Puff=function(element){element=$(element);var oldStyle={opacity:element.getInlineOpacity(),position:element.getStyle('position'),top:element.style.top,left:element.style.left,width:element.style.width,height:element.style.height};return new Effect.Parallel([new Effect.Scale(element,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(element,{sync:true,to:0.0})],Object.extend({duration:1.0,beforeSetupInternal:function(effect){Position.absolutize(effect.effects[0].element)},afterFinishInternal:function(effect){effect.effects[0].element.hide().setStyle(oldStyle);}},arguments[1]||{}));};Effect.BlindUp=function(element){element=$(element);element.makeClipping();return new Effect.Scale(element,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(effect){effect.element.hide().undoClipping();}},arguments[1]||{}));};Effect.BlindDown=function(element){element=$(element);var elementDimensions=element.getDimensions();return new Effect.Scale(element,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:elementDimensions.height,originalWidth:elementDimensions.width},restoreAfterFinish:true,afterSetup:function(effect){effect.element.makeClipping().setStyle({height:'0px'}).show();},afterFinishInternal:function(effect){effect.element.undoClipping();}},arguments[1]||{}));};Effect.SwitchOff=function(element){element=$(element);var oldOpacity=element.getInlineOpacity();return new Effect.Appear(element,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(effect){new Effect.Scale(effect.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(effect){effect.element.makePositioned().makeClipping();},afterFinishInternal:function(effect){effect.element.hide().undoClipping().undoPositioned().setStyle({opacity:oldOpacity});}})}},arguments[1]||{}));};Effect.DropOut=function(element){element=$(element);var oldStyle={top:element.getStyle('top'),left:element.getStyle('left'),opacity:element.getInlineOpacity()};return new Effect.Parallel([new Effect.Move(element,{x:0,y:100,sync:true}),new Effect.Opacity(element,{sync:true,to:0.0})],Object.extend({duration:0.5,beforeSetup:function(effect){effect.effects[0].element.makePositioned();},afterFinishInternal:function(effect){effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);}},arguments[1]||{}));};Effect.Shake=function(element){element=$(element);var options=Object.extend({distance:20,duration:0.5},arguments[1]||{});var distance=parseFloat(options.distance);var split=parseFloat(options.duration)/10.0;var oldStyle={top:element.getStyle('top'),left:element.getStyle('left')};return new Effect.Move(element,{x:distance,y:0,duration:split,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:-distance*2,y:0,duration:split*2,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:distance*2,y:0,duration:split*2,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:-distance*2,y:0,duration:split*2,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:distance*2,y:0,duration:split*2,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:-distance,y:0,duration:split,afterFinishInternal:function(effect){effect.element.undoPositioned().setStyle(oldStyle);}})}})}})}})}})}});};Effect.SlideDown=function(element){element=$(element).cleanWhitespace();var oldInnerBottom=element.down().getStyle('bottom');var elementDimensions=element.getDimensions();return new Effect.Scale(element,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:elementDimensions.height,originalWidth:elementDimensions.width},restoreAfterFinish:true,afterSetup:function(effect){effect.element.makePositioned();effect.element.down().makePositioned();if(window.opera)effect.element.setStyle({top:''});effect.element.makeClipping().setStyle({height:'0px'}).show();},afterUpdateInternal:function(effect){effect.element.down().setStyle({bottom:(effect.dims[0]-effect.element.clientHeight)+'px'});},afterFinishInternal:function(effect){effect.element.undoClipping().undoPositioned();effect.element.down().undoPositioned().setStyle({bottom:oldInnerBottom});}},arguments[1]||{}));};Effect.SlideUp=function(element){element=$(element).cleanWhitespace();var oldInnerBottom=element.down().getStyle('bottom');var elementDimensions=element.getDimensions();return new Effect.Scale(element,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:'box',scaleFrom:100,scaleMode:{originalHeight:elementDimensions.height,originalWidth:elementDimensions.width},restoreAfterFinish:true,afterSetup:function(effect){effect.element.makePositioned();effect.element.down().makePositioned();if(window.opera)effect.element.setStyle({top:''});effect.element.makeClipping().show();},afterUpdateInternal:function(effect){effect.element.down().setStyle({bottom:(effect.dims[0]-effect.element.clientHeight)+'px'});},afterFinishInternal:function(effect){effect.element.hide().undoClipping().undoPositioned();effect.element.down().undoPositioned().setStyle({bottom:oldInnerBottom});}},arguments[1]||{}));};Effect.Squish=function(element){return new Effect.Scale(element,window.opera?1:0,{restoreAfterFinish:true,beforeSetup:function(effect){effect.element.makeClipping();},afterFinishInternal:function(effect){effect.element.hide().undoClipping();}});};Effect.Grow=function(element){element=$(element);var options=Object.extend({direction:'center',moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});var oldStyle={top:element.style.top,left:element.style.left,height:element.style.height,width:element.style.width,opacity:element.getInlineOpacity()};var dims=element.getDimensions();var initialMoveX,initialMoveY;var moveX,moveY;switch(options.direction){case'top-left':initialMoveX=initialMoveY=moveX=moveY=0;break;case'top-right':initialMoveX=dims.width;initialMoveY=moveY=0;moveX=-dims.width;break;case'bottom-left':initialMoveX=moveX=0;initialMoveY=dims.height;moveY=-dims.height;break;case'bottom-right':initialMoveX=dims.width;initialMoveY=dims.height;moveX=-dims.width;moveY=-dims.height;break;case'center':initialMoveX=dims.width/2;initialMoveY=dims.height/2;moveX=-dims.width/2;moveY=-dims.height/2;break;}
return new Effect.Move(element,{x:initialMoveX,y:initialMoveY,duration:0.01,beforeSetup:function(effect){effect.element.hide().makeClipping().makePositioned();},afterFinishInternal:function(effect){new Effect.Parallel([new Effect.Opacity(effect.element,{sync:true,to:1.0,from:0.0,transition:options.opacityTransition}),new Effect.Move(effect.element,{x:moveX,y:moveY,sync:true,transition:options.moveTransition}),new Effect.Scale(effect.element,100,{scaleMode:{originalHeight:dims.height,originalWidth:dims.width},sync:true,scaleFrom:window.opera?1:0,transition:options.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(effect){effect.effects[0].element.setStyle({height:'0px'}).show();},afterFinishInternal:function(effect){effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);}},options))}});};Effect.Shrink=function(element){element=$(element);var options=Object.extend({direction:'center',moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});var oldStyle={top:element.style.top,left:element.style.left,height:element.style.height,width:element.style.width,opacity:element.getInlineOpacity()};var dims=element.getDimensions();var moveX,moveY;switch(options.direction){case'top-left':moveX=moveY=0;break;case'top-right':moveX=dims.width;moveY=0;break;case'bottom-left':moveX=0;moveY=dims.height;break;case'bottom-right':moveX=dims.width;moveY=dims.height;break;case'center':moveX=dims.width/2;moveY=dims.height/2;break;}
return new Effect.Parallel([new Effect.Opacity(element,{sync:true,to:0.0,from:1.0,transition:options.opacityTransition}),new Effect.Scale(element,window.opera?1:0,{sync:true,transition:options.scaleTransition,restoreAfterFinish:true}),new Effect.Move(element,{x:moveX,y:moveY,sync:true,transition:options.moveTransition})],Object.extend({beforeStartInternal:function(effect){effect.effects[0].element.makePositioned().makeClipping();},afterFinishInternal:function(effect){effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle);}},options));};Effect.Pulsate=function(element){element=$(element);var options=arguments[1]||{};var oldOpacity=element.getInlineOpacity();var transition=options.transition||Effect.Transitions.sinoidal;var reverser=function(pos){return transition(1-Effect.Transitions.pulse(pos,options.pulses))};reverser.bind(transition);return new Effect.Opacity(element,Object.extend(Object.extend({duration:2.0,from:0,afterFinishInternal:function(effect){effect.element.setStyle({opacity:oldOpacity});}},options),{transition:reverser}));};Effect.Fold=function(element){element=$(element);var oldStyle={top:element.style.top,left:element.style.left,width:element.style.width,height:element.style.height};element.makeClipping();return new Effect.Scale(element,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(effect){new Effect.Scale(element,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(effect){effect.element.hide().undoClipping().setStyle(oldStyle);}});}},arguments[1]||{}));};Effect.Morph=Class.create(Effect.Base,{initialize:function(element){this.element=$(element);if(!this.element)throw(Effect._elementDoesNotExistError);var options=Object.extend({style:{}},arguments[1]||{});if(!Object.isString(options.style))this.style=$H(options.style);else{if(options.style.include(':'))
this.style=options.style.parseStyle();else{this.element.addClassName(options.style);this.style=$H(this.element.getStyles());this.element.removeClassName(options.style);var css=this.element.getStyles();this.style=this.style.reject(function(style){return style.value==css[style.key];});options.afterFinishInternal=function(effect){effect.element.addClassName(effect.options.style);effect.transforms.each(function(transform){effect.element.style[transform.style]='';});}}}
this.start(options);},setup:function(){function parseColor(color){if(!color||['rgba(0, 0, 0, 0)','transparent'].include(color))color='#ffffff';color=color.parseColor();return $R(0,2).map(function(i){return parseInt(color.slice(i*2+1,i*2+3),16)});}
this.transforms=this.style.map(function(pair){var property=pair[0],value=pair[1],unit=null;if(value.parseColor('#zzzzzz')!='#zzzzzz'){value=value.parseColor();unit='color';}else if(property=='opacity'){value=parseFloat(value);if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout))
this.element.setStyle({zoom:1});}else if(Element.CSS_LENGTH.test(value)){var components=value.match(/^([\+\-]?[0-9\.]+)(.*)$/);value=parseFloat(components[1]);unit=(components.length==3)?components[2]:null;}
var originalValue=this.element.getStyle(property);return{style:property.camelize(),originalValue:unit=='color'?parseColor(originalValue):parseFloat(originalValue||0),targetValue:unit=='color'?parseColor(value):value,unit:unit};}.bind(this)).reject(function(transform){return((transform.originalValue==transform.targetValue)||(transform.unit!='color'&&(isNaN(transform.originalValue)||isNaN(transform.targetValue))))});},update:function(position){var style={},transform,i=this.transforms.length;while(i--)
style[(transform=this.transforms[i]).style]=transform.unit=='color'?'#'+
(Math.round(transform.originalValue[0]+
(transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart()+
(Math.round(transform.originalValue[1]+
(transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart()+
(Math.round(transform.originalValue[2]+
(transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart():(transform.originalValue+
(transform.targetValue-transform.originalValue)*position).toFixed(3)+
(transform.unit===null?'':transform.unit);this.element.setStyle(style,true);}});Effect.Transform=Class.create({initialize:function(tracks){this.tracks=[];this.options=arguments[1]||{};this.addTracks(tracks);},addTracks:function(tracks){tracks.each(function(track){track=$H(track);var data=track.values().first();this.tracks.push($H({ids:track.keys().first(),effect:Effect.Morph,options:{style:data}}));}.bind(this));return this;},play:function(){return new Effect.Parallel(this.tracks.map(function(track){var ids=track.get('ids'),effect=track.get('effect'),options=track.get('options');var elements=[$(ids)||$$(ids)].flatten();return elements.map(function(e){return new effect(e,Object.extend({sync:true},options))});}).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 style,styleRules=$H();if(Prototype.Browser.WebKit)
style=new Element('div',{style:this}).style;else{String.__parseStyleElement.innerHTML='<div style="'+this+'"></div>';style=String.__parseStyleElement.childNodes[0].style;}
Element.CSS_PROPERTIES.each(function(property){if(style[property])styleRules.set(property,style[property]);});if(Prototype.Browser.IE&&this.include('opacity'))
styleRules.set('opacity',this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]);return styleRules;};if(document.defaultView&&document.defaultView.getComputedStyle){Element.getStyles=function(element){var css=document.defaultView.getComputedStyle($(element),null);return Element.CSS_PROPERTIES.inject({},function(styles,property){styles[property]=css[property];return styles;});};}else{Element.getStyles=function(element){element=$(element);var css=element.currentStyle,styles;styles=Element.CSS_PROPERTIES.inject({},function(results,property){results[property]=css[property];return results;});if(!styles.opacity)styles.opacity=element.getOpacity();return styles;};};Effect.Methods={morph:function(element,style){element=$(element);new Effect.Morph(element,Object.extend({style:style},arguments[2]||{}));return element;},visualEffect:function(element,effect,options){element=$(element)
var s=effect.dasherize().camelize(),klass=s.charAt(0).toUpperCase()+s.substring(1);new Effect[klass](element,options);return element;},highlight:function(element,options){element=$(element);new Effect.Highlight(element,options);return element;}};$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+'pulsate shake puff squish switchOff dropOut').each(function(effect){Effect.Methods[effect]=function(element,options){element=$(element);Effect[effect.charAt(0).toUpperCase()+effect.substring(1)](element,options);return element;}});$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each(function(f){Effect.Methods[f]=Element[f];});Element.addMethods(Effect.Methods);if(!Control)var Control={};Control.Slider=Class.create({initialize:function(handle,track,options){var slider=this;if(Object.isArray(handle)){this.handles=handle.collect(function(e){return $(e)});}else{this.handles=[$(handle)];}
this.track=$(track);this.options=options||{};this.axis=this.options.axis||'horizontal';this.increment=this.options.increment||1;this.step=parseInt(this.options.step||'1');this.range=this.options.range||$R(0,1);this.value=0;this.values=this.handles.map(function(){return 0});this.spans=this.options.spans?this.options.spans.map(function(s){return $(s)}):false;this.options.startSpan=$(this.options.startSpan||null);this.options.endSpan=$(this.options.endSpan||null);this.restricted=this.options.restricted||false;this.maximum=this.options.maximum||this.range.end;this.minimum=this.options.minimum||this.range.start;this.alignX=parseInt(this.options.alignX||'0');this.alignY=parseInt(this.options.alignY||'0');this.trackLength=this.maximumOffset()-this.minimumOffset();this.handleLength=this.isVertical()?(this.handles[0].offsetHeight!=0?this.handles[0].offsetHeight:this.handles[0].style.height.replace(/px$/,"")):(this.handles[0].offsetWidth!=0?this.handles[0].offsetWidth:this.handles[0].style.width.replace(/px$/,""));this.active=false;this.dragging=false;this.disabled=false;if(this.options.disabled)this.setDisabled();this.allowedValues=this.options.values?this.options.values.sortBy(Prototype.K):false;if(this.allowedValues){this.minimum=this.allowedValues.min();this.maximum=this.allowedValues.max();}
this.eventMouseDown=this.startDrag.bindAsEventListener(this);this.eventMouseUp=this.endDrag.bindAsEventListener(this);this.eventMouseMove=this.update.bindAsEventListener(this);this.handles.each(function(h,i){i=slider.handles.length-1-i;slider.setValue(parseFloat((Object.isArray(slider.options.sliderValue)?slider.options.sliderValue[i]:slider.options.sliderValue)||slider.range.start),i);h.makePositioned().observe("mousedown",slider.eventMouseDown);});this.track.observe("mousedown",this.eventMouseDown);document.observe("mouseup",this.eventMouseUp);document.observe("mousemove",this.eventMouseMove);this.initialized=true;},dispose:function(){var slider=this;Event.stopObserving(this.track,"mousedown",this.eventMouseDown);Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);this.handles.each(function(h){Event.stopObserving(h,"mousedown",slider.eventMouseDown);});},setDisabled:function(){this.disabled=true;},setEnabled:function(){this.disabled=false;},getNearestValue:function(value){if(this.allowedValues){if(value>=this.allowedValues.max())return(this.allowedValues.max());if(value<=this.allowedValues.min())return(this.allowedValues.min());var offset=Math.abs(this.allowedValues[0]-value);var newValue=this.allowedValues[0];this.allowedValues.each(function(v){var currentOffset=Math.abs(v-value);if(currentOffset<=offset){newValue=v;offset=currentOffset;}});return newValue;}
if(value>this.range.end)return this.range.end;if(value<this.range.start)return this.range.start;return value;},setValue:function(sliderValue,handleIdx){if(!this.active){this.activeHandleIdx=handleIdx||0;this.activeHandle=this.handles[this.activeHandleIdx];this.updateStyles();}
handleIdx=handleIdx||this.activeHandleIdx||0;if(this.initialized&&this.restricted){if((handleIdx>0)&&(sliderValue<this.values[handleIdx-1]))
sliderValue=this.values[handleIdx-1];if((handleIdx<(this.handles.length-1))&&(sliderValue>this.values[handleIdx+1]))
sliderValue=this.values[handleIdx+1];}
sliderValue=this.getNearestValue(sliderValue);this.values[handleIdx]=sliderValue;this.value=this.values[0];this.handles[handleIdx].style[this.isVertical()?'top':'left']=this.translateToPx(sliderValue);this.drawSpans();if(!this.dragging||!this.event)this.updateFinished();},setValueBy:function(delta,handleIdx){this.setValue(this.values[handleIdx||this.activeHandleIdx||0]+delta,handleIdx||this.activeHandleIdx||0);},translateToPx:function(value){return Math.round(((this.trackLength-this.handleLength)/(this.range.end-this.range.start))*(value-this.range.start))+"px";},translateToValue:function(offset){return((offset/(this.trackLength-this.handleLength)*(this.range.end-this.range.start))+this.range.start);},getRange:function(range){var v=this.values.sortBy(Prototype.K);range=range||0;return $R(v[range],v[range+1]);},minimumOffset:function(){return(this.isVertical()?this.alignY:this.alignX);},maximumOffset:function(){return(this.isVertical()?(this.track.offsetHeight!=0?this.track.offsetHeight:this.track.style.height.replace(/px$/,""))-this.alignY:(this.track.offsetWidth!=0?this.track.offsetWidth:this.track.style.width.replace(/px$/,""))-this.alignX);},isVertical:function(){return(this.axis=='vertical');},drawSpans:function(){var slider=this;if(this.spans)
$R(0,this.spans.length-1).each(function(r){slider.setSpan(slider.spans[r],slider.getRange(r))});if(this.options.startSpan)
this.setSpan(this.options.startSpan,$R(0,this.values.length>1?this.getRange(0).min():this.value));if(this.options.endSpan)
this.setSpan(this.options.endSpan,$R(this.values.length>1?this.getRange(this.spans.length-1).max():this.value,this.maximum));},setSpan:function(span,range){if(this.isVertical()){span.style.top=this.translateToPx(range.start);span.style.height=this.translateToPx(range.end-range.start+this.range.start);}else{span.style.left=this.translateToPx(range.start);span.style.width=this.translateToPx(range.end-range.start+this.range.start);}},updateStyles:function(){this.handles.each(function(h){Element.removeClassName(h,'selected')});Element.addClassName(this.activeHandle,'selected');},startDrag:function(event){if(Event.isLeftClick(event)){if(!this.disabled){this.active=true;var handle=Event.element(event);var pointer=[Event.pointerX(event),Event.pointerY(event)];var track=handle;if(track==this.track){var offsets=Position.cumulativeOffset(this.track);this.event=event;this.setValue(this.translateToValue((this.isVertical()?pointer[1]-offsets[1]:pointer[0]-offsets[0])-(this.handleLength/2)));var offsets=Position.cumulativeOffset(this.activeHandle);this.offsetX=(pointer[0]-offsets[0]);this.offsetY=(pointer[1]-offsets[1]);}else{while((this.handles.indexOf(handle)==-1)&&handle.parentNode)
handle=handle.parentNode;if(this.handles.indexOf(handle)!=-1){this.activeHandle=handle;this.activeHandleIdx=this.handles.indexOf(this.activeHandle);this.updateStyles();var offsets=Position.cumulativeOffset(this.activeHandle);this.offsetX=(pointer[0]-offsets[0]);this.offsetY=(pointer[1]-offsets[1]);}}}
Event.stop(event);}},update:function(event){if(this.active){if(!this.dragging)this.dragging=true;this.draw(event);if(Prototype.Browser.WebKit)window.scrollBy(0,0);Event.stop(event);}},draw:function(event){var pointer=[Event.pointerX(event),Event.pointerY(event)];var offsets=Position.cumulativeOffset(this.track);pointer[0]-=this.offsetX+offsets[0];pointer[1]-=this.offsetY+offsets[1];this.event=event;this.setValue(this.translateToValue(this.isVertical()?pointer[1]:pointer[0]));if(this.initialized&&this.options.onSlide)
this.options.onSlide(this.values.length>1?this.values:this.value,this);},endDrag:function(event){if(this.active&&this.dragging){this.finishDrag(event,true);Event.stop(event);}
this.active=false;this.dragging=false;},finishDrag:function(event,success){this.active=false;this.dragging=false;this.updateFinished();},updateFinished:function(){if(this.initialized&&this.options.onChange)
this.options.onChange(this.values.length>1?this.values:this.value,this);this.event=null;}});if(typeof(Prototype)=="undefined")
throw"Event.Behavior requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Event.Behavior requires Object.Event to be loaded.";Event.Behavior={addVerbs:function(verbs){for(name in verbs){v=new Event.Behavior.Verb(verbs[name]);Event.Behavior.Verbs[name]=v;Event.Behavior[name.underscore()]=Event.Behavior[name]=v.getCallbackForStack.bind(v);}},addEvents:function(events){$H(events).each(function(event_type){Event.Behavior.Adjective.prototype[event_type.key.underscore()]=Event.Behavior.Adjective.prototype[event_type.key]=function(){this.nextConditionType='and';this.events.push(event_type.value);this.attachObserver(false);return this;};});},invokeElementMethod:function(element,action,args){if(typeof(element)=='function'){return $A(element()).each(function(e){if(typeof(args[0])=='function'){return $A(args[0]).each(function(a){return $(e)[action].apply($(e),(a?[a]:[]));});}else
return $(e)[action].apply($(e),args||[]);});}else
return $(element)[action].apply($(element),args||[]);}};Event.Behavior.Verbs=$H({});Event.Behavior.Verb=Class.create();Object.extend(Event.Behavior.Verb.prototype,{originalAction:false,execute:false,executeOpposite:false,target:false,initialize:function(action){this.originalAction=action;this.execute=function(action,target,argument){return(argument)?action(target,argument):action(target);}.bind(this,action);},setOpposite:function(opposite_verb){opposite_action=opposite_verb.originalAction;this.executeOpposite=function(opposite_action,target,argument){return(argument)?opposite_action(target,argument):opposite_action(target);}.bind(this,opposite_action);},getCallbackForStack:function(argument){return new Event.Behavior.Noun(this,argument);}});Event.Behavior.addVerbs({call:function(callback){callback();},show:function(element){return Event.Behavior.invokeElementMethod(element,'show');},hide:function(element){return Event.Behavior.invokeElementMethod(element,'hide');},remove:function(element){return Event.Behavior.invokeElementMethod(element,'remove');},setStyle:function(element,styles){return Event.Behavior.invokeElementMethod(element,'setStyle',[(typeof(styles)=='function'?styles():styles)]);},addClassName:function(element,class_name){return Event.Behavior.invokeElementMethod(element,'addClassName',[(typeof(class_name)=='function'?class_name():class_name)]);},removeClassName:function(element,class_name){return Event.Behavior.invokeElementMethod(element,'removeClassName',[(typeof(class_name)=='function'?class_name():class_name)]);},setClassName:function(element,class_name){c=(typeof(class_name)=='function')?class_name():class_name;if(typeof(element)=='function'){return $A(element()).each(function(e){$(e).className=c;});}else
return $(element).className=c;},update:function(content,element){return Event.Behavior.invokeElementMethod(element,'update',[(typeof(content)=='function'?content():content)]);},replace:function(content,element){return Event.Behavior.invokeElementMethod(element,'replace',[(typeof(content)=='function'?content():content)]);}});Event.Behavior.Verbs.show.setOpposite(Event.Behavior.Verbs.hide);Event.Behavior.Verbs.hide.setOpposite(Event.Behavior.Verbs.show);Event.Behavior.Verbs.addClassName.setOpposite(Event.Behavior.Verbs.removeClassName);Event.Behavior.Verbs.removeClassName.setOpposite(Event.Behavior.Verbs.addClassName);Event.Behavior.Noun=Class.create();Object.extend(Event.Behavior.Noun.prototype,{verbs:false,verb:false,argument:false,subject:false,target:false,initialize:function(verb,argument){this.verb=verb;this.argument=argument;},execute:function(){return(this.target)?this.verb.execute(this.target,this.argument):this.verb.execute(this.argument);},executeOpposite:function(){return(this.target)?this.verb.executeOpposite(this.target,this.argument):this.verb.executeOpposite(this.argument);},when:function(subject){this.subject=subject;return new Event.Behavior.Adjective(this);},getValue:function(){return Try.these(function(){return $(this.subject).getValue();}.bind(this),function(){return $(this.subject).options[$(this.subject).options.selectedIndex].value;}.bind(this),function(){return $(this.subject).value;}.bind(this),function(){return $(this.subject).innerHTML;}.bind(this));},containsValue:function(match){value=this.getValue();if(typeof(match)=='function'){return $A(match()).include(value);}else
return value.match(match);},setTarget:function(target){this.target=target;return this;},and:function(){}});Event.Behavior.Noun.prototype._with=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.on=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.of=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.to=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.from=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Adjective=Class.create();Object.extend(Event.Behavior.Adjective.prototype,{noun:false,lastConditionName:'',nextConditionType:'and',conditions:$A([]),events:$A([]),attached:false,initialize:function(noun){this.conditions=$A([]);this.events=$A([]);this.noun=noun;},attachObserver:function(execute_on_load){if(this.attached){if(execute_on_load)
this.execute();return;}
this.attached=true;if(typeof(this.noun.subject)=='function'){$A(this.noun.subject()).each(function(subject){(this.events.length>0?this.events:$A(['change'])).each(function(event_name){(subject.observe?subject:$(subject)).observe(event_name,function(){this.execute();}.bind(this));}.bind(this));}.bind(this));}else{(this.events.length>0?this.events:$A(['change'])).each(function(event_name){$(this.noun.subject).observe(event_name,function(){this.execute();}.bind(this));}.bind(this));}
if(execute_on_load)
this.execute();},execute:function(){if(this.match())
return this.noun.execute();else if(this.noun.verb.executeOpposite)
this.noun.executeOpposite();},attachCondition:function(callback){this.conditions.push([this.nextConditionType,callback.bind(this)]);},match:function(){if(this.conditions.length==0)
return true;else{return this.conditions.inject(new Boolean(),function(bool,condition){return(condition[0]=='and')?(bool&&condition[1]()):(bool||condition[1]());});}},is:function(item){this.lastConditionName='is';this.attachCondition(function(item){return(typeof(item)=='function'?item():item)==this.noun.getValue();}.bind(this,item));this.attachObserver(true);return this;},isNot:function(item){this.lastConditionName='isNot';this.attachCondition(function(item){return(typeof(item)=='function'?item():item)!=this.noun.getValue();}.bind(this,item));this.attachObserver(true);return this;},contains:function(item){this.lastConditionName='contains';this.attachCondition(function(item){return this.noun.containsValue(item);}.bind(this,item));this.attachObserver(true);return this;},within:function(item){this.lastConditionName='within';this.attachCondition(function(item){}.bind(this,item));this.attachObserver(true);return this;},change:function(){this.nextConditionType='and';this.attachObserver(true);return this;},and:function(condition){this.attached=false;this.nextConditionType='and';if(condition)
this[this.lastConditionName](condition);return this;},or:function(condition){this.attached=false;this.nextConditionType='or';if(condition)
this[this.lastConditionName](condition);return this;}});Event.Behavior.addEvents({losesFocus:'blur',gainsFocus:'focus',isClicked:'click',isDoubleClicked:'dblclick',keyPressed:'keypress'});Event.Behavior.Adjective.prototype.is_not=Event.Behavior.Adjective.prototype.isNot;Event.Behavior.Adjective.prototype.include=Event.Behavior.Adjective.prototype.contains;Event.Behavior.Adjective.prototype.includes=Event.Behavior.Adjective.prototype.contains;Event.Behavior.Adjective.prototype.are=Event.Behavior.Adjective.prototype.is;Event.Behavior.Adjective.prototype.areNot=Event.Behavior.Adjective.prototype.isNot;Event.Behavior.Adjective.prototype.are_not=Event.Behavior.Adjective.prototype.isNot;Event.Behavior.Adjective.prototype.changes=Event.Behavior.Adjective.prototype.change;if(typeof(Prototype)=="undefined")
throw"Control.ContextMenu requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.ContextMenu requires Object.Event to be loaded.";Control.ContextMenu=Class.create({initialize:function(container,options){Control.ContextMenu.load();this.options=Object.extend({leftClick:false,disableOnShiftKey:true,disableOnAltKey:true,selectedClassName:'selected',activatedClassName:'activated',animation:true,animationCycles:2,animationLength:300,delayCallback:true},options||{});this.activated=false;this.items=this.options.items||[];this.container=$(container);this.container.observe(this.options.leftClick?'click':(Prototype.Browser.Opera?'click':'contextmenu'),function(event){if(!Control.ContextMenu.enabled||Prototype.Browser.Opera&&!event.ctrlKey)
return;this.open(event);}.bindAsEventListener(this));},open:function(event){if(Control.ContextMenu.current&&!Control.ContextMenu.current.close())
return;if(this.notify('beforeOpen',event)===false)
return false;this.buildMenu();if(this.items.length==0){this.close(event);return false;}
Control.ContextMenu.current=this;Control.ContextMenu.positionContainer(event);Control.ContextMenu.container.show();if(this.notify('afterOpen',event)===false)
return false;event.stop();return true;},close:function(event){if(event)
event.stop();if(this.notify('beforeClose')===false)
return false;Control.ContextMenu.current=false;this.activated=false;Control.ContextMenu.container.removeClassName(this.options.activatedClassName);Control.ContextMenu.container.select('li').invoke('stopObserving');Control.ContextMenu.container.hide();Control.ContextMenu.container.update('');if(this.notify('afterClose')===false)
return false;return true;},buildMenu:function(){var list=document.createElement('ul');Control.ContextMenu.container.appendChild(list);this.items.each(function(item){if(!(!item.condition||item.condition&&item.condition()!==false))
return;var item_container=$(document.createElement('li'));item_container.update($value(item.label));list.appendChild(item_container);item_container.observe('mousedown',function(event,item){this.activated=$value(item.label);}.bindAsEventListener(this,item));item_container.observe('click',this.selectMenuItem.bindAsEventListener(this,item,item_container));item_container.observe('contextmenu',this.selectMenuItem.bindAsEventListener(this,item,item_container));}.bind(this));},addItem:function(params){this.items.push(params);return this;},destroy:function(){this.container.stopObserving(Prototype.Browser.Opera||this.options.leftClick?'click':'contextmenu');this.items=[];},selectMenuItem:function(event,item,item_container){if(!this.activated||this.activated==$value(item.label)){if(this.options.animation){Control.ContextMenu.container.addClassName(this.options.activatedClassName);$A($R(0,this.options.animationCycles*2)).each(function(i){window.setTimeout(function(){item_container.toggleClassName(this.options.selectedClassName);}.bind(this),i*parseInt(this.options.animationLength/(this.options.animationCycles*2)));}.bind(this));window.setTimeout(function(){if(this.close()&&this.options.delayCallback)
item.callback();}.bind(this),this.options.animationLength);if(!this.options.delayCallback)
item.callback();}else if(this.close())
item.callback();}
event.stop();return false;}});Object.extend(Control.ContextMenu,{loaded:false,capture_all:false,menus:[],current:false,enabled:false,offset:4,load:function(capture_all){if(Control.ContextMenu.loaded)
return;Control.ContextMenu.loaded=true;if(typeof(capture_all)=='undefined')
capture_all=false;Control.ContextMenu.capture_all=capture_all;Control.ContextMenu.container=$(document.createElement('div'));Control.ContextMenu.container.id='control_contextmenu';Control.ContextMenu.container.style.position='absolute';Control.ContextMenu.container.style.zIndex=99999;Control.ContextMenu.container.hide();document.body.appendChild(Control.ContextMenu.container);Control.ContextMenu.enable();},enable:function(){Control.ContextMenu.enabled=true;Event.observe(document.body,'click',Control.ContextMenu.onClick);if(Control.ContextMenu.capture_all)
Event.observe(document.body,'contextmenu',Control.ContextMenu.onContextMenu);},disable:function(){Event.stopObserving(document.body,'click',Control.ContextMenu.onClick);if(Control.ContextMenu.capture_all)
Event.stopObserving(document.body,'contextmenu',Control.ContextMenu.onContextMenu);},onContextMenu:function(event){event.stop();return false;},onClick:function(){if(Control.ContextMenu.current)
Control.ContextMenu.current.close();},positionContainer:function(event){var dimensions=Control.ContextMenu.container.getDimensions();var top=Event.pointerY(event);var left=Event.pointerX(event);var bottom=dimensions.height+top;var right=dimensions.width+left;var viewport_dimensions=document.viewport.getDimensions();var viewport_scroll_offsets=document.viewport.getScrollOffsets();if(bottom>viewport_dimensions.height+viewport_scroll_offsets.top)
top-=bottom-((viewport_dimensions.height+viewport_scroll_offsets.top)-Control.ContextMenu.offset);if(right>viewport_dimensions.width+viewport_scroll_offsets.left)
left-=right-((viewport_dimensions.width+viewport_scroll_offsets.left)-Control.ContextMenu.offset);Control.ContextMenu.container.setStyle({top:top+'px',left:left+'px'});}});Object.Event.extend(Control.ContextMenu);if(typeof(Prototype)=="undefined")
throw"Control.ScrollBar requires Prototype to be loaded.";if(typeof(Control.Slider)=="undefined")
throw"Control.ScrollBar requires Control.Slider to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.ScrollBar requires Object.Event to be loaded.";Control.ScrollBar=Class.create({initialize:function(container,track,options){this.enabled=false;this.notificationTimeout=false;this.container=$(container);this.boundMouseWheelEvent=this.onMouseWheel.bindAsEventListener(this);this.boundResizeObserver=this.onWindowResize.bind(this);this.track=$(track);this.handle=this.track.firstDescendant();this.options=Object.extend({active_class_name:'scrolling',apply_active_class_name_to:this.container,notification_timeout_length:125,handle_minimum_height:25,scroll_to_smoothing:0.01,scroll_to_steps:15,proportional:true,slider_options:{}},options||{});this.slider=new Control.Slider(this.handle,this.track,Object.extend({axis:'vertical',onSlide:this.onChange.bind(this),onChange:this.onChange.bind(this)},this.options.slider_options));this.recalculateLayout();Event.observe(window,'resize',this.boundResizeObserver);this.handle.observe('mousedown',function(){if(this.auto_sliding_executer)
this.auto_sliding_executer.stop();}.bind(this));},destroy:function(){Event.stopObserving(window,'resize',this.boundResizeObserver);},enable:function(){this.enabled=true;this.container.observe('mouse:wheel',this.boundMouseWheelEvent);this.slider.setEnabled();this.track.show();if(this.options.active_class_name)
$(this.options.apply_active_class_name_to).addClassName(this.options.active_class_name);this.notify('enabled');},disable:function(){this.enabled=false;this.container.stopObserving('mouse:wheel',this.boundMouseWheelEvent);this.slider.setDisabled();this.track.hide();if(this.options.active_class_name)
$(this.options.apply_active_class_name_to).removeClassName(this.options.active_class_name);this.notify('disabled');this.reset();},reset:function(){this.slider.setValue(0);},recalculateLayout:function(){if(this.container.scrollHeight<=this.container.offsetHeight)
this.disable();else{this.slider.trackLength=this.slider.maximumOffset()-this.slider.minimumOffset();if(this.options.proportional){this.handle.style.height=Math.max(this.container.offsetHeight*(this.container.offsetHeight/this.container.scrollHeight),this.options.handle_minimum_height)+'px';this.slider.handleLength=this.handle.style.height.replace(/px/,'');}
this.enable();}},onWindowResize:function(){this.recalculateLayout();this.scrollBy(0);},onMouseWheel:function(event){if(this.auto_sliding_executer)
this.auto_sliding_executer.stop();this.slider.setValueBy(-(event.memo.delta/20));event.stop();return false;},onChange:function(value){this.container.scrollTop=Math.round(value/this.slider.maximum*(this.container.scrollHeight-this.container.offsetHeight));if(this.notification_timeout)
window.clearTimeout(this.notificationTimeout);this.notificationTimeout=window.setTimeout(function(){this.notify('change',value);}.bind(this),this.options.notification_timeout_length);},getCurrentMaximumDelta:function(){return this.slider.maximum*(this.container.scrollHeight-this.container.offsetHeight);},getDeltaToElement:function(element){return this.slider.maximum*((element.positionedOffset().top+(element.getHeight()/2))-(this.container.getHeight()/2));},scrollTo:function(y,animate){var current_maximum_delta=this.getCurrentMaximumDelta();if(y=='top')
y=0;else if(y=='bottom')
y=current_maximum_delta;else if(typeof(y)!="number")
y=this.getDeltaToElement($(y));if(this.enabled){y=Math.max(0,Math.min(y,current_maximum_delta));if(this.auto_sliding_executer)
this.auto_sliding_executer.stop();var target_value=y/current_maximum_delta;var original_slider_value=this.slider.value;var delta=(target_value-original_slider_value)*current_maximum_delta;if(animate){this.auto_sliding_executer=new PeriodicalExecuter(function(){if(Math.round(this.slider.value*100)/100<Math.round(target_value*100)/100||Math.round(this.slider.value*100)/100>Math.round(target_value*100)/100){this.scrollBy(delta/this.options.scroll_to_steps);}else{this.auto_sliding_executer.stop();this.auto_sliding_executer=null;if(typeof(animate)=="function")
animate();}}.bind(this),this.options.scroll_to_smoothing);}else
this.scrollBy(delta);}else if(typeof(animate)=="function")
animate();},scrollBy:function(y){if(!this.enabled)
return false;this.slider.setValueBy(y/this.getCurrentMaximumDelta());}});Object.Event.extend(Control.ScrollBar);if(typeof(Prototype)=="undefined")
throw"Cookie requires Prototype to be loaded."
if(typeof(Object.Event)=="undefined")
throw"Cookie requires Object.Event to be loaded.";var Cookie={set:function(name,value,seconds){if(seconds){var d=new Date();d.setTime(d.getTime()+(seconds*1000));var expiry='; expires='+d.toGMTString();}else
var expiry='';Cookie.notify('set',name,value);document.cookie=name+"="+value+expiry+"; path=/";},get:function(name){Cookie.notify('get',name);var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==' ')
c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)
return c.substring(nameEQ.length,c.length);}
return null;},unset:function(name){Cookie.notify('unset',name);Cookie.set(name,'',-1);}};Object.Event.extend(Cookie);if(typeof(Draggable)!='undefined'){Draggable.prototype.draw=function(point){var pos=Position.cumulativeOffset(this.element);if(this.options.ghosting){var r=Position.realOffset(this.element);pos[0]+=r[0]-Position.deltaX;pos[1]+=r[1]-Position.deltaY;}
var d=this.currentDelta();pos[0]-=d[0];pos[1]-=d[1];if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){pos[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;pos[1]-=this.options.scroll.scrollTop-this.originalScrollTop;}
var p=[0,1].map(function(i){return(point[i]-pos[i]-this.offset[i])}.bind(this));if(this.options.snap){if(typeof this.options.snap=='function'){p=this.options.snap(p[0],p[1],this);}else{if(this.options.snap instanceof Array){p=p.map(function(v,i){return Math.round(v/this.options.snap[i])*this.options.snap[i]}.bind(this))}else{p=p.map(function(v){return Math.round(v/this.options.snap)*this.options.snap}.bind(this))}}}
if(this.options.onDraw)
this.options.onDraw.bind(this)(p);else{var style=this.element.style;if(this.options.constrainToViewport){var viewport_dimensions=document.viewport.getDimensions();var container_dimensions=this.element.getDimensions();var margin_top=parseInt(this.element.getStyle('margin-top'));var margin_left=parseInt(this.element.getStyle('margin-left'));var boundary=[[0-margin_left,0-margin_top],[(viewport_dimensions.width-container_dimensions.width)-margin_left,(viewport_dimensions.height-container_dimensions.height)-margin_top]];if((!this.options.constraint)||(this.options.constraint=='horizontal')){if((p[0]>=boundary[0][0])&&(p[0]<=boundary[1][0]))
this.element.style.left=p[0]+"px";else
this.element.style.left=((p[0]<boundary[0][0])?boundary[0][0]:boundary[1][0])+"px";}
if((!this.options.constraint)||(this.options.constraint=='vertical')){if((p[1]>=boundary[0][1])&&(p[1]<=boundary[1][1]))
this.element.style.top=p[1]+"px";else
this.element.style.top=((p[1]<=boundary[0][1])?boundary[0][1]:boundary[1][1])+"px";}}else{if((!this.options.constraint)||(this.options.constraint=='horizontal'))
style.left=p[0]+"px";if((!this.options.constraint)||(this.options.constraint=='vertical'))
style.top=p[1]+"px";}
if(style.visibility=="hidden")
style.visibility="";}};}
if(typeof(Prototype)=="undefined")
throw"Control.Window requires Prototype to be loaded.";if(typeof(IframeShim)=="undefined")
throw"Control.Window requires IframeShim to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.Window requires Object.Event to be loaded.";Control.Window=Class.create({initialize:function(container,options){Control.Window.windows.push(this);this.container=false;this.isOpen=false;this.href=false;this.sourceContainer=false;this.ajaxRequest=false;this.remoteContentLoaded=false;this.numberInSequence=Control.Window.windows.length+1;this.indicator=false;this.effects={fade:false,appear:false};this.indicatorEffects={fade:false,appear:false};this.options=Object.extend({beforeOpen:Prototype.emptyFunction,afterOpen:Prototype.emptyFunction,beforeClose:Prototype.emptyFunction,afterClose:Prototype.emptyFunction,height:null,width:null,className:false,position:'center',offsetLeft:0,offsetTop:0,iframe:false,hover:false,indicator:false,closeOnClick:false,iframeshim:true,fade:false,fadeDuration:0.75,draggable:false,onDrag:Prototype.emptyFunction,resizable:false,minHeight:false,minWidth:false,maxHeight:false,maxWidth:false,onResize:Prototype.emptyFunction,constrainToViewport:false,parameters:{},onComplete:Prototype.emptyFunction,onSuccess:Prototype.emptyFunction,onFailure:Prototype.emptyFunction,onException:Prototype.emptyFunction,onRemoteContentLoaded:Prototype.emptyFunction,insertRemoteContentAt:false},options||{});this.indicator=this.options.indicator?$(this.options.indicator):false;if(container){if(typeof(container)=="string"&&container.match(Control.Window.uriRegex))
this.href=container;else{this.container=$(container);this.createDefaultContainer(container);if(this.container&&((this.container.readAttribute('href')&&this.container.readAttribute('href')!='')||(this.options.hover&&this.options.hover!==true))){if(this.options.hover&&this.options.hover!==true)
this.sourceContainer=$(this.options.hover);else{this.sourceContainer=this.container;this.href=this.container.readAttribute('href');var rel=this.href.match(/^#(.+)$/);if(rel&&rel[1]){this.container=$(rel[1]);this.href=false;}else
this.container=false;}
this.sourceContainerOpenHandler=function(event){this.open(event);event.stop();return false;}.bindAsEventListener(this);this.sourceContainerCloseHandler=function(event){this.close(event);}.bindAsEventListener(this);this.sourceContainerMouseMoveHandler=function(event){this.position(event);}.bindAsEventListener(this);if(this.options.hover){this.sourceContainer.observe('mouseenter',this.sourceContainerOpenHandler);this.sourceContainer.observe('mouseleave',this.sourceContainerCloseHandler);if(this.options.position=='mouse')
this.sourceContainer.observe('mousemove',this.sourceContainerMouseMoveHandler);}else
this.sourceContainer.observe('click',this.sourceContainerOpenHandler);}}}
this.createDefaultContainer(container);if(this.options.insertRemoteContentAt===false)
this.options.insertRemoteContentAt=this.container;var styles={margin:0,position:'absolute',zIndex:Control.Window.initialZIndexForWindow()};if(this.options.width)
styles.width=$value(this.options.width)+'px';if(this.options.height)
styles.height=$value(this.options.height)+'px';this.container.setStyle(styles);if(this.options.className)
this.container.addClassName(this.options.className);this.positionHandler=this.position.bindAsEventListener(this);this.outOfBoundsPositionHandler=this.ensureInBounds.bindAsEventListener(this);this.bringToFrontHandler=this.bringToFront.bindAsEventListener(this);this.container.observe('mousedown',this.bringToFrontHandler);this.container.hide();this.closeHandler=this.close.bindAsEventListener(this);if(this.options.iframeshim){this.iFrameShim=new IframeShim();this.iFrameShim.hide();}
this.applyResizable();this.applyDraggable();Event.observe(window,'resize',this.outOfBoundsPositionHandler);this.notify('afterInitialize');},open:function(event){if(this.isOpen){this.bringToFront();return false;}
if(this.notify('beforeOpen')===false)
return false;if(this.options.closeOnClick){if(this.options.closeOnClick===true)
this.closeOnClickContainer=$(document.body);else if(this.options.closeOnClick=='container')
this.closeOnClickContainer=this.container;else if(this.options.closeOnClick=='overlay'){Control.Overlay.load();this.closeOnClickContainer=Control.Overlay.container;}else
this.closeOnClickContainer=$(this.options.closeOnClick);this.closeOnClickContainer.observe('click',this.closeHandler);}
if(this.href&&!this.options.iframe&&!this.remoteContentLoaded){this.remoteContentLoaded=true;if(this.href.match(/\.(jpe?g|gif|png|tiff?)$/i)){var img=new Element('img');img.observe('load',function(img){this.getRemoteContentInsertionTarget().insert(img);this.position();if(this.notify('onRemoteContentLoaded')!==false){if(this.options.indicator)
this.hideIndicator();this.finishOpen();}}.bind(this,img));img.writeAttribute('src',this.href);}else{if(!this.ajaxRequest){if(this.options.indicator)
this.showIndicator();this.ajaxRequest=new Ajax.Request(this.href,{method:'post',parameters:this.options.parameters,onComplete:function(request){this.notify('onComplete',request);this.ajaxRequest=false;}.bind(this),onSuccess:function(request){this.getRemoteContentInsertionTarget().insert(request.responseText);this.notify('onSuccess',request);if(this.notify('onRemoteContentLoaded')!==false){if(this.options.indicator)
this.hideIndicator();this.finishOpen();}}.bind(this),onFailure:function(request){this.notify('onFailure',request);if(this.options.indicator)
this.hideIndicator();}.bind(this),onException:function(request,e){this.notify('onException',request,e);if(this.options.indicator)
this.hideIndicator();}.bind(this)});}}
return true;}else if(this.options.iframe&&!this.remoteContentLoaded){this.remoteContentLoaded=true;if(this.options.indicator)
this.showIndicator();this.getRemoteContentInsertionTarget().insert(Control.Window.iframeTemplate.evaluate({href:this.href}));var iframe=this.container.down('iframe');iframe.onload=function(){this.notify('onRemoteContentLoaded');if(this.options.indicator)
this.hideIndicator();iframe.onload=null;}.bind(this);}
this.finishOpen(event);return true},close:function(event){if(!this.isOpen||this.notify('beforeClose',event)===false)
return false;if(this.options.closeOnClick)
this.closeOnClickContainer.stopObserving('click',this.closeHandler);if(this.options.fade){this.effects.fade=new Effect.Fade(this.container,{queue:{position:'front',scope:'Control.Window'+this.numberInSequence},from:1,to:0,duration:this.options.fadeDuration/2,afterFinish:function(){if(this.iFrameShim)
this.iFrameShim.hide();this.isOpen=false;this.notify('afterClose');}.bind(this)});}else{this.container.hide();if(this.iFrameShim)
this.iFrameShim.hide();}
if(this.ajaxRequest)
this.ajaxRequest.transport.abort();if(!(this.options.draggable||this.options.resizable)&&this.options.position=='center')
Event.stopObserving(window,'resize',this.positionHandler);if(!this.options.draggable&&this.options.position=='center')
Event.stopObserving(window,'scroll',this.positionHandler);if(this.options.indicator)
this.hideIndicator();if(!this.options.fade){this.isOpen=false;this.notify('afterClose');}
return true;},position:function(event){if(this.options.position=='mouse'){var xy=[Event.pointerX(event),Event.pointerY(event)];this.container.setStyle({top:xy[1]+$value(this.options.offsetTop)+'px',left:xy[0]+$value(this.options.offsetLeft)+'px'});return;}
var container_dimensions=this.container.getDimensions();var viewport_dimensions=document.viewport.getDimensions();Position.prepare();var offset_left=(Position.deltaX+Math.floor((viewport_dimensions.width-container_dimensions.width)/2));var offset_top=(Position.deltaY+((viewport_dimensions.height>container_dimensions.height)?Math.floor((viewport_dimensions.height-container_dimensions.height)/2):0));if(this.options.position=='center'){this.container.setStyle({top:(container_dimensions.height<=viewport_dimensions.height)?((offset_top!=null&&offset_top>0)?offset_top:0)+'px':0,left:(container_dimensions.width<=viewport_dimensions.width)?((offset_left!=null&&offset_left>0)?offset_left:0)+'px':0});}else if(this.options.position=='relative'){var xy=this.sourceContainer.cumulativeOffset();var top=xy[1]+$value(this.options.offsetTop);var left=xy[0]+$value(this.options.offsetLeft);this.container.setStyle({top:(container_dimensions.height<=viewport_dimensions.height)?(this.options.constrainToViewport?Math.max(0,Math.min(viewport_dimensions.height-(container_dimensions.height),top)):top)+'px':0,left:(container_dimensions.width<=viewport_dimensions.width)?(this.options.constrainToViewport?Math.max(0,Math.min(viewport_dimensions.width-(container_dimensions.width),left)):left)+'px':0});}else if(this.options.position.length){var top=$value(this.options.position[1])+$value(this.options.offsetTop);var left=$value(this.options.position[0])+$value(this.options.offsetLeft);this.container.setStyle({top:(container_dimensions.height<=viewport_dimensions.height)?(this.options.constrainToViewport?Math.max(0,Math.min(viewport_dimensions.height-(container_dimensions.height),top)):top)+'px':0,left:(container_dimensions.width<=viewport_dimensions.width)?(this.options.constrainToViewport?Math.max(0,Math.min(viewport_dimensions.width-(container_dimensions.width),left)):left)+'px':0});}
if(this.iFrameShim)
this.updateIFrameShimZIndex();},ensureInBounds:function(){if(!this.isOpen)
return;var viewport_dimensions=document.viewport.getDimensions();var container_offset=this.container.cumulativeOffset();var container_dimensions=this.container.getDimensions();if(container_offset.left+container_dimensions.width>viewport_dimensions.width){this.container.setStyle({left:(Math.max(0,viewport_dimensions.width-container_dimensions.width))+'px'});}
if(container_offset.top+container_dimensions.height>viewport_dimensions.height){this.container.setStyle({top:(Math.max(0,viewport_dimensions.height-container_dimensions.height))+'px'});}},bringToFront:function(){Control.Window.bringToFront(this);this.notify('bringToFront');},destroy:function(){this.container.stopObserving('mousedown',this.bringToFrontHandler);if(this.draggable){Resizables.removeObserver(this.container);this.draggable.handle.stopObserving('mousedown',this.bringToFrontHandler);this.draggable.destroy();}
if(this.resizable){Resizables.removeObserver(this.container);this.resizable.handle.stopObserving('mousedown',this.bringToFrontHandler);this.resizable.destroy();}
if(this.container&&!this.sourceContainer)
this.container.remove();if(this.sourceContainer){if(this.options.hover){this.sourceContainer.stopObserving('mouseenter',this.sourceContainerOpenHandler);this.sourceContainer.stopObserving('mouseleave',this.sourceContainerCloseHandler);if(this.options.position=='mouse')
this.sourceContainer.stopObserving('mousemove',this.sourceContainerMouseMoveHandler);}else
this.sourceContainer.stopObserving('click',this.sourceContainerOpenHandler);}
if(this.iFrameShim)
this.iFrameShim.destroy();Event.stopObserving(window,'resize',this.outOfBoundsPositionHandler);Control.Window.windows=Control.Window.windows.without(this);this.notify('afterDestroy');},applyResizable:function(){if(this.options.resizable){if(typeof(Resizable)=="undefined")
throw"Control.Window requires resizable.js to be loaded.";var resizable_handle=null;if(this.options.resizable===true){resizable_handle=new Element('div',{className:'resizable_handle'});this.container.insert(resizable_handle);}else
resizable_handle=$(this.options.resziable);this.resizable=new Resizable(this.container,{handle:resizable_handle,minHeight:this.options.minHeight,minWidth:this.options.minWidth,maxHeight:this.options.constrainToViewport?function(element){return(document.viewport.getDimensions().height-parseInt(element.style.top||0))-(element.getHeight()-parseInt(element.style.height||0));}:this.options.maxHeight,maxWidth:this.options.constrainToViewport?function(element){return(document.viewport.getDimensions().width-parseInt(element.style.left||0))-(element.getWidth()-parseInt(element.style.width||0));}:this.options.maxWidth});this.resizable.handle.observe('mousedown',this.bringToFrontHandler);Resizables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){if(this.iFrameShim)
this.updateIFrameShimZIndex();this.notify('onResize');}.bind(this)));}},applyDraggable:function(){if(this.options.draggable){if(typeof(Draggables)=="undefined")
throw"Control.Window requires dragdrop.js to be loaded.";var draggable_handle=null;if(this.options.draggable===true){draggable_handle=new Element('div',{className:'draggable_handle'});this.container.insert(draggable_handle);}else
draggable_handle=$(this.options.draggable);this.draggable=new Draggable(this.container,{handle:draggable_handle,constrainToViewport:this.options.constrainToViewport,zindex:this.container.getStyle('z-index'),starteffect:function(){if(Prototype.Browser.IE){this.old_onselectstart=document.onselectstart;document.onselectstart=function(){return false;};}}.bind(this),endeffect:function(){document.onselectstart=this.old_onselectstart;}.bind(this)});this.draggable.handle.observe('mousedown',this.bringToFrontHandler);Draggables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){if(this.iFrameShim)
this.updateIFrameShimZIndex();this.notify('onDrag');}.bind(this)));}},createDefaultContainer:function(container){if(!this.container){this.container=new Element('div',{id:'control_window_'+this.numberInSequence});$(document.body).insert(this.container);if(typeof(container)=="string"&&$(container)==null&&!container.match(/^#(.+)$/)&&!container.match(Control.Window.uriRegex))
this.container.update(container);}},finishOpen:function(event){this.bringToFront();if(this.options.fade){if(typeof(Effect)=="undefined")
throw"Control.Window requires effects.js to be loaded."
if(this.effects.fade)
this.effects.fade.cancel();this.effects.appear=new Effect.Appear(this.container,{queue:{position:'end',scope:'Control.Window.'+this.numberInSequence},from:0,to:1,duration:this.options.fadeDuration/2,afterFinish:function(){if(this.iFrameShim)
this.updateIFrameShimZIndex();this.isOpen=true;this.notify('afterOpen');}.bind(this)});}else
this.container.show();this.position(event);if(!(this.options.draggable||this.options.resizable)&&this.options.position=='center')
Event.observe(window,'resize',this.positionHandler,false);if(!this.options.draggable&&this.options.position=='center')
Event.observe(window,'scroll',this.positionHandler,false);if(!this.options.fade){this.isOpen=true;this.notify('afterOpen');}
return true;},showIndicator:function(){this.showIndicatorTimeout=window.setTimeout(function(){if(this.options.fade){this.indicatorEffects.appear=new Effect.Appear(this.indicator,{queue:{position:'front',scope:'Control.Window.indicator.'+this.numberInSequence},from:0,to:1,duration:this.options.fadeDuration/2});}else
this.indicator.show();}.bind(this),Control.Window.indicatorTimeout);},hideIndicator:function(){if(this.showIndicatorTimeout)
window.clearTimeout(this.showIndicatorTimeout);this.indicator.hide();},getRemoteContentInsertionTarget:function(){return typeof(this.options.insertRemoteContentAt)=="string"?this.container.down(this.options.insertRemoteContentAt):$(this.options.insertRemoteContentAt);},updateIFrameShimZIndex:function(){if(this.iFrameShim)
this.iFrameShim.positionUnder(this.container);}});Object.extend(Control.Window,{windows:[],baseZIndex:9999,indicatorTimeout:250,iframeTemplate:new Template('<iframe src="#{href}" width="100%" height="100%" frameborder="0"></iframe>'),uriRegex:/^(\/|\#|https?\:\/\/|[\w]+\/)/,bringToFront:function(w){Control.Window.windows=Control.Window.windows.without(w);Control.Window.windows.push(w);Control.Window.windows.each(function(w,i){var z_index=Control.Window.baseZIndex+i;w.container.setStyle({zIndex:z_index});if(w.isOpen){if(w.iFrameShim)
w.updateIFrameShimZIndex();}
if(w.options.draggable)
w.draggable.options.zindex=z_index;});},open:function(container,options){var w=new Control.Window(container,options);w.open();return w;},initialZIndexForWindow:function(w){return Control.Window.baseZIndex+(Control.Window.windows.length-1);}});Object.Event.extend(Control.Window);Control.Window.LayoutUpdateObserver=Class.create({initialize:function(w,observer){this.w=w;this.element=$(w.container);this.observer=observer;},onStart:Prototype.emptyFunction,onEnd:function(event_name,instance){if(instance.element==this.element&&this.iFrameShim)
this.w.updateIFrameShimZIndex();},onResize:function(event_name,instance){if(instance.element==this.element)
this.observer(this.element);},onDrag:function(event_name,instance){if(instance.element==this.element)
this.observer(this.element);}});Control.Overlay={id:'control_overlay',loaded:false,container:false,lastOpacity:0,styles:{position:'fixed',top:0,left:0,width:'100%',height:'100%',zIndex:9998},ieStyles:{position:'absolute',top:0,left:0,zIndex:9998},effects:{fade:false,appear:false},load:function(){if(Control.Overlay.loaded)
return false;Control.Overlay.loaded=true;Control.Overlay.container=new Element('div',{id:Control.Overlay.id});$(document.body).insert(Control.Overlay.container);if(Prototype.Browser.IE){Control.Overlay.container.setStyle(Control.Overlay.ieStyles);Event.observe(window,'scroll',Control.Overlay.positionOverlay);Event.observe(window,'resize',Control.Overlay.positionOverlay);Control.Overlay.observe('beforeShow',Control.Overlay.positionOverlay);}else
Control.Overlay.container.setStyle(Control.Overlay.styles);Control.Overlay.iFrameShim=new IframeShim();Control.Overlay.iFrameShim.hide();Event.observe(window,'resize',Control.Overlay.positionIFrameShim);Control.Overlay.container.hide();return true;},unload:function(){if(!Control.Overlay.loaded)
return false;Event.stopObserving(window,'resize',Control.Overlay.positionOverlay);Control.Overlay.stopObserving('beforeShow',Control.Overlay.positionOverlay);Event.stopObserving(window,'resize',Control.Overlay.positionIFrameShim);Control.Overlay.iFrameShim.destroy();Control.Overlay.container.remove();Control.Overlay.loaded=false;return true;},show:function(opacity,fade){if(Control.Overlay.notify('beforeShow')===false)
return false;Control.Overlay.lastOpacity=opacity;Control.Overlay.positionIFrameShim();Control.Overlay.iFrameShim.show();if(fade){if(typeof(Effect)=="undefined")
throw"Control.Window requires effects.js to be loaded."
if(Control.Overlay.effects.fade)
Control.Overlay.effects.fade.cancel();Control.Overlay.effects.appear=new Effect.Appear(Control.Overlay.container,{queue:{position:'end',scope:'Control.Overlay'},afterFinish:function(){Control.Overlay.notify('afterShow');},from:0,to:Control.Overlay.lastOpacity,duration:(fade===true?0.75:fade)/2});}else{Control.Overlay.container.setStyle({opacity:opacity||1});Control.Overlay.container.show();Control.Overlay.notify('afterShow');}
return true;},hide:function(fade){if(Control.Overlay.notify('beforeHide')===false)
return false;if(Control.Overlay.effects.appear)
Control.Overlay.effects.appear.cancel();Control.Overlay.iFrameShim.hide();if(fade){Control.Overlay.effects.fade=new Effect.Fade(Control.Overlay.container,{queue:{position:'front',scope:'Control.Overlay'},afterFinish:function(){Control.Overlay.notify('afterHide');},from:Control.Overlay.lastOpacity,to:0,duration:(fade===true?0.75:fade)/2});}else{Control.Overlay.container.hide();Control.Overlay.notify('afterHide');}
return true;},positionIFrameShim:function(){if(Control.Overlay.container.visible())
Control.Overlay.iFrameShim.positionUnder(Control.Overlay.container);},positionOverlay:function(){var dimensions=document.viewport.getDimensions();Control.Overlay.container.setStyle({width:dimensions.width+'px',height:dimensions.height+'px'});}};Object.Event.extend(Control.Overlay);Control.ToolTip=Class.create(Control.Window,{initialize:function($super,container,tooltip,options){$super(tooltip,Object.extend(Object.extend(Control.ToolTip.defaultOptions,options||{}),{position:'mouse',hover:container}));}});Object.extend(Control.ToolTip,{defaultOptions:{offsetLeft:10}});Control.Modal=Class.create(Control.Window,{initialize:function($super,container,options){Control.Modal.InstanceMethods.beforeInitialize.bind(this)();$super(container,Object.extend(Control.Modal.defaultOptions,options||{}));}});Object.extend(Control.Modal,{defaultOptions:{overlayOpacity:0.5,closeOnClick:'overlay'},current:false,open:function(container,options){var modal=new Control.Modal(container,options);modal.open();return modal;},close:function(){if(Control.Modal.current)
Control.Modal.current.close();},InstanceMethods:{beforeInitialize:function(){Control.Overlay.load();this.overlayFinishedOpening=false;this.observe('beforeOpen',Control.Modal.Observers.beforeOpen.bind(this));this.observe('afterOpen',Control.Modal.Observers.afterOpen.bind(this));this.observe('afterClose',Control.Modal.Observers.afterClose.bind(this));}},Observers:{beforeOpen:function(){if(!this.overlayFinishedOpening){Control.Overlay.observeOnce('afterShow',function(){this.overlayFinishedOpening=true;this.open();}.bind(this));Control.Overlay.show(this.options.overlayOpacity,this.options.fade?this.options.fadeDuration:false);throw $break;}else
Control.Window.windows.without(this).invoke('close');},afterOpen:function(){Control.Modal.current=this;},afterClose:function(){Control.Overlay.hide(this.options.fade?this.options.fadeDuration:false);Control.Modal.current=false;this.overlayFinishedOpening=false;}}});Control.LightBox=Class.create(Control.Window,{initialize:function($super,container,options){this.allImagesLoaded=false;if(options.modal){var options=Object.extend(Control.LightBox.defaultOptions,options||{});options=Object.extend(Control.Modal.defaultOptions,options);options=Control.Modal.InstanceMethods.beforeInitialize.bind(this)(options);$super(container,options);}else
$super(container,Object.extend(Control.LightBox.defaultOptions,options||{}));this.hasRemoteContent=this.href&&!this.options.iframe;if(this.hasRemoteContent)
this.observe('onRemoteContentLoaded',Control.LightBox.Observers.onRemoteContentLoaded.bind(this));else
this.applyImageObservers();this.observe('beforeOpen',Control.LightBox.Observers.beforeOpen.bind(this));},applyImageObservers:function(){var images=this.getImages();this.numberImagesToLoad=images.length;this.numberofImagesLoaded=0;images.each(function(image){image.observe('load',function(image){++this.numberofImagesLoaded;if(this.numberImagesToLoad==this.numberofImagesLoaded){this.allImagesLoaded=true;this.onAllImagesLoaded();}}.bind(this,image));image.hide();}.bind(this));},onAllImagesLoaded:function(){this.getImages().each(function(image){this.showImage(image);}.bind(this));if(this.hasRemoteContent){if(this.options.indicator)
this.hideIndicator();this.finishOpen();}else
this.open();},getImages:function(){return this.container.select(Control.LightBox.imageSelector);},showImage:function(image){image.show();}});Object.extend(Control.LightBox,{imageSelector:'img',defaultOptions:{},Observers:{beforeOpen:function(){if(!this.hasRemoteContent&&!this.allImagesLoaded)
throw $break;},onRemoteContentLoaded:function(){this.applyImageObservers();if(!this.allImagesLoaded)
throw $break;}}});if(typeof(Prototype)=="undefined")
throw"Control.Tabs requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.Tabs requires Object.Event to be loaded.";Control.Tabs=Class.create({initialize:function(tab_list_container,options){if(!$(tab_list_container))
throw"Control.Tabs could not find the element: "+tab_list_container;this.activeContainer=false;this.activeLink=false;this.containers=$H({});this.links=[];Control.Tabs.instances.push(this);this.options={beforeChange:Prototype.emptyFunction,afterChange:Prototype.emptyFunction,hover:false,linkSelector:'li a',setClassOnContainer:false,activeClassName:'active',defaultTab:'first',autoLinkExternal:true,targetRegExp:/#(.+)$/,showFunction:Element.show,hideFunction:Element.hide};Object.extend(this.options,options||{});(typeof(this.options.linkSelector=='string')?$(tab_list_container).select(this.options.linkSelector):this.options.linkSelector($(tab_list_container))).findAll(function(link){return(/^#/).exec(link.href.replace(window.location.href.split('#')[0],''));}).each(function(link){this.addTab(link);}.bind(this));this.containers.values().each(Element.hide);if(this.options.defaultTab=='first')
this.setActiveTab(this.links.first());else if(this.options.defaultTab=='last')
this.setActiveTab(this.links.last());else
this.setActiveTab(this.options.defaultTab);var targets=this.options.targetRegExp.exec(window.location);if(targets&&targets[1]){targets[1].split(',').each(function(target){this.setActiveTab(this.links.find(function(link){return link.key==target;}));}.bind(this));}
if(this.options.autoLinkExternal){$A(document.getElementsByTagName('a')).each(function(a){if(!this.links.include(a)){var clean_href=a.href.replace(window.location.href.split('#')[0],'');if(clean_href.substring(0,1)=='#'){if(this.containers.keys().include(clean_href.substring(1))){$(a).observe('click',function(event,clean_href){this.setActiveTab(clean_href.substring(1));}.bindAsEventListener(this,clean_href));}}}}.bind(this));}},addTab:function(link){this.links.push(link);link.key=link.getAttribute('href').replace(window.location.href.split('#')[0],'').split('/').last().replace(/#/,'');var container=$(link.key);if(!container)
throw"Control.Tabs: #"+link.key+" was not found on the page."
this.containers.set(link.key,container);link[this.options.hover?'onmouseover':'onclick']=function(link){if(window.event)
Event.stop(window.event);this.setActiveTab(link);return false;}.bind(this,link);},setActiveTab:function(link){if(!link)
return;if(typeof(link)=='string'){this.setActiveTab(this.links.find(function(_link){return _link.key==link;}));}else{if(this.notify('beforeChange',this.activeContainer,this.containers.get(link.key))===false)
return;if(this.activeContainer)
this.options.hideFunction(this.activeContainer);this.links.each(function(item){(this.options.setClassOnContainer?$(item.parentNode):item).removeClassName(this.options.activeClassName);}.bind(this));(this.options.setClassOnContainer?$(link.parentNode):link).addClassName(this.options.activeClassName);this.activeContainer=this.containers.get(link.key);this.activeLink=link;this.options.showFunction(this.containers.get(link.key));this.notify('afterChange',this.containers.get(link.key));}},next:function(){this.links.each(function(link,i){if(this.activeLink==link&&this.links[i+1]){this.setActiveTab(this.links[i+1]);throw $break;}}.bind(this));},previous:function(){this.links.each(function(link,i){if(this.activeLink==link&&this.links[i-1]){this.setActiveTab(this.links[i-1]);throw $break;}}.bind(this));},first:function(){this.setActiveTab(this.links.first());},last:function(){this.setActiveTab(this.links.last());}});Object.extend(Control.Tabs,{instances:[],findByTabId:function(id){return Control.Tabs.instances.find(function(tab){return tab.links.find(function(link){return link.key==id;});});}});Object.Event.extend(Control.Tabs);if(typeof(Prototype)=="undefined")
throw"HotKey requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"HotKey requires Object.Event to be loaded.";var HotKey=Class.create({initialize:function(letter,callback,options){letter=letter.toUpperCase();HotKey.hotkeys.push(this);this.options=Object.extend({element:false,shiftKey:false,altKey:false,ctrlKey:true},options||{});this.letter=letter;this.callback=callback;this.element=$(this.options.element||document);this.handler=function(event){if(!event||((Event['KEY_'+this.letter]||this.letter.charCodeAt(0))==event.keyCode&&((!this.options.shiftKey||(this.options.shiftKey&&event.shiftKey))&&(!this.options.altKey||(this.options.altKey&&event.altKey))&&(!this.options.ctrlKey||(this.options.ctrlKey&&event.ctrlKey))))){if(this.notify('beforeCallback',event)===false)
return;this.callback(event);this.notify('afterCallback',event);}}.bind(this);this.enable();},trigger:function(){this.handler();},enable:function(){this.element.observe('keydown',this.handler);},disable:function(){this.element.stopObserving('keydown',this.handler);},destroy:function(){this.disable();HotKey.hotkeys=Control.HotKey.hotkeys.without(this);}});Object.extend(HotKey,{hotkeys:[]});Object.Event.extend(HotKey);if(typeof(Prototype)=="undefined")
throw"Control.TextArea requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.TextArea requires Object.Event to be loaded.";Control.TextArea=Class.create({initialize:function(textarea){this.onChangeTimeout=false;this.element=$(textarea);$(this.element).observe('keyup',this.doOnChange.bindAsEventListener(this));$(this.element).observe('paste',this.doOnChange.bindAsEventListener(this));$(this.element).observe('input',this.doOnChange.bindAsEventListener(this));if(!!document.selection){$(this.element).observe('mouseup',this.saveRange.bindAsEventListener(this));$(this.element).observe('keyup',this.saveRange.bindAsEventListener(this));}},doOnChange:function(event){if(this.onChangeTimeout)
window.clearTimeout(this.onChangeTimeout);this.onChangeTimeout=window.setTimeout(function(){this.notify('change',this.getValue());}.bind(this),Control.TextArea.onChangeTimeoutLength);},saveRange:function(){this.range=document.selection.createRange();},getValue:function(){return this.element.value;},getSelection:function(){if(!!document.selection)
return document.selection.createRange().text;else if(!!this.element.setSelectionRange)
return this.element.value.substring(this.element.selectionStart,this.element.selectionEnd);else
return false;},replaceSelection:function(text){var scroll_top=this.element.scrollTop;if(!!document.selection){this.element.focus();var range=(this.range)?this.range:document.selection.createRange();range.text=text;range.select();}else if(!!this.element.setSelectionRange){var selection_start=this.element.selectionStart;this.element.value=this.element.value.substring(0,selection_start)+text+this.element.value.substring(this.element.selectionEnd);this.element.setSelectionRange(selection_start+text.length,selection_start+text.length);}
this.doOnChange();this.element.focus();this.element.scrollTop=scroll_top;},wrapSelection:function(before,after){this.replaceSelection(before+this.getSelection()+after);},insertBeforeSelection:function(text){this.replaceSelection(text+this.getSelection());},insertAfterSelection:function(text){this.replaceSelection(this.getSelection()+text);},collectFromEachSelectedLine:function(callback,before,after){this.replaceSelection((before||'')+$A(this.getSelection().split("\n")).collect(callback).join("\n")+(after||''));},insertBeforeEachSelectedLine:function(text,before,after){this.collectFromEachSelectedLine(function(line){},before,after);}});Object.extend(Control.TextArea,{onChangeTimeoutLength:500});Object.Event.extend(Control.TextArea);Control.TextArea.ToolBar=Class.create({initialize:function(textarea,toolbar){this.textarea=textarea;if(toolbar)
this.container=$(toolbar);else{this.container=$(document.createElement('ul'));this.textarea.element.parentNode.insertBefore(this.container,this.textarea.element);}},attachButton:function(node,callback){node.onclick=function(){return false;}
$(node).observe('click',callback.bindAsEventListener(this.textarea));},addButton:function(link_text,callback,attrs){var li=document.createElement('li');var a=document.createElement('a');a.href='#';this.attachButton(a,callback);li.appendChild(a);Object.extend(a,attrs||{});if(link_text){var span=document.createElement('span');span.innerHTML=link_text;a.appendChild(span);}
this.container.appendChild(li);}});if(typeof Effect=='undefined')
throw("controls.js requires including script.aculo.us' effects.js library");var Autocompleter={}
Autocompleter.Base=function(){};Autocompleter.Base.prototype={baseInitialize:function(element,update,options){this.element=$(element);this.update=$(update);this.hasFocus=false;this.changed=false;this.active=false;this.index=0;this.entryCount=0;if(this.setOptions)
this.setOptions(options);else
this.options=options||{};this.options.paramName=this.options.paramName||this.element.name;this.options.tokens=this.options.tokens||[];this.options.frequency=this.options.frequency||0.4;this.options.minChars=this.options.minChars||1;this.options.onShow=this.options.onShow||function(element,update){if(!update.style.position||update.style.position=='absolute'){update.style.position='absolute';Position.clone(element,update,{setHeight:false,offsetTop:element.offsetHeight});}
Effect.Appear(update,{duration:0.15});};this.options.onHide=this.options.onHide||function(element,update){new Effect.Fade(update,{duration:0.15})};if(typeof(this.options.tokens)=='string')
this.options.tokens=new Array(this.options.tokens);this.observer=null;this.element.setAttribute('autocomplete','off');Element.hide(this.update);Event.observe(this.element,"blur",this.onBlur.bindAsEventListener(this));Event.observe(this.element,"keypress",this.onKeyPress.bindAsEventListener(this));},show:function(){if(Element.getStyle(this.update,'display')=='none')this.options.onShow(this.element,this.update);if(!this.iefix&&(navigator.appVersion.indexOf('MSIE')>0)&&(navigator.userAgent.indexOf('Opera')<0)&&(Element.getStyle(this.update,'position')=='absolute')){new Insertion.After(this.update,'<iframe id="'+this.update.id+'_iefix" '+'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" '+'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');this.iefix=$(this.update.id+'_iefix');}
if(this.iefix)setTimeout(this.fixIEOverlapping.bind(this),50);},fixIEOverlapping:function(){Position.clone(this.update,this.iefix,{setTop:(!this.update.style.height)});this.iefix.style.zIndex=1;this.update.style.zIndex=2;Element.show(this.iefix);},hide:function(){this.stopIndicator();if(Element.getStyle(this.update,'display')!='none')this.options.onHide(this.element,this.update);if(this.iefix)Element.hide(this.iefix);},startIndicator:function(){if(this.options.indicator)Element.show(this.options.indicator);},stopIndicator:function(){if(this.options.indicator)Element.hide(this.options.indicator);},onKeyPress:function(event){if(this.active)
switch(event.keyCode){case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();Event.stop(event);case Event.KEY_ESC:this.hide();this.active=false;Event.stop(event);return;case Event.KEY_LEFT:case Event.KEY_RIGHT:return;case Event.KEY_UP:this.markPrevious();this.render();if(navigator.appVersion.indexOf('AppleWebKit')>0)Event.stop(event);return;case Event.KEY_DOWN:this.markNext();this.render();if(navigator.appVersion.indexOf('AppleWebKit')>0)Event.stop(event);return;}
else
if(event.keyCode==Event.KEY_TAB||event.keyCode==Event.KEY_RETURN||(navigator.appVersion.indexOf('AppleWebKit')>0&&event.keyCode==0))return;this.changed=true;this.hasFocus=true;if(this.observer)clearTimeout(this.observer);this.observer=setTimeout(this.onObserverEvent.bind(this),this.options.frequency*1000);},activate:function(){this.changed=false;this.hasFocus=true;this.getUpdatedChoices();},onHover:function(event){var element=Event.findElement(event,'LI');if(this.index!=element.autocompleteIndex)
{this.index=element.autocompleteIndex;this.render();}
Event.stop(event);},onClick:function(event){var element=Event.findElement(event,'LI');this.index=element.autocompleteIndex;this.selectEntry();this.hide();},onBlur:function(event){setTimeout(this.hide.bind(this),250);this.hasFocus=false;this.active=false;},render:function(){if(this.entryCount>0){for(var i=0;i<this.entryCount;i++)
this.index==i?Element.addClassName(this.getEntry(i),"selected"):Element.removeClassName(this.getEntry(i),"selected");if(this.hasFocus){this.show();this.active=true;}}else{this.active=false;this.hide();}},markPrevious:function(){if(this.index>0)this.index--
else this.index=this.entryCount-1;this.getEntry(this.index).scrollIntoView(true);},markNext:function(){if(this.index<this.entryCount-1)this.index++
else this.index=0;this.getEntry(this.index).scrollIntoView(false);},getEntry:function(index){return this.update.firstChild.childNodes[index];},getCurrentEntry:function(){return this.getEntry(this.index);},selectEntry:function(){this.active=false;this.updateElement(this.getCurrentEntry());},updateElement:function(selectedElement){if(this.options.updateElement){this.options.updateElement(selectedElement);return;}
var value='';if(this.options.select){var nodes=document.getElementsByClassName(this.options.select,selectedElement)||[];if(nodes.length>0)value=Element.collectTextNodes(nodes[0],this.options.select);}else
value=Element.collectTextNodesIgnoreClass(selectedElement,'informal');var lastTokenPos=this.findLastToken();if(lastTokenPos!=-1){var newValue=this.element.value.substr(0,lastTokenPos+1);var whitespace=this.element.value.substr(lastTokenPos+1).match(/^\s+/);if(whitespace)
newValue+=whitespace[0];this.element.value=newValue+value;}else{this.element.value=value;}
this.element.focus();if(this.options.afterUpdateElement)
this.options.afterUpdateElement(this.element,selectedElement);},updateChoices:function(choices){if(!this.changed&&this.hasFocus){this.update.innerHTML=choices;Element.cleanWhitespace(this.update);Element.cleanWhitespace(this.update.down());if(this.update.firstChild&&this.update.down().childNodes){this.entryCount=this.update.down().childNodes.length;for(var i=0;i<this.entryCount;i++){var entry=this.getEntry(i);entry.autocompleteIndex=i;this.addObservers(entry);}}else{this.entryCount=0;}
this.stopIndicator();this.index=0;if(this.entryCount==1&&this.options.autoSelect){this.selectEntry();this.hide();}else{this.render();}}},addObservers:function(element){Event.observe(element,"mouseover",this.onHover.bindAsEventListener(this));Event.observe(element,"click",this.onClick.bindAsEventListener(this));},onObserverEvent:function(){this.changed=false;if(this.getToken().length>=this.options.minChars){this.startIndicator();this.getUpdatedChoices();}else{this.active=false;this.hide();}},getToken:function(){var tokenPos=this.findLastToken();if(tokenPos!=-1)
var ret=this.element.value.substr(tokenPos+1).replace(/^\s+/,'').replace(/\s+$/,'');else
var ret=this.element.value;return/\n/.test(ret)?'':ret;},findLastToken:function(){var lastTokenPos=-1;for(var i=0;i<this.options.tokens.length;i++){var thisTokenPos=this.element.value.lastIndexOf(this.options.tokens[i]);if(thisTokenPos>lastTokenPos)
lastTokenPos=thisTokenPos;}
return lastTokenPos;}}
Ajax.Autocompleter=Class.create();Object.extend(Object.extend(Ajax.Autocompleter.prototype,Autocompleter.Base.prototype),{initialize:function(element,update,url,options){this.baseInitialize(element,update,options);this.options.asynchronous=true;this.options.onComplete=this.onComplete.bind(this);this.options.defaultParams=this.options.parameters||null;this.url=url;},getUpdatedChoices:function(){entry=encodeURIComponent(this.options.paramName)+'='+
encodeURIComponent(this.getToken());this.options.parameters=this.options.callback?this.options.callback(this.element,entry):entry;if(this.options.defaultParams)
this.options.parameters+='&'+this.options.defaultParams;new Ajax.Request(this.url,this.options);},onComplete:function(request){this.updateChoices(request.responseText);}});Autocompleter.Local=Class.create();Autocompleter.Local.prototype=Object.extend(new Autocompleter.Base(),{initialize:function(element,update,array,options){this.baseInitialize(element,update,options);this.options.array=array;},getUpdatedChoices:function(){this.updateChoices(this.options.selector(this));},setOptions:function(options){this.options=Object.extend({choices:10,partialSearch:true,partialChars:2,ignoreCase:true,fullSearch:false,selector:function(instance){var ret=[];var partial=[];var entry=instance.getToken();var count=0;for(var i=0;i<instance.options.array.length&&ret.length<instance.options.choices;i++){var elem=instance.options.array[i];var foundPos=instance.options.ignoreCase?elem.toLowerCase().indexOf(entry.toLowerCase()):elem.indexOf(entry);while(foundPos!=-1){if(foundPos==0&&elem.length!=entry.length){ret.push("<li><strong>"+elem.substr(0,entry.length)+"</strong>"+
elem.substr(entry.length)+"</li>");break;}else if(entry.length>=instance.options.partialChars&&instance.options.partialSearch&&foundPos!=-1){if(instance.options.fullSearch||/\s/.test(elem.substr(foundPos-1,1))){partial.push("<li>"+elem.substr(0,foundPos)+"<strong>"+
elem.substr(foundPos,entry.length)+"</strong>"+elem.substr(foundPos+entry.length)+"</li>");break;}}
foundPos=instance.options.ignoreCase?elem.toLowerCase().indexOf(entry.toLowerCase(),foundPos+1):elem.indexOf(entry,foundPos+1);}}
if(partial.length)
ret=ret.concat(partial.slice(0,instance.options.choices-ret.length))
return"<ul>"+ret.join('')+"</ul>";}},options||{});}});Field.scrollFreeActivate=function(field){setTimeout(function(){Field.activate(field);},1);}
Ajax.InPlaceEditor=Class.create();Ajax.InPlaceEditor.defaultHighlightColor="#FFFF99";Ajax.InPlaceEditor.prototype={initialize:function(element,url,options){this.url=url;this.element=$(element);this.options=Object.extend({paramName:"value",okButton:true,okText:"ok",cancelLink:true,cancelText:"cancel",savingText:"Saving...",clickToEditText:"Click to edit",okText:"ok",rows:1,onComplete:function(transport,element){new Effect.Highlight(element,{startcolor:this.options.highlightcolor});},onFailure:function(transport){alert("Error communicating with the server: "+transport.responseText.stripTags());},callback:function(form){return Form.serialize(form);},handleLineBreaks:true,loadingText:'Loading...',savingClassName:'inplaceeditor-saving',loadingClassName:'inplaceeditor-loading',formClassName:'inplaceeditor-form',highlightcolor:Ajax.InPlaceEditor.defaultHighlightColor,highlightendcolor:"#FFFFFF",externalControl:null,submitOnBlur:false,ajaxOptions:{},evalScripts:false},options||{});if(!this.options.formId&&this.element.id){this.options.formId=this.element.id+"-inplaceeditor";if($(this.options.formId)){this.options.formId=null;}}
if(this.options.externalControl){this.options.externalControl=$(this.options.externalControl);}
this.originalBackground=Element.getStyle(this.element,'background-color');if(!this.originalBackground){this.originalBackground="transparent";}
this.element.title=this.options.clickToEditText;this.onclickListener=this.enterEditMode.bindAsEventListener(this);this.mouseoverListener=this.enterHover.bindAsEventListener(this);this.mouseoutListener=this.leaveHover.bindAsEventListener(this);Event.observe(this.element,'click',this.onclickListener);Event.observe(this.element,'mouseover',this.mouseoverListener);Event.observe(this.element,'mouseout',this.mouseoutListener);if(this.options.externalControl){Event.observe(this.options.externalControl,'click',this.onclickListener);Event.observe(this.options.externalControl,'mouseover',this.mouseoverListener);Event.observe(this.options.externalControl,'mouseout',this.mouseoutListener);}},enterEditMode:function(evt){if(this.saving)return;if(this.editing)return;this.editing=true;this.onEnterEditMode();if(this.options.externalControl){Element.hide(this.options.externalControl);}
Element.hide(this.element);this.createForm();this.element.parentNode.insertBefore(this.form,this.element);if(!this.options.loadTextURL)Field.scrollFreeActivate(this.editField);if(evt){Event.stop(evt);}
return false;},createForm:function(){this.form=document.createElement("form");this.form.id=this.options.formId;Element.addClassName(this.form,this.options.formClassName)
this.form.onsubmit=this.onSubmit.bind(this);this.createEditField();if(this.options.textarea){var br=document.createElement("br");this.form.appendChild(br);}
if(this.options.okButton){okButton=document.createElement("input");okButton.type="submit";okButton.value=this.options.okText;okButton.className='editor_ok_button';this.form.appendChild(okButton);}
if(this.options.cancelLink){cancelLink=document.createElement("a");cancelLink.href="#";cancelLink.appendChild(document.createTextNode(this.options.cancelText));cancelLink.onclick=this.onclickCancel.bind(this);cancelLink.className='editor_cancel';this.form.appendChild(cancelLink);}},hasHTMLLineBreaks:function(string){if(!this.options.handleLineBreaks)return false;return string.match(/<br/i)||string.match(/<p>/i);},convertHTMLLineBreaks:function(string){return string.replace(/<br>/gi,"\n").replace(/<br\/>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<p>/gi,"");},createEditField:function(){var text;if(this.options.loadTextURL){text=this.options.loadingText;}else{text=this.getText();}
var obj=this;if(this.options.rows==1&&!this.hasHTMLLineBreaks(text)){this.options.textarea=false;var textField=document.createElement("input");textField.obj=this;textField.type="text";textField.name=this.options.paramName;textField.value=text;textField.style.backgroundColor=this.options.highlightcolor;textField.className='editor_field';var size=this.options.size||this.options.cols||0;if(size!=0)textField.size=size;if(this.options.submitOnBlur)
textField.onblur=this.onSubmit.bind(this);this.editField=textField;}else{this.options.textarea=true;var textArea=document.createElement("textarea");textArea.obj=this;textArea.name=this.options.paramName;textArea.value=this.convertHTMLLineBreaks(text);textArea.rows=this.options.rows;textArea.cols=this.options.cols||40;textArea.className='editor_field';if(this.options.submitOnBlur)
textArea.onblur=this.onSubmit.bind(this);this.editField=textArea;}
if(this.options.loadTextURL){this.loadExternalText();}
this.form.appendChild(this.editField);},getText:function(){return this.element.innerHTML;},loadExternalText:function(){Element.addClassName(this.form,this.options.loadingClassName);this.editField.disabled=true;new Ajax.Request(this.options.loadTextURL,Object.extend({asynchronous:true,onComplete:this.onLoadedExternalText.bind(this)},this.options.ajaxOptions));},onLoadedExternalText:function(transport){Element.removeClassName(this.form,this.options.loadingClassName);this.editField.disabled=false;this.editField.value=transport.responseText.stripTags();Field.scrollFreeActivate(this.editField);},onclickCancel:function(){this.onComplete();this.leaveEditMode();return false;},onFailure:function(transport){this.options.onFailure(transport);if(this.oldInnerHTML){this.element.innerHTML=this.oldInnerHTML;this.oldInnerHTML=null;}
return false;},onSubmit:function(){var form=this.form;var value=this.editField.value;this.onLoading();if(this.options.evalScripts){new Ajax.Request(this.url,Object.extend({parameters:this.options.callback(form,value),onComplete:this.onComplete.bind(this),onFailure:this.onFailure.bind(this),asynchronous:true,evalScripts:true},this.options.ajaxOptions));}else{new Ajax.Updater({success:this.element,failure:null},this.url,Object.extend({parameters:this.options.callback(form,value),onComplete:this.onComplete.bind(this),onFailure:this.onFailure.bind(this)},this.options.ajaxOptions));}
if(arguments.length>1){Event.stop(arguments[0]);}
return false;},onLoading:function(){this.saving=true;this.removeForm();this.leaveHover();this.showSaving();},showSaving:function(){this.oldInnerHTML=this.element.innerHTML;this.element.innerHTML=this.options.savingText;Element.addClassName(this.element,this.options.savingClassName);this.element.style.backgroundColor=this.originalBackground;Element.show(this.element);},removeForm:function(){if(this.form){if(this.form.parentNode)Element.remove(this.form);this.form=null;}},enterHover:function(){if(this.saving)return;this.element.style.backgroundColor=this.options.highlightcolor;if(this.effect){this.effect.cancel();}
Element.addClassName(this.element,this.options.hoverClassName)},leaveHover:function(){if(this.options.backgroundColor){this.element.style.backgroundColor=this.oldBackground;}
Element.removeClassName(this.element,this.options.hoverClassName)
if(this.saving)return;this.effect=new Effect.Highlight(this.element,{startcolor:this.options.highlightcolor,endcolor:this.options.highlightendcolor,restorecolor:this.originalBackground});},leaveEditMode:function(){Element.removeClassName(this.element,this.options.savingClassName);this.removeForm();this.leaveHover();this.element.style.backgroundColor=this.originalBackground;Element.show(this.element);if(this.options.externalControl){Element.show(this.options.externalControl);}
this.editing=false;this.saving=false;this.oldInnerHTML=null;this.onLeaveEditMode();},onComplete:function(transport){this.leaveEditMode();this.options.onComplete.bind(this)(transport,this.element);},onEnterEditMode:function(){},onLeaveEditMode:function(){},dispose:function(){if(this.oldInnerHTML){this.element.innerHTML=this.oldInnerHTML;}
this.leaveEditMode();Event.stopObserving(this.element,'click',this.onclickListener);Event.stopObserving(this.element,'mouseover',this.mouseoverListener);Event.stopObserving(this.element,'mouseout',this.mouseoutListener);if(this.options.externalControl){Event.stopObserving(this.options.externalControl,'click',this.onclickListener);Event.stopObserving(this.options.externalControl,'mouseover',this.mouseoverListener);Event.stopObserving(this.options.externalControl,'mouseout',this.mouseoutListener);}}};Ajax.InPlaceCollectionEditor=Class.create();Object.extend(Ajax.InPlaceCollectionEditor.prototype,Ajax.InPlaceEditor.prototype);Object.extend(Ajax.InPlaceCollectionEditor.prototype,{createEditField:function(){if(!this.cached_selectTag){var selectTag=document.createElement("select");var collection=this.options.collection||[];var optionTag;collection.each(function(e,i){optionTag=document.createElement("option");optionTag.value=(e instanceof Array)?e[0]:e;if((typeof this.options.value=='undefined')&&((e instanceof Array)?this.element.innerHTML==e[1]:e==optionTag.value))optionTag.selected=true;if(this.options.value==optionTag.value)optionTag.selected=true;optionTag.appendChild(document.createTextNode((e instanceof Array)?e[1]:e));selectTag.appendChild(optionTag);}.bind(this));this.cached_selectTag=selectTag;}
this.editField=this.cached_selectTag;if(this.options.loadTextURL)this.loadExternalText();this.form.appendChild(this.editField);this.options.callback=function(form,value){return"value="+encodeURIComponent(value);}}});Form.Element.DelayedObserver=Class.create();Form.Element.DelayedObserver.prototype={initialize:function(element,delay,callback){this.delay=delay||0.5;this.element=$(element);this.callback=callback;this.timer=null;this.lastValue=$F(this.element);Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));},delayedListener:function(event){if(this.lastValue==$F(this.element))return;if(this.timer)clearTimeout(this.timer);this.timer=setTimeout(this.onTimerEvent.bind(this),this.delay*1000);this.lastValue=$F(this.element);},onTimerEvent:function(){this.timer=null;this.callback(this.element,$F(this.element));}};if(typeof(Prototype)=="undefined")
throw"Control.Rating requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.Rating requires Object.Event to be loaded.";Control.Rating=Class.create({initialize:function(container,options){Control.Rating.instances.push(this);this.value=false;this.links=[];this.container=$(container);this.container.update('');this.options={min:1,max:5,rated:false,input:false,reverse:false,capture:true,multiple:false,classNames:{off:'rating_off',half:'rating_half',on:'rating_on',selected:'rating_selected'},updateUrl:false,updateParameterName:'value',afterChange:Prototype.emptyFunction};Object.extend(this.options,options||{});if(this.options.value){this.value=this.options.value;delete this.options.value;}
if(this.options.input){this.options.input=$(this.options.input);this.options.input.observe('change',function(input){this.setValueFromInput(input);}.bind(this,this.options.input));this.setValueFromInput(this.options.input,true);}
var range=$R(this.options.min,this.options.max);(this.options.reverse?$A(range).reverse():range).each(function(i){var link=this.buildLink(i);this.container.appendChild(link);this.links.push(link);}.bind(this));this.setValue(this.value||this.options.min-1,false,true);},buildLink:function(rating){var link=$(document.createElement('a'));link.value=rating;if(this.options.multiple||(!this.options.rated&&!this.options.multiple)){link.href='';link.onmouseover=this.mouseOver.bind(this,link);link.onmouseout=this.mouseOut.bind(this,link);link.onclick=this.click.bindAsEventListener(this,link);}else{link.style.cursor='default';link.observe('click',function(event){Event.stop(event);return false;}.bindAsEventListener(this));}
link.addClassName(this.options.classNames.off);return link;},disable:function(){this.links.each(function(link){link.onmouseover=Prototype.emptyFunction;link.onmouseout=Prototype.emptyFunction;link.onclick=Prototype.emptyFunction;link.observe('click',function(event){Event.stop(event);return false;}.bindAsEventListener(this));link.style.cursor='default';}.bind(this));},setValueFromInput:function(input,prevent_callbacks){this.setValue((input.options?input.options[input.options.selectedIndex].value:input.value),true,prevent_callbacks);},setValue:function(value,force_selected,prevent_callbacks){this.value=value;if(this.options.input){if(this.options.input.options){$A(this.options.input.options).each(function(option,i){if(option.value==this.value){this.options.input.options.selectedIndex=i;throw $break;}}.bind(this));}else
this.options.input.value=this.value;}
this.render(this.value,force_selected);if(!prevent_callbacks){if(this.options.updateUrl){var params={};params[this.options.updateParameterName]=this.value;new Ajax.Request(this.options.updateUrl,{parameters:params});}
this.notify('afterChange',this.value);}},render:function(rating,force_selected){(this.options.reverse?this.links.reverse():this.links).each(function(link,i){if(link.value<=Math.ceil(rating)){link.className=this.options.classNames[link.value<=rating?'on':'half'];if(this.options.rated||force_selected)
link.addClassName(this.options.classNames.selected);}else
link.className=this.options.classNames.off;}.bind(this));},mouseOver:function(link){this.render(link.value,true);},mouseOut:function(link){this.render(this.value);},click:function(event,link){this.options.rated=true;this.setValue((link.value?link.value:link),true);if(!this.options.multiple)
this.disable();if(this.options.capture){Event.stop(event);return false;}}});Object.extend(Control.Rating,{instances:[],findByElementId:function(id){return Control.Rating.instances.find(function(instance){return(instance.container.id&&instance.container.id==id);});}});Object.Event.extend(Control.Rating);if(typeof(Prototype)=="undefined")
throw"Control.Selection requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.Selection requires Object.Event to be loaded.";Control.Selection={options:{resize_layout_timeout:125,selected:Prototype.emptyFunction,deselected:Prototype.emptyFunction,change:Prototype.emptyFunction,selection_id:'control_selection',selection_style:{zIndex:999,cursor:'default',border:'1px dotted #000'},filter:function(element){return true;},drag_proxy:false,drag_proxy_threshold:1,drag_proxy_options:{}},selectableElements:[],elements:[],selectableObjects:[],objects:[],active:false,container:false,resizeTimeout:false,load:function(options){Control.Selection.options=Object.extend(Control.Selection.options,options||{});Control.Selection.selection_div=$(document.createElement('div'));Control.Selection.selection_div.id=Control.Selection.options.selection_id;Control.Selection.selection_div.style.display='none';Control.Selection.selection_div.setStyle(Control.Selection.options.selection_style);Control.Selection.border_width=parseInt(Control.Selection.selection_div.getStyle('border-top-width'))*2;Control.Selection.container=Prototype.Browser.IE?window.container:window;$(document.body).insert(Control.Selection.selection_div);Control.Selection.enable();if(Control.Selection.options.drag_proxy&&typeof(Draggable)!='undefined')
Control.Selection.DragProxy.load();Event.observe(window,'resize',function(){if(Control.Selection.resizeTimeout)
window.clearTimeout(Control.Selection.resizeTimeout);Control.Selection.resizeTimeout=window.setTimeout(Control.Selection.recalculateLayout,Control.Selection.options.resize_layout_timeout);});if(Prototype.Browser.IE){var body=$$('body').first();body.observe('mouseleave',Control.Selection.stop);body.observe('mouseup',Control.Selection.stop);}},enable:function(){if(Prototype.Browser.IE){document.onselectstart=function(){return false;}}
Event.observe(Control.Selection.container,'mousedown',Control.Selection.start);Event.observe(Control.Selection.container,'mouseup',Control.Selection.stop);},disable:function(){if(Prototype.Browser.IE){document.onselectstart=function(){return true;}}
Event.stopObserving(Control.Selection.container,'mousedown',Control.Selection.start);Event.stopObserving(Control.Selection.container,'mouseup',Control.Selection.stop);},recalculateLayout:function(){Control.Selection.selectableElements.each(function(element){var dimensions=element.getDimensions();var offset=element.cumulativeOffset();var scroll_offset=element.cumulativeScrollOffset();if(!element._control_selection)
element._control_selection={};element._control_selection.top=offset[1]-scroll_offset[1];element._control_selection.left=offset[0]-scroll_offset[0];element._control_selection.width=dimensions.width;element._control_selection.height=dimensions.height;});},addSelectable:function(element,object,activation_targets,activation_target_callback){element=$(element);if(activation_targets)
activation_targets=activation_targets.each?activation_targets:[activation_targets];var dimensions=element.getDimensions();var offset=Position.cumulativeOffset(element);element._control_selection={activation_targets:activation_targets,is_selected:false,top:offset[1],left:offset[0],width:dimensions.width,height:dimensions.height,activationTargetMouseMove:function(){Control.Selection.notify('activationTargetMouseMove',element);if(activation_targets){activation_targets.each(function(activation_target){activation_target.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);});}
Control.Selection.DragProxy.container.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);},activationTargetMouseDown:function(event){if(!Control.Selection.elements.include(element))
Control.Selection.select(element);Control.Selection.DragProxy.start(event);Control.Selection.DragProxy.container.hide();if(activation_targets){activation_targets.each(function(activation_target){activation_target.observe('mousemove',element._control_selection.activationTargetMouseMove);});}
Control.Selection.DragProxy.container.observe('mousemove',element._control_selection.activationTargetMouseMove);},activationTargetClick:function(){Control.Selection.select(element);if(typeof(activation_target_callback)=="function")
activation_target_callback();if(activation_targets){activation_targets.each(function(activation_target){activation_target.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);});}
Control.Selection.DragProxy.container.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);}};element.onselectstart=function(){return false;};element.unselectable='on';element.style.MozUserSelect='none';if(activation_targets){activation_targets.each(function(activation_target){activation_target.observe('mousedown',element._control_selection.activationTargetMouseDown);activation_target.observe('click',element._control_selection.activationTargetClick);});}
Control.Selection.selectableElements.push(element);Control.Selection.selectableObjects.push(object);},removeSelectable:function(element){element=$(element);if(element._control_selection.activation_targets){element._control_selection.activation_targets.each(function(activation_target){activation_target.stopObserving('mousedown',element._control_selection.activationTargetMouseDown);});element._control_selection.activation_targets.each(function(activation_target){activation_target.stopObserving('click',element._control_selection.activationTargetClick);});}
element._control_selection=null;element.onselectstart=function(){return true;};element.unselectable='off';element.style.MozUserSelect='';var position=0;Control.Selection.selectableElements.each(function(selectable_element,i){if(selectable_element==element){position=i;throw $break;}});Control.Selection.selectableElements=Control.Selection.selectableElements.without(element);Control.Selection.selectableObjects=Control.Selection.selectableObjects.slice(0,position).concat(Control.Selection.selectableObjects.slice(position+1))},select:function(selected_elements){if(typeof(selected_elements)=="undefined"||!selected_elements)
selected_elements=[];if(!selected_elements.each&&!selected_elements._each)
selected_elements=[selected_elements];var selected_items_have_changed=!(Control.Selection.elements.length==selected_elements.length&&Control.Selection.elements.all(function(item,i){return selected_elements[i]==item;}));if(!selected_items_have_changed)
return;var selected_objects_indexed_by_element={};var selected_objects=selected_elements.collect(function(selected_element){var selected_object=Control.Selection.selectableObjects[Control.Selection.selectableElements.indexOf(selected_element)];selected_objects_indexed_by_element[selected_element]=selected_object;return selected_object;});if(Control.Selection.elements.length==0&&selected_elements.length!=0){selected_elements.each(function(element){Control.Selection.notify('selected',element,selected_objects_indexed_by_element[element]);});}else{Control.Selection.elements.each(function(element){if(!selected_elements.include(element)){Control.Selection.notify('deselected',element,selected_objects_indexed_by_element[element]);}});selected_elements.each(function(element){if(!Control.Selection.elements.include(element)){Control.Selection.notify('selected',element,selected_objects_indexed_by_element[element]);}});}
Control.Selection.elements=selected_elements;Control.Selection.objects=selected_objects;Control.Selection.notify('change',Control.Selection.elements,Control.Selection.objects);},deselect:function(){if(Control.Selection.notify('deselect')===false)
return false;Control.Selection.elements.each(function(element){Control.Selection.notify('deselected',element,Control.Selection.selectableObjects[Control.Selection.selectableElements.indexOf(element)]);});Control.Selection.objects=[];Control.Selection.elements=[];Control.Selection.notify('change',Control.Selection.objects,Control.Selection.elements);return true;},start:function(event){if(!event.isLeftClick()||Control.Selection.notify('start',event)===false)
return false;if(!event.shiftKey&&!event.altKey)
Control.Selection.deselect();Event.observe(Control.Selection.container,'mousemove',Control.Selection.onMouseMove);Event.stop(event);return false;},stop:function(){Event.stopObserving(Control.Selection.container,'mousemove',Control.Selection.onMouseMove);Control.Selection.active=false;Control.Selection.selection_div.setStyle({display:'none',top:null,left:null,width:null,height:null});Control.Selection.start_mouse_coordinates={};Control.Selection.current_mouse_coordinates={};},mouseCoordinatesFromEvent:function(event){return{x:Event.pointerX(event),y:Event.pointerY(event)};},onClick:function(event,element,source){var selection=[];if(event.shiftKey){selection=Control.Selection.elements.clone();if(!selection.include(element))
selection.push(element);}else if(event.altKey){selection=Control.Selection.elements.clone();if(selection.include(element))
selection=selection.without(element);}else{selection=[element];}
Control.Selection.select(selection);if(source=='click')
Event.stop(event);},onMouseMove:function(event){if(!Control.Selection.active){Control.Selection.active=true;Control.Selection.start_mouse_coordinates=Control.Selection.mouseCoordinatesFromEvent(event);}else{Control.Selection.current_mouse_coordinates=Control.Selection.mouseCoordinatesFromEvent(event);Control.Selection.drawSelectionDiv();var current_selection=Control.Selection.selectableElements.findAll(function(element){return Control.Selection.options.filter(element)&&Control.Selection.elementWithinSelection(element);});if(event.shiftKey&&!event.altKey){Control.Selection.elements.each(function(element){if(!current_selection.include(element))
current_selection.push(element);});}else if(event.altKey&&!event.shiftKey){current_selection=Control.Selection.elements.findAll(function(element){return!current_selection.include(element);});}
Control.Selection.select(current_selection);}},drawSelectionDiv:function(){if(Control.Selection.start_mouse_coordinates==Control.Selection.current_mouse_coordinates){Control.Selection.selection_div.style.display='none';}else{Control.Selection.viewport=document.viewport.getDimensions();Control.Selection.selection_div.style.position='absolute';Control.Selection.current_direction=(Control.Selection.start_mouse_coordinates.y>Control.Selection.current_mouse_coordinates.y?'N':'S')+(Control.Selection.start_mouse_coordinates.x<Control.Selection.current_mouse_coordinates.x?'E':'W');Control.Selection.selection_div.setStyle(Control.Selection['dimensionsFor'+Control.Selection.current_direction]());Control.Selection.selection_div.style.display='block';}},dimensionsForNW:function(){return{top:(Control.Selection.start_mouse_coordinates.y-(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y))+'px',left:(Control.Selection.start_mouse_coordinates.x-(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x))+'px',width:(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x)+'px',height:(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y)+'px'};},dimensionsForNE:function(){return{top:(Control.Selection.start_mouse_coordinates.y-(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y))+'px',left:Control.Selection.start_mouse_coordinates.x+'px',width:Math.min((Control.Selection.viewport.width-Control.Selection.start_mouse_coordinates.x)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.x-Control.Selection.start_mouse_coordinates.x)+'px',height:(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y)+'px'};},dimensionsForSE:function(){return{top:Control.Selection.start_mouse_coordinates.y+'px',left:Control.Selection.start_mouse_coordinates.x+'px',width:Math.min((Control.Selection.viewport.width-Control.Selection.start_mouse_coordinates.x)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.x-Control.Selection.start_mouse_coordinates.x)+'px',height:Math.min((Control.Selection.viewport.height-Control.Selection.start_mouse_coordinates.y)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.y-Control.Selection.start_mouse_coordinates.y)+'px'};},dimensionsForSW:function(){return{top:Control.Selection.start_mouse_coordinates.y+'px',left:(Control.Selection.start_mouse_coordinates.x-(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x))+'px',width:(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x)+'px',height:Math.min((Control.Selection.viewport.height-Control.Selection.start_mouse_coordinates.y)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.y-Control.Selection.start_mouse_coordinates.y)+'px'};},inBoundsForNW:function(element,selection){return(((element.left>selection.left||element.right>selection.left)&&selection.right>element.left)&&((element.top>selection.top||element.bottom>selection.top)&&selection.bottom>element.top));},inBoundsForNE:function(element,selection){return(((element.left<selection.right||element.left<selection.right)&&selection.left<element.right)&&((element.top>selection.top||element.bottom>selection.top)&&selection.bottom>element.top));},inBoundsForSE:function(element,selection){return(((element.left<selection.right||element.left<selection.right)&&selection.left<element.right)&&((element.bottom<selection.bottom||element.top<selection.bottom)&&selection.top<element.bottom));},inBoundsForSW:function(element,selection){return(((element.left>selection.left||element.right>selection.left)&&selection.right>element.left)&&((element.bottom<selection.bottom||element.top<selection.bottom)&&selection.top<element.bottom));},elementWithinSelection:function(element){if(Control.Selection['inBoundsFor'+Control.Selection.current_direction]({top:element._control_selection.top,left:element._control_selection.left,bottom:element._control_selection.top+element._control_selection.height,right:element._control_selection.left+element._control_selection.width},{top:parseInt(Control.Selection.selection_div.style.top),left:parseInt(Control.Selection.selection_div.style.left),bottom:parseInt(Control.Selection.selection_div.style.top)+parseInt(Control.Selection.selection_div.style.height),right:parseInt(Control.Selection.selection_div.style.left)+parseInt(Control.Selection.selection_div.style.width)})){element._control_selection.is_selected=true;return true;}else{element._control_selection.is_selected=false;return false;}},DragProxy:{active:false,xorigin:0,yorigin:0,load:function(){Control.Selection.DragProxy.container=$(document.createElement('div'));Control.Selection.DragProxy.container.id='control_selection_drag_proxy';Control.Selection.DragProxy.container.setStyle({position:'absolute',top:'1px',left:'1px',zIndex:99999});Control.Selection.DragProxy.container.hide();document.body.appendChild(Control.Selection.DragProxy.container);Control.Selection.observe('selected',Control.Selection.DragProxy.selected);Control.Selection.observe('deselected',Control.Selection.DragProxy.deselected);},start:function(event){if(event.isRightClick()){Control.Selection.DragProxy.container.hide();return;}
if(Control.Selection.DragProxy.xorigin==Event.pointerX(event)&&Control.Selection.DragProxy.yorigin==Event.pointerY(event))
return;Control.Selection.DragProxy.active=true;Control.Selection.DragProxy.container.setStyle({position:'absolute',top:Event.pointerY(event)+'px',left:Event.pointerX(event)+'px'});Control.Selection.DragProxy.container.observe('mouseup',Control.Selection.DragProxy.onMouseUp);Control.Selection.DragProxy.container.show();Control.Selection.DragProxy.container._draggable=new Draggable(Control.Selection.DragProxy.container,Object.extend({onEnd:Control.Selection.DragProxy.stop},Control.Selection.options.drag_proxy_options));Control.Selection.DragProxy.container._draggable.eventMouseDown(event);Control.Selection.DragProxy.notify('start',Control.Selection.DragProxy.container,Control.Selection.elements);},stop:function(){window.setTimeout(function(){Control.Selection.DragProxy.active=false;Control.Selection.DragProxy.container.hide();if(Control.Selection.DragProxy.container._draggable){Control.Selection.DragProxy.container._draggable.destroy();Control.Selection.DragProxy.container._draggable=null;}
Control.Selection.DragProxy.notify('stop');},1);},onClick:function(event){Control.Selection.DragProxy.xorigin=Event.pointerX(event);Control.Selection.DragProxy.yorigin=Event.pointerY(event);if(event.isRightClick())
Control.Selection.DragProxy.container.hide();if(Control.Selection.elements.length>=Control.Selection.options.drag_proxy_threshold&&!(event.shiftKey||event.altKey)&&(Control.Selection.DragProxy.xorigin!=Event.pointerX(event)||Control.Selection.DragProxy.yorigin!=Event.pointerY(event))){Control.Selection.DragProxy.start(event);Event.stop(event);}},onMouseUp:function(event){Control.Selection.DragProxy.stop();Control.Selection.DragProxy.container.stopObserving('mouseup',Control.Selection.DragProxy.onMouseUp);},selected:function(element){element.observe('mousedown',Control.Selection.DragProxy.onClick);},deselected:function(element){element.stopObserving('mousedown',Control.Selection.DragProxy.onClick);}}};Object.Event.extend(Control.Selection);Object.Event.extend(Control.Selection.DragProxy);if(typeof(Prototype)=="undefined")
throw"Control.SelectMultiple requires Prototype to be loaded.";if(typeof(Object.Event)=="undefined")
throw"Control.SelectMultiple requires Object.Event to be loaded.";Control.SelectMultiple=Class.create({select:false,container:false,numberOfCheckedBoxes:0,checkboxes:[],hasExtraOption:false,initialize:function(select,container,options){this.options={checkboxSelector:'input[type=checkbox]',nameSelector:'span.name',labelSeparator:', ',valueSeparator:',',afterChange:Prototype.emptyFunction,overflowString:function(str){return str.truncate();},overflowLength:30};Object.extend(this.options,options||{});this.select=$(select);this.container=$(container);this.checkboxes=(typeof(this.options.checkboxSelector)=='function')?this.options.checkboxSelector.bind(this)():this.container.getElementsBySelector(this.options.checkboxSelector);var value_was_set=false;if(this.options.value){value_was_set=true;this.setValue(this.options.value);delete this.options.value;}
this.hasExtraOption=false;this.checkboxes.each(function(checkbox){checkbox.observe('click',this.checkboxOnClick.bind(this,checkbox));}.bind(this));this.select.observe('change',this.selectOnChange.bind(this));this.countAndCheckCheckBoxes();if(!value_was_set)
this.scanCheckBoxes();this.notify('afterChange',this.select.options[this.select.options.selectedIndex].value);},countAndCheckCheckBoxes:function(){this.numberOfCheckedBoxes=this.checkboxes.inject(0,function(number,checkbox){checkbox.checked=(this.select.options[this.select.options.selectedIndex].value==checkbox.value);if(checkbox.checked)
++number;return number;}.bind(this));},setValue:function(value_string){this.numberOfCheckedBoxes=0;(value_string.split?value_string.split(this.options.valueSeparator):value_string).each(function(value){this.checkboxes.each(function(checkbox){if(checkbox.value==value){++this.numberOfCheckedBoxes;checkbox.checked=true;}else
checkbox.checked=false;}.bind(this));}.bind(this));this.scanCheckBoxes();},selectOnChange:function(){this.removeExtraOption();this.countAndCheckCheckBoxes();this.notify('afterChange',this.select.options[this.select.options.selectedIndex].value);},checkboxOnClick:function(checkbox){this.numberOfCheckedBoxes+=(checkbox.checked)?1:-1;this.scanCheckBoxes();this.notify('afterChange',this.select.options[this.select.options.selectedIndex].value);},scanCheckBoxes:function(){switch(this.numberOfCheckedBoxes){case 1:this.checkboxes.each(function(checkbox){if(checkbox.checked){$A(this.select.options).each(function(option,i){if(option.value==checkbox.value){this.select.options.selectedIndex=i;throw $break;}}.bind(this));throw $break;}}.bind(this));case 0:this.removeExtraOption();break;default:this.addExtraOption();break;};},getLabelForExtraOption:function(){var label=(typeof(this.options.nameSelector)=='function'?this.options.nameSelector.bind(this)():this.container.getElementsBySelector(this.options.nameSelector).inject([],function(labels,name_element,i){if(this.checkboxes[i].checked)
labels.push(name_element.innerHTML);return labels;}.bind(this))).join(this.options.labelSeparator);return(label.length>=this.options.overflowLength&&this.options.overflowLength>0)?(typeof(this.options.overflowString)=='function'?this.options.overflowString(label):this.options.overflowString):label;},getValueForExtraOption:function(){return this.checkboxes.inject([],function(values,checkbox){if(checkbox.checked)
values.push(checkbox.value);return values;}).join(this.options.valueSeparator);},addExtraOption:function(){this.removeExtraOption();this.hasExtraOption=true;this.select.options[this.select.options.length]=new Option(this.getLabelForExtraOption(),this.getValueForExtraOption());this.select.options.selectedIndex=this.select.options.length-1;},removeExtraOption:function(){if(this.hasExtraOption){this.select.remove(this.select.options.length-1);this.hasExtraOption=false;}}});Object.Event.extend(Control.SelectMultiple);