
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(navigator.appVersion.indexOf('AppleWebKit')>0)window.scrollBy(0,0);return element;};Element.getOpacity=function(element){return $(element).getStyle('opacity');};Element.setOpacity=function(element,value){return $(element).setStyle({opacity:value});};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){}};Array.prototype.call=function(){var args=arguments;this.each(function(f){f.apply(this,args);});};var Effect={_elementDoesNotExistError:{name:'ElementDoesNotExistError',message:'The specified DOM element does not exist, but is required for this effect to operate'},tagifyText:function(element){if(typeof Builder=='undefined')
throw("Effect.tagifyText requires including script.aculo.us' builder.js library");var tagifyStyle='position:relative';if(/MSIE/.test(navigator.userAgent)&&!window.opera)tagifyStyle+=';zoom:1';element=$(element);$A(element.childNodes).each(function(child){if(child.nodeType==3){child.nodeValue.toArray().each(function(character){element.insertBefore(Builder.node('span',{style:tagifyStyle},character==' '?String.fromCharCode(160):character),child);});Element.remove(child);}});},multiple:function(element,effect){var elements;if(((typeof element=='object')||(typeof element=='function'))&&(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);}};var Effect2=Effect;Effect.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){return((-Math.cos(pos*Math.PI)/4)+0.75)+Math.random()/4;},wobble:function(pos){return(-Math.cos(pos*Math.PI*(9*pos))/2)+0.5;},pulse:function(pos,pulses){pulses=pulses||5;return(Math.round((pos%(1/pulses))*pulses)==0?((pos*pulses*2)-Math.floor(pos*pulses*2)):1-((pos*pulses*2)-Math.floor(pos*pulses*2)));},none:function(pos){return 0;},full:function(pos){return 1;}};Effect.ScopedQueue=Class.create();Object.extend(Object.extend(Effect.ScopedQueue.prototype,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=(typeof effect.options.queue=='string')?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++)
if(this.effects[i])this.effects[i].loop(timePos);}});Effect.Queues={instances:$H(),get:function(queueName){if(typeof queueName!='string')return queueName;if(!this.instances[queueName])
this.instances[queueName]=new Effect.ScopedQueue();return this.instances[queueName];}};Effect.Queue=Effect.Queues.get('global');Effect.DefaultOptions={transition:Effect.Transitions.sinoidal,duration:1.0,fps:60.0,sync:false,from:0.0,to:1.0,delay:0.0,queue:'parallel'};Effect.Base=function(){};Effect.Base.prototype={position:null,start:function(options){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.event('beforeStart');if(!this.options.sync)
Effect.Queues.get(typeof this.options.queue=='string'?'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.finishOn-this.startOn);var frame=Math.round(pos*this.options.fps*this.options.duration);if(frame>this.currentFrame){this.render(pos);this.currentFrame=frame;}}},render:function(pos){if(this.state=='idle'){this.state='running';this.event('beforeSetup');if(this.setup)this.setup();this.event('afterSetup');}
if(this.state=='running'){if(this.options.transition)pos=this.options.transition(pos);pos*=(this.options.to-this.options.from);pos+=this.options.from;this.position=pos;this.event('beforeUpdate');if(this.update)this.update(pos);this.event('afterUpdate');}},cancel:function(){if(!this.options.sync)
Effect.Queues.get(typeof this.options.queue=='string'?'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(typeof this[property]!='function')data[property]=this[property];return'#<Effect:'+data.inspect()+',options:'+$H(this.options).inspect()+'>';}};Effect.Parallel=Class.create();Object.extend(Object.extend(Effect.Parallel.prototype,Effect.Base.prototype),{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.Event=Class.create();Object.extend(Object.extend(Effect.Event.prototype,Effect.Base.prototype),{initialize:function(){var options=Object.extend({duration:0},arguments[0]||{});this.start(options);},update:Prototype.emptyFunction});Effect.Opacity=Class.create();Object.extend(Object.extend(Effect.Opacity.prototype,Effect.Base.prototype),{initialize:function(element){this.element=$(element);if(!this.element)throw(Effect._elementDoesNotExistError);if(/MSIE/.test(navigator.userAgent)&&!window.opera&&(!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();Object.extend(Object.extend(Effect.Move.prototype,Effect.Base.prototype),{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:Math.round(this.options.x*position+this.originalLeft)+'px',top:Math.round(this.options.y*position+this.originalTop)+'px'});}});Effect.MoveBy=function(element,toTop,toLeft){return new Effect.Move(element,Object.extend({x:toLeft,y:toTop},arguments[3]||{}));};Effect.Scale=Class.create();Object.extend(Object.extend(Effect.Scale.prototype,Effect.Base.prototype),{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=Math.round(width)+'px';if(this.options.scaleY)d.height=Math.round(height)+'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();Object.extend(Object.extend(Effect.Highlight.prototype,Effect.Base.prototype),{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+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart());}.bind(this))});},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}));}});Effect.ScrollTo=Class.create();Object.extend(Object.extend(Effect.ScrollTo.prototype,Effect.Base.prototype),{initialize:function(element){this.element=$(element);this.start(arguments[1]||{});},setup:function(){Position.prepare();var offsets=Position.cumulativeOffset(this.element);if(this.options.offset)offsets[1]+=this.options.offset;var max=window.innerHeight?window.height-window.innerHeight:document.body.scrollHeight-
(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight);this.scrollStart=Position.deltaY;this.delta=(offsets[1]>max?max:offsets[1])-this.scrollStart;},update:function(position){Position.prepare();window.scrollTo(Position.deltaX,this.scrollStart+(position*this.delta));}});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 oldStyle={top:element.getStyle('top'),left:element.getStyle('left')};return new Effect.Move(element,{x:20,y:0,duration:0.05,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(effect){new Effect.Move(effect.element,{x:-20,y:0,duration:0.05,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');return new Effect.Scale(element,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:'box',scaleFrom:100,restoreAfterFinish:true,beforeStartInternal: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().setStyle({bottom:oldInnerBottom});effect.element.down().undoPositioned();}},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();Object.extend(Object.extend(Effect.Morph.prototype,Effect.Base.prototype),{initialize:function(element){this.element=$(element);if(!this.element)throw(Effect._elementDoesNotExistError);var options=Object.extend({style:{}},arguments[1]||{});if(typeof options.style=='string'){if(options.style.indexOf(':')==-1){var cssText='',selector='.'+options.style;$A(document.styleSheets).reverse().each(function(styleSheet){if(styleSheet.cssRules)cssRules=styleSheet.cssRules;else if(styleSheet.rules)cssRules=styleSheet.rules;$A(cssRules).reverse().each(function(rule){if(selector==rule.selectorText){cssText=rule.style.cssText;throw $break;}});if(cssText)throw $break;});this.style=cssText.parseStyle();options.afterFinishInternal=function(effect){effect.element.addClassName(effect.options.style);effect.transforms.each(function(transform){if(transform.style!='opacity')
effect.element.style[transform.style.camelize()]='';});};}else this.style=options.style.parseStyle();}else this.style=$H(options.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].underscore().dasherize(),value=pair[1],unit=null;if(value.parseColor('#zzzzzz')!='#zzzzzz'){value=value.parseColor();unit='color';}else if(property=='opacity'){value=parseFloat(value);if(/MSIE/.test(navigator.userAgent)&&!window.opera&&(!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 $H({style:property,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=$H(),value=null;this.transforms.each(function(transform){value=transform.unit=='color'?$R(0,2).inject('#',function(m,v,i){return m+(Math.round(transform.originalValue[i]+
(transform.targetValue[i]-transform.originalValue[i])*position)).toColorPart();}):transform.originalValue+Math.round(((transform.targetValue-transform.originalValue)*position)*1000)/1000+transform.unit;style[transform.style]=value;});this.element.setStyle(style);}});Effect.Transform=Class.create();Object.extend(Effect.Transform.prototype,{initialize:function(tracks){this.tracks=[];this.options=arguments[1]||{};this.addTracks(tracks);},addTracks:function(tracks){tracks.each(function(track){var data=$H(track).values().first();this.tracks.push($H({ids:$H(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 elements=[$(track.ids)||$$(track.ids)].flatten();return elements.map(function(e){return new track.effect(e,Object.extend({sync:true},track.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.prototype.parseStyle=function(){var element=Element.extend(document.createElement('div'));element.innerHTML='<div style="'+this+'"></div>';var style=element.down().style,styleRules=$H();Element.CSS_PROPERTIES.each(function(property){if(style[property])styleRules[property]=style[property];});if(/MSIE/.test(navigator.userAgent)&&!window.opera&&this.indexOf('opacity')>-1){styleRules.opacity=this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];}
return styleRules;};Element.morph=function(element,style){new Effect.Morph(element,Object.extend({style:style},arguments[2]||{}));return element;};['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom','collectTextNodes','collectTextNodesIgnoreClass','morph'].each(function(f){Element.Methods[f]=Element[f];});Element.Methods.visualEffect=function(element,effect,options){s=effect.gsub(/_/,'-').camelize();effect_class=s.charAt(0).toUpperCase()+s.substring(1);new Effect[effect_class](element,options);return $(element);};Element.addMethods();

Effect.PhaseIn=function(element){element=$(element);new Effect.BlindDown(element,arguments[1]||{});new Effect.Appear(element,arguments[2]||arguments[1]||{});};Effect.PhaseOut=function(element){element=$(element);new Effect.Fade(element,arguments[1]||{});new Effect.BlindUp(element,arguments[2]||arguments[1]||{});};

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 Effect=='undefined')
throw("dragdrop.js requires including script.aculo.us' effects.js library");var Droppables={drops:[],remove:function(element){this.drops=this.drops.reject(function(d){return d.element==$(element);});},add:function(element){element=$(element);var options=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});if(options.containment){options._containers=[];var containment=options.containment;if((typeof containment=='object')&&(containment.constructor==Array)){containment.each(function(c){options._containers.push($(c));});}else{options._containers.push($(containment));}}
if(options.accept)options.accept=[options.accept].flatten();Element.makePositioned(element);options.element=element;this.drops.push(options);},findDeepestChild:function(drops){deepest=drops[0];for(i=1;i<drops.length;++i)
if(Element.isParent(drops[i].element,deepest.element))
deepest=drops[i];return deepest;},isContained:function(element,drop){var containmentNode;if(drop.tree){containmentNode=element.treeNode;}else{containmentNode=element.parentNode;}
return drop._containers.detect(function(c){return containmentNode==c;});},isAffected:function(point,element,drop){return((drop.element!=element)&&((!drop._containers)||this.isContained(element,drop))&&((!drop.accept)||(Element.classNames(element).detect(function(v){return drop.accept.include(v);})))&&Position.within(drop.element,point[0],point[1]));},deactivate:function(drop){if(drop.hoverclass)
Element.removeClassName(drop.element,drop.hoverclass);this.last_active=null;},activate:function(drop){if(drop.hoverclass)
Element.addClassName(drop.element,drop.hoverclass);this.last_active=drop;},show:function(point,element){if(!this.drops.length)return;var affected=[];if(this.last_active)this.deactivate(this.last_active);this.drops.each(function(drop){if(Droppables.isAffected(point,element,drop))
affected.push(drop);});if(affected.length>0){drop=Droppables.findDeepestChild(affected);Position.within(drop.element,point[0],point[1]);if(drop.onHover)
drop.onHover(element,drop.element,Position.overlap(drop.overlap,drop.element));Droppables.activate(drop);}},fire:function(event,element){if(!this.last_active)return;Position.prepare();if(this.isAffected([Event.pointerX(event),Event.pointerY(event)],element,this.last_active))
if(this.last_active.onDrop)
this.last_active.onDrop(element,this.last_active.element,event);},reset:function(){if(this.last_active)
this.deactivate(this.last_active);}};var Draggables={drags:[],observers:[],register:function(draggable){if(this.drags.length==0){this.eventMouseUp=this.endDrag.bindAsEventListener(this);this.eventMouseMove=this.updateDrag.bindAsEventListener(this);this.eventKeypress=this.keyPress.bindAsEventListener(this);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove);Event.observe(document,"keypress",this.eventKeypress);}
this.drags.push(draggable);},unregister:function(draggable){this.drags=this.drags.reject(function(d){return d==draggable;});if(this.drags.length==0){Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress);}},activate:function(draggable){if(draggable.options.delay){this._timeout=setTimeout(function(){Draggables._timeout=null;window.focus();Draggables.activeDraggable=draggable;}.bind(this),draggable.options.delay);}else{window.focus();this.activeDraggable=draggable;}},deactivate:function(){this.activeDraggable=null;},updateDrag:function(event){if(!this.activeDraggable)return;var pointer=[Event.pointerX(event),Event.pointerY(event)];if(this._lastPointer&&(this._lastPointer.inspect()==pointer.inspect()))return;this._lastPointer=pointer;this.activeDraggable.updateDrag(event,pointer);},endDrag:function(event){if(this._timeout){clearTimeout(this._timeout);this._timeout=null;}
if(!this.activeDraggable)return;this._lastPointer=null;this.activeDraggable.endDrag(event);this.activeDraggable=null;},keyPress:function(event){if(this.activeDraggable)
this.activeDraggable.keyPress(event);},addObserver:function(observer){this.observers.push(observer);this._cacheObserverCallbacks();},removeObserver:function(element){this.observers=this.observers.reject(function(o){return o.element==element;});this._cacheObserverCallbacks();},notify:function(eventName,draggable,event){if(this[eventName+'Count']>0)
this.observers.each(function(o){if(o[eventName])o[eventName](eventName,draggable,event);});if(draggable.options[eventName])draggable.options[eventName](draggable,event);},_cacheObserverCallbacks:function(){['onStart','onEnd','onDrag'].each(function(eventName){Draggables[eventName+'Count']=Draggables.observers.select(function(o){return o[eventName];}).length;});}};var Draggable=Class.create();Draggable._dragging={};Draggable.prototype={initialize:function(element){var defaults={handle:false,reverteffect:function(element,top_offset,left_offset){var dur=Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02;new Effect.Move(element,{x:-left_offset,y:-top_offset,duration:dur,queue:{scope:'_draggable',position:'end'}});},endeffect:function(element){var toOpacity=typeof element._opacity=='number'?element._opacity:1.0;new Effect.Opacity(element,{duration:0.2,from:0.7,to:toOpacity,queue:{scope:'_draggable',position:'end'},afterFinish:function(){Draggable._dragging[element]=false;}});},zindex:1000,revert:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false,delay:0};if(!arguments[1]||typeof arguments[1].endeffect=='undefined')
Object.extend(defaults,{starteffect:function(element){element._opacity=Element.getOpacity(element);Draggable._dragging[element]=true;new Effect.Opacity(element,{duration:0.2,from:element._opacity,to:0.7});}});var options=Object.extend(defaults,arguments[1]||{});this.element=$(element);if(options.handle&&(typeof options.handle=='string'))
this.handle=this.element.down('.'+options.handle,0);if(!this.handle)this.handle=$(options.handle);if(!this.handle)this.handle=this.element;if(options.scroll&&!options.scroll.scrollTo&&!options.scroll.outerHTML){options.scroll=$(options.scroll);this._isScrollChild=Element.childOf(this.element,options.scroll);}
Element.makePositioned(this.element);this.delta=this.currentDelta();this.options=options;this.dragging=false;this.eventMouseDown=this.initDrag.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);Draggables.register(this);},destroy:function(){Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);Draggables.unregister(this);},currentDelta:function(){return([parseInt(Element.getStyle(this.element,'left')||'0'),parseInt(Element.getStyle(this.element,'top')||'0')]);},initDrag:function(event){if(typeof Draggable._dragging[this.element]!='undefined'&&Draggable._dragging[this.element])return;if(Event.isLeftClick(event)){var src=Event.element(event);if((tag_name=src.tagName.toUpperCase())&&(tag_name=='INPUT'||tag_name=='SELECT'||tag_name=='OPTION'||tag_name=='BUTTON'||tag_name=='TEXTAREA'))return;var pointer=[Event.pointerX(event),Event.pointerY(event)];var pos=Position.cumulativeOffset(this.element);this.offset=[0,1].map(function(i){return(pointer[i]-pos[i]);});Draggables.activate(this);Event.stop(event);}},startDrag:function(event){this.dragging=true;if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,'z-index')||0);this.element.style.zIndex=this.options.zindex;}
if(this.options.ghosting){this._clone=this.element.cloneNode(true);Position.absolutize(this.element);this.element.parentNode.insertBefore(this._clone,this.element);}
if(this.options.scroll){if(this.options.scroll==window){var where=this._getWindowScroll(this.options.scroll);this.originalScrollLeft=where.left;this.originalScrollTop=where.top;}else{this.originalScrollLeft=this.options.scroll.scrollLeft;this.originalScrollTop=this.options.scroll.scrollTop;}}
Draggables.notify('onStart',this,event);if(this.options.starteffect)this.options.starteffect(this.element);},updateDrag:function(event,pointer){if(!this.dragging)this.startDrag(event);Position.prepare();Droppables.show(pointer,this.element);Draggables.notify('onDrag',this,event);this.draw(pointer);if(this.options.change)this.options.change(this);if(this.options.scroll){this.stopScrolling();var p;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){p=[left,top,left+width,top+height];}}else{p=Position.page(this.options.scroll);p[0]+=this.options.scroll.scrollLeft+Position.deltaX;p[1]+=this.options.scroll.scrollTop+Position.deltaY;p.push(p[0]+this.options.scroll.offsetWidth);p.push(p[1]+this.options.scroll.offsetHeight);}
var speed=[0,0];if(pointer[0]<(p[0]+this.options.scrollSensitivity))speed[0]=pointer[0]-(p[0]+this.options.scrollSensitivity);if(pointer[1]<(p[1]+this.options.scrollSensitivity))speed[1]=pointer[1]-(p[1]+this.options.scrollSensitivity);if(pointer[0]>(p[2]-this.options.scrollSensitivity))speed[0]=pointer[0]-(p[2]-this.options.scrollSensitivity);if(pointer[1]>(p[3]-this.options.scrollSensitivity))speed[1]=pointer[1]-(p[3]-this.options.scrollSensitivity);this.startScrolling(speed);}
if(navigator.appVersion.indexOf('AppleWebKit')>0)window.scrollBy(0,0);Event.stop(event);},finishDrag:function(event,success){this.dragging=false;if(this.options.ghosting){Position.relativize(this.element);Element.remove(this._clone);this._clone=null;}
if(success)Droppables.fire(event,this.element);Draggables.notify('onEnd',this,event);var revert=this.options.revert;if(revert&&typeof revert=='function')revert=revert(this.element);var d=this.currentDelta();if(revert&&this.options.reverteffect){this.options.reverteffect(this.element,d[1]-this.delta[1],d[0]-this.delta[0]);}else{this.delta=d;}
if(this.options.zindex)
this.element.style.zIndex=this.originalZ;if(this.options.endeffect)
this.options.endeffect(this.element);Draggables.deactivate(this);Droppables.reset();},keyPress:function(event){if(event.keyCode!=Event.KEY_ESC)return;this.finishDrag(event,false);Event.stop(event);},endDrag:function(event){if(!this.dragging)return;this.stopScrolling();this.finishDrag(event,true);Event.stop(event);},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));}}}
var style=this.element.style;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="";},stopScrolling:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;Draggables._lastScrollPointer=null;}},startScrolling:function(speed){if(!(speed[0]||speed[1]))return;this.scrollSpeed=[speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed];this.lastScrolled=new Date();this.scrollInterval=setInterval(this.scroll.bind(this),10);},scroll:function(){var current=new Date();var delta=current-this.lastScrolled;this.lastScrolled=current;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){if(this.scrollSpeed[0]||this.scrollSpeed[1]){var d=delta/1000;this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1]);}}}else{this.options.scroll.scrollLeft+=this.scrollSpeed[0]*delta/1000;this.options.scroll.scrollTop+=this.scrollSpeed[1]*delta/1000;}
Position.prepare();Droppables.show(Draggables._lastPointer,this.element);Draggables.notify('onDrag',this);if(this._isScrollChild){Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*delta/1000;Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*delta/1000;if(Draggables._lastScrollPointer[0]<0)
Draggables._lastScrollPointer[0]=0;if(Draggables._lastScrollPointer[1]<0)
Draggables._lastScrollPointer[1]=0;this.draw(Draggables._lastScrollPointer);}
if(this.options.change)this.options.change(this);},_getWindowScroll:function(w){var T,L,W,H;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft;}else if(w.document.body){T=body.scrollTop;L=body.scrollLeft;}
if(w.innerWidth){W=w.innerWidth;H=w.innerHeight;}else if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight;}else{W=body.offsetWidth;H=body.offsetHeight;}}
return{top:T,left:L,width:W,height:H};}};var SortableObserver=Class.create();SortableObserver.prototype={initialize:function(element,observer){this.element=$(element);this.observer=observer;this.lastValue=Sortable.serialize(this.element);},onStart:function(){this.lastValue=Sortable.serialize(this.element);},onEnd:function(){Sortable.unmark();if(this.lastValue!=Sortable.serialize(this.element))
this.observer(this.element);}};var Sortable={SERIALIZE_RULE:/^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,sortables:{},_findRootElement:function(element){while(element.tagName.toUpperCase()!="BODY"){if(element.id&&Sortable.sortables[element.id])return element;element=element.parentNode;}},options:function(element){element=Sortable._findRootElement($(element));if(!element)return;return Sortable.sortables[element.id];},destroy:function(element){var s=Sortable.options(element);if(s){Draggables.removeObserver(s.element);s.droppables.each(function(d){Droppables.remove(d);});s.draggables.invoke('destroy');delete Sortable.sortables[s.element.id];}},create:function(element){element=$(element);var options=Object.extend({element:element,tag:'li',dropOnEmpty:false,tree:false,treeTag:'ul',overlap:'vertical',constraint:'vertical',containment:element,handle:false,only:false,delay:0,hoverclass:null,ghosting:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,format:this.SERIALIZE_RULE,onChange:Prototype.emptyFunction,onUpdate:Prototype.emptyFunction},arguments[1]||{});this.destroy(element);var options_for_draggable={revert:true,scroll:options.scroll,scrollSpeed:options.scrollSpeed,scrollSensitivity:options.scrollSensitivity,delay:options.delay,ghosting:options.ghosting,constraint:options.constraint,handle:options.handle};if(options.starteffect)
options_for_draggable.starteffect=options.starteffect;if(options.reverteffect)
options_for_draggable.reverteffect=options.reverteffect;else
if(options.ghosting)options_for_draggable.reverteffect=function(element){element.style.top=0;element.style.left=0;};if(options.endeffect)
options_for_draggable.endeffect=options.endeffect;if(options.zindex)
options_for_draggable.zindex=options.zindex;var options_for_droppable={overlap:options.overlap,containment:options.containment,tree:options.tree,hoverclass:options.hoverclass,onHover:Sortable.onHover};var options_for_tree={onHover:Sortable.onEmptyHover,overlap:options.overlap,containment:options.containment,hoverclass:options.hoverclass};Element.cleanWhitespace(element);options.draggables=[];options.droppables=[];if(options.dropOnEmpty||options.tree){Droppables.add(element,options_for_tree);options.droppables.push(element);}
(this.findElements(element,options)||[]).each(function(e){var handle=options.handle?$(e).down('.'+options.handle,0):e;options.draggables.push(new Draggable(e,Object.extend(options_for_draggable,{handle:handle})));Droppables.add(e,options_for_droppable);if(options.tree)e.treeNode=element;options.droppables.push(e);});if(options.tree){(Sortable.findTreeElements(element,options)||[]).each(function(e){Droppables.add(e,options_for_tree);e.treeNode=element;options.droppables.push(e);});}
this.sortables[element.id]=options;Draggables.addObserver(new SortableObserver(element,options.onUpdate));},findElements:function(element,options){return Element.findChildren(element,options.only,options.tree?true:false,options.tag);},findTreeElements:function(element,options){return Element.findChildren(element,options.only,options.tree?true:false,options.treeTag);},onHover:function(element,dropon,overlap){if(Element.isParent(dropon,element))return;if(overlap>.33&&overlap<.66&&Sortable.options(dropon).tree){return;}else if(overlap>0.5){Sortable.mark(dropon,'before');if(dropon.previousSibling!=element){var oldParentNode=element.parentNode;element.style.visibility="hidden";dropon.parentNode.insertBefore(element,dropon);if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);Sortable.options(dropon.parentNode).onChange(element);}}else{Sortable.mark(dropon,'after');var nextElement=dropon.nextSibling||null;if(nextElement!=element){var oldParentNode=element.parentNode;element.style.visibility="hidden";dropon.parentNode.insertBefore(element,nextElement);if(dropon.parentNode!=oldParentNode)
Sortable.options(oldParentNode).onChange(element);Sortable.options(dropon.parentNode).onChange(element);}}},onEmptyHover:function(element,dropon,overlap){var oldParentNode=element.parentNode;var droponOptions=Sortable.options(dropon);if(!Element.isParent(dropon,element)){var index;var children=Sortable.findElements(dropon,{tag:droponOptions.tag,only:droponOptions.only});var child=null;if(children){var offset=Element.offsetSize(dropon,droponOptions.overlap)*(1.0-overlap);for(index=0;index<children.length;index+=1){if(offset-Element.offsetSize(children[index],droponOptions.overlap)>=0){offset-=Element.offsetSize(children[index],droponOptions.overlap);}else if(offset-(Element.offsetSize(children[index],droponOptions.overlap)/2)>=0){child=index+1<children.length?children[index+1]:null;break;}else{child=children[index];break;}}}
dropon.insertBefore(element,child);Sortable.options(oldParentNode).onChange(element);droponOptions.onChange(element);}},unmark:function(){if(Sortable._marker)Sortable._marker.hide();},mark:function(dropon,position){var sortable=Sortable.options(dropon.parentNode);if(sortable&&!sortable.ghosting)return;if(!Sortable._marker){Sortable._marker=($('dropmarker')||Element.extend(document.createElement('DIV'))).hide().addClassName('dropmarker').setStyle({position:'absolute'});document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);}
var offsets=Position.cumulativeOffset(dropon);Sortable._marker.setStyle({left:offsets[0]+'px',top:offsets[1]+'px'});if(position=='after')
if(sortable.overlap=='horizontal')
Sortable._marker.setStyle({left:(offsets[0]+dropon.clientWidth)+'px'});else
Sortable._marker.setStyle({top:(offsets[1]+dropon.clientHeight)+'px'});Sortable._marker.show();},_tree:function(element,options,parent){var children=Sortable.findElements(element,options)||[];for(var i=0;i<children.length;++i){var match=children[i].id.match(options.format);if(!match)continue;var child={id:encodeURIComponent(match?match[1]:null),element:element,parent:parent,children:[],position:parent.children.length,container:$(children[i]).down(options.treeTag)};if(child.container)
this._tree(child.container,options,child);parent.children.push(child);}
return parent;},tree:function(element){element=$(element);var sortableOptions=this.options(element);var options=Object.extend({tag:sortableOptions.tag,treeTag:sortableOptions.treeTag,only:sortableOptions.only,name:element.id,format:sortableOptions.format},arguments[1]||{});var root={id:null,parent:null,children:[],container:element,position:0};return Sortable._tree(element,options,root);},_constructIndex:function(node){var index='';do{if(node.id)index='['+node.position+']'+index;}while((node=node.parent)!=null);return index;},sequence:function(element){element=$(element);var options=Object.extend(this.options(element),arguments[1]||{});return $(this.findElements(element,options)||[]).map(function(item){return item.id.match(options.format)?item.id.match(options.format)[1]:'';});},setSequence:function(element,new_sequence){element=$(element);var options=Object.extend(this.options(element),arguments[2]||{});var nodeMap={};this.findElements(element,options).each(function(n){if(n.id.match(options.format))
nodeMap[n.id.match(options.format)[1]]=[n,n.parentNode];n.parentNode.removeChild(n);});new_sequence.each(function(ident){var n=nodeMap[ident];if(n){n[1].appendChild(n[0]);delete nodeMap[ident];}});},serialize:function(element){element=$(element);var options=Object.extend(Sortable.options(element),arguments[1]||{});var name=encodeURIComponent((arguments[1]&&arguments[1].name)?arguments[1].name:element.id);if(options.tree){return Sortable.tree(element,arguments[1]).children.map(function(item){return[name+Sortable._constructIndex(item)+"[id]="+
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));}).flatten().join('&');}else{return Sortable.sequence(element,arguments[1]).map(function(item){return name+"[]="+encodeURIComponent(item);}).join('&');}}};Element.isParent=function(child,element){if(!child.parentNode||child==element)return false;if(child.parentNode==element)return true;return Element.isParent(child.parentNode,element);};Element.findChildren=function(element,only,recursive,tagName){if(!element.hasChildNodes())return null;tagName=tagName.toUpperCase();if(only)only=[only].flatten();var elements=[];$A(element.childNodes).each(function(e){if(e.tagName&&e.tagName.toUpperCase()==tagName&&(!only||(Element.classNames(e).detect(function(v){return only.include(v);}))))
elements.push(e);if(recursive){var grandchildren=Element.findChildren(e,only,recursive,tagName);if(grandchildren)elements.push(grandchildren);}});return(elements.length>0?elements.flatten():[]);};Element.offsetSize=function(element,type){return element['offset'+((type=='vertical'||type=='height')?'Height':'Width')];};

if(!Control)var Control={};Control.Slider=Class.create();Control.Slider.prototype={initialize:function(handle,track,options){var slider=this;if(handle instanceof Array){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((slider.options.sliderValue instanceof Array?slider.options.sliderValue[i]:slider.options.sliderValue)||slider.range.start),i);Element.makePositioned(h);Event.observe(h,"mousedown",slider.eventMouseDown);});Event.observe(this.track,"mousedown",this.eventMouseDown);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"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.alignY);},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(navigator.appVersion.indexOf('AppleWebKit')>0)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;}}

Object.extend(Event,{_domReady:function(){if(arguments.callee&&arguments.callee.done)return false;arguments.callee.done=true;if(this._timer){clearInterval(this._timer);}
this._readyCallbacks.each(function(f){f();});this._readyCallbacks=null;return true;},onDOMReady:function(f){if(!this._readyCallbacks){var domReady=this._domReady.bind(this);if(this.checkForDomReadyEvent(domReady)){}
else if(this.checkForWebKitLoaded(domReady)){}
Event.observe(window,'load',domReady);Event._readyCallbacks=[];}
Event._readyCallbacks.push(f);},checkForIEDomLoaded:function(domReady)
{if(Prototype.Browser.IE&&!Prototype.Browser.IE6){document.write("<scr"+"ipt id='__ie_onload' type='text/javascript' defer='true' src='//:'><\/scr"+"ipt>");var el=document.getElementById("__ie_onload");el.onreadystatechange=this._ieReady.bind(el,domReady);return true;}
return false;},_ieReady:function(domReady)
{if(this.readyState=="complete"){this.onreadystatechange=null;domReady();}},checkForWebKitLoaded:function(domReady)
{if(/WebKit|KHTML/i.test(navigator.userAgent)){this._timer=setInterval(function(){if(/loaded|complete/.test(document.readyState))domReady();},10);return true;}
return false;},checkForDomReadyEvent:function(domReady)
{if(document.addEventListener){document.addEventListener("DOMContentLoaded",domReady,false);return true;}
return false;}});

var StateNames={stateCodeRegex:/^(A[LKZR]|C[AOT]|D[EC]|FL|GA|HI|I[DLNA]|K[SY]|LA|M[EDAINSOT]|N[EVHJMYCD]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[TA]|W[AVIY])$/,states:{'alabama':'AL','alaska':'AK','arizona':'AZ','arkansas':'AR','california':'CA','colorado':'CO','connecticut':'CT','delaware':'DE','district of columbia':'DC','florida':'FL','georgia':'GA','hawaii':'HI','idaho':'ID','illinois':'IL','indiana':'IN','iowa':'IA','kansas':'KS','kentucky':'KY','louisiana':'LA','maine':'ME','maryland':'MD','massachusetts':'MA','michigan':'MI','minnesota':'MN','mississippi':'MS','missouri':'MO','montana':'MT','nebraska':'NE','nevada':'NV','new hampshire':'NH','new jersey':'NJ','new mexico':'NM','new york':'NY','north carolina':'NC','north dakota':'ND','ohio':'OH','oklahoma':'OK','oregon':'OR','pennsylvania':'PA','rhode island':'RI','south carolina':'SC','south dakota':'SD','tennessee':'TN','texas':'TX','utah':'UT','vermont':'VT','virginia':'VA','washington':'WA','west virginia':'WV','wisconsin':'WI','wyoming':'WY'},validStateCode:function(code){code=code.toUpperCase();return this.stateCodeRegex.test(code)&&code;},validStateName:function(name){var code=""+this.states[name.toLowerCase()];return this.stateCodeRegex.test(code)&&code;}};

var CM=Class.create();CM.WidgetPage=Class.create();Object.extend(CM.WidgetPage.prototype,{initialize:function()
{this.bvrMapping=new Array();this.bvrObjects=new Array();},register:function(bvr,klass,options)
{this.bvrMapping[bvr]={klass:klass,options:options};},registerGroup:function(bvrs)
{Object.extend(this.bvrMapping,bvrs);},unregister:function(bvr)
{this.bvrMapping[bvr]=null;this.bvrMapping=this.bvrMapping.compact();},apply:function(element,options)
{var bvrMapping=this.bvrMapping;if(options){for(var bvr in options){bvrMapping[bvr]={klass:options[bvr],options:{}};}}
this.bvrObjects.push(Widget.AddBehavioursByClassName(element,bvrMapping));this.bvrObjects=this.bvrObjects.flatten();return this.bvrObjects;},findObjectsByName:function(klassName)
{return this.findObjectsByCondition(function(bvrObject){return(klassName==bvrObject.bvrClassName);});},findObjectsByCondition:function(conditionalCallBack)
{return this.bvrObjects.select(conditionalCallBack);},findByElement:function(element)
{return this.bvrObjects.select(function(obj){return obj.element==element;});},findByElementAndBvr:function(bvr,element)
{return this.bvrObjects.select(function(obj){return(obj.element==element&&obj.bvrClassName==bvr);});},release:function(element)
{element=(element||document);this.bvrObjects.each(function(bvr){if(bvr.element.descendantOf(element)){this.bvrObjects=this.bvrObjects.reject(function(obj){var ret=bvr==obj;if(ret&&bvr.cleanup){bvr.cleanup();}
return ret;});}}.bind(this));}});var Widget=Class.create();Object.extend(Widget.prototype,{initialize:function(el)
{this.element=$(el).cleanWhitespace();}});CM.Behavior=Class.create();Object.extend(CM.Behavior,{create:function()
{var klass=Class.create();var len=arguments.length-1;Object.extend(klass.prototype,Widget.prototype);for(var i=0;i<len;++i){Object.extend(klass.prototype,arguments[i].prototype);}
Object.extend(klass.prototype,arguments[len]);return klass;},attach:function()
{if(!CM.windowLoaded){var id="marker-"+Math.random();var ret=document.write("<div id='"+id+"'></div>");var parent=$(id).parentNode;Event.onElementReady(parent,0,PageObject.apply.bind(PageObject,parent));}},register:function(bvr,eventName,handler){PageObject.register(bvr,ObserveWidget,{handler:handler,eventName:eventName});}});Object.extend(Widget,{AddBehaviourByClassNameFromDoc:function(doc,cssClassName,bvrClassName)
{console.debug("deprecated, use PageObject.register("+cssClassName+", "+bvrClassName+")");},AddBehaviourByClassName:function(cssClassName,bvrClassName,parent)
{console.debug("deprecated, use PageObject.register("+cssClassName+", "+bvrClassName+")");},AddBehavioursByClassName:function(parent,mapping)
{var bvrMatch=/bvr-\S+/;var bvrClassName;var elements=$A((parent||document.body).getElementsByTagName("*"));var length=elements.length;var objects=new Array();var start_timer=null;for(var i=0;i<length;++i){var className=elements[i].className;if((bvrClassName=className.match(bvrMatch))){var element=elements[i];bvrClassName=bvrClassName[0];var config=mapping[bvrClassName];if(config&&PageObject.findByElementAndBvr(bvrClassName,element).length===0){try{var obj=new config.klass(element,config.options);obj.bvrClassName=bvrClassName;}catch(e){try{console.debug("Failed to create class =>"+bvrClassName+", error: "+e.message);}catch(e){}
continue;}
objects.push(obj);}}}
return objects;},AddBehaviourById:function(idName,bvrClassName)
{var element=$(idName);if(element){new bvrClassName(element);}}});

var QuoteWidget=CM.Behavior.create({initialize:function(el){Widget.prototype.initialize.apply(this,arguments);Event.observe(this.element,"click",this.quote.bindAsEventListener(this));},quote:function(event){var answer_text=this.element.id+"_text";$('reply_form').text_input.value="[quote]"+$(answer_text).innerHTML+"[/quote]";Event.stop(event);}});

var ProfileMenuToggleWidget=CM.Behavior.create({initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);Event.observe(this.element,"click",this.toggle.bindAsEventListener(this));this.element.style.cursor="pointer";},toggle:function(event)
{$('profile_toggle').toggle();if(this.element.hasClassName("open")){this.element.removeClassName("open");this.element.addClassName("closed");}else{this.element.addClassName("open");this.element.removeClassName("closed");}
Event.stop(event);}});

var QnaToggleWidget=CM.Behavior.create({initialize:function(el){Widget.prototype.initialize.apply(this,arguments);Event.observe(this.element,"click",this.toggle.bindAsEventListener(this));Event.observe(this.element,"mousedown",this.toggle.bindAsEventListener(this));},toggle:function(el){if(this.element.id=="text_input"){$('text_input').className="text_input_big";if($('text_input').value=="Post a new topic or ask a question"){$('text_input').value="";}
try{$('extra_fields').className="buttons_show";}catch(e){}
Try.these(function(){Element.hide('post_errors');},function(){Element.hide('reply_errors');});}else{$('text_input').className="bvr-qna-toggle text_input_small";try{$('extra_fields').className="buttons_hide";}catch(e){}
if($('text_input').value!="Post a new topic or ask a question"){$('text_input').value="";}
Try.these(function(){Element.hide('reply_errors');Element.hide('post_errors');},function(){Element.hide('post_errors');});}}});function show_subcategory()
{var this_div=document.getElementsByClassName('select_categories').last();var category_id=document.getElementsByClassName('categories',this_div).first().value;var category_domid='category_'+category_id;document.getElementsByClassName('sub_categories',this_div).each(function(this_sub_cat){Element.hide(this_sub_cat);});document.getElementsByClassName('sub_categories',this_div).each(function(this_sub_cat){if(this_sub_cat.id==category_domid){Element.show(this_sub_cat);}});document.getElementsByClassName('category_hidden',this_div).first().value=category_id;}
function set_subcategory(subcat_id)
{var this_div=document.getElementsByClassName('select_categories').last();document.getElementsByClassName('category_hidden',this_div).first().value=subcat_id;}
function resetBox()
{var this_div=document.getElementsByClassName('select_categories').last();document.getElementsByClassName('sub_categories',this_div).each(function(this_sub_cat){Element.hide(this_sub_cat);});$('topic[category_id]').value="";$('select_category').selectedIndex=0;$('text_input').value="Post a new topic or ask a question";}
function validate()
{var retval=true;var cat_error=document.getElementsByName('category_error')[0];var question_error=document.getElementsByName('question_error')[0];if($('topic[category_id]').value==''){cat_error.style.display='block';retval=false;}
else{cat_error.style.display='none';}
if($('text_input').value==''){question_error.style.display='block';retval=false;}
else{question_error.style.display='none';}
return retval;}

CM.InputLabel=CM.Behavior.create({initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);Event.observe(this.element,"focus",this.focus.bindAsEventListener(this));Event.observe(this.element,"blur",this.blur.bindAsEventListener(this));this.save=this.element.value;},focus:function(event)
{if(this.save==this.element.value){this.element.value="";}},blur:function(event)
{if(this.element.value==""){this.element.value=this.save;}}});CM.InputSelect=CM.Behavior.create({initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);Event.observe(this.element,"focus",this.focus.bindAsEventListener(this));},focus:function(event)
{this.element.select();}});

var HoverBubble=CM.Behavior.create({initialize:function(el){Widget.prototype.initialize.apply(this,arguments);this.timeout=null;this.type_container=this.element.getElementsByClassName("bubble")[0];if(!this.type_container){return;}
this.type_container.style.position="absolute";this.type_container.style.display="none";try{Element.removeClassName(this.type_container,'no_display');}catch(e){};try{Element.removeClassName(this.type_container,'bubble');}catch(e){};if(navigator.appVersion.match(/\bMSIE\b/)&&window.attachEvent){this.type_container.style.behavior='url("/javascripts/ie_select_zindex.htc")';}
this.position_container=document.createElement('div');this.top_container=document.createElement('div');Element.addClassName(this.top_container,'bubble_top');while(this.type_container.childNodes.length>0){this.top_container.appendChild(this.type_container.childNodes[0]);}
this.position_container.appendChild(this.top_container);this.bottom_container=document.createElement('div');Element.addClassName(this.bottom_container,'bubble_bottom');this.position_container.appendChild(this.bottom_container);this.type_container.appendChild(this.position_container);(($('container')&&$('container').parentNode)||document.body).appendChild(this.type_container);if(Element.hasClassName(this.element,'rollover')){Event.observe(this.element,"mouseover",this.showPopup.bindAsEventListener(this));}else{Event.observe(this.element,"click",this.showPopup.bindAsEventListener(this));}
Event.observe(this.element,"mouseout",this.hidePopup.bindAsEventListener(this));Event.observe(this.element,"mouseover",this.keepPopup.bindAsEventListener(this));Event.observe(this.type_container,"mouseout",this.hidePopup.bindAsEventListener(this));Event.observe(this.type_container,"mouseover",this.keepPopup.bindAsEventListener(this));},showPopup:function(event)
{var pos_left=0;var pos_top=0;var anchor_top=Event.pointerY(event);this.anchor_top=anchor_top;var anchor_left=Event.pointerX(event);var mouse_pos_top=anchor_top-Position.getScrollTop();var mouse_pos_left=anchor_left-Position.getScrollLeft();var window_height=Position.getWindowHeight();var window_width=Position.getWindowWidth();var pos=(mouse_pos_top<window_height/2)?"top":"bottom";if(mouse_pos_left<window_width/4)pos+="_left";else if(mouse_pos_left>(window_width*3/4))pos+="_right";else pos+="_middle";var classNames=(""+Element.classNames(this.position_container)).split(" ");if(classNames.length==0){Element.addClassName(this.position_container,pos);}else if(classNames[0]!=pos){Element.removeClassName(this.position_container,classNames[0]);Element.addClassName(this.position_container,pos);}
var container_size=Element.getDimensions(this.type_container);var container_width=container_size.width;var container_height=container_size.height;switch(pos){case"top_middle":pos_left=anchor_left-123;pos_top=anchor_top;break;case"top_left":pos_left=anchor_left-50;pos_top=anchor_top;break;case"top_right":pos_left=anchor_left-160;pos_top=anchor_top;break;case"bottom_middle":pos_left=anchor_left-(container_width/2);pos_top=anchor_top-container_height;break;case"bottom_left":pos_left=anchor_left-61;pos_top=anchor_top-container_height;break;case"bottom_right":pos_left=anchor_left-167;pos_top=anchor_top-container_height;break;}
this.type_container.style.left=pos_left+"px";this.type_container.style.top=pos_top+"px";this.type_container.style.zIndex=1000;new Effect.Appear(this.type_container,{duration:0.3,fps:40});Event.stop(event);},keepPopup:function(event)
{if(this.timeout)clearTimeout(this.timeout);},hidePopup:function(event)
{if(this.timeout)clearTimeout(this.timeout);this.timeout=setTimeout(this._hideDisplay.bind(this),500);Event.stop(event);},_hideDisplay:function()
{this.timeout=false;new Effect.Fade(this.type_container,{duration:0.3,fps:40});}});var HoverWindowWidget=Class.create();Object.extend(HoverWindowWidget.prototype,HoverBubble.prototype);Object.extend(HoverWindowWidget.prototype,{initialize:function(el){this.href=el.href;if(!this.href)return;Element.removeClassName(el,'bvr-hover-window');this.span=document.createElement('span');el.parentNode.insertBefore(this.span,el);this.span.appendChild(el);var hover_span=document.createElement('span');Element.addClassName(hover_span,'bubble');Element.addClassName(hover_span,'send_box_590');this.span.appendChild(hover_span);HoverBubble.prototype.initialize.apply(this,[this.span]);},showPopup:function(e){if(!this.already_loaded_dynamic_content){this.already_loaded_dynamic_content=true;this.top_container.innerHTML='Loading...';new Ajax.Updater(this.top_container,this.href,{evalScripts:true,onComplete:function(){associateWidgets(this.top_container);}.bind(this)});}
HoverBubble.prototype.showPopup.apply(this,[e]);if((Element.classNames(this.position_container)+"").match(/bottom_/)){this.readjustTopAnchor();}},_hideDisplay:function(e){if(this.top_anchor_timeout){clearTimeout(this.top_anchor_timeout);this.top_anchor_timeout=null;}
HoverBubble.prototype._hideDisplay.apply(this,[e]);},readjustTopAnchor:function(){this.type_container.style.top=(this.anchor_top-Element.getDimensions(this.type_container).height)+"px";if(this.top_anchor_timeout){clearTimeout(this.top_anchor_timeout);}
this.top_anchor_timeout=setTimeout(this.readjustTopAnchor.bind(this),500);}});

var DismissableWidget=CM.Behavior.create({initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);var buttons=document.getElementsByClassName("bvr-dismissable-button",this.element);var i;for(i=0;i<buttons.length;++i){Event.observe(buttons[i],"click",this.remove.bindAsEventListener(this,true));}
var no_stop_buttons=document.getElementsByClassName("bvr-dismissable-no-stop-button",this.element);for(i=0;i<no_stop_buttons.length;++i){Event.observe(no_stop_buttons[i],"click",this.remove.bindAsEventListener(this,false));}},remove:function(event,stop)
{if(stop){Event.stop(event);}
var element=this.element;Element.update(element,'');Event.stop(event);}});

var CollapsibleWidget=CM.Behavior.create({initialize:function(el){Widget.prototype.initialize.apply(this,arguments);var classNames=el.className;if(classNames.indexOf('opener')>-1)
{Event.observe(this.element,"focus",this.open.bindAsEventListener(this));}
if(classNames.indexOf('closer')>-1)
{Event.observe(this.element,"focus",this.close.bindAsEventListener(this));}
this.close(this);},open:function(el){var show_these=document.getElementsByClassName('to_be_opened');for(var i=0;i<show_these.length;i++){Element.show(show_these[i]);}
var hide_these=document.getElementsByClassName('to_be_collapsed');for(var i=0;i<hide_these.length;i++){Element.hide(hide_these[i]);}},close:function(el){var scope=this.element.up(".input");var show_these=document.getElementsByClassName('to_be_collapsed',scope);for(var i=0,len=show_these.length;i<len;++i){show_these[i].show();}
var hide_these=document.getElementsByClassName('to_be_opened',scope);for(var i=0,len=hide_these.length;i<len;++i){hide_these[i].hide();}}});

var TargetedCollapsibleSectionWidget=CM.Behavior.create({initialize:function(element)
{Widget.prototype.initialize.apply(this,arguments);Event.observe(this.element,"click",this.toggle.bindAsEventListener(this,element));this.element.style.cursor="pointer";},toggle:function(event,element)
{var toggle_id=element.getAttribute('id');var id=toggle_id.substring(0,toggle_id.lastIndexOf('_toggle'));this.toggleDrawers(element.parentNode.parentNode,id+"_toggle_target");},toggleDrawers:function(headerId,blockId){if(Element.hasClassName(headerId,"lock"))return;Element.addClassName(headerId,"lock");if(Element.hasClassName(headerId,"open")){new Effect.PhaseOut(blockId,{duration:0.5,afterFinish:function(effect){Element.removeClassName(headerId,"open");Element.addClassName(headerId,"closed");Element.removeClassName(headerId,"lock");}});}else{Element.removeClassName(headerId,"closed");Element.addClassName(headerId,"open");new Effect.PhaseIn(blockId,{duration:0.5,afterFinish:function(effect){Element.removeClassName(headerId,"lock");}});}}});

var ObserveWidget=CM.Behavior.create({initialize:function(element,options)
{Widget.prototype.initialize.apply(this,arguments);this.observeOptions=options;var eventName=options["eventName"]||"click";Event.observe(this.element,eventName,this.handler.bindAsEventListener(this));},handler:function(event)
{this.observeOptions["handler"](event);Event.stop(event);}});

var Cookies={create:function(name,date){var value=date.getTime();var expires="; expires="+date.toGMTString();document.cookie=name+"="+value+expires+"; path=/";},write:function(name,value,expire){expire=new Date((expire||""));var expires="; expires="+expire.toGMTString();document.cookie=name+"="+value+expires+"; path=/";},read:function(name){var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0,length=ca.length;i<length;++i){var c=ca[i];while(c.charAt(0)==' '){c=c.substring(1,c.length);}
if(c.indexOf(nameEQ)==0){var cookieVal=c.substring(nameEQ.length,c.length);return cookieVal;}}
return null;},checkEnabled:function()
{document.cookie="Enabled=true";var cookieValid=""+document.cookie;cookiesEnabled=false;if(cookieValid.indexOf("Enabled=true")!=-1){cookiesEnabled=true;var cookie_date=new Date();cookie_date.setTime(cookie_date.getTime()-1);document.cookie="Enabled=; expires="+cookie_date.toGMTString();}
if(!cookiesEnabled&&window.location.href.indexOf('cookies_off')<0){setTimeout(function(){window.location.href='/registration/login/cookies_off';},0);}}};

var PageAdController=Class.create();PageAdController.prototype={initialize:function()
{this.ord=Math.round(Math.random()*new Date().getTime());this.positionCounter=0;this.ads=[];this.secure=(window.location.protocol=="https:")?";!c=unsecure":";!c=secure";this.count=(Cookies.read("av")||0);},render:function(ad,share,pos,tile)
{ad.url+=this.secure+share+";sc="+this.count+";pos="+pos+";tile="+tile+";ord="+this.ord+"?";ad.render();}};PageAdController.instance=new PageAdController();var PageAd=Class.create();Object.extend(PageAd.prototype,{initialize:function(host,path,width,height,share,pos,tile,channel){this.setup(host,path,width,height,share,pos,tile,channel);this.invoke();},setup:function(host,path,width,height,share,pos,tile,channel)
{this.width=width;this.height=height;this.url=host+"/"+path;this.share=share;this.controller=PageAdController.instance;this.channel=channel;this.pos=pos;this.tile=tile;},invoke:function()
{if(this.share){this.share=";u="+this.share;}
else{this.share="";}
this.controller.render(this,this.share,this.pos,this.tile);},render:function(secure)
{document.write("<script type='text/javascript' src='//"+this.url+"'></script>");}});var PageAdi=Class.create();Object.extend(PageAdi.prototype,PageAd.prototype);Object.extend(PageAdi.prototype,{render:function(secure)
{document.write("<if"+"rame src='//"+encodeURI(this.url)+"'"+" allowtransparency='true' marginwidth='0' frameborder='0' marginheight='0' scrolling='no' height='"+
this.height+"' width='"+this.width+"' hspace='0' vspace='0'></iframe>");}});var PageAdj=Class.create();Object.extend(PageAdj.prototype,PageAd.prototype);var PageAdsense=Class.create();Object.extend(PageAdsense.prototype,PageAd.prototype);Object.extend(PageAdsense.prototype,{initialize:function(host,path,width,height,share,pos,tile,channel){this.setup(host,path,width,height,share,pos,tile,channel);google_ad_client="pub-8100477917393715";google_ad_width=this.width;google_ad_height=this.height;google_ad_format=this.width+"x"+this.height+"_as";google_ad_type="text_image";google_ad_channel=this.channel;google_color_border="FFFFFF";google_color_bg="FFFFFF";google_color_link="2663ED";google_color_url="5A9957";google_color_text="2A2A2A";this.render();}});

var SelectControl={setSelectWaiting:function(select,message){var options=this.truncateSelectOptions(select,1,true);if(!options)return;options[0]=new Option(message,'',true,true);},truncateSelectOptions:function(select,length,disable){select=$(select);if(!(select&&select.nodeName.toLowerCase()=="select"))return;var options=select.options;for(var i=options.length-1;i>=length;--i)options[i]=null;if(disable)select.disabled=true;return options;},replaceSelectOptions:function(select,newOptions,selected,enable){select=$(select);if(!(select&&select.nodeName.toLowerCase()=="select"))return;var options=this.truncateSelectOptions(select,newOptions.length);var i=0;newOptions.each(function(opt){var optsel=false;if(selected&&(selected==opt[1]||selected.indexOf(opt[1])>=0)){optsel=true;}
var label=opt[0];label=label.gsub('&amp;','&');label=label.gsub('&gt;','>');label=label.gsub('&lt;','<');options[i++]=new Option(label,opt[1],optsel,optsel);});if(enable&&newOptions.length>1)select.disabled=false;}};

var WW_MINIMUM_QUERY_LENGTH=1;var last_query='';var module_id='-1';var disabled=[]
function cauldronSuggests(query){}
function searchBoxClickHandler(position)
{document.onclick=function(){var ac=$('search_box_auto_complete'+position);if(ac==null){return true;}
ac.hide();return true;};wheelRemoteProxy(position);return false;}
function wheelRemoteProxy(position)
{for(var i=0;i<disabled.length;i++){if(disabled[i]==position){return false;}}
var field=$('query'+position);var value=field.value;var type=field.form['ww_category'].value;if(value!=''&&last_query==value){show_word_wheel(position);return;}
last_query=value;if(value!=null&&value.length>=WW_MINIMUM_QUERY_LENGTH){var word_wheel_json_url="/SearchService/ww_jsonrpc/getWordWheelList";new Ajax.Request(word_wheel_json_url,{method:'get',parameters:encodeURI('query='+value+'&type='+type),onSuccess:function(req){render_word_wheel(req,value,position);}});}else{var container='search_box_auto_complete'+position;Element.hide(container);}}
function hide_element(elementName){Element.addClassName(elementName,'display_none');$(elementName).hide();}
function show_element(elementName){Element.removeClassName(elementName,'display_none');$(elementName).show();}
function render_word_wheel(req,query,position)
{try{var word_wheel_result=window.eval("("+req.responseText+")").result;var results=word_wheel_result.phraseList;var search_box="search_box_auto_complete"+position;var wheel_list="wheel_list"+position;var fresh_value=$F('query'+position);if(!query||!query||(results.length==0)){hide_element(search_box);}else{if(query==fresh_value){show_element(search_box);$(wheel_list).show();word_wheel_list="";for(var i=0;i<results.length;i++){phrase=results[i];word_wheel_list+=("<li class=\"word\"><a href=\"#\" onclick=\"return wwOnClick('"+position+"', '"+escape(phrase)+"')\" class = \"wheel_link\">"+phrase+"<\/a><\/li>\n");}
$(wheel_list).update(word_wheel_list);}}}catch(e){return;}}
function show_word_wheel(position)
{var word_wheel="search_box_auto_complete"+position;show_element(word_wheel);}
function hideWordWheel(position,width)
{disabled.push(position);return false;}
function wwOnClick(position,newVal)
{if($('query'+position)){$('query'+position).value=unescape(newVal);}
if($('src')){$('src').value='ww_'+$F('src');}
if($('submit_query_form'+position)){$('submit_query_form'+position).submit();}
return false;}
CM.WordWheel=Class.create();Object.extend(CM.WordWheel.prototype,Widget.prototype);Object.extend(CM.WordWheel.prototype,{initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);var queryBox=this.element;if(Element.hasClassName(queryBox,"bvr-ww-disabled")){return;}
if(queryBox.setAttribute){queryBox.setAttribute("autocomplete","off");}
Event.observe(queryBox,"click",function(event){var queryId=new String(Event.element(event).id);var position=queryId.substr(5,queryId.length);searchBoxClickHandler(position);Event.stop(event);});new Form.Element.Observer(queryBox,0.5,function(element,value){var queryId=element.id;var position=queryId.substr(5,queryId.length);wheelRemoteProxy(position);});}});function chooseNextLink(event,pos)
{var container='search_box_auto_complete'+pos;if(Element.hasClassName($(container),'display_none')){return false;}
if(event.keyCode==40||event.keyCode==38||event.keyCode==13||event.keyCode==27){var list_items=document.getElementsByClassName('word',container);var links=document.getElementsByClassName('wheel_link',container);if(event.keyCode==40){for(var i=0,len=list_items.length-1;i<len;++i){if(Element.hasClassName(list_items[i],'hovered')){toggleHoverStyles([list_items[i],list_items[i+1],links[i],links[i+1]]);Event.stop(event);return;}}
toggleHoverStyles([list_items.first(),links.first(),list_items.last(),links.last()]);Event.stop(event);}
if(event.keyCode==38){for(var i=list_items.length-1;i>0;--i){if(Element.hasClassName(list_items[i],'hovered')){toggleHoverStyles([list_items[i],list_items[i-1],links[i],links[i-1]]);Event.stop(event);return false;}}
toggleHoverStyles([list_items.last(),links.last(),list_items.first(),links.first()]);Event.stop(event);return false;}
if(event.keyCode==13){for(var i=0,len=links.length;i<len;++i){if(Element.hasClassName(list_items[i],'hovered')){$(getEventTarget(event).id).value=links[i].innerHTML;wwOnClick(event.target.id.substring(5),links[i].innerHTML);Event.stop(event);return true;}}}
if(event.keyCode==27){Element.hide(container);}}}
function getEventTarget(event){var targetElement=null;if(typeof event.target!="undefined"){targetElement=event.target;}else{targetElement=event.srcElement;}
while(targetElement.nodeType==3&&targetElement.parentNode!=null){targetElement=targetElement.parentNode;}
return targetElement;}
function toggleHoverStyles(elements)
{var element=null;var switches=0;for(var i=0,len=elements.length;i<len;++i){element=elements[i];if(Element.hasClassName(element,'hovered')){Element.removeClassName(element,'hovered');}else{if(switches<2){Element.addClassName(element,'hovered');switches++;}}}}
function disable_word_wheel(boxId,autoCompleteId,boxValue,inputContainerId,width)
{if(Prototype.Browser.Opera||Prototype.Browser.Webkit){var box=$(boxId);Element.remove(autoCompleteId);var box_value=$(boxValue).value;Element.update(inputContainerId,"<input type='text' id='"+boxId+"'_passive' name='query' class='search_box_"+width+" value='"+box_value+"' autocomplete='off' />");$(boxId+'_box_id_passive').focus();}}

function alertsGetAlertLinkFromContainer(container){var link=null;if((container!=null)&&(container.childNodes.length>0)){var children=container.childNodes;for(var i=0;i<children.length;i++){if(children[i].nodeType==1){link=children[i];break;}}}
return link;}
function alertsGetClass(link){var className=link.getAttribute('class');if(className==null){className=link.getAttribute('className');}
return className;}
function alertsSetClass(link,className){link.setAttribute('class',className);if(link.getAttribute('class')==null){link.setAttribute('className',className);}}

function update_review(rating,rating_element_id)
{var li_name=rating_element_id+'_rating_goes_here';$(li_name).className="average_rating average"+rating;$(rating_element_id+'_rating').value=rating;}
function addReply(display_name,comment_id)
{$('rating_comment').value=display_name+" wrote:\n\""+$(comment_id).innerHTML+"\"";}
function close_review_bubble(bubble_element,e)
{Effect.toggle(bubble_element);}
function toggle_review_bubble(bubble_element,e,rateable_id,rating)
{update_review(rating);var posx=0;var posy=0;if(!e)e=window.event;if(e.pageX||e.pageY)
{posx=e.pageX;posy=e.pageY;}
else if(e.clientX||e.clientY)
{posx=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;posy=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;}
if(!Element.visible(bubble_element))
Effect.toggle(bubble_element);var iestyle={top:posy+"px",left:posx-150+"px"};var style={top:posy-30+"px",left:posx-150+"px"};if(navigator.appVersion.match(/MSIE/i))
$(bubble_element).setStyle(iestyle);else
$(bubble_element).setStyle(style);if(rateable_id)
$('rateable_id').value=rateable_id;}
function toggle_options(id){Element.toggle('options'+id);var link='options_link'+id;if($(link).className=="options_closed"){$(link).className="options_open";update=false;}else{$(link).className="options_closed";update=true;}}
function toggle_review_bubble_and_set_type(bubble_element,e,rateable_id,rating,rateable_type,score_id)
{toggle_review_bubble(bubble_element,e,rateable_id,rating);if(rateable_type)
$('rateable_type').value=rateable_type;if(score_id)
$('score_id').value=score_id;}

var COMMENTS_MAX_LENGTH=1000;function checkCommentsMaxLength(Object)
{if(Object.value.length>COMMENTS_MAX_LENGTH)
{Object.value=Object.value.substring(0,COMMENTS_MAX_LENGTH);}
$('num_chars').innerHTML=Object.value.length;}
function rollOver(rat_id,text){$(rat_id).innerHTML=text;}
function rollOut(rat_id,default_text){$(rat_id).innerHTML=default_text;}
function rateClick(rat_id,text){$(rat_id).innerHTML=text;}
function update_rating(rating_id,hidden_field_id,rating,class_rating){$(hidden_field_id).value=rating;for(var i=10;i<=100;i+=10){Element.classNames($("current_rating_for_"+rating_id)).remove("average"+i);}
Element.addClassName($("current_rating_for_"+rating_id),class_rating);}
function addReply(display_name,comment_id){$('rating_comment').value=display_name+" wrote:\n\""+$(comment_id).innerHTML+"\"";}
function toggle_rating_bubble(bubble_element,e,rating_id){var posx=0;var posy=0;if(!e)var e=window.event;if(e.pageX||e.pageY){posx=e.pageX;posy=e.pageY;}
else if(e.clientX||e.clientY){posx=e.clientX+document.body.scrollLeft
+document.documentElement.scrollLeft;posy=e.clientY+document.body.scrollTop
+document.documentElement.scrollTop;}
if(rating_id){$("rating["+rating_id+"]").value=0.0;for(var i=10;i<=100;i+=10){Element.classNames($("current_rating_for_"+rating_id)).remove("average"+i);}}
Effect.toggle(bubble_element);if(!Element.visible(bubble_element)){var style={top:posy-30+"px",left:posx-150+"px"};$(bubble_element).setStyle(style);}}
function updateRatingSelection(id,value_for_class,value,formId){var ratingSelectedId="rating_selected_"+id;$(ratingSelectedId).className="average_rating average"+value_for_class;$(formId).value=value;$("rating_display_"+id).innerHTML=value;}

var DialogPage=Class.create();Object.extend(DialogPage.prototype,{initialize:function(options)
{this.active=null;},activate:function(dialog)
{if(this.active){this.active.hide();}
this.active=dialog;}});var DialogPageInstance=new DialogPage();var Dialog=Class.create();Object.extend(Dialog.prototype,{initialize:function(options)
{this.dialogOverlay=$("dialog-overlay");this.dialogBox=$("dialog-box");this.setupDialogDOM();this.hideHandler=Dialog.prototype.hide.bindAsEventListener(this);this.options=(options||{});this.controls=['input','select','button','textarea'];if((/Konqueror|Webkit|KHTML/.test(navigator.userAgent))||(/Linux|Mac/i.test(navigator.userAgent))){this.controls.push("object");this.controls.push("embed");}},setupDialogDOM:function()
{if(!this.dialogBox||!this.dialogOverlay){this.dialogBox=$(document.createElement("div"));this.dialogOverlay=$(document.createElement("div"));this.dialogOverlay.id="dialog-overlay";this.dialogBox.id="dialog-box";this.dialogOverlay.setOpacity(0.5);this.dialogOverlay.hide();this.dialogBox.hide();(($('container')&&$('container').parentNode)||document.body).appendChild(this.dialogOverlay);(($('container')&&$('container').parentNode)||document.body).appendChild(this.dialogBox);this.dialogOverlay=$("dialog-overlay");this.dialogBox=$("dialog-box");}},isVisible:function()
{return this.dialogBox.visible();},hide:function(event)
{this.showControls();this.dialogOverlay.hide();this.dialogBox.hide();if(event)Event.stop(event);if(!this.options.no_hiding_allowed){Event.stopObserving(this.dialogOverlay,"click",this.hideHandler);}
Event.stopObserving(window,"resize",this.resize.bindAsEventListener(this));},show:function(options)
{DialogPageInstance.activate(this);if(!this.options.no_hiding_allowed){Event.observe(this.dialogOverlay,"click",this.hideHandler);}
Event.observe(window,"resize",this.resize.bindAsEventListener(this));if(this.hideEffect){this.hideEffect.cancel();}
if(options){var visible=options.visible;if(options.left){this.options.left=options.left;}
if(options.top){this.options.top=options.top;}}
this.hideControls();this.dialogOverlay.show();this.resize(null);Element.show(this.dialogBox);try{if(visible){visible();}}catch(e){}},resize:function(event)
{var dim=Element.getDimensions($('main-content'));var scrollY=Position.getScrollTop();var scrollX=Position.getScrollLeft();var height=Position.getWindowHeight();var width=Position.getWindowWidth();if(height<dim.height){height=dim.height;}
if(width<dim.width){width=dim.width;}
this.dialogOverlay.style.top="0px";this.dialogOverlay.style.left="0px";this.dialogOverlay.style.width=width+scrollX+"px";this.dialogOverlay.style.height=height+scrollY+"px";this.dialogBox.style.position='absolute';this.dialogBox.style.zIndex=301;Position.center(this.dialogBox,this.options);},iterateControls:function(callable)
{var index=0;for(var i=0;i<this.controls.length;++i){var elements=document.getElementsByTagName(this.controls[i]);for(var j=0;j<elements.length;++j){var el=elements[j];if(!Element.childOf(el,this.dialogBox)){try{callable(el,index++);}catch(e){}}}}},hideControls:function()
{this.hiddenInputStates=[];this.iterateControls(this.hideControl.bind(this));},showControls:function()
{this.iterateControls(this.showControl.bind(this));},hideControl:function(el,index){if(el.style.visibility){this.hiddenInputStates.push(el.style.visibility);}
else{this.hiddenInputStates.push("");}
el.style.visibility="hidden";if(el.tagName=="embed"||el.tagName=="object"){el.style.display="none";}},showControl:function(el,index){el.style.visibility=this.hiddenInputStates[index];if(el.tagName=="embed"||el.tagName=="object"){el.style.display="block";}}});

var RemoteDialog=CM.Behavior.create(Dialog,{initialize:function(link)
{Widget.prototype.initialize.apply(this,arguments);Dialog.prototype.initialize.apply(this,arguments);Event.observe(link,"click",this.callDialog.bindAsEventListener(this));this.url=link.href;},verify:function(){return true;},callDialog:function(event)
{if(this.verify()){try{this.dialogBox.innerHTML="<div class='dialog'><div class='dialog-content'> <h2>Loading...</h2> <div class='dialog_close'></div></div><div class='dialog-cap'></div></div>";this.show({visible:this.visible.bind(this)});}catch(e){}
new Ajax.Request(this.url,{method:"get",onSuccess:this.showDialog.bind(this),onFailure:this.error.bind(this)});Event.stop(event);}},linkBehaviors:function()
{associateWidgets(this.dialogBox);var closeHooks=document.getElementsByClassName("bvr-dialog-close",this.dialogBox);var acceptHooks=document.getElementsByClassName("bvr-dialog-accept",this.dialogBox);for(var i=0,length=closeHooks.length;i<length;++i){Event.observe(closeHooks[i],"click",this.cancel.bindAsEventListener(this));}
for(var i=0,length=acceptHooks.length;i<length;++i){Event.observe(acceptHooks[i],"click",this.accept.bindAsEventListener(this));}},showDialog:function(req)
{this.dialogBox.innerHTML=req.responseText;try{this.show({visible:this.visible.bind(this)});}catch(e){}
this.linkBehaviors();},visible:function(){},accept:function(event)
{this.hide(event);},cancel:function(event)
{this.hide(event);Event.stop(event);},error:function(req)
{document.location=this.url;}});

CM.TabNav=CM.Behavior.create({initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);this.preloaded=this.element.hasClassName("bvr-tab-preloaded");this.list=this.element.down("ul").getElementsByTagName("li");for(var i=0,len=this.list.length;i<len;++i){var li=$(this.list[i]);if(li.hasClassName("selected")){this.selectedItem=li;this.selectedIndex=i;}
if(!li.hasClassName("non-clickable")){if(this.preloaded){Event.observe(li,"click",this.preloadShow.bindAsEventListener(this,i,li));}
else{Event.observe(li,"click",this.load.bindAsEventListener(this,li));}}}
this.panel=this.element.down("div.bvr-tab-container");this.panel.appear=function(options){Effect.Appear(this,options)}.bind(this.panel);this.panel.fade=function(options){Effect.Fade(this,options)}.bind(this.panel);if(this.preloaded){this.preloadedTabs=this.panel.getElementsByClassName("bvr-tab-nav-preloaded");}
this.tabCache={};if(!this.preloaded){var link=this.selectedItem.down("a").href;this.tabCache[link]=this.panel.innerHTML.replace(/_extended="true"/g,'');}
this.requesting=false;this.showing=false;this.progressVisible=false;this.noResponseCount=0;Event.observe(window,"unload",this.cleanup.bind(this));},cleanup:function()
{this.tabCache={};this.panel=null;this.selectedItem=null;this.element=null;},preloadShow:function(event,listIndex,listItem)
{Event.stop(event);if(listIndex==this.selectedIndex){return;}
var curTab=this.preloadedTabs[listIndex];var prevTab=$(this.preloadedTabs[this.selectedIndex]);var config={to:0.01,afterFinish:function(){prevTab.style.display="none";curTab.style.display="";this.panel.appear();}.bind(this)}
this.panel.fade(config);this.element.down("ul").removeClassName(prevTab.readAttribute("list_class"));this.element.down("ul").addClassName(curTab.readAttribute("list_class"));this.toggleItem(listItem);this.selectedIndex=listIndex;},toggleItem:function(listItem)
{if(listItem==this.selectedItem){return;}
this.selectedItem.removeClassName("selected");this.selectedItem=listItem;this.selectedItem.addClassName("selected");},load:function(event,listItem)
{if(event){Event.stop(event);}
if(listItem==this.selectedItem){return;}
this.toggleItem(listItem);var link=listItem.down("a").href;var config={to:0.01,queue:{position:'front',scope:'transition'}};this.showing=link;this.request(link);config.afterFinish=this.show.bind(this,link);if(!this.fade||(this.fade.finished()&&this.panel.getOpacity()>0.98)){this.noResponseCount=0;this.fade=this.panel.fade(config);}},request:function(link)
{var body=this.tabCache[link];if(body){return true;}
var config={method:'get',parameters:"__ajax__=1",onSuccess:this.store.bind(this,link),onFailure:this.failure.bind(this),onComplete:function(req){this.requesting=false;}.bind(this)};this.requesting=true;this.req=new Ajax.Request(link,config);return false;},store:function(link,req)
{this.tabCache[link]=req.responseText;},show:function(link)
{var body=this.tabCache[link];var display=(this.showing==link);if(!body){this.progress();setTimeout(this.show.bind(this,link),200);return;}
if(display){PageObject.release(this.panel);this.panel.parentNode.style.visiblity="hidden";this.panel.innerHTML=body;this.panel.parentNode.style.visiblity="visible";PageObject.apply(this.panel);var config={to:1.0,queue:{position:'end',scope:'transition'}};config.afterFinish=function(){this.appear=null;}.bind(this);if(!this.appear||(this.appear.finished()&&this.panel.getOpacity()<0.98)){this.fade=null;config.from=this.panel.getOpacity();if(Prototype.Browser.WebKit&&navigator.userAgent.indexOf('419')){config.afterFinish=function(){this.appear=null;this.panel.innerHTML=this.panel.innerHTML;PageObject.apply(this.panel);}.bind(this);}
this.appear=this.panel.appear(config);}
this.removeProgress();}},removeProgress:function()
{if(this.progressVisible){this.progressVisible=false;try{$(this.panel.parentNode).down("div.interstitial").remove();}catch(e){alert(e);}}},progress:function()
{this.fade=null;this.noResponseCount++;if(!this.progressVisible&&this.requesting&&this.noResponseCount>3){new Insertion.Before(this.panel,'<div class="interstitial">'+'<div class="modal_top"></div>'+'<div class="modal_middle">'+'<h3>Loading...</h3>'+'<div class="progress_bar"></div>'+'</div>'+'<div class="modal_bottom"></div>'+'</div>');this.progressVisible=true;}},failure:function(req)
{displayErrorMessage("Error while requesting... Please try again later.");this.panel.appear({queue:{position:'end',scope:'b'}});this.removeProgress();new Effect.Highlight(this.panel,{color:'red'});}});

var SessionTimeOut={timeOutInterval:30,timeOutWarnInterval:28,timeOutWarnCookieName:'CM_css_to_warn'};var timeoutDialog;var SessionTimeoutDialog=CM.Behavior.create(RemoteDialog,{initDate:null,jsTimeout:null,initialize:function(options)
{RemoteDialog.prototype.initialize.apply(this,arguments);timeoutDialog=this;this.startTicking();this.initDate=new Date();},showDialog:function(req)
{Event.stopObserving(this.dialogOverlay,"click",this.hideHandler);this.hideHandler=this.handleExtend.bindAsEventListener(this);Event.observe(this.dialogOverlay,"click",this.hideHandler);this.dialogBox.innerHTML=req.responseText;this.show();var buttons=this.dialogBox.getElementsByTagName("button");for(var i=0;i<buttons.length;++i){var button=buttons[i];if(button.className.match("bvr-dialog-close")){Event.observe(button,"click",this.handleLogout.bindAsEventListener(this));}
else{Event.observe(button,"click",this.handleExtend.bindAsEventListener(this));}}},handleExtend:function(event)
{this.clearTimeouts();if(Element.visible(this.dialogBox))
{new Ajax.Request('/session_extend',{method:'get'});this.hide();}
this.startTicking();Event.stop(event);},handleLogout:function(event)
{this.clearTimeouts();this.hide();window.location.href='/registration/login/signout';Event.stop(event);},startTicking:function(){if(Cookies.read("RTOKEN")==null)return;Cookies.create(SessionTimeOut.timeOutWarnCookieName,this.getDateAfter(SessionTimeOut.timeOutInterval));var warning_seconds=(SessionTimeOut.timeOutInterval-SessionTimeOut.timeOutWarnInterval)*60;var time_left=this.getTimeRemaining().getTime()/1000;setTimeout(this.showWarningIfNecessary.bind(this),(time_left-warning_seconds)*1000);},getTimeRemaining:function(){if(Cookies.read(SessionTimeOut.timeOutWarnCookieName)!=null)
{var timeOutTime=parseInt(Cookies.read(SessionTimeOut.timeOutWarnCookieName));var timeRemaining=new Date();timeRemaining.setTime(timeOutTime-new Date().getTime());return timeRemaining;}
else
{var timeRemaining=new Date();timeRemaining.setTime(0);return timeRemaining;}},minsToMillis:function(mins){return(mins*60*1000);},getDateAfter:function(mins){var futureDate=new Date();futureDate.setMinutes(futureDate.getMinutes()+mins);return futureDate;},showWarningIfNecessary:function(){var warning_seconds=(SessionTimeOut.timeOutInterval-SessionTimeOut.timeOutWarnInterval)*60;var time_left=this.getTimeRemaining().getTime()/1000;if(time_left<=warning_seconds&&time_left>0)
{new Ajax.Request('/registration/login/session_warning',{method:"get",onSuccess:this.showDialog.bind(this),onFailure:this.error.bind(this)});this.jsTimeout=setInterval(this.countDown.bind(this),1000);}
else if(time_left>warning_seconds)
{setTimeout(this.showWarningIfNecessary.bind(this),(time_left-warning_seconds)*1000);this.hide();}
else if(time_left==0||time_left<0)
{window.location.href='/registration/login/session_ended?dest='+window.location.href;}},countDown:function(){var warning_seconds=(SessionTimeOut.timeOutInterval-SessionTimeOut.timeOutWarnInterval)*60;var time_left=this.getTimeRemaining().getTime()/1000;if(time_left<=warning_seconds&&time_left>=0)
{if(document.getElementById("countdown"))
{document.getElementById("countdown").innerHTML=parseInt(time_left);}}
else if(time_left>warning_seconds)
{this.hide();this.clearTimeouts();setTimeout(this.showWarningIfNecessary.bind(this),(time_left-warning_seconds)*1000);}
else if(time_left==0||time_left<0)
{window.location.href='/registration/login/session_ended?dest='+window.location.href;}
if(Cookies.read("RTOKEN")==null)
{this.hide();window.location.href='/registration/login/signout';this.clearTimeouts();}
this.logoutIfNecessary();},logoutIfNecessary:function(){var warning_seconds=(SessionTimeOut.timeOutInterval-SessionTimeOut.timeOutWarnInterval)*60;var time_left=this.getTimeRemaining().getTime()/1000;if(Cookies.read(SessionTimeOut.timeOutWarnCookieName)==null){this.hide();this.clearTimeouts();window.location.href='/registration/login/session_ended?dest='+window.location.href;}},clearTimeouts:function(){clearInterval(this.jsTimeout);}});

var TextSizer=Class.create();Object.extend(TextSizer.prototype,Widget.prototype);Object.extend(TextSizer,{SIZES:$A(['','text_medium','text_large','text_xlarge'])});Object.extend(TextSizer.prototype,{initialize:function()
{var smaller=$("text_smaller");var larger=$("text_larger");if(!larger||!smaller){return;}
this.max=TextSizer.SIZES.length-1;this.size=0;Element.addClassName("main-content",TextSizer.SIZES[this.size]);Event.observe(smaller,'click',this.decrease.bindAsEventListener(this));Event.observe(larger,'click',this.increase.bindAsEventListener(this));},increase:function(e)
{if(this.size==this.max){Element.addClassName('text_larger','disabled');}
else{Element.removeClassName('text_smaller','disabled');Element.removeClassName("main-content",TextSizer.SIZES[this.size++]);Element.addClassName("main-content",TextSizer.SIZES[this.size]);if(this.size==this.max){Element.addClassName('text_larger','disabled');}}
Event.stop(e);},decrease:function(e)
{if(this.size==0){Element.addClassName('text_smaller','disabled');}else{Element.removeClassName('text_larger','disabled');Element.removeClassName("main-content",TextSizer.SIZES[this.size--]);Element.addClassName("main-content",TextSizer.SIZES[this.size]);if(this.size==0){Element.addClassName('text_smaller','disabled');}}
Event.stop(e);}});

function replaceWithSpinner(element,size)
{if(!size)size="large";$(element).innerHTML='<div class="module_spinner_'+size+'"></div>';}
CareProviders={conditionsCache:{},ajaxPrefix:"/care_providers/ajax",nameRegex:(/^[-' a-z]*$/i),city_state_zip:/^\s*(\d{5}|([\w\s]+)[\s,]\s*([a-z]+))\s*$/i,validateLocation:function(){var loc=$('search_city_state_zip');var match=this.city_state_zip.exec(loc.value);var code=match&&match[2]&&(StateNames.validStateCode(match[3])||StateNames.validStateName(match[3]));Element.hide('care_providers_flash_error');if(match&&(!match[3]||code)){if(code){loc.value=match[2]+', '+code;}
Element.hide('location_warning');return true;}else{Element.show('location_warning');return false;}},validateDocName:function(){var name=$('search_last');return(!name)||this.validateName($F(name));},validateFacName:function(){var name=$('search_facility_name');return(!name)||this.validateName($F(name));},validateName:function(name){return(!name)||name.match(this.nameRegex);},searchType:function(){var fields=$A(document.getElementsByTagName('input')).findAll(function(input){return input.name=='search[type]';});if(fields.length==1){return fields[0].value;}else if(fields.length>1){var checked=fields.find(function(input){return input.checked;});if(checked)return checked.value;}
return'provider_search';},validateSearch:function(evt){if(!this.validateLocation()){if(evt)Event.stop(evt);displayErrorMessage("We did not understand the location you entered. Please enter a city and state or a zip code.");return false;}
if(!this.validateDocName()){if(evt)Event.stop(evt);displayErrorMessage("The doctor's last name you entered contains characters that cannot appear in a doctor's last name.");return false;}
if(!this.validateFacName()){if(evt)Event.stop(evt);displayErrorMessage("The facility name you entered contains characters that cannot appear in a facility name.");return false;}
return true;},setCategoriesForSpecialty:function(specialty,data){this.conditionsCache["spec"+specialty]=data;this.displayCategories(data.categories);},displayCategories:function(data){SelectControl.replaceSelectOptions('search[condition_cat]',data,'',data.length>1);},displayConditions:function(data){if(data&&data.length>0){data=[['2) Select condition or treatment','']].concat(data);}else{data=[['No available conditions','']];}
SelectControl.replaceSelectOptions('search[conditions]',data,'',data.length>1);},updateCategoryAndConditionDropdowns:function(){if(!$('search[condition_cat]'))return;var specialty=$('search[specialty]');specialty=specialty?specialty.value:'';SelectControl.setSelectWaiting('search[conditions]','2) Select condition or treatment');var data=this.conditionsCache["spec"+specialty];if(data){this.displayCategories(data.categories);}else{SelectControl.setSelectWaiting('search[condition_cat]','Updating categories list...');var facility=(this.searchType()=='facility_search')?'&facility=true':'';new Ajax.Request(this.ajaxPrefix+'/update_conditions_cat_dd?specialty_id='+specialty+facility,{method:'get'});}},updateConditionsDropdown:function(){var condition_cat=$F('search[condition_cat]');var specialty=$('search[specialty]');specialty=specialty?specialty.value:'';var data=this.conditionsCache["spec"+specialty];if(data){this.displayConditions(data["cat"+condition_cat]);}else{SelectControl.setSelectWaiting('search[conditions]','Updating conditions list...');var facility=(CareProviders.searchType()=='facility_search')?'&facility=true':'';new Ajax.Request(CareProviders.ajaxPrefix+'/update_conditions_dd?cat_id='+condition_cat+'&specialty_id='+specialty+facility,{method:'get'});}},updateSpecialtiesDropdown:function(provider_type){var cur;SelectControl.setSelectWaiting('search[specialty]','Updating specialties list...');this.updateCategoryAndConditionDropdowns();if(provider_type instanceof Array){provider_type=provider_type.inject('',function(str,arg){return str+"&provider_type[]="+arg;}).slice(1);}else{provider_type="provider_type="+provider_type;}
new Ajax.Request(CareProviders.ajaxPrefix+'/update_specialties_dd?'+provider_type,{method:'get'});},updateAffiliationDropdowns:function(){var group=$('search[group_affiliation]');var hospital=$('search[hospital_affiliation]');if(!(group&&hospital))return;if(this.validateLocation()){SelectControl.setSelectWaiting(group,'Updating affiliations...');SelectControl.setSelectWaiting(hospital,'Updating affiliations...');new Ajax.Request(CareProviders.ajaxPrefix+'/update_affiliation_drop_down?city_state_zip='+escape($F('search_city_state_zip')),{method:'get'});}else{SelectControl.setSelectWaiting(group,'Enter a city and state or zip first');SelectControl.setSelectWaiting(hospital,'Enter a city and state or zip first');}}};function updateConditionsDropdown()
{CareProviders.updateConditionsDropdown();}
function updateCategoryAndConditionDropdowns()
{CareProviders.updateCategoryAndConditionDropdowns();}
function updateSpecialtiesDropdown(provider_type)
{CareProviders.updateSpecialtiesDropdown(provider_type);}
function glanceSwitchTab(id,target_tab)
{$$('.at_a_glance_'+id+'_tab').each(function(el){Element.removeClassName(el,'selected');});$$('.at_a_glance_'+id+'_content').each(function(el){Element.hide(el);});Element.show('at_a_glance_'+id+'_content_'+target_tab);Element.addClassName('at_a_glance_'+id+'_tab_'+target_tab,'selected');}
String.prototype.isEmpty=function(){var s=this.toString();return((s==null)||(s.length==0));};String.prototype.isWhitespace=function(){var s=this.toString();if(isEmpty(s))return true;for(i=0;i<s.length;i++){if(s.charCodeAt(i)>=32)return false;}
return true;};function validateEmail(email)
{var email_regex=/^[a-z0-9,\!\#\$\%\&\'\*\+\/=\?\^_\`\{\|}~-]+(\.[a-z0-9,\!\#\$\%\&\'\*\+\/=\?\^_\`\{\|}~-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.([a-z]{2,})$/i;if(email_regex.test(email)){return true;}else{return false;}}

function popup_symptom_checker(url){var win=window.open(url,'symptom_checker','menubar=no,toolbar=yes,scrollbars=yes,width=1000,height=600,resizable=yes');win.focus();return win;}
var new_parent=null;function display_content(url){if(opener!=null){opener.location.href=url;opener.focus();return;}
if(new_parent!=null){new_parent.location.href=url;new_parent.focus();}else{new_parent=window.open(url);new_parent.focus();}}

var SearchDrawerWidget=CM.Behavior.create({initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);Event.observe(this.element,"click",this.toggle.bindAsEventListener(this,true));this.expansion=$(this.element.id+"_expansion");this.form=$(this.element.id+"_form");this.cleanup_drawer(this.expansion);},cleanup_drawer:function(expansion)
{if(Element.hasClassName(expansion,'nodisplay')){Element.hide(expansion);Element.removeClassName(expansion,'nodisplay');}},close_drawer_if_needed:function()
{if(Element.hasClassName(this.expansion,'bvr-hide-on-load')){Element.removeClassName(this.expansion,'bvr-hide-on-load');Element.hide(this.expansion);Element.update(this.element,'More options');}},toggle:function(event,stop)
{Event.stop(event);this.toggle_form();},toggle_form:function()
{var initial_state_closed=!Element.visible(this.expansion);var new_state_closed=!initial_state_closed;this.toggle_form_elements(new_state_closed);Effect.toggle(this.expansion,'blind',{duration:0.5});Element.removeClassName(this.element,initial_state_closed?'closed':'open');Element.addClassName(this.element,new_state_closed?'closed':'open');Element.update(this.element,new_state_closed?'More options':'Hide options');},toggle_form_elements:function(disable)
{elements=new Form.getElements(this.form);for(i=0;i<elements.length;i++){form_element=elements[i];if(!(Element.hasClassName(form_element,'bvr-search-box'))){if(disable&&!(Element.hasClassName(form_element,'bvr-enabled-no-override'))){form_element.disabled='true';}else if(!Element.hasClassName(form_element,'bvr-disabled-no-override')){form_element.disabled='';}}}},initialize_form_elements:function(expansion)
{var initial_state_closed=!Element.visible(expansion);this.toggle_form_elements(initial_state_closed);}});

function infoEffects(div,left,top,width,height,count){if($(div+"_1")==null)return;var flash=new SWFObject("/flash/text_effects/TextEffects.swf",div+"_swf",width,height,"8","#ffffff");flash.addParam("wmode","opaque");flash.addVariable("font_path","/flash/RevolutionFonts.swf");for(var i=1;i<=count;i++){var textDiv=div+"_"+i;flash.addVariable("p"+i,escape($(textDiv).innerHTML));}
flash.addVariable("delay","6");flash.addVariable("font-size","22");flash.addVariable("left",left+"");flash.addVariable("top",top+"");flash.addVariable("text-width",width+"");flash.addVariable("text-height",height+"");flash.write(div);}
function hideInfo(div,count){if(deconcept.SWFObjectUtil.getPlayerVersion().major<8)return;for(var i=1;i<=count;i++){var textDiv=div+"_"+i;$(textDiv).hide();}}

if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",_7);this.setAttribute("doExpressInstall",false);var _d=(_9)?_9:window.location;this.setAttribute("xiRedirectUrl",_d);this.setAttribute("redirectUrl","");if(_a){this.setAttribute("redirectUrl",_a);}};deconcept.SWFObject.prototype={setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};deconcept.PlayerVersion=function(_27){this.major=_27[0]!=null?parseInt(_27[0]):0;this.minor=_27[1]!=null?parseInt(_27[1]):0;this.rev=_27[2]!=null?parseInt(_27[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_29){var q=document.location.search||document.location.hash;if(q){var _2b=q.substring(1).split("&");for(var i=0;i<_2b.length;i++){if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return"";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};if(typeof window.onunload=="function"){var _30=window.onunload;window.onunload=function(){deconcept.SWFObjectUtil.cleanupSWFs();_30();};}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};if(typeof window.onbeforeunload=="function"){var oldBeforeUnload=window.onbeforeunload;window.onbeforeunload=function(){deconcept.SWFObjectUtil.prepUnload();oldBeforeUnload();};}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){Array.prototype.push=function(_31){this[this.length]=_31;return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

var notify_us_dialog_position="relative";var notify_us_dialog_width="auto";var notify_us_dialog_background="transparent";var notify_us_dialog_border="none";var notify_us_dialog_padding="0px";var NotifyUsDialog=CM.Behavior.create(Dialog,{initialize:function(dialog)
{Dialog.prototype.initialize.call(this);this.dialogBox.style.position=notify_us_dialog_position;this.dialogBox.style.width=notify_us_dialog_width;this.dialogBox.style.background=notify_us_dialog_background;this.dialogBox.style.border=notify_us_dialog_border;this.dialogBox.style.padding=notify_us_dialog_padding;Event.observe(dialog,"click",this.showNotifyUsDialog.bindAsEventListener(this,dialog));},showNotifyUsDialog:function(event,dialog)
{var self=this;var action=dialog.getAttribute('notify_us_action');dialog.href="#";new Ajax.Request(action,{onSuccess:function(req){showNotifyUsText(self,event,req.responseText);},onFailure:function(req){showNotifyUsText(self,event,'Failed to make request');}});Event.stop(event);}});function showNotifyUsText(dialog,event,text)
{this.notify_us_dialog=dialog;showDialogText(text);dialog.show();}
function showDialogText(text)
{this.notify_us_dialog.dialogBox.innerHTML=text;}
function remove_notify_us_div()
{this.notify_us_dialog.hide();}
function initialize_notify_us_dialogs()
{var elements=document.getElementsByClassName("notify_us_element");for(var i=0;i<elements.length;++i){new NotifyUsDialog(elements[i]);}}
function initialize_one_notify_us_dialog(dialog)
{new NotifyUsDialog(dialog);}
function send_report(action)
{new Ajax.Request(action,{onSuccess:function(req){showDialogText(req.responseText);},onFailure:function(req){showDialogText('Failed to make request');}});}

function peopleLikeMeFlyout(condition_id){new Ajax.Updater('people_like_me','/my-profile/people_like_me_flyout?'+condition_id,{asynchronous:true,onComplete:function(){Element.show('people_like_me');}});}
function add_comment_form()
{try{if(!Element.visible('add_a_review'))Effect.toggle('add_a_review');Element.show('add_a_review');$('comment').value='';OdoEngine.setEditorContent('comment','');}catch(e){}}
function edit_comment_form(id)
{try{Element.hide("comments");Element.show('edit_a_comment');$('edit_a_comment_id').value=id;}catch(e){}}
function toggleCondition(elementID)
{var toggleElement=$(elementID);new Effect.toggle(toggleElement);var linkElement=$("link_"+elementID);if(linkElement.className=="arrow_closed")
{linkElement.className="arrow_open";}
else
{linkElement.className="arrow_closed";}}
function toggleArrow(element){if(Element.classNames(element).include('arrow_open')){Element.removeClassName(element,'arrow_open');Element.addClassName(element,'arrow_closed');}else{Element.removeClassName(element,'arrow_closed');Element.addClassName(element,'arrow_open');}}

var MedSearch=Class.create();MedSearch.prototype={initialize:function(){Event.observe("medication-search-name","click",this.toggleSearch.bind(this));Event.observe("medication-search-condition","click",this.toggleSearch.bind(this));},toggleSearch:function(e){var button=Event.element(e);if(button.id=="medication-search-name"){Element.show('med-manager-search-name');Element.hide('med-manager-search-condition');$("dd-"+button.id).className="selected";$("dd-medication-search-condition").className="";}else{Element.hide('med-manager-search-name');Element.show('med-manager-search-condition');$("dd-"+button.id).className="selected";$("dd-medication-search-name").className="";}}};Event.onDOMReady(function(){if($("search_term")){var st=new MedWordWheel($("search_term"),true);if($("radio_medication")){Event.observe($("radio_medication"),"click",function(e){st.updateType("medication");});}
if($("radio_condition")){Event.observe($("radio_condition"),"click",function(e){st.updateType("condition");});}}
if($("medication_term")){var mw=new MedWordWheel($("medication_term"),true);}
if($("condition_term")){var cw=new MedWordWheel($("condition_term"),true);cw.updateType('condition');}});var MedQuicklist=Class.create();MedQuicklist.prototype={initialize:function(){this.init();}};MedQuicklist.prototype.init=function(){$$("#med_manager #my_medications .edit a.edit_quicklist").each(function(e){Event.observe(e,"click",this.toggle.bind(this));}.bind(this));$$("#med_manager #my_medications .edit .list li input").each(function(e){Event.observe(e,"click",this.save.bind(this));}.bind(this));};MedQuicklist.prototype.save=function(event){var form=Event.element(event).parentNode.parentNode;var id=form.id.split('-')[2];new Ajax.Request(form.action,{method:'post',postBody:Form.serialize(form),onSuccess:function(e){$("li-quicklist-"+id).className="hide_edit";new Effect.Fade($("div-quicklist-"+id),{afterFinish:function(effect){$("my_medications").innerHTML=e.responseText;this.init();}.bind(this)});}.bind(this)});};MedQuicklist.prototype.hide=function(id){if(id){$("li-quicklist-"+id).className="hide_edit";new Effect.Fade($("div-quicklist-"+id));}};MedQuicklist.prototype.remove=function(id){if(id){$("li-quicklist-"+id).className="hide_edit";new Effect.Fade($("div-quicklist-"+id));}};MedQuicklist.prototype.toggle=function(event){Event.stop(event);var link=Event.element(event);if(link.id.split("-")[3]!=this.id){this.hide(this.id);}
this.id=link.id.split("-")[3];var li=$("li-quicklist-"+this.id);var div=$("div-quicklist-"+this.id);if(li.className=="hide_edit"){li.className="show_edit";new Effect.Appear(div);link.innerHTML="Cancel";}else{this.hide(this.id);link.innerHTML="Edit";}};var MedDetail=Class.create();MedDetail.prototype={initialize:function(id){this.id=id;if($("quicklist-dropdown")){this.quicklist=new MedQuicklist();if($("quicklist-add-"+this.id)){Event.observe("quicklist-add-"+this.id,"click",this.toggle.bind(this));}
$$("#quicklist-dropdown-"+this.id+" li input").each(function(e){Event.observe(e,"click",this.add.bind(this));}.bind(this));}}};MedDetail.prototype.toggle=function(event){Event.stop(event);if($("quicklist-dropdown-"+this.id).style.display=="none"){new Effect.BlindDown("quicklist-dropdown-"+this.id);}else{new Effect.BlindUp("quicklist-dropdown-"+this.id);}};MedDetail.prototype.add=function(event){var radio=Event.element(event);var label=$(radio.id+"_label");var form=$("quicklist-form-"+this.id);new Ajax.Request(form.action,{method:'post',postBody:Form.serialize(form),onSuccess:function(e){$("my_medications").innerHTML=e.responseText;new Effect.Highlight("my_medications");this.quicklist.init();$("quicklist-add-"+this.id).hide();$("quicklist-remove-"+this.id).show();$("quicklist-dropdown-"+this.id).hide();$("div-quicklist-"+this.id).className="remove_from_list";$("li-quicklist-"+this.id).className="on_my_quicklist";$("add-to-quicklist-"+this.id).removeClassName("show_dropdown");$("add-to-quicklist-"+this.id).addClassName("hide_dropdown");}.bind(this)});};var MedSearchResult=Class.create();MedSearchResult.prototype={initialize:function(){$$("#med_manager ul.data dd a.add-quicklist").each(function(e){Event.observe(e,"click",this.viewAdd.bind(this));}.bind(this));$$("#med_manager ul.data dd a.remove-quicklist").each(function(e){Event.observe(e,"click",this.remove.bind(this));}.bind(this));$$("#med_manager ul.data .quicklist_result form input").each(function(e){Event.observe(e,"click",this.add.bind(this));}.bind(this));this.searchOptions=$("detailed-search-options");Event.observe($("link-search-options"),"click",this.toggleSearchOptions.bind(this));this.quicklist=new MedQuicklist();}};MedSearchResult.prototype.add=function(event){var form=Event.element(event).parentNode.parentNode.parentNode;var id=form.id.split('-')[2];new Ajax.Request(form.action,{method:'post',postBody:Form.serialize(form),onSuccess:function(e){$("my_medications").innerHTML=e.responseText;new Effect.Highlight("my_medications");this.quicklist.init();$("quicklist-add-"+id).hide();$("quicklist-remove-"+id).show();$("quicklist-dropdown-"+id).hide();$("div-quicklist-"+id).className="remove_from_list";$("li-quicklist-"+id).className="on_my_quicklist";$("add-to-quicklist-"+id).removeClassName("show_dropdown");$("add-to-quicklist-"+id).addClassName("hide_dropdown");form.reset();}.bind(this)});};MedSearchResult.prototype.toggleSearchOptions=function(event){Event.stop(event);var link=Event.element(event);if(link.innerHTML.match(/Refine/)){new Effect.BlindDown(this.searchOptions);link.innerHTML="Hide search options";}else{new Effect.BlindUp(this.searchOptions);link.innerHTML="Refine search options";}};MedSearchResult.prototype.remove=function(event){Event.stop(event);var link=Event.element(event);var id=link.id.split('-')[2];new Ajax.Request(link.href,{method:'post',onSuccess:function(e){$("my_medications").innerHTML=e.responseText;this.quicklist.init();new Effect.Highlight("my_medications");$("quicklist-add-"+id).show();$("quicklist-remove-"+id).hide();$("div-quicklist-"+id).className="add_to_list";$("li-quicklist-"+id).className="not_on_quicklist";}.bind(this)});};MedSearchResult.prototype.viewAdd=function(event){Event.stop(event);var id=Event.element(event).id.split('-')[2];var quicklist=$("quicklist-dropdown-"+id);var dd=$("add-to-quicklist-"+id);if(dd.hasClassName("hide_dropdown")){dd.removeClassName("hide_dropdown");dd.addClassName("show_dropdown");new Effect.BlindDown(quicklist,{duration:0.25});new Effect.Appear(quicklist,{duration:0.25});}else{new Effect.Fade(quicklist,{duration:0.25});new Effect.BlindUp(quicklist,{duration:0.25,afterFinish:function(e){dd.removeClassName("show_dropdown");dd.addClassName("hide_dropdown");}.bind(this)});}};

var MedWordWheel=Class.create();MedWordWheel.prototype={initialize:function(text_field,search_type){this.url="/medications/word_wheel/search";this.url=this.url+"?search_type="+this.searchType;this.results=document.createElement('div');this.results.id="medication-wordwheel";document.body.appendChild(this.results);this.autoCompleter=new Ajax.Autocompleter(text_field,this.results.id,this.url,{paramName:"search_term",frequency:0.2,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});}
new Effect.SlideDown(update,{duration:0.4});}.bind(this),onHide:function(element,update){new Effect.SlideUp(update,{duration:0.3});}.bind(this)});},updateType:function(type){this.autoCompleter.url="/medications/word_wheel/search?search_type="+type;}};MedWordWheel.prototype.searchType="medication";

var PageObject=new CM.WidgetPage();PageObject.registerGroup({"bvr-collapsible-toggle":{klass:CollapsibleWidget},"bvr-qna-toggle":{klass:QnaToggleWidget},"bvr-profile-menu-toggle":{klass:ProfileMenuToggleWidget},"bvr-quote-text":{klass:QuoteWidget},"bvr-input-label":{klass:CM.InputLabel},"bvr-input-select":{klass:CM.InputSelect},"bvr-hover-bubble":{klass:HoverBubble},"bvr-hover-window":{klass:HoverWindowWidget},"bvr-dismissable":{klass:DismissableWidget},"bvr-search-drawer":{klass:SearchDrawerWidget},"bvr-search-box":{klass:CM.WordWheel},"bvr-remote-dialog":{klass:RemoteDialog},"bvr-session-timeout-dialog":{klass:SessionTimeoutDialog},"bvr-notify-us-dialog":{klass:NotifyUsDialog},"bvr-targeted-collapsible-section-toggle":{klass:TargetedCollapsibleSectionWidget}});Effect.DefaultOptions.duration=0.5;debug_mode_on=false;CM.windowLoaded=false;function pageInit()
{var start_timer=null;if(debug_mode_on){start_timer=new Date();}
CM.windowLoaded=true;initializeMenus();associateWidgets();new TextSizer();var form=$('care_providers_search_results_form');if(form){Event.observe(form,'submit',CareProviders.validateSearch.bindAsEventListener(CareProviders));}
if(debug_mode_on){try{console.debug("Total Page Load took "+((new Date())-start_timer)+" ms to initialize");}catch(e){}}}
Event.onDOMReady(pageInit);function browserCSSDetection()
{var ua=navigator.userAgent.toLowerCase();var is=function(t){return ua.indexOf(t)!=-1;};var b=(!(/opera|webtv/i.test(ua))&&/msie(\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')?'gecko':is('opera/9')?'opera opera9':/opera(\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'';if(/webkit/.test(ua)){var version=$A(new RegExp(/applewebkit\/(\d{3,})/).exec(ua)).last();if(version>419){b="webkit";}}
var os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';var css={browser:b,os:os};return css;}
function associateWidgets(parent)
{PageObject.apply(parent);}
function displayErrorMessage(msg)
{displayErroBarMessage(msg,'error');}
function displayNoticeMessage(msg)
{displayErroBarMessage(msg,'notice');}
Object.extend(CM,{hideNoticeMessage:function()
{var container=$("error_container");if(container&&container.visible()){Effect.SlideUp(container);}}});function displayErroBarMessage(msg,err_type)
{var err=$('error_container');var content=$$('#error_container div')[0];if(!(err&&content)){var err_bar=$('error_bar');if(!err_bar){document.createElement('div');err_bar.id='error_bar';document.body.insertBefore(err_bar,document.body.firstChild);}
err=document.createElement('div');Event.observe(err,'click',function(evt){Effect.SlideUp('error_container');Event.stop(evt);});content=document.createElement('div');err_bar.appendChild(err);err.appendChild(content);Element.hide(err);}
err.id='error_container';err.className='on';content.className=err_type;Element.addClassName(err,err_type);content.innerHTML=" <div>"+msg+"<span> </span><a href='#'>Hide</a></div> ";new Effect.SlideDown(err);}
CM.LinuxMenu=Class.create();Object.extend(CM.LinuxMenu.prototype,Widget.prototype);CM.LinuxMenu.active=0;Object.extend(CM.LinuxMenu.prototype,{initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);var items=this.element.immediateDescendants();for(var i=0,len=items.length;i<len;++i){var li=$(items[i]);var ddown=(li.getElementsBySelector("div.ddown")[0]||li.getElementsByTagName("ul")[0]);if(ddown){if(ddown.tagName=="ul"){ddown=ddown.firstChild;}
Event.observe(li,"mouseover",this.show.bindAsEventListener(this.element,li,ddown));Event.observe(document.body,"mouseout",this.hide.bindAsEventListener(this.element,li,ddown));}}},show:function(event,li,ddown)
{if(!li.activated&&Event.element(event).descendantOf(li)){li.activated=true;var container=$("linux-overlap-iframe");container.style.width=ddown.getWidth()-8+"px";container.style.height=ddown.getHeight()+22+"px";var offset=Position.cumulativeOffset(li);container.style.left=offset[0]+"px";container.style.top=offset[1]+"px";container.style.display="block";CM.LinuxMenu.active++;}},hide:function(event,li,ddown)
{if(li.activated&&!Event.element(event).descendantOf(li)){li.activated=false;CM.LinuxMenu.active--;if(CM.LinuxMenu.active<=0){$("linux-overlap-iframe").style.display="none";}}}});function initializeMenus(){if(Prototype.Browser.Gecko&&navigator.userAgent.indexOf('Linux')>-1){new Insertion.Before("container","<iframe src='javascript:;' id='linux-overlap-iframe' frameborder='0' scrolling='no'></iframe>");PageObject.register("bvr-menu",CM.LinuxMenu);}}

CM.FlashWidget=CM.Behavior.create({initialize:function(e)
{Widget.prototype.initialize.apply(this,arguments);var src=(this.element.src||this.element.getAttribute("src"));if(src&&(deconcept.SWFObjectUtil.getPlayerVersion().major>7)){this.setup(src);this.write(src);}
else{this.element=this.element.up(".flash");this.element.innerHTML="<img src='"+src+"'/>";}
Event.observe(window,"unload",this.finialize.bind(this));},finialize:function(){this.so=null;},setup:function(src)
{var params=src.toQueryParams();this.imgSrc=src;this.width=(this.width||params["flash_width"]);this.height=(this.height||params["flash_height"]);this.flashId=params["flash_asset"];this.flashSrc=params["flash_src"];this.wmode=(params["wmode"]||'transparent');this.so=new SWFObject(this.flashSrc,this.flashId,this.width,this.height,'8');this.so.addParam("wmode",this.wmode);this.so.addParam("allowscale","false");this.so.addVariable("omniture_source",params["omniture_src"]);if(params["account"]){this.so.addVariable("account",params["account"]);}},write:function(src)
{if(!this.element.hasClassName("flash")){this.element=this.element.up(".flash");this.contents=this.element.innerHTML;}
this.so.write(this.element);},reWrite:function(options)
{Object.extend(this,options);this.setup(this.imgSrc);this.write(this.imgSrc);},revert:function(options)
{this.element.innerHTML=this.contents;}});PageObject.register("bvr-flash-widget",CM.FlashWidget);

CM.NumberedFlashWidget=CM.Behavior.create(CM.FlashWidget,{initialize:function(e)
{Widget.prototype.initialize.apply(this,arguments);var src=(this.element.src||this.element.getAttribute("src"));var params=src.toQueryParams();if(src&&(params["image_count"]>0)&&(deconcept.SWFObjectUtil.getPlayerVersion().major>7)){this.setup(src);this.write(src);}
else{this.element=this.element.up(".flash");this.element.innerHTML="<img src='"+src+"'/>";}
Event.observe(window,"unload",this.finialize.bind(this));},setup:function(src)
{var params=src.toQueryParams();this.imgSrc=src;this.width=(this.width||params["flash_width"]);this.height=(this.height||params["flash_height"]);this.flashId=params["flash_asset"];this.flashSrc=params["flash_src"];this.wmode=(params["wmode"]||'transparent');this.color=params["color"];this.image_count=params["image_count"]
this.so=new SWFObject(this.flashSrc,this.flashId,this.width,this.height,'8');this.so.addParam("wmode",this.wmode);this.so.addParam("allowscale","false");this.so.addVariable("omniture_source",params["omniture_src"]);this.so.addVariable("bgColor",this.color);this.so.addVariable("dl_timer",params["dl_timer"]);for(var count=0;count<this.image_count;count++){this.so.addVariable("dl_img"+count,params["dl_image"+count]);this.so.addVariable("dl_link"+count,params["dl_link"+count]);}
if(params["account"]){this.so.addVariable("account",params["account"]);}}});PageObject.register("bvr-numbered-flash-widget",CM.NumberedFlashWidget);

CM.PopupLinkWidget=CM.Behavior.create({size_class_regex:/^popup_size_(\d+)x(\d+)$/,win_fmt:'width=#{1},height=#{2},location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=yes',initialize:function(element){var size=Element.classNames(element).grep(this.size_class_regex)[0];this.url=element.href;if(size){var match=size.match(this.size_class_regex);this.width=parseInt(match[1]);this.height=parseInt(match[2]);}else{this.width=640;this.height=480;}
Event.observe(element,"click",this.click.bindAsEventListener(this));},click:function(evt){Event.stop(evt);var win=window.open(this.url,"RevolutionHealthPopup",this.win_fmt.format(this.width,this.height));try{win.resizeTo(this.width,this.height);}catch(ex){}
try{win.focus();}catch(ex){}}});PageObject.register("bvr-popup-window-link",CM.PopupLinkWidget);

CM.Carousel=CM.Behavior.create({initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);this.id=this.element.id;this.base_link="/content/modules/image/carousel";this.cache={};this.updating=false;this.setupEventHandlers();},setupEventHandlers:function()
{var links=this.element.getElementsBySelector("a.carousel-link");for(var i=0,len=links.length;i<len;++i){var link=links[i];Event.observe(link,"click",this.toggle.bindAsEventListener(this,link.search));}},toggle:function(e,query)
{if(!this.updating){this.updating=true;$(this.id+"-spinner").toggle();if(this.cache[query]){this.update(query);}
else{new Ajax.Request(this.base_link+query,{onSuccess:this.update.bind(this,query),onFailure:this.error.bind(this),onComplete:this.verifyResponse.bind(this)});}}
Event.stop(e);},update:function(query,req)
{if(!this.cache[query]){this.cache[query]=req.responseText;}
this.element.style.height=this.element.up(".q_module").getHeight()+"px";this.min_height=$("list-"+this.id).style.height=($("list-"+this.id).getHeight()-20)+"px";new Effect.Fade($("list-"+this.id),{from:1,to:0.1,afterFinish:this.showNewContent.bind(this,this.cache[query])});},showNewContent:function(content)
{$("list-"+this.id).hide();this.element.update(content);new Effect.Appear($("list-"+this.id));try{$("list-"+this.id).style.minHeight=this.min_height;}catch(e){$("list-"+this.id).style.height=this.min_height;}
this.setupEventHandlers();this.updating=false;this.element.style.height="auto";},verifyResponse:function(req)
{if(!req.responseText.match(/<div class="carousel_pagination">/)){this.error(req);}},error:function(req)
{$(this.id+"-spinner").hide();try{$(this.id+"-error").remove();}catch(e){}
new Insertion.Top(this.id,"<strong style='display:none;position:absolute;top:"+parseInt(this.element.style.height)/2+"px;left:80px;z-index:200;background:#ff5555;padding:10px;' id='"+
this.id+"-error'>Network Error, Please try again.</strong>");new Effect.Appear(this.id+"-error");this.updating=false;}});PageObject.register("bvr-carousel",CM.Carousel);

CM.UtilityBar=Class.create();Object.extend(CM.UtilityBar,{update:function(content,noUp,usefade,downOptions,upOptions)
{var container=$('CM-main-content-inner-wrapper-wrapper');if(usefade){var oldHeight=$(container.firstChild).getHeight();var oldWidth=$(container.firstChild).getWidth();$(container).style.height=oldHeight+"px";$(container).style.display="block";$(container.firstChild).style.position="absolute";$(container.firstChild).style.top="0px";$(container.firstChild).style.width=(oldWidth-10)+"px";this.up(upOptions,usefade);new Insertion.Top(container,content);var newHeight=$(container.firstChild).getHeight();if(newHeight>oldHeight){$(container).style.height=newHeight+"px";}}
else{container.hide();container.update(content);$(container.firstChild).hide();container.show();}
PageObject.apply(container);this.down(downOptions,usefade);},register:function(cache)
{if(!this.users){this.users=new Array();}
this.users.push(cache);},clear:function(cache,usefade)
{for(var i=0,len=this.users.length;i<len;++i){var c=this.users[i];if(c!=cache&&typeof(c.isContentVisible)=='function'&&c.isContentVisible()){c.hide(usefade);}}},isDown:function()
{var container=$('CM-main-content-inner-wrapper-wrapper');return(container.childNodes.length>0&&container.firstChild&&$(container.firstChild).visible&&$(container.firstChild).visible());},down:function(options,usefade)
{if(Prototype.Browser.IE){var call=function(){};if(options&&options.afterFinish){call=options.afterFinish;}
options.afterFinish=function(){call();$('CM-main-content-inner-wrapper-wrapper').firstChild.style.zoom=1;}.bind(this);}
if(usefade){Effect.Appear($('CM-main-content-inner-wrapper-wrapper').firstChild,options);}
else{Effect.BlindDown($('CM-main-content-inner-wrapper-wrapper').firstChild,options);}},removeFromDOM:function()
{var container=$('CM-main-content-inner-wrapper-wrapper');var descendants=container.immediateDescendants();if(descendants.length>1){$(descendants[1]).remove();}
else{$(container.firstChild).remove();}
container.style.height="auto";},up:function(options,usefade)
{if(options&&options.afterFinish){var callback=options.afterFinish;options.afterFinish=function(){callback();this.removeFromDOM();}.bind(this);}
else{options={};options.afterFinish=this.removeFromDOM.bind(this);}
if(usefade){Effect.Fade($('CM-main-content-inner-wrapper-wrapper').firstChild,options);}
else{Effect.BlindUp($('CM-main-content-inner-wrapper-wrapper').firstChild,options);}},isLoading:function()
{return this.loading;},setLoading:function(v)
{this.loading=v;}});CM.UtilityBar.setLoading(false);CM.UtilityBarRequestCache=Class.create();Object.extend(CM.UtilityBarRequestCache.prototype,{initialize:function(request,options)
{this.cache=null;this.request=request;this.onVisible=options.onVisible;this.onHidden=options.onHidden;this.options=options;this.isContentVisible=options.isContentVisible;CM.UtilityBar.register(this);},exposeTitle:function()
{if(this.options.title){try{if($("utility-bar-title")){$("utility-bar-title").remove();}
$("page_header").down("h1").hide();$("fabric-nav-tabs").hide();}catch(e){}
new Insertion.Top($("page_header").down(".box"),"<h1 id='utility-bar-title'>"+this.options.title()+"</h1>");}},restoreTitle:function()
{if($("utility-bar-title")){$("utility-bar-title").remove();}
try{$("page_header").down("h1").show();$("fabric-nav-tabs").show();}catch(e){}},show:function(force,usefade)
{if(!force&&CM.UtilityBar.isLoading()){return;}
CM.UtilityBar.setLoading(true);if(!usefade){try{CM.UtilityBar.clear(this,usefade);}catch(e){alert(e);}}
this.exposeTitle();CM.UtilityBar.update(this.cache,force,usefade,{afterFinish:function(){if(this.onVisible){this.onVisible();}
this.exposeTitle();CM.UtilityBar.setLoading(false);}.bind(this)});if(usefade){try{CM.UtilityBar.clear(this,usefade);}catch(e){alert(e);}}},hide:function(usefade)
{if(!usefade){this.restoreTitle();}
if(this.onHidden){this.onHidden();}
if(!usefade){CM.UtilityBar.up();}},toggle:function(event)
{if(event){Event.stop(event);}
if(CM.UtilityBar.isLoading()){return;}
if(CM.UtilityBar.isDown()){if(this.isContentVisible&&this.isContentVisible()){this.hide();}
else{this.showDefault(true);}}
else{this.showDefault(false);}},showDefault:function(usefade)
{CM.hideNoticeMessage();if(this.cache){this.show(false,usefade);}
else{if(CM.UtilityBar.isLoading()){return;}
CM.UtilityBar.setLoading(true);new Ajax.Request(this.request,{postBody:this.options.postBody,onSuccess:function(req){this.cache=req.responseText;this.show(true,usefade);CM.UtilityBar.setLoading(false);}.bind(this),onFailure:function(req){CM.UtilityBar.setLoading(false);displayErrorMessage("Error while requesting... Please try again later.");}});}}});CM.SendPage=CM.Behavior.create({initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);this.cache=new CM.UtilityBarRequestCache('/global/send_page/show',{postBody:"url="+encodeURI(window.location),onVisible:this.show.bind(this),title:this.title.bind(this),isContentVisible:this.isContentVisible.bind(this)});Event.observe(this.element,"click",this.cache.toggle.bindAsEventListener(this.cache));PageObject.register("bvr-sendpage-close",ObserveWidget,{handler:this.close.bind(this),eventName:"click"});PageObject.register("bvr-sendpage-accept",ObserveWidget,{handler:this.send.bind(this),eventName:"click"});},show:function(force)
{var form=$("send-page-to-a-friend").getElementsByTagName("form")[0];Form.focusFirstElement(form);new Effect.Highlight(form.getElementsByTagName("textarea")[0],{duration:1.0});},send:function(event)
{var form=$($("send-page-to-a-friend").getElementsByTagName("form")[0]);new Ajax.Request(form.action,{postBody:form.serialize(),onSuccess:function(req){displayNoticeMessage(req.responseText);this.close(null,true);}.bind(this),onFailure:this.reportErrors.bind(this)});if(event){Event.stop(event);}},reportErrors:function(req)
{this.highlight();displayErrorMessage(req.responseText);},highlight:function()
{var inputs=$("send-page-to-a-friend").getElementsByTagName("input");for(var i=0,len=inputs.length;i<len;++i){new Effect.Highlight(inputs[i]);}},close:function(event,keepopen)
{this.cache.hide();if(!keepopen){CM.hideNoticeMessage();}
if(event){Event.stop(event);}},isContentVisible:function()
{return($("send-page-to-a-friend")&&$("send-page-to-a-friend").visible());},title:function()
{return"Send to a friend";}});PageObject.register("bvr-send-page",CM.SendPage);

CM.Progress=CM.Behavior.create(Dialog,{initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);Dialog.prototype.initialize.apply(this,arguments);Event.observe(this.element,"click",this.begin.bindAsEventListener(this));},setupRequest:function()
{var tagName=this.element.tagName.toLowerCase();var postBody={};if(tagName=="button"||tagName=="input"){var form=$(this.element.up("form"));this.request=form.action;postBody=form.serialize();}
else{this.request=this.element.href;}
return postBody;},begin:function(event)
{var postBody=this.setupRequest();if(event){Event.stop(event);}
new Ajax.Request(this.request,{postBody:postBody,onSuccess:this.processing.bind(this),onFailure:this.failed.bind(this)});},processing:function(req)
{try{var progress=window.eval("("+req.responseText+")");this.dialogBox.update(progress.body);if(!this.isVisible()){this.show();}
if(progress.finished){this.finished(progress.url);}
else{setTimeout(this.iterate.bind(this,progress.url),parseFloat(progress.delay)*1000);}}catch(e){alert(e);}},iterate:function(url)
{try{new Ajax.Request(url,{onSuccess:this.processing.bind(this),onFailure:this.failed.bind(this)});}catch(e){alert(e);}},finished:function(url)
{window.location=url;},failed:function(req)
{},visible:function()
{this.dialog.dialogBox.update;}});PageObject.register("bvr-progress",CM.Progress);

var FabricClippingTools=CM.Behavior.create({initialize:function(el){Widget.prototype.initialize.apply(this,arguments);var options={twoColumnMinWidth:270,buttonWidth:125,buttonHeight:33,spacing:10,maxTop:120};this.controls=document.getElementsByClassName('module_clipping_tool_controls',this.element)[0];this.clipper=document.getElementsByClassName('clipper',this.element)[0];this.syndicater=document.getElementsByClassName('syndicater',this.element)[0];this.matte=document.getElementsByClassName('module_clipping_tool_matte',this.element)[0];this.moduleWidth=Element.getWidth(this.element.parentNode);this.moduleHeight=Element.getHeight(this.element.parentNode);if(Prototype.Browser.IE6){try{Element.setStyle(this.matte,{width:this.moduleWidth-10,height:this.moduleHeight-10});}catch(e){}}
if(this.clipper){this.clipper.href=this.clipper.href+'&height='+this.moduleWidth+'&width='+this.moduleHeight;this.clipper_dialog=new RemoteDialog(this.clipper);}
if(this.syndicater){this.syndicater.href=this.syndicater.href+'&height='+this.moduleWidth+'&width='+this.moduleHeight;this.syndicater_dialog=new RemoteDialog(this.syndicater);}
if(this.clipper&&this.syndicater&&(this.moduleWidth>options.twoColumnMinWidth)){var top=Math.min(parseInt((this.moduleHeight-options.buttonHeight)/2),options.maxTop);var left=parseInt((this.moduleWidth-options.buttonWidth*2-options.spacing)/2);Element.setStyle(this.clipper,{left:left+'px',top:top+'px'});Element.setStyle(this.syndicater,{left:(options.buttonWidth+options.spacing+left)+'px',top:top+'px'});}else if(this.clipper&&this.syndicater){var top=Math.min(parseInt((this.moduleHeight-options.buttonHeight*2-options.spacing)/2),options.maxTop);var left=parseInt((this.moduleWidth-options.buttonWidth)/2);Element.setStyle(this.clipper,{left:left+'px',top:top+'px'});Element.setStyle(this.syndicater,{left:left+'px',top:(top+options.buttonHeight+options.spacing)+'px'});}else{var top=Math.min(parseInt((this.moduleHeight-options.buttonHeight)/2),options.maxTop);var left=parseInt((this.moduleWidth-options.buttonWidth)/2);Element.setStyle(this.clipper||this.syndicater,{left:left+'px',top:top+'px'});}
Event.observe(this.element,'mouseover',function(){Element.addClassName(this.element,'module_clipping_tool_hover')}.bind(this));Event.observe(this.element,'mouseout',function(){Element.removeClassName(this.element,'module_clipping_tool_hover')}.bind(this));FabricClippingTools.instances.push(this);}});PageObject.register('bvr-fabric-module-clippping-tools',FabricClippingTools);FabricClippingTools.instances=new Array();var FabricPageClippingMode=CM.Behavior.create({initialize:function(el)
{Widget.prototype.initialize.apply(this,arguments);this.cache=new CM.UtilityBarRequestCache('/fabric/clips/splash',{onVisible:this.enableClipping.bind(this),onHidden:this.removeClipping.bind(this),title:function(){return"Clipping Mode";},isContentVisible:this.isClippingContentVisible.bind(this)});Event.observe(this.element,"click",this.cache.toggle.bindAsEventListener(this.cache));PageObject.register("bvr-fabric-clipping-close",ObserveWidget,{handler:this.close.bind(this),eventName:"click"});},close:function(event)
{this.removeClipping();this.cache.hide();Event.stop(event);},removeClipping:function()
{if(this.isClippingContentVisible()){Element.removeClassName(document.body,'clipping');}},enableClipping:function()
{if(!this.isClippingContentVisible()){Element.addClassName(document.body,'clipping');}
if(Prototype.Browser.IE6){for(var i=0,len=FabricClippingTools.instances.length;i<len;++i){FabricClippingTools.instances[i].element.style.zoom=1;}}},isClippingContentVisible:function()
{return Element.hasClassName(document.body,'clipping');}});PageObject.register("bvr-fabric-clipping-toggle",FabricPageClippingMode);FabricPageClippingMode.toggle=function(event){};

JavascriptValidations=Class.create();JavascriptValidations.prototype={initialize:function(options,fields)
{this.fields=fields;this.onSuccess=this.removeFieldError;this.onFailure=this.addFieldError;for(var i=0,len=this.fields.length;i<len;++i){var field=this.fields[i];Event.observe($(field.id),options.event,this.check.bindAsEventListener(this,i));}},check:function(event,fieldIndex)
{var element=Event.element(event);var field=this.fields[fieldIndex];var status_field=(field.status_field)?$(field.status_field):$(field.id+"_status");for(var i=0;i<field.conditions.length;++i){var cond=field.conditions[i];var m=true;if(cond.regex){m=cond.regex.test($F(element));}
if(cond.func){m=cond.func(field,this.getObjectName(field),$F(element));}
if(cond.match){var match_field=$F(cond.match);var match_me=$F(element);m=match_field==match_me;}
if(!m){status_field.innerHTML=cond.message;if(this.onFailure){this.onFailure(field,$F(element));}
break;}
status_field.innerHTML="";if(this.onSuccess){this.onSuccess(field,$F(element));}}},addFieldError:function(field,value)
{var form_field=$(field.id);var status_field=(field.status_field)?$(field.status_field):$(field.id+"_status");status_field.addClassName('failed');status_field.removeClassName('succeed');form_field.addClassName('failed');form_field.removeClassName('succeed');},removeFieldError:function(field,value)
{var form_field=$(field.id);var status_field=(field.status_field)?$(field.status_field):$(field.id+"_status");status_field.addClassName('succeed');status_field.removeClassName('failed');form_field.addClassName('succeed');form_field.removeClassName('failed');},getObjectName:function(field)
{try{return field.id.split("_",1)[0];}catch(err){return null;}}};

CM.Ratings={FormPill:Class.create(),FormButton:Class.create(),AjaxPill:Class.create(),AjaxButton:Class.create(),shared:{init_regex:/^rating_init_(\d+)$/,value_regex:/^rating_value_(\d+)$/,scale_regex:/^rating_scale_(\d+(_\d+)?)$/,replaceWithButton:function(handler,scale,element){var btn=document.createElement('li');btn.id=element.id;btn.title=element.title;btn.alt=element.title;btn.className=element.className;element.parentNode.replaceChild(btn,element);new handler(btn,scale);},createHidden:function(base_id,name){var hidden=document.createElement('input');hidden.type='hidden';hidden.name=name;hidden.id=base_id+'_hidden';return hidden;}}};['FormPill','FormButton','AjaxPill','AjaxButton'].each(function(name){Object.extend(CM.Ratings[name].prototype,CM.Ratings.shared);});Object.extend(CM.Ratings.AjaxPill.prototype,{initialize:function(element){var scale=Element.classNames(element).grep(this.scale_regex)[0];if(scale){scale=parseFloat(scale.replace(this.scale_regex,'$1').replace(/_/,'.'));}
var replacer=this.replaceWithButton.bind(this,CM.Ratings.AjaxButton,scale);$(element).getElementsBySelector('input').each(replacer);element.appendChild(this.createHidden(element.id,'rating'));var submit=document.createElement('input');submit.type='submit';submit.id=element.id+'_submit';Element.hide(submit);element.appendChild(submit);}});Object.extend(CM.Ratings.AjaxButton.prototype,{initialize:function(element,scale){this.className=Element.classNames(element).grep(this.value_regex)[0];if(!(this.className&&element.id))return;this.element_id=element.id;this.scale=scale;this.surround_id=element.id.replace(/_\d+$/,'');Event.observe(element,"click",this.click.bindAsEventListener(this));Event.observe(element,"mouseover",this.mouseOver.bindAsEventListener(this));Event.observe(element,"mouseout",this.mouseOut.bindAsEventListener(this));},click:function(evt){Event.stop(evt);var value=this.className.replace(this.value_regex,'$1');if(this.scale)value=parseInt(value)*this.scale;$(this.surround_id+'_hidden').value=value;$(this.surround_id+'_submit').click();},mouseOver:function(){Element.addClassName(this.surround_id,this.className);Element.addClassName(this.element_id,'hover_selected');},mouseOut:function(){Element.removeClassName(this.surround_id,this.className);Element.removeClassName(this.element_id,'hover_selected');}});Object.extend(CM.Ratings.FormPill.prototype,{initialize:function(element){var name='rating';var scale=Element.classNames(element).grep(this.scale_regex)[0];if(scale){scale=parseFloat(scale.replace(this.scale_regex,'$1').replace(/_/,'.'));}
var replacer=this.replaceWithButton.bind(this,CM.Ratings.FormButton,scale);$A($(element).childNodes).each(function(element){if(element.tagName&&element.tagName.toLowerCase()=='input'){name=element.name;replacer(element);}else{element.parentNode.removeChild(element);}});element.appendChild(this.createHidden(element.id,name));}});Object.extend(CM.Ratings.FormButton.prototype,{initialize:function(element,scale){this.className=Element.classNames(element).grep(this.value_regex)[0];if(!(this.className&&element.id))return;this.element_id=element.id;this.scale=scale;this.surround_id=element.id.replace(/_\d+$/,'');Event.observe(element,"click",this.click.bindAsEventListener(this));Event.observe(element,"mouseover",this.mouseOver.bindAsEventListener(this));Event.observe(element,"mouseout",this.mouseOut.bindAsEventListener(this));},click:function(evt){Event.stop(evt);var value=this.className.replace(this.value_regex,'$1');if(this.scale)value=parseInt(value)*this.scale;var surround=$(this.surround_id);var oldInit=Element.classNames(surround).grep(this.init_regex)[0];if(oldInit)Element.removeClassName(surround,oldInit);Element.addClassName(surround,this.className.replace(/value/,'init'));$(this.surround_id+'_hidden').value=value;},mouseOver:function(){Element.addClassName(this.surround_id,this.className);Element.addClassName(this.element_id,'hover_selected');},mouseOut:function(){Element.removeClassName(this.surround_id,this.className);Element.removeClassName(this.element_id,'hover_selected');}});PageObject.register("bvr-rating-ajax-pill",CM.Ratings.AjaxPill);PageObject.register("bvr-rating-form-pill",CM.Ratings.FormPill);
