if(typeof(Control)=="undefined"){Control={}}var $proc=function(a){return typeof(a)=="function"?a:function(){return a}};var $value=function(a){return typeof(a)=="function"?a():a};Object.Event={extend:function(a){a._objectEventSetup=function(b){this._observers=this._observers||{};this._observers[b]=this._observers[b]||[]};a.observe=function(d,b){if(typeof(d)=="string"&&typeof(b)!="undefined"){this._objectEventSetup(d);if(!this._observers[d].include(b)){this._observers[d].push(b)}}else{for(var c in d){this.observe(c,d[c])}}};a.stopObserving=function(c,b){this._objectEventSetup(c);if(c&&b){this._observers[c]=this._observers[c].without(b)}else{if(c){this._observers[c]=[]}else{this._observers={}}}};a.observeOnce=function(d,c){var b=function(){c.apply(this,arguments);this.stopObserving(d,b)}.bind(this);this._objectEventSetup(d);this._observers[d].push(b)};a.notify=function(g){this._objectEventSetup(g);var d=[];var b=$A(arguments).slice(1);try{for(var c=0;c<this._observers[g].length;++c){d.push(this._observers[g][c].apply(this,b)||null)}}catch(f){if(f==$break){return false}else{throw f}}return d};if(a.prototype){a.prototype._objectEventSetup=a._objectEventSetup;a.prototype.observe=a.observe;a.prototype.stopObserving=a.stopObserving;a.prototype.observeOnce=a.observeOnce;a.prototype.notify=function(h){if(a.notify){var c=$A(arguments).slice(1);c.unshift(this);c.unshift(h);a.notify.apply(a,c)}this._objectEventSetup(h);var c=$A(arguments).slice(1);var f=[];try{if(this.options&&this.options[h]&&typeof(this.options[h])=="function"){f.push(this.options[h].apply(this,c)||null)}var b=this._observers[h];for(var d=0;d<b.length;++d){f.push(b[d].apply(this,c)||null)}}catch(g){if(g==$break){return false}else{throw g}}return f}}}};Element.addMethods({observeOnce:function(c,d,b){var a=function(){b.apply(this,arguments);Element.stopObserving(c,d,a)};Element.observe(c,d,a)}});(function(){function a(d){var e,c,b;if(d.wheelDelta){e=d.wheelDelta/120}else{if(d.detail){e=-d.detail/3}}if(!e){return}c=Event.extend(d).target;c=Element.extend(c.nodeType===Node.TEXT_NODE?c.parentNode:c);b=c.fire("mouse:wheel",{delta:e});if(b.stopped){Event.stop(d);return false}}document.observe("mousewheel",a);document.observe("DOMMouseScroll",a)})();var IframeShim=Class.create({initialize:function(){this.element=new Element("iframe",{style:"position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none",src:"javascript:void(0);",frameborder:0});$(document.body).insert(this.element)},hide:function(){this.element.hide();return this},show:function(){this.element.show();return this},positionUnder:function(a){var a=$(a);var c=a.cumulativeOffset();var b=a.getDimensions();this.element.setStyle({left:c[0]+"px",top:c[1]+"px",width:b.width+"px",height:b.height+"px",zIndex:a.getStyle("zIndex")-1}).show();return this},setBounds:function(a){for(prop in a){a[prop]+="px"}this.element.setStyle(a);return this},destroy:function(){if(this.element){this.element.remove()}return this}});if(typeof(Prototype)=="undefined"){throw"Event.Behavior requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Event.Behavior requires Object.Event to be loaded."}Event.Behavior={addVerbs:function(c){var a;for(var b in c){if(c.hasOwnProperty(b)){a=new Event.Behavior.Verb(c[b]);Event.Behavior.Verbs[b]=a;Event.Behavior[b.underscore()]=Event.Behavior[b]=a.getCallbackForStack.bind(a)}}},addEvents:function(a){$H(a).each(function(b){Event.Behavior.Adjective.prototype[b.key.underscore()]=Event.Behavior.Adjective.prototype[b.key]=function(){this.nextConditionType="and";this.events.push(b.value);this.attachObserver(false);return this}})},invokeElementMethod:function(b,c,a){if(typeof(b)=="function"){return $A(b()).each(function(d){if(typeof(a[0])=="function"){return $A(a[0]).each(function(e){return $(d)[c].apply($(d),(e?[e]:[]))})}else{return $(d)[c].apply($(d),a||[])}})}else{return $(b)[c].apply($(b),a||[])}}};Event.Behavior.Verbs=$H({});Event.Behavior.Verb=Class.create();Object.extend(Event.Behavior.Verb.prototype,{originalAction:false,execute:false,executeOpposite:false,target:false,initialize:function(a){this.originalAction=a;this.execute=function(c,d,b){return(b)?c(d,b):c(d)}.bind(this,a)},setOpposite:function(b){var a=b.originalAction;this.executeOpposite=function(c,e,d){return(d)?c(e,d):c(e)}.bind(this,a)},getCallbackForStack:function(a){return new Event.Behavior.Noun(this,a)}});Event.Behavior.addVerbs({call:function(a){a()},show:function(a){return Event.Behavior.invokeElementMethod(a,"show")},hide:function(a){return Event.Behavior.invokeElementMethod(a,"hide")},remove:function(a){return Event.Behavior.invokeElementMethod(a,"remove")},setStyle:function(a,b){return Event.Behavior.invokeElementMethod(a,"setStyle",[(typeof(b)=="function"?b():b)])},addClassName:function(a,b){return Event.Behavior.invokeElementMethod(a,"addClassName",[(typeof(b)=="function"?b():b)])},removeClassName:function(a,b){return Event.Behavior.invokeElementMethod(a,"removeClassName",[(typeof(b)=="function"?b():b)])},setClassName:function(a,b){var d=(typeof(b)=="function")?b():b;if(typeof(a)=="function"){return $A(a()).each(function(c){$(c).className=d})}else{d=$(a).className;return d}},update:function(b,a){return Event.Behavior.invokeElementMethod(a,"update",[(typeof(b)=="function"?b():b)])},replace:function(b,a){return Event.Behavior.invokeElementMethod(a,"replace",[(typeof(b)=="function"?b():b)])}});Event.Behavior.Verbs.show.setOpposite(Event.Behavior.Verbs.hide);Event.Behavior.Verbs.hide.setOpposite(Event.Behavior.Verbs.show);Event.Behavior.Verbs.addClassName.setOpposite(Event.Behavior.Verbs.removeClassName);Event.Behavior.Verbs.removeClassName.setOpposite(Event.Behavior.Verbs.addClassName);Event.Behavior.Noun=Class.create();Object.extend(Event.Behavior.Noun.prototype,{verbs:false,verb:false,argument:false,subject:false,target:false,initialize:function(b,a){this.verb=b;this.argument=a},execute:function(){return(this.target)?this.verb.execute(this.target,this.argument):this.verb.execute(this.argument)},executeOpposite:function(){return(this.target)?this.verb.executeOpposite(this.target,this.argument):this.verb.executeOpposite(this.argument)},when:function(a){this.subject=a;return new Event.Behavior.Adjective(this)},getValue:function(){return Try.these(function(){return $(this.subject).getValue()}.bind(this),function(){return $(this.subject).options[$(this.subject).options.selectedIndex].value}.bind(this),function(){return $(this.subject).value}.bind(this),function(){return $(this.subject).innerHTML}.bind(this))},containsValue:function(a){var b=this.getValue();if(typeof(a)=="function"){return $A(a()).include(b)}else{return b.match(a)}},setTarget:function(a){this.target=a;return this},and:function(){}});Event.Behavior.Noun.prototype._with=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.on=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.of=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.to=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Noun.prototype.from=Event.Behavior.Noun.prototype.setTarget;Event.Behavior.Adjective=Class.create();Object.extend(Event.Behavior.Adjective.prototype,{noun:false,lastConditionName:"",nextConditionType:"and",conditions:$A([]),events:$A([]),attached:false,initialize:function(a){this.conditions=$A([]);this.events=$A([]);this.noun=a},attachObserver:function(a){if(this.attached){if(a){this.execute()}return}this.attached=true;if(typeof(this.noun.subject)=="function"){$A(this.noun.subject()).each(function(b){(this.events.length>0?this.events:$A(["change"])).each(function(c){(b.observe?b:$(b)).observe(c,function(){this.execute()}.bind(this))}.bind(this))}.bind(this))}else{(this.events.length>0?this.events:$A(["change"])).each(function(b){$(this.noun.subject).observe(b,function(){this.execute()}.bind(this))}.bind(this))}if(a){this.execute()}},execute:function(){if(this.match()){return this.noun.execute()}else{if(this.noun.verb.executeOpposite){this.noun.executeOpposite()}}},attachCondition:function(a){this.conditions.push([this.nextConditionType,a.bind(this)])},match:function(){if(this.conditions.length===0){return true}else{return this.conditions.inject(false,function(a,b){return(b[0]==="or")?(a&&b[1]()):(a||b[1]())})}},is:function(a){this.lastConditionName="is";this.attachCondition(function(b){return(typeof(b)=="function"?b():b)==this.noun.getValue()}.bind(this,a));this.attachObserver(true);return this},isNot:function(a){this.lastConditionName="isNot";this.attachCondition(function(b){return(typeof(b)=="function"?b():b)!=this.noun.getValue()}.bind(this,a));this.attachObserver(true);return this},contains:function(a){this.lastConditionName="contains";this.attachCondition(function(b){return this.noun.containsValue(b)}.bind(this,a));this.attachObserver(true);return this},within:function(a){this.lastConditionName="within";this.attachCondition(function(b){}.bind(this,a));this.attachObserver(true);return this},change:function(){this.nextConditionType="and";this.attachObserver(true);return this},and:function(a){this.attached=false;this.nextConditionType="and";if(a){this[this.lastConditionName](a)}return this},or:function(a){this.attached=false;this.nextConditionType="or";if(a){this[this.lastConditionName](a)}return this}});Event.Behavior.addEvents({losesFocus:"blur",gainsFocus:"focus",isClicked:"click",isDoubleClicked:"dblclick",keyPressed:"keypress"});Event.Behavior.Adjective.prototype.is_not=Event.Behavior.Adjective.prototype.isNot;Event.Behavior.Adjective.prototype.include=Event.Behavior.Adjective.prototype.contains;Event.Behavior.Adjective.prototype.includes=Event.Behavior.Adjective.prototype.contains;Event.Behavior.Adjective.prototype.are=Event.Behavior.Adjective.prototype.is;Event.Behavior.Adjective.prototype.areNot=Event.Behavior.Adjective.prototype.isNot;Event.Behavior.Adjective.prototype.are_not=Event.Behavior.Adjective.prototype.isNot;Event.Behavior.Adjective.prototype.changes=Event.Behavior.Adjective.prototype.change;if(typeof(Prototype)=="undefined"){throw"Control.ContextMenu requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.ContextMenu requires Object.Event to be loaded."}Control.ContextMenu=Class.create({initialize:function(a,b){Control.ContextMenu.load();this.options=Object.extend({leftClick:false,disableOnShiftKey:true,disableOnAltKey:true,selectedClassName:"selected",activatedClassName:"activated",animation:true,animationCycles:2,animationLength:300,delayCallback:true},b||{});this.activated=false;this.items=this.options.items||[];this.container=$(a);this.container.observe(this.options.leftClick?"click":(Prototype.Browser.Opera?"click":"contextmenu"),function(c){if(!Control.ContextMenu.enabled||Prototype.Browser.Opera&&!c.ctrlKey){return}this.open(c)}.bindAsEventListener(this))},open:function(a){if(Control.ContextMenu.current&&!Control.ContextMenu.current.close()){return}if(this.notify("beforeOpen",a)===false){return false}this.buildMenu();if(this.items.length===0){this.close(a);return false}this.clicked=Event.element(a);Control.ContextMenu.current=this;Control.ContextMenu.positionContainer(a);Control.ContextMenu.container.show();if(this.notify("afterOpen",a)===false){return false}a.stop();return true},close:function(a){if(a){a.stop()}if(this.notify("beforeClose")===false){return false}Control.ContextMenu.current=false;this.activated=false;Control.ContextMenu.container.removeClassName(this.options.activatedClassName);Control.ContextMenu.container.select("li").invoke("stopObserving");Control.ContextMenu.container.hide();Control.ContextMenu.container.update("");if(this.notify("afterClose")===false){return false}return true},buildMenu:function(){var a=document.createElement("ul");Control.ContextMenu.container.appendChild(a);this.items.each(function(c){if(!(!c.condition||c.condition&&c.condition()!==false)){return}var b=$(document.createElement("li"));b.update($value(c.label));a.appendChild(b);b[$value(c.enabled)?"removeClassName":"addClassName"]("disabled");b.observe("mousedown",function(e,d){if(!$value(d.enabled)){return e.stop()}this.activated=$value(d.label)}.bindAsEventListener(this,c));b.observe("click",this.selectMenuItem.bindAsEventListener(this,c,b));b.observe("contextmenu",this.selectMenuItem.bindAsEventListener(this,c,b))}.bind(this))},addItem:function(a){if(!("enabled" in a)){a.enabled=true}this.items.push(a);return this},destroy:function(){this.container.stopObserving(Prototype.Browser.Opera||this.options.leftClick?"click":"contextmenu");this.items=[]},selectMenuItem:function(c,b,a){if(!$value(b.enabled)){return c.stop()}if(!this.activated||this.activated==$value(b.label)){if(this.options.animation){Control.ContextMenu.container.addClassName(this.options.activatedClassName);$A($R(0,this.options.animationCycles*2)).each(function(d){window.setTimeout(function(){a.toggleClassName(this.options.selectedClassName)}.bind(this),d*parseInt(this.options.animationLength/(this.options.animationCycles*2),10))}.bind(this));window.setTimeout(function(){if(this.close()&&this.options.delayCallback){b.callback(this.clicked)}}.bind(this),this.options.animationLength);if(!this.options.delayCallback){b.callback(this.clicked)}}else{if(this.close()){b.callback(this.clicked)}}}c.stop();return false}});Object.extend(Control.ContextMenu,{loaded:false,capture_all:false,menus:[],current:false,enabled:false,offset:4,load:function(a){if(Control.ContextMenu.loaded){return}Control.ContextMenu.loaded=true;if(typeof(a)=="undefined"){a=false}Control.ContextMenu.capture_all=a;Control.ContextMenu.container=$(document.createElement("div"));Control.ContextMenu.container.id="control_contextmenu";Control.ContextMenu.container.style.position="absolute";Control.ContextMenu.container.style.zIndex=99999;Control.ContextMenu.container.hide();document.body.appendChild(Control.ContextMenu.container);Control.ContextMenu.enable()},enable:function(){Control.ContextMenu.enabled=true;Event.observe(document.body,"click",Control.ContextMenu.onClick);if(Control.ContextMenu.capture_all){Event.observe(document.body,"contextmenu",Control.ContextMenu.onContextMenu)}},disable:function(){Event.stopObserving(document.body,"click",Control.ContextMenu.onClick);if(Control.ContextMenu.capture_all){Event.stopObserving(document.body,"contextmenu",Control.ContextMenu.onContextMenu)}},onContextMenu:function(a){a.stop();return false},onClick:function(){if(Control.ContextMenu.current){Control.ContextMenu.current.close()}},positionContainer:function(e){var d=Control.ContextMenu.container.getDimensions();var h=Event.pointerY(e);var g=Event.pointerX(e);var a=d.height+h;var b=d.width+g;var c=document.viewport.getDimensions();var f=document.viewport.getScrollOffsets();if(a>c.height+f.top){h-=a-((c.height+f.top)-Control.ContextMenu.offset)}if(b>c.width+f.left){g-=b-((c.width+f.left)-Control.ContextMenu.offset)}Control.ContextMenu.container.setStyle({top:h+"px",left:g+"px"})}});Object.Event.extend(Control.ContextMenu);if(typeof(Prototype)=="undefined"){throw"Cookie requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Cookie requires Object.Event to be loaded."}var Cookie={build:function(){return $A(arguments).compact().join("; ")},secondsFromNow:function(b){var a=new Date();a.setTime(a.getTime()+(b*1000));return a.toGMTString()},set:function(a,c,d){Cookie.notify("set",a,c);var b=d?"expires="+Cookie.secondsFromNow(d):null;document.cookie=Cookie.build(a+"="+c,b,"path=/")},get:function(a){Cookie.notify("get",a);var b=new RegExp(a+"=([^;]+)").exec(document.cookie);return b?b[1]:null},unset:function(a){Cookie.notify("unset",a);Cookie.set(a,"",-1)}};Object.Event.extend(Cookie);if(typeof(Prototype)=="undefined"){throw"HotKey requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"HotKey requires Object.Event to be loaded."}var HotKey=Class.create({initialize:function(b,c,a){b=b.toUpperCase();HotKey.hotkeys.push(this);this.options=Object.extend({element:false,shiftKey:false,altKey:false,ctrlKey:true,bubbleEvent:true,fireOnce:false},a||{});this.letter=b;this.callback=function(d){if(!(this.options.fireOnce&&this.fired)&&Object.isFunction(c)){c(d)}if(!this.options.bubbleEvent){d.stop()}this.fired=true};this.element=$(this.options.element||document);this.handler=function(d){if(!d||((Event["KEY_"+this.letter]||this.letter.charCodeAt(0))==d.keyCode&&((!this.options.shiftKey||(this.options.shiftKey&&d.shiftKey))&&(!this.options.altKey||(this.options.altKey&&d.altKey))&&(!this.options.ctrlKey||(this.options.ctrlKey&&d.ctrlKey))))){if(this.notify("beforeCallback",d)===false){return}this.callback(d);this.notify("afterCallback",d)}}.bind(this);this.enable()},trigger:function(){this.handler()},enable:function(){this.element.observe("keydown",this.handler)},disable:function(){this.element.stopObserving("keydown",this.handler)},destroy:function(){this.disable();HotKey.hotkeys=HotKey.hotkeys.without(this)}});Object.extend(HotKey,{hotkeys:[]});Object.Event.extend(HotKey);if(typeof(Prototype)=="undefined"){throw"Control.ProgressBar requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.ProgressBar requires Object.Event to be loaded."}Control.ProgressBar=Class.create({initialize:function(a,b){this.progress=0;this.executer=false;this.active=false;this.poller=false;this.container=$(a);this.containerWidth=this.container.getDimensions().width-(parseInt(this.container.getStyle("border-right-width").replace(/px/,""),10)+parseInt(this.container.getStyle("border-left-width").replace(/px/,""),10));this.progressContainer=$(document.createElement("div"));this.progressContainer.setStyle({width:this.containerWidth+"px",height:"100%",position:"absolute",top:"0px",right:"0px"});this.container.appendChild(this.progressContainer);this.options={afterChange:Prototype.emptyFunction,interval:0.25,step:1,classNames:{active:"progress_bar_active",inactive:"progress_bar_inactive"}};Object.extend(this.options,b||{});this.container.addClassName(this.options.classNames.inactive);this.active=false},setProgress:function(a){this.progress=a;this.draw();if(this.progress>=100){this.stop(false)}this.notify("afterChange",this.progress,this.active)},poll:function(c,b,a){a=a||{};var d=a.onSuccess||Prototype.emptyFunction;a.onSuccess=d.wrap(function(e,f){this.setProgress(parseInt(f.responseText,10));if(!this.active){this.poller.stop()}e(f)}).bind(this);this.active=true;this.poller=new PeriodicalExecuter(function(){var e=new Ajax.Request(c,a)}.bind(this),b||3)},start:function(){this.active=true;this.container.removeClassName(this.options.classNames.inactive);this.container.addClassName(this.options.classNames.active);this.executer=new PeriodicalExecuter(this.step.bind(this,this.options.step),this.options.interval)},stop:function(a){this.active=false;if(this.executer){this.executer.stop()}this.container.removeClassName(this.options.classNames.active);this.container.addClassName(this.options.classNames.inactive);if(typeof a==="undefined"||a===true){this.reset()}},step:function(a){this.active=true;this.setProgress(Math.min(100,this.progress+a))},reset:function(){this.active=false;this.setProgress(0)},draw:function(){this.progressContainer.setStyle({width:(this.containerWidth-Math.floor((parseInt(this.progress,10)/100)*this.containerWidth))+"px"})},notify:function(a){if(this.options[a]){return[this.options[a].apply(this.options[a],$A(arguments).slice(1))]}}});Object.Event.extend(Control.ProgressBar);if(typeof(Prototype)=="undefined"){throw"Control.Rating requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.Rating requires Object.Event to be loaded."}Control.Rating=Class.create({initialize:function(a,c){Control.Rating.instances.push(this);this.value=false;this.links=[];this.container=$(a);this.container.update("");this.options={min:1,max:5,rated:false,input:false,reverse:false,capture:true,multiple:false,classNames:{off:"rating_off",half:"rating_half",on:"rating_on",selected:"rating_selected"},updateUrl:false,updateParameterName:"value",updateOptions:{},afterChange:Prototype.emptyFunction};Object.extend(this.options,c||{});if(this.options.value){this.value=this.options.value;delete this.options.value}if(this.options.input){this.options.input=$(this.options.input);this.options.input.observe("change",function(d){this.setValueFromInput(d)}.bind(this,this.options.input));this.setValueFromInput(this.options.input,true)}var b=$R(this.options.min,this.options.max);(this.options.reverse?$A(b).reverse():b).each(function(d){var e=this.buildLink(d);this.container.appendChild(e);this.links.push(e)}.bind(this));this.setValue(this.value||this.options.min-1,false,true)},buildLink:function(a){var b=$(document.createElement("a"));b.value=a;if(this.options.multiple||(!this.options.rated&&!this.options.multiple)){b.href="";b.onmouseover=this.mouseOver.bind(this,b);b.onmouseout=this.mouseOut.bind(this,b);b.onclick=this.click.bindAsEventListener(this,b)}else{b.style.cursor="default";b.observe("click",function(c){Event.stop(c);return false}.bindAsEventListener(this))}b.addClassName(this.options.classNames.off);return b},disable:function(){this.links.each(function(a){a.onmouseover=Prototype.emptyFunction;a.onmouseout=Prototype.emptyFunction;a.onclick=Prototype.emptyFunction;a.observe("click",function(b){Event.stop(b);return false}.bindAsEventListener(this));a.style.cursor="default"}.bind(this))},setValueFromInput:function(a,b){this.setValue($F(a),true,b)},setValue:function(e,c,d){this.value=e;if(this.options.input){if(this.options.input.options){$A(this.options.input.options).each(function(g,a){if(g.value==this.value){this.options.input.options.selectedIndex=a;throw $break}}.bind(this))}else{this.options.input.value=this.value}}this.render(this.value,c);if(!d){if(this.options.updateUrl){var f={},b;f[this.options.updateParameterName]=this.value;b=new Ajax.Request(this.options.updateUrl,Object.extend(this.options.updateOptions,{parameters:f}))}this.notify("afterChange",this.value)}},render:function(b,a){(this.options.reverse?this.links.reverse():this.links).each(function(d,c){if(d.value<=Math.ceil(b)){d.className=this.options.classNames[d.value<=b?"on":"half"];if(this.options.rated||a){d.addClassName(this.options.classNames.selected)}}else{d.className=this.options.classNames.off}}.bind(this))},mouseOver:function(a){this.render(a.value,true)},mouseOut:function(a){this.render(this.value)},click:function(b,a){this.options.rated=true;this.setValue((a.value?a.value:a),true);if(!this.options.multiple){this.disable()}if(this.options.capture){Event.stop(b);return false}}});Object.extend(Control.Rating,{instances:[],findByElementId:function(a){return Control.Rating.instances.find(function(b){return(b.container.id&&b.container.id==a)})}});Object.Event.extend(Control.Rating);var Resizables={instances:[],observers:[],register:function(a){if(this.instances.length==0){this.eventMouseUp=this.endResize.bindAsEventListener(this);this.eventMouseMove=this.updateResize.bindAsEventListener(this);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove)}this.instances.push(a)},unregister:function(a){this.instances=this.instances.reject(function(b){return b==a});if(this.instances.length==0){Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove)}},activate:function(a){if(a.options.delay){this._timeout=setTimeout(function(){Resizables._timeout=null;Resizables.activeResizable=a}.bind(this),a.options.delay)}else{this.activeResizable=a}},deactivate:function(){this.activeResizable=null},updateResize:function(a){if(!this.activeResizable){return}var b=[Event.pointerX(a),Event.pointerY(a)];if(this._lastPointer&&(this._lastPointer.inspect()==b.inspect())){return}this._lastPointer=b;this.activeResizable.updateResize(a,b)},endResize:function(a){if(this._timeout){clearTimeout(this._timeout);this._timeout=null}if(!this.activeResizable){return}this._lastPointer=null;this.activeResizable.endResize(a);this.activeResizable=null},addObserver:function(a){this.observers.push(a);this._cacheObserverCallbacks()},removeObserver:function(a){this.observers=this.observers.reject(function(b){return b.element==a});this._cacheObserverCallbacks()},notify:function(a,b,c){if(this[a+"Count"]>0){this.observers.each(function(d){if(d[a]){d[a](a,b,c)}})}if(b.options[a]){b.options[a](b,c)}},_cacheObserverCallbacks:function(){["onStart","onEnd","onResize"].each(function(a){Resizables[a+"Count"]=Resizables.observers.select(function(b){return b[a]}).length})}};var Resizable=Class.create();Resizable._resizing={};Resizable.prototype={initialize:function(b){var c={handle:false,snap:false,delay:0,minHeight:false,minwidth:false,maxHeight:false,maxWidth:false};this.element=$(b);var a=Object.extend(c,arguments[1]||{});if(a.handle&&typeof a.handle=="string"){this.handle=$(a.handle)}else{if(a.handle){this.handle=a.handle}}if(!this.handle){this.handle=this.element}this.options=a;this.dragging=false;this.eventMouseDown=this.initResize.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);Resizables.register(this)},destroy:function(){Event.stopObserving(this.handle,"mousedown",this.eventMouseDown)},currentDelta:function(){return([parseInt(Element.getStyle(this.element,"width")||"0"),parseInt(Element.getStyle(this.element,"height")||"0")])},initResize:function(a){if(typeof Resizable._resizing[this.element]!="undefined"&&Resizable._resizing[this.element]){return}if(Event.isLeftClick(a)){var b=Event.element(a);if((tag_name=b.tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){return}this.pointer=[Event.pointerX(a),Event.pointerY(a)];this.size=[parseInt(this.element.getStyle("width"))||0,parseInt(this.element.getStyle("height"))||0];Resizables.activate(this);Event.stop(a)}},startResize:function(a){this.resizing=true;if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);this.element.style.zIndex=this.options.zindex}Resizables.notify("onStart",this,a);Resizable._resizing[this.element]=true},updateResize:function(a,b){if(!this.resizing){this.startResize(a)}Resizables.notify("onResize",this,a);this.draw(b);if(this.options.change){this.options.change(this)}if(Prototype.Browser.WebKit){window.scrollBy(0,0)}Event.stop(a)},finishResize:function(a,b){this.resizing=false;Resizables.notify("onEnd",this,a);if(this.options.zindex){this.element.style.zIndex=this.originalZ}Resizable._resizing[this.element]=false;Resizables.deactivate(this)},endResize:function(a){if(!this.resizing){return}this.finishResize(a,true);Event.stop(a)},draw:function(a){var g=[0,1].map(function(h){return(this.size[h]+a[h]-this.pointer[h])}.bind(this));if(this.options.snap){if(typeof this.options.snap=="function"){g=this.options.snap(g[0],g[1],this)}else{if(this.options.snap instanceof Array){g=g.map(function(h,j){return Math.round(h/this.options.snap[j])*this.options.snap[j]}.bind(this))}else{g=g.map(function(h){return Math.round(h/this.options.snap)*this.options.snap}.bind(this))}}}var c=(typeof(this.options.minWidth)=="function")?this.options.minWidth(this.element):this.options.minWidth;var e=(typeof(this.options.maxWidth)=="function")?this.options.maxWidth(this.element):this.options.maxWidth;var f=(typeof(this.options.minHeight)=="function")?this.options.minHeight(this.element):this.options.minHeight;var d=(typeof(this.options.maxHeight)=="function")?this.options.maxHeight(this.element):this.options.maxHeight;if(c&&g[0]<=c){g[0]=c}if(e&&g[0]>=e){g[0]=e}if(f&&g[1]<=f){g[1]=f}if(d&&g[1]>=d){g[1]=d}var b=this.element.style;if((!this.options.constraint)||(this.options.constraint=="horizontal")){b.width=g[0]+"px"}if((!this.options.constraint)||(this.options.constraint=="vertical")){b.height=g[1]+"px"}if(b.visibility=="hidden"){b.visibility=""}}};if(typeof(Prototype)=="undefined"){throw"Control.ScrollBar requires Prototype to be loaded."}if(typeof(Control.Slider)=="undefined"){throw"Control.ScrollBar requires Control.Slider to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.ScrollBar requires Object.Event to be loaded."}Control.ScrollBar=Class.create({initialize:function(b,a,c){Control.ScrollBar.instances.push(this);this.enabled=false;this.notificationTimeout=false;this.container=$(b);this.boundMouseWheelEvent=this.onMouseWheel.bindAsEventListener(this);this.boundResizeObserver=this.onWindowResize.bind(this);this.track=$(a);this.handle=this.track.firstDescendant();this.options=Object.extend({active_class_name:"scrolling",apply_active_class_name_to:this.container,notification_timeout_length:125,handle_minimum_length:25,scroll_to_smoothing:0.01,scroll_to_steps:15,scroll_to_precision:100,proportional:true,custom_event:null,custom_event_handler:null,scroll_axis:"vertical",fixed_scroll_distance:-1,slider_options:{}},c||{});this.slider=new Control.Slider(this.handle,this.track,Object.extend({axis:this.options.scroll_axis,onSlide:this.onChange.bind(this),onChange:this.onChange.bind(this)},this.options.slider_options));this.recalculateLayout();Event.observe(window,"resize",this.boundResizeObserver);if(this.options.custom_event){if(Object.isFunction(this.options.custom_event_handler)){this.container.observe(this.options.custom_event,this.options.custom_event_handler)}else{this.container.observe(this.options.custom_event,this.boundResizeObserver)}}this.handle.observe("mousedown",function(){if(this.auto_sliding_executer){this.auto_sliding_executer.stop()}}.bind(this))},destroy:function(){Event.stopObserving(window,"resize",this.boundResizeObserver);if(this.options.active_class_name){$(this.options.apply_active_class_name_to).removeClassName(this.options.active_class_name)}if(this.options.custom_event){this.container.stopObserving(this.options.custom_event)}},scrollLength:function(){return(this.options.scroll_axis=="vertical")?this.container.scrollHeight:this.container.scrollWidth},offsetLength:function(){return(this.options.scroll_axis=="vertical")?this.container.offsetHeight:this.container.offsetWidth},enable:function(){this.enabled=true;this.container.observe("mouse:wheel",this.boundMouseWheelEvent);this.slider.setEnabled();this.track.show();if(this.options.active_class_name){$(this.options.apply_active_class_name_to).addClassName(this.options.active_class_name)}this.notify("enabled")},disable:function(){this.enabled=false;this.container.stopObserving("mouse:wheel",this.boundMouseWheelEvent);this.slider.setDisabled();this.track.hide();if(this.options.active_class_name){$(this.options.apply_active_class_name_to).removeClassName(this.options.active_class_name)}this.notify("disabled");this.reset()},reset:function(){this.slider.setValue(0)},recalculateLayout:function(){if(this.scrollLength()<=this.offsetLength()){this.disable()}else{this.enable();this.slider.trackLength=this.slider.maximumOffset()-this.slider.minimumOffset();if(this.options.proportional){this.slider.handleLength=Math.max(this.offsetLength()*(this.offsetLength()/this.scrollLength()),this.options.handle_minimum_length);if(this.options.scroll_axis=="vertical"){this.handle.style.height=this.slider.handleLength+"px"}else{this.handle.style.width=this.slider.handleLength+"px"}}this.scrollBy(0)}},onWindowResize:function(){this.recalculateLayout();this.scrollBy(0)},onMouseWheel:function(a){if(this.auto_sliding_executer){this.auto_sliding_executer.stop()}if(this.options.fixed_scroll_distance>0){this.slider.setValueBy(-(this.options.fixed_scroll_distance*a.memo.delta/(this.scrollLength()-this.slider.trackLength)))}else{this.slider.setValueBy(-(a.memo.delta/20))}a.stop();return false},onChange:function(b){var a=Math.round(b/this.slider.maximum*(this.scrollLength()-this.offsetLength()));if(this.options.scroll_axis=="vertical"){this.container.scrollTop=a}else{this.container.scrollLeft=a}if(this.notification_timeout){window.clearTimeout(this.notificationTimeout)}this.notificationTimeout=window.setTimeout(function(){this.notify("change",b)}.bind(this),this.options.notification_timeout_length)},getCurrentMaximumDelta:function(){return this.slider.maximum*(this.scrollLength()-this.offsetLength())},getContainerOffset:function(a){var b=a.positionedOffset();while(a.getOffsetParent()!=this.container){a=a.getOffsetParent();b[0]+=a.positionedOffset()[0];b[1]+=a.positionedOffset()[1];b.top+=a.positionedOffset().top;b.left+=a.positionedOffset().left}return b},getDeltaToElement:function(a){if(this.options.scroll_axis=="vertical"){return this.slider.maximum*((this.getContainerOffset(a).top+(a.getHeight()/2))-(this.container.getHeight()/2))}else{return this.slider.maximum*((this.getContainerOffset(a).left+(a.getWidth()/2))-(this.container.getWidth()/2))}},scrollTo:function(g,b){var a=this.options.scroll_to_precision,d=this.getCurrentMaximumDelta();if(a=="auto"){a=Math.pow(10,Math.ceil(Math.log(d)/Math.log(10)))}if(g=="top"){g=0}else{if(g=="bottom"){g=d}else{if(typeof(g)!="number"){g=this.getDeltaToElement($(g))}}}if(this.enabled){g=Math.max(0,Math.min(g,d));if(this.auto_sliding_executer){this.auto_sliding_executer.stop()}var c=g/d;var f=this.slider.value;var e=(c-f)*d;if(b){this.auto_sliding_executer=new PeriodicalExecuter(function(){if(Math.round(this.slider.value*a)/a<Math.round(c*a)/a||Math.round(this.slider.value*a)/a>Math.round(c*a)/a){this.scrollBy(e/this.options.scroll_to_steps)}else{this.auto_sliding_executer.stop();this.auto_sliding_executer=null;if(typeof(b)=="function"){b()}}}.bind(this),this.options.scroll_to_smoothing)}else{this.scrollBy(e)}}else{if(typeof(b)=="function"){b()}}},scrollBy:function(a){if(!this.enabled){return false}this.slider.setValueBy(a/(this.getCurrentMaximumDelta()==0?1:this.getCurrentMaximumDelta()))}});Object.extend(Control.ScrollBar,{instances:[],findByElementId:function(a){return Control.ScrollBar.instances.find(function(b){return(b.container.id&&b.container.id==a)})}});Object.Event.extend(Control.ScrollBar);if(typeof(Prototype)=="undefined"){throw"Control.Selection requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.Selection requires Object.Event to be loaded."}Control.Selection={options:{resize_layout_timeout:125,selected:Prototype.emptyFunction,deselected:Prototype.emptyFunction,change:Prototype.emptyFunction,selection_id:"control_selection",selection_style:{zIndex:999,cursor:"default",border:"1px dotted #000"},filter:function(a){return true},drag_proxy:false,drag_proxy_threshold:1,drag_proxy_options:{}},selectableElements:[],elements:[],selectableObjects:[],objects:[],active:false,container:false,resizeTimeout:false,load:function(b){Control.Selection.options=Object.extend(Control.Selection.options,b||{});Control.Selection.selection_div=$(document.createElement("div"));Control.Selection.selection_div.id=Control.Selection.options.selection_id;Control.Selection.selection_div.style.display="none";Control.Selection.selection_div.setStyle(Control.Selection.options.selection_style);Control.Selection.border_width=parseInt(Control.Selection.selection_div.getStyle("border-top-width"),10)*2;Control.Selection.container=Prototype.Browser.IE?window.container:window;$(document.body).insert(Control.Selection.selection_div);Control.Selection.enable();if(Control.Selection.options.drag_proxy&&typeof(Draggable)!="undefined"){Control.Selection.DragProxy.load()}Event.observe(window,"resize",function(){if(Control.Selection.resizeTimeout){window.clearTimeout(Control.Selection.resizeTimeout)}Control.Selection.resizeTimeout=window.setTimeout(Control.Selection.recalculateLayout,Control.Selection.options.resize_layout_timeout)});if(Prototype.Browser.IE){var a=$$("body").first();a.observe("mouseleave",Control.Selection.stop);a.observe("mouseup",Control.Selection.stop)}},enable:function(){if(Prototype.Browser.IE){document.onselectstart=function(){return false}}Event.observe(Control.Selection.container,"mousedown",Control.Selection.start);Event.observe(Control.Selection.container,"mouseup",Control.Selection.stop)},disable:function(){if(Prototype.Browser.IE){document.onselectstart=function(){return true}}Event.stopObserving(Control.Selection.container,"mousedown",Control.Selection.start);Event.stopObserving(Control.Selection.container,"mouseup",Control.Selection.stop)},recalculateLayout:function(){Control.Selection.selectableElements.each(function(b){var c=b.getDimensions();var d=b.cumulativeOffset();var a=b.cumulativeScrollOffset();if(!b._control_selection){b._control_selection={}}b._control_selection.top=d[1]-a[1];b._control_selection.left=d[0]-a[0];b._control_selection.width=c.width;b._control_selection.height=c.height})},addSelectable:function(b,a,d,e){b=$(b);if(d){d=d.each?d:[d]}var c=b.getDimensions();var f=Element.cumulativeOffset(b);b._control_selection={activation_targets:d,is_selected:false,top:f[1],left:f[0],width:c.width,height:c.height,activationTargetMouseMove:function(){Control.Selection.notify("activationTargetMouseMove",b);if(d){d.each(function(g){g.stopObserving("mousemove",b._control_selection.activationTargetMouseMove)})}Control.Selection.DragProxy.container.stopObserving("mousemove",b._control_selection.activationTargetMouseMove)},activationTargetMouseDown:function(g){if(!Control.Selection.elements.include(b)){Control.Selection.select(b)}Control.Selection.DragProxy.start(g);Control.Selection.DragProxy.container.hide();if(d){d.each(function(h){h.observe("mousemove",b._control_selection.activationTargetMouseMove)})}Control.Selection.DragProxy.container.observe("mousemove",b._control_selection.activationTargetMouseMove)},activationTargetClick:function(){Control.Selection.select(b);if(typeof(e)=="function"){e()}if(d){d.each(function(g){g.stopObserving("mousemove",b._control_selection.activationTargetMouseMove)})}Control.Selection.DragProxy.container.stopObserving("mousemove",b._control_selection.activationTargetMouseMove)}};b.onselectstart=function(){return false};b.unselectable="on";b.style.MozUserSelect="none";if(d){d.each(function(g){g.observe("mousedown",b._control_selection.activationTargetMouseDown);g.observe("click",b._control_selection.activationTargetClick)})}Control.Selection.selectableElements.push(b);Control.Selection.selectableObjects.push(a)},removeSelectable:function(b){b=$(b);if(b._control_selection.activation_targets){b._control_selection.activation_targets.each(function(c){c.stopObserving("mousedown",b._control_selection.activationTargetMouseDown)});b._control_selection.activation_targets.each(function(c){c.stopObserving("click",b._control_selection.activationTargetClick)})}b._control_selection=null;b.onselectstart=function(){return true};b.unselectable="off";b.style.MozUserSelect="";var a=0;Control.Selection.selectableElements.each(function(c,d){if(c==b){a=d;throw $break}});Control.Selection.selectableElements=Control.Selection.selectableElements.without(b);Control.Selection.selectableObjects=Control.Selection.selectableObjects.slice(0,a).concat(Control.Selection.selectableObjects.slice(a+1))},select:function(c){if(typeof(c)=="undefined"||!c){c=[]}if(!c.each&&!c._each){c=[c]}var a=!(Control.Selection.elements.length==c.length&&Control.Selection.elements.all(function(f,e){return c[e]==f}));if(!a){return}var b={};var d=c.collect(function(e){var f=Control.Selection.selectableObjects[Control.Selection.selectableElements.indexOf(e)];b[e]=f;return f});if(Control.Selection.elements.length===0&&c.length!==0){c.each(function(e){Control.Selection.notify("selected",e,b[e])})}else{Control.Selection.elements.each(function(e){if(!c.include(e)){Control.Selection.notify("deselected",e,b[e])}});c.each(function(e){if(!Control.Selection.elements.include(e)){Control.Selection.notify("selected",e,b[e])}})}Control.Selection.elements=c;Control.Selection.objects=d;Control.Selection.notify("change",Control.Selection.elements,Control.Selection.objects)},deselect:function(){if(Control.Selection.notify("deselect")===false){return false}Control.Selection.elements.each(function(a){Control.Selection.notify("deselected",a,Control.Selection.selectableObjects[Control.Selection.selectableElements.indexOf(a)])});Control.Selection.objects=[];Control.Selection.elements=[];Control.Selection.notify("change",Control.Selection.objects,Control.Selection.elements);return true},start:function(a){if(!a.isLeftClick()||Control.Selection.notify("start",a)===false){return false}if(!a.shiftKey&&!a.altKey){Control.Selection.deselect()}Event.observe(Control.Selection.container,"mousemove",Control.Selection.onMouseMove);Event.stop(a);return false},stop:function(){Event.stopObserving(Control.Selection.container,"mousemove",Control.Selection.onMouseMove);Control.Selection.active=false;Control.Selection.selection_div.setStyle({display:"none",top:null,left:null,width:null,height:null});Control.Selection.start_mouse_coordinates={};Control.Selection.current_mouse_coordinates={}},mouseCoordinatesFromEvent:function(a){return{x:Event.pointerX(a),y:Event.pointerY(a)}},onClick:function(c,a,d){var b=[];if(c.shiftKey){b=Control.Selection.elements.clone();if(!b.include(a)){b.push(a)}}else{if(c.altKey){b=Control.Selection.elements.clone();if(b.include(a)){b=b.without(a)}}else{b=[a]}}Control.Selection.select(b);if(d=="click"){Event.stop(c)}},onMouseMove:function(b){if(!Control.Selection.active){Control.Selection.active=true;Control.Selection.start_mouse_coordinates=Control.Selection.mouseCoordinatesFromEvent(b)}else{Control.Selection.current_mouse_coordinates=Control.Selection.mouseCoordinatesFromEvent(b);Control.Selection.drawSelectionDiv();var a=Control.Selection.selectableElements.findAll(function(c){return Control.Selection.options.filter(c)&&Control.Selection.elementWithinSelection(c)});if(b.shiftKey&&!b.altKey){Control.Selection.elements.each(function(c){if(!a.include(c)){a.push(c)}})}else{if(b.altKey&&!b.shiftKey){a=Control.Selection.elements.findAll(function(c){return !a.include(c)})}}Control.Selection.select(a)}},drawSelectionDiv:function(){if(Control.Selection.start_mouse_coordinates==Control.Selection.current_mouse_coordinates){Control.Selection.selection_div.style.display="none"}else{Control.Selection.viewport=document.viewport.getDimensions();Control.Selection.selection_div.style.position="absolute";Control.Selection.current_direction=(Control.Selection.start_mouse_coordinates.y>Control.Selection.current_mouse_coordinates.y?"N":"S")+(Control.Selection.start_mouse_coordinates.x<Control.Selection.current_mouse_coordinates.x?"E":"W");Control.Selection.selection_div.setStyle(Control.Selection["dimensionsFor"+Control.Selection.current_direction]());Control.Selection.selection_div.style.display="block"}},dimensionsForNW:function(){return{top:(Control.Selection.start_mouse_coordinates.y-(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y))+"px",left:(Control.Selection.start_mouse_coordinates.x-(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x))+"px",width:(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x)+"px",height:(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y)+"px"}},dimensionsForNE:function(){return{top:(Control.Selection.start_mouse_coordinates.y-(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y))+"px",left:Control.Selection.start_mouse_coordinates.x+"px",width:Math.min((Control.Selection.viewport.width-Control.Selection.start_mouse_coordinates.x)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.x-Control.Selection.start_mouse_coordinates.x)+"px",height:(Control.Selection.start_mouse_coordinates.y-Control.Selection.current_mouse_coordinates.y)+"px"}},dimensionsForSE:function(){return{top:Control.Selection.start_mouse_coordinates.y+"px",left:Control.Selection.start_mouse_coordinates.x+"px",width:Math.min((Control.Selection.viewport.width-Control.Selection.start_mouse_coordinates.x)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.x-Control.Selection.start_mouse_coordinates.x)+"px",height:Math.min((Control.Selection.viewport.height-Control.Selection.start_mouse_coordinates.y)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.y-Control.Selection.start_mouse_coordinates.y)+"px"}},dimensionsForSW:function(){return{top:Control.Selection.start_mouse_coordinates.y+"px",left:(Control.Selection.start_mouse_coordinates.x-(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x))+"px",width:(Control.Selection.start_mouse_coordinates.x-Control.Selection.current_mouse_coordinates.x)+"px",height:Math.min((Control.Selection.viewport.height-Control.Selection.start_mouse_coordinates.y)-Control.Selection.border_width,Control.Selection.current_mouse_coordinates.y-Control.Selection.start_mouse_coordinates.y)+"px"}},inBoundsForNW:function(a,b){return(((a.left>b.left||a.right>b.left)&&b.right>a.left)&&((a.top>b.top||a.bottom>b.top)&&b.bottom>a.top))},inBoundsForNE:function(a,b){return(((a.left<b.right||a.left<b.right)&&b.left<a.right)&&((a.top>b.top||a.bottom>b.top)&&b.bottom>a.top))},inBoundsForSE:function(a,b){return(((a.left<b.right||a.left<b.right)&&b.left<a.right)&&((a.bottom<b.bottom||a.top<b.bottom)&&b.top<a.bottom))},inBoundsForSW:function(a,b){return(((a.left>b.left||a.right>b.left)&&b.right>a.left)&&((a.bottom<b.bottom||a.top<b.bottom)&&b.top<a.bottom))},elementWithinSelection:function(a){if(Control.Selection["inBoundsFor"+Control.Selection.current_direction]({top:a._control_selection.top,left:a._control_selection.left,bottom:a._control_selection.top+a._control_selection.height,right:a._control_selection.left+a._control_selection.width},{top:parseInt(Control.Selection.selection_div.style.top,10),left:parseInt(Control.Selection.selection_div.style.left,10),bottom:parseInt(Control.Selection.selection_div.style.top,10)+parseInt(Control.Selection.selection_div.style.height,10),right:parseInt(Control.Selection.selection_div.style.left,10)+parseInt(Control.Selection.selection_div.style.width,10)})){a._control_selection.is_selected=true;return true}else{a._control_selection.is_selected=false;return false}},DragProxy:{active:false,xorigin:0,yorigin:0,load:function(){Control.Selection.DragProxy.container=$(document.createElement("div"));Control.Selection.DragProxy.container.id="control_selection_drag_proxy";Control.Selection.DragProxy.container.setStyle({position:"absolute",top:"1px",left:"1px",zIndex:99999});Control.Selection.DragProxy.container.hide();document.body.appendChild(Control.Selection.DragProxy.container);Control.Selection.observe("selected",Control.Selection.DragProxy.selected);Control.Selection.observe("deselected",Control.Selection.DragProxy.deselected)},start:function(a){if(a.isRightClick()){Control.Selection.DragProxy.container.hide();return}if(Control.Selection.DragProxy.xorigin==Event.pointerX(a)&&Control.Selection.DragProxy.yorigin==Event.pointerY(a)){return}Control.Selection.DragProxy.active=true;Control.Selection.DragProxy.container.setStyle({position:"absolute",top:Event.pointerY(a)+"px",left:Event.pointerX(a)+"px"});Control.Selection.DragProxy.container.observe("mouseup",Control.Selection.DragProxy.onMouseUp);Control.Selection.DragProxy.container.show();Control.Selection.DragProxy.container._draggable=new Draggable(Control.Selection.DragProxy.container,Object.extend({onEnd:Control.Selection.DragProxy.stop},Control.Selection.options.drag_proxy_options));Control.Selection.DragProxy.container._draggable.eventMouseDown(a);Control.Selection.DragProxy.notify("start",Control.Selection.DragProxy.container,Control.Selection.elements)},stop:function(){window.setTimeout(function(){Control.Selection.DragProxy.active=false;Control.Selection.DragProxy.container.hide();if(Control.Selection.DragProxy.container._draggable){Control.Selection.DragProxy.container._draggable.destroy();Control.Selection.DragProxy.container._draggable=null}Control.Selection.DragProxy.notify("stop")},1)},onClick:function(a){Control.Selection.DragProxy.xorigin=Event.pointerX(a);Control.Selection.DragProxy.yorigin=Event.pointerY(a);if(a.isRightClick()){Control.Selection.DragProxy.container.hide()}if(Control.Selection.elements.length>=Control.Selection.options.drag_proxy_threshold&&!(a.shiftKey||a.altKey)&&(Control.Selection.DragProxy.xorigin!=Event.pointerX(a)||Control.Selection.DragProxy.yorigin!=Event.pointerY(a))){Control.Selection.DragProxy.start(a);Event.stop(a)}},onMouseUp:function(a){Control.Selection.DragProxy.stop();Control.Selection.DragProxy.container.stopObserving("mouseup",Control.Selection.DragProxy.onMouseUp)},selected:function(a){a.observe("mousedown",Control.Selection.DragProxy.onClick)},deselected:function(a){a.stopObserving("mousedown",Control.Selection.DragProxy.onClick)}}};Object.Event.extend(Control.Selection);Object.Event.extend(Control.Selection.DragProxy);if(typeof(Prototype)=="undefined"){throw"Control.SelectMultiple requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.SelectMultiple requires Object.Event to be loaded."}Control.SelectMultiple=Class.create({select:false,container:false,numberOfCheckedBoxes:0,checkboxes:[],hasExtraOption:false,initialize:function(b,c,d){this.options={checkboxSelector:"input[type=checkbox]",nameSelector:"span.name",labelSeparator:", ",valueSeparator:",",afterChange:Prototype.emptyFunction,overflowString:function(e){return e.truncate()},overflowLength:30};Object.extend(this.options,d||{});this.select=$(b);this.container=$(c);this.checkboxes=(typeof(this.options.checkboxSelector)=="function")?this.options.checkboxSelector.bind(this)():this.container.getElementsBySelector(this.options.checkboxSelector);var a=false;if(this.options.value){a=true;this.setValue(this.options.value);delete this.options.value}this.hasExtraOption=false;this.checkboxes.each(function(e){e.observe("click",this.checkboxOnClick.bind(this,e))}.bind(this));this.select.observe("change",this.selectOnChange.bind(this));this.countAndCheckCheckBoxes();if(!a){this.scanCheckBoxes()}this.notify("afterChange",this.select.options[this.select.options.selectedIndex].value)},countAndCheckCheckBoxes:function(){this.numberOfCheckedBoxes=this.checkboxes.inject(0,function(c,d){d.checked=(this.select.options[this.select.options.selectedIndex].value==d.value);var b=this.select.options[this.select.options.selectedIndex].value;var e=$A(b.split?b.split(this.options.valueSeparator):b);var a=e.any(function(f){if(!a&&d.value==f){return true}}.bind(this));d.checked=a;if(d.checked){++c}return c}.bind(this))},setValue:function(a){this.numberOfCheckedBoxes=0;var b=$A(a.split?a.split(this.options.valueSeparator):a);this.checkboxes.each(function(c){c.checked=false;b.each(function(d){if(c.value==d){++this.numberOfCheckedBoxes;c.checked=true}}.bind(this))}.bind(this));this.scanCheckBoxes()},selectOnChange:function(){this.removeExtraOption();this.countAndCheckCheckBoxes();this.notify("afterChange",this.select.options[this.select.options.selectedIndex].value)},checkboxOnClick:function(a){this.numberOfCheckedBoxes=this.checkboxes.findAll(function(b){return b.checked}).length;this.scanCheckBoxes();this.notify("afterChange",this.numberOfCheckedBoxes===0?"":this.select.options[this.select.options.selectedIndex].value)},scanCheckBoxes:function(){switch(this.numberOfCheckedBoxes){case 1:this.checkboxes.each(function(a){if(a.checked){$A(this.select.options).each(function(c,b){if(c.value==a.value){this.select.options.selectedIndex=b;throw $break}}.bind(this));throw $break}}.bind(this));break;case 0:this.removeExtraOption();break;default:this.addExtraOption();break}},getLabelForExtraOption:function(){var a=(typeof(this.options.nameSelector)=="function"?this.options.nameSelector.bind(this)():this.container.getElementsBySelector(this.options.nameSelector).inject([],function(d,c,b){if(this.checkboxes[b].checked){d.push(c.innerHTML)}return d}.bind(this))).join(this.options.labelSeparator);return(a.length>=this.options.overflowLength&&this.options.overflowLength>0)?(typeof(this.options.overflowString)=="function"?this.options.overflowString(a):this.options.overflowString):a},getValueForExtraOption:function(){return this.checkboxes.inject([],function(a,b){if(b.checked){a.push(b.value)}return a}).join(this.options.valueSeparator)},addExtraOption:function(){this.removeExtraOption();this.hasExtraOption=true;this.select.options[this.select.options.length]=new Option(this.getLabelForExtraOption(),this.getValueForExtraOption());this.select.options.selectedIndex=this.select.options.length-1},removeExtraOption:function(){if(this.hasExtraOption){this.select.remove(this.select.options.length-1);this.hasExtraOption=false}}});Object.Event.extend(Control.SelectMultiple);if(typeof(Prototype)=="undefined"){throw"Control.Tabs requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.Tabs requires Object.Event to be loaded."}Control.Tabs=Class.create({initialize:function(d,b){if(!$(d)){throw"Control.Tabs could not find the element: "+d}this.activeContainer=false;this.activeLink=false;this.containers=$H({});this.links=[];this.options={beforeChange:Prototype.emptyFunction,afterChange:Prototype.emptyFunction,hover:false,tracked:true,linkSelector:"li a",linkAttribute:"href",setClassOnContainer:false,activeClassName:"active",disabledClassName:"disabled",defaultTab:"first",autoLinkExternal:true,targetRegExp:/#(.+)$/,showFunction:Element.show,hideFunction:Element.hide};Object.extend(this.options,b||{});if(this.options.tracked){Control.Tabs.instances.push(this)}var c;switch(this.options.linkAttribute){case"href":case"src":c=function(e){return(/^#/).test(e.getAttribute(this.options.linkAttribute).replace(window.location.href.split("#")[0],""))};break;default:if(typeof(this.options.linkAttribute)=="function"){c=this.options.linkAttribute}else{c=function(e){return e.hasAttribute(this.options.linkAttribute)}}}(typeof(this.options.linkSelector)=="string"?$(d).select(this.options.linkSelector):this.options.linkSelector($(d))).findAll(c.bind(this)).each(function(e){this.addTab(e)}.bind(this));this.containers.values().each(Element.hide);if(this.options.defaultTab=="first"){this.setActiveTab(this.links.first())}else{if(this.options.defaultTab=="last"){this.setActiveTab(this.links.last())}else{this.setActiveTab(this.options.defaultTab)}}var a=this.options.targetRegExp.exec(window.location);if(a&&a[1]){a[1].split(",").each(function(e){this.setActiveTab(this.links.find(function(f){return f.key==e}))}.bind(this))}if(this.options.autoLinkExternal){$A(document.getElementsByTagName("a")).each(function(e){if(!this.links.include(e)){var f=e.href.replace(window.location.href.split("#")[0],"");if(f.substring(0,1)=="#"){if(this.containers.keys().include(f.substring(1))){$(e).observe("click",function(h,g){this.setActiveTab(g.substring(1))}.bindAsEventListener(this,f))}}}}.bind(this))}},addTab:function(b){this.links.push(b);switch(this.options.linkAttribute){case"href":case"src":b.key=b.getAttribute(this.options.linkAttribute).replace(window.location.href.split("#")[0],"").split("#").last().replace(/#/,"");break;default:if(typeof(this.options.linkAttribute)=="function"){b.key=this.options.linkAttribute(b)}else{b.key=b.getAttribute(this.options.linkAttribute)}}var a=this.options.tabs_container?this.options.tabs_container.down("#"+b.key):$(b.key);if(!a){throw"Control.Tabs: #"+b.key+" was not found on the page."}this.containers.set(b.key,a);b[this.options.hover?"onmouseover":"onclick"]=function(c){if(window.event){Event.stop(window.event)}this.setActiveTab(c);return false}.bind(this,b)},getTab:function(a){if(!a&&typeof(a)=="undefined"){return null}if(typeof(a)=="string"){return this.getTab(this.links.find(function(b){return b.key==a}))}else{if(typeof(a)=="number"){return this.getTab(this.links[a])}else{return this.containers.get(a.key)}}},setActiveTab:function(a){if(!a&&typeof(a)=="undefined"){return}if(typeof(a)=="string"){this.setActiveTab(this.links.find(function(b){return b.key==a}))}else{if(typeof(a)=="number"){this.setActiveTab(this.links[a])}else{if(!(this.options.setClassOnContainer?$(a.parentNode):a).hasClassName(this.options.disabledClassName)){if(a==this.activeLink){return}if(this.notify("beforeChange",this.activeContainer,this.containers.get(a.key))===false){return}if(this.activeContainer){this.options.hideFunction(this.activeContainer)}this.links.each(function(b){(this.options.setClassOnContainer?$(b.parentNode):b).removeClassName(this.options.activeClassName)}.bind(this));(this.options.setClassOnContainer?$(a.parentNode):a).addClassName(this.options.activeClassName);this.activeContainer=this.containers.get(a.key);this.activeLink=a;this.options.showFunction(this.containers.get(a.key));this.notify("afterChange",this.containers.get(a.key))}}}},disableTab:function(a){if(!a&&typeof(a)=="undefined"){return}if(typeof(a)=="string"){this.disableTab(this.links.find(function(b){return b.key==a}))}else{if(typeof(a)=="number"){this.disableTab(this.links[a])}else{if({INPUT:true,BUTTON:true,SELECT:true,TEXTAREA:true}[a.nodeName]){a.disabled=true}(this.options.setClassOnContainer?$(a.parentNode):a).addClassName(this.options.disabledClassName)}}},enableTab:function(a){if(!a&&typeof(a)=="undefined"){return}if(typeof(a)=="string"){this.enableTab(this.links.find(function(b){return b.key==a}))}else{if(typeof(a)=="number"){this.enableTab(this.links[a])}else{if({INPUT:true,BUTTON:true,SELECT:true,TEXTAREA:true}[a.nodeName]){a.disabled=false}(this.options.setClassOnContainer?$(a.parentNode):a).removeClassName(this.options.disabledClassName)}}},next:function(){this.links.each(function(b,a){if(this.activeLink==b&&this.links[a+1]){this.setActiveTab(this.links[a+1]);throw $break}}.bind(this))},previous:function(){this.links.each(function(b,a){if(this.activeLink==b&&this.links[a-1]){this.setActiveTab(this.links[a-1]);throw $break}}.bind(this))},first:function(){this.setActiveTab(this.links.first())},last:function(){this.setActiveTab(this.links.last())}});Object.extend(Control.Tabs,{instances:[],findByTabId:function(a){return Control.Tabs.instances.find(function(b){return b.links.find(function(c){return c.key==a})})}});Object.Event.extend(Control.Tabs);if(typeof(Prototype)=="undefined"){throw"Control.TextArea requires Prototype to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.TextArea requires Object.Event to be loaded."}Control.TextArea=Class.create({initialize:function(a){this.onChangeTimeout=false;this.element=$(a);$(this.element).observe("keyup",this.doOnChange.bindAsEventListener(this));$(this.element).observe("paste",this.doOnChange.bindAsEventListener(this));$(this.element).observe("input",this.doOnChange.bindAsEventListener(this));if(!!document.selection){$(this.element).observe("mouseup",this.saveRange.bindAsEventListener(this));$(this.element).observe("keyup",this.saveRange.bindAsEventListener(this))}},doOnChange:function(a){if(this.onChangeTimeout){window.clearTimeout(this.onChangeTimeout)}this.onChangeTimeout=window.setTimeout(function(){this.notify("change",this.getValue())}.bind(this),Control.TextArea.onChangeTimeoutLength)},saveRange:function(){this.range=document.selection.createRange()},getValue:function(){return this.element.value},getSelection:function(){if(!!document.selection){return document.selection.createRange().text}else{if(!!this.element.setSelectionRange){return this.element.value.substring(this.element.selectionStart,this.element.selectionEnd)}else{return false}}},replaceSelection:function(c){var b=this.element.scrollTop;if(!!document.selection){this.element.focus();var a=(this.range)?this.range:document.selection.createRange();a.text=c;a.select()}else{if(!!this.element.setSelectionRange){var d=this.element.selectionStart;this.element.value=this.element.value.substring(0,d)+c+this.element.value.substring(this.element.selectionEnd);this.element.setSelectionRange(d+c.length,d+c.length)}}this.doOnChange();this.element.focus();this.element.scrollTop=b},wrapSelection:function(b,c){var a=this.getSelection();if(a.indexOf(b)===0&&a.lastIndexOf(c)===(a.length-c.length)){this.replaceSelection(a.substring(b.length,a.length-c.length))}else{this.replaceSelection(b+a+c)}},insertBeforeSelection:function(a){this.replaceSelection(a+this.getSelection())},insertAfterSelection:function(a){this.replaceSelection(this.getSelection()+a)},collectFromEachSelectedLine:function(c,a,b){this.replaceSelection((a||"")+$A(this.getSelection().split("\n")).collect(c).join("\n")+(b||""))},insertBeforeEachSelectedLine:function(c,a,b){this.collectFromEachSelectedLine(function(d){},a,b)}});Object.extend(Control.TextArea,{onChangeTimeoutLength:500});Object.Event.extend(Control.TextArea);Control.TextArea.ToolBar=Class.create({initialize:function(a,b){this.textarea=a;if(b){this.container=$(b)}else{this.container=$(document.createElement("ul"));this.textarea.element.parentNode.insertBefore(this.container,this.textarea.element)}},attachButton:function(a,b){a.onclick=function(){return false};$(a).observe("click",b.bindAsEventListener(this.textarea))},addButton:function(d,g,e){var b=document.createElement("li");var c=document.createElement("a");c.href="#";this.attachButton(c,g);b.appendChild(c);Object.extend(c,e||{});if(d){var f=document.createElement("span");f.innerHTML=d;c.appendChild(f)}this.container.appendChild(b)}});if(typeof(Draggable)!="undefined"){Draggable.prototype.draw=function(j){var i=Position.cumulativeOffset(this.element);if(this.options.ghosting){var a=Position.realOffset(this.element);i[0]+=a[0]-Position.deltaX;i[1]+=a[1]-Position.deltaY}var h=this.currentDelta();i[0]-=h[0];i[1]-=h[1];if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){i[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;i[1]-=this.options.scroll.scrollTop-this.originalScrollTop}var c=[0,1].map(function(d){return(j[d]-i[d]-this.offset[d])}.bind(this));if(this.options.snap){if(typeof this.options.snap=="function"){c=this.options.snap(c[0],c[1],this)}else{if(this.options.snap instanceof Array){c=c.map(function(d,m){return Math.round(d/this.options.snap[m])*this.options.snap[m]}.bind(this))}else{c=c.map(function(d){return Math.round(d/this.options.snap)*this.options.snap}.bind(this))}}}if(this.options.onDraw){this.options.onDraw.bind(this)(c)}else{var b=this.element.style;if(this.options.constrainToViewport){var l=document.viewport.getDimensions();var f=this.element.getDimensions();var g=parseInt(this.element.getStyle("margin-top"));var k=parseInt(this.element.getStyle("margin-left"));var e=[[0-k,0-g],[(l.width-f.width)-k,(l.height-f.height)-g]];if((!this.options.constraint)||(this.options.constraint=="horizontal")){if((c[0]>=e[0][0])&&(c[0]<=e[1][0])){this.element.style.left=c[0]+"px"}else{this.element.style.left=((c[0]<e[0][0])?e[0][0]:e[1][0])+"px"}}if((!this.options.constraint)||(this.options.constraint=="vertical")){if((c[1]>=e[0][1])&&(c[1]<=e[1][1])){this.element.style.top=c[1]+"px"}else{this.element.style.top=((c[1]<=e[0][1])?e[0][1]:e[1][1])+"px"}}}else{if((!this.options.constraint)||(this.options.constraint=="horizontal")){b.left=c[0]+"px"}if((!this.options.constraint)||(this.options.constraint=="vertical")){b.top=c[1]+"px"}}if(b.visibility=="hidden"){b.visibility=""}}}}if(typeof(Prototype)=="undefined"){throw"Control.Window requires Prototype to be loaded."}if(typeof(IframeShim)=="undefined"){throw"Control.Window requires IframeShim to be loaded."}if(typeof(Object.Event)=="undefined"){throw"Control.Window requires Object.Event to be loaded."}Control.Window=Class.create({initialize:function(b,c){Control.Window.windows.push(this);this.container=false;this.isOpen=false;this.href=false;this.sourceContainer=false;this.ajaxRequest=false;this.remoteContentLoaded=false;this.numberInSequence=Control.Window.windows.length+1;this.indicator=false;this.effects={fade:false,appear:false};this.indicatorEffects={fade:false,appear:false};this.options=Object.extend({beforeOpen:Prototype.emptyFunction,afterOpen:Prototype.emptyFunction,beforeClose:Prototype.emptyFunction,afterClose:Prototype.emptyFunction,height:null,width:null,className:false,position:"center",offsetLeft:0,offsetTop:0,iframe:false,hover:false,indicator:false,closeOnClick:false,iframeshim:true,fade:false,fadeDuration:0.75,draggable:false,onDrag:Prototype.emptyFunction,resizable:false,minHeight:false,minWidth:false,maxHeight:false,maxWidth:false,onResize:Prototype.emptyFunction,constrainToViewport:false,method:"post",parameters:{},onComplete:Prototype.emptyFunction,onSuccess:Prototype.emptyFunction,onFailure:Prototype.emptyFunction,onException:Prototype.emptyFunction,onRemoteContentLoaded:Prototype.emptyFunction,insertRemoteContentAt:false},c||{});this.indicator=this.options.indicator?$(this.options.indicator):false;if(b){if(typeof(b)=="string"&&b.match(Control.Window.uriRegex)){this.href=b}else{this.container=$(b);this.createDefaultContainer(b);if(this.container&&((this.container.readAttribute("href")&&this.container.readAttribute("href")!="")||(this.options.hover&&this.options.hover!==true))){if(this.options.hover&&this.options.hover!==true){this.sourceContainer=$(this.options.hover)}else{this.sourceContainer=this.container;this.href=this.container.readAttribute("href");var a=this.href.match(/^#(.+)$/);if(a&&a[1]){this.container=$(a[1]);this.href=false}else{this.container=false}}this.sourceContainerOpenHandler=function(e){this.open(e);e.stop();return false}.bindAsEventListener(this);this.sourceContainerCloseHandler=function(e){this.close(e)}.bindAsEventListener(this);this.sourceContainerMouseMoveHandler=function(e){this.position(e)}.bindAsEventListener(this);if(this.options.hover){this.sourceContainer.observe("mouseenter",this.sourceContainerOpenHandler);this.sourceContainer.observe("mouseleave",this.sourceContainerCloseHandler);if(this.options.position=="mouse"){this.sourceContainer.observe("mousemove",this.sourceContainerMouseMoveHandler)}}else{this.sourceContainer.observe("click",this.sourceContainerOpenHandler)}}}}this.createDefaultContainer(b);if(this.options.insertRemoteContentAt===false){this.options.insertRemoteContentAt=this.container}var d={margin:0,position:"absolute",zIndex:Control.Window.initialZIndexForWindow()};if(this.options.width){d.width=$value(this.options.width)+"px"}if(this.options.height){d.height=$value(this.options.height)+"px"}this.container.setStyle(d);if(this.options.className){this.container.addClassName(this.options.className)}this.positionHandler=this.position.bindAsEventListener(this);this.outOfBoundsPositionHandler=this.ensureInBounds.bindAsEventListener(this);this.bringToFrontHandler=this.bringToFront.bindAsEventListener(this);this.container.observe("mousedown",this.bringToFrontHandler);this.container.hide();this.closeHandler=this.close.bindAsEventListener(this);if(this.options.iframeshim){this.iFrameShim=new IframeShim();this.iFrameShim.hide()}this.applyResizable();this.applyDraggable();Event.observe(window,"resize",this.outOfBoundsPositionHandler);this.notify("afterInitialize")},open:function(c){if(this.isOpen){this.bringToFront();return false}if(this.notify("beforeOpen")===false){return false}if(this.options.closeOnClick){if(this.options.closeOnClick===true){this.closeOnClickContainer=$(document.body)}else{if(this.options.closeOnClick=="container"){this.closeOnClickContainer=this.container}else{if(this.options.closeOnClick=="overlay"){Control.Overlay.load();this.closeOnClickContainer=Control.Overlay.container}else{this.closeOnClickContainer=$(this.options.closeOnClick)}}}this.closeOnClickContainer.observe("click",this.closeHandler)}if(this.href&&!this.options.iframe&&!this.remoteContentLoaded){this.remoteContentLoaded=true;if(this.href.match(/\.(jpe?g|gif|png|tiff?)$/i)){var a=new Element("img");a.observe("load",function(d){this.getRemoteContentInsertionTarget().insert(d);this.position();if(this.notify("onRemoteContentLoaded")!==false){if(this.options.indicator){this.hideIndicator()}this.finishOpen()}}.bind(this,a));a.writeAttribute("src",this.href)}else{if(!this.ajaxRequest){if(this.options.indicator){this.showIndicator()}this.ajaxRequest=new Ajax.Request(this.href,{method:this.options.method,parameters:this.options.parameters,onComplete:function(d){this.notify("onComplete",d);this.ajaxRequest=false}.bind(this),onSuccess:function(d){this.getRemoteContentInsertionTarget().insert(d.responseText);this.notify("onSuccess",d);if(this.notify("onRemoteContentLoaded")!==false){if(this.options.indicator){this.hideIndicator()}this.finishOpen()}}.bind(this),onFailure:function(d){this.notify("onFailure",d);if(this.options.indicator){this.hideIndicator()}}.bind(this),onException:function(d,f){this.notify("onException",d,f);if(this.options.indicator){this.hideIndicator()}}.bind(this)})}}return true}else{if(this.options.iframe&&!this.remoteContentLoaded){this.remoteContentLoaded=true;if(this.options.indicator){this.showIndicator()}this.getRemoteContentInsertionTarget().insert(Control.Window.iframeTemplate.evaluate({href:this.href}));var b=this.container.down("iframe");b.onload=function(){this.notify("onRemoteContentLoaded");if(this.options.indicator){this.hideIndicator()}b.onload=null}.bind(this)}}this.finishOpen(c);return true},close:function(a){if(!this.isOpen||this.notify("beforeClose",a)===false){return false}if(this.options.closeOnClick){this.closeOnClickContainer.stopObserving("click",this.closeHandler)}if(this.options.fade){this.effects.fade=new Effect.Fade(this.container,{queue:{position:"front",scope:"Control.Window"+this.numberInSequence},from:1,to:0,duration:this.options.fadeDuration/2,afterFinish:function(){if(this.iFrameShim){this.iFrameShim.hide()}this.isOpen=false;this.notify("afterClose")}.bind(this)})}else{this.container.hide();if(this.iFrameShim){this.iFrameShim.hide()}}if(this.ajaxRequest){this.ajaxRequest.transport.abort()}if(!(this.options.draggable||this.options.resizable)&&this.options.position=="center"){Event.stopObserving(window,"resize",this.positionHandler)}if(!this.options.draggable&&this.options.position=="center"){Event.stopObserving(window,"scroll",this.positionHandler)}if(this.options.indicator){this.hideIndicator()}if(!this.options.fade){this.isOpen=false;this.notify("afterClose")}return true},position:function(d){if(this.options.position=="mouse"){var g=[Event.pointerX(d),Event.pointerY(d)];this.container.setStyle({top:g[1]+$value(this.options.offsetTop)+"px",left:g[0]+$value(this.options.offsetLeft)+"px"});return}var h=this.container.getDimensions();var c=document.viewport.getDimensions();Position.prepare();var b=(Position.deltaX+Math.floor((c.width-h.width)/2));var a=(Position.deltaY+((c.height>h.height)?Math.floor((c.height-h.height)/2):0));if(this.options.position=="center"||this.options.position=="center_once"){this.container.setStyle({top:(h.height<=c.height)?((a!=null&&a>0)?a:0)+"px":0,left:(h.width<=c.width)?((b!=null&&b>0)?b:0)+"px":0})}else{if(this.options.position=="relative"){var g=this.sourceContainer.cumulativeOffset();var f=g[1]+$value(this.options.offsetTop);var e=g[0]+$value(this.options.offsetLeft);this.container.setStyle({top:(h.height<=c.height)?(this.options.constrainToViewport?Math.max(0,Math.min(c.height-(h.height),f)):f)+"px":0,left:(h.width<=c.width)?(this.options.constrainToViewport?Math.max(0,Math.min(c.width-(h.width),e)):e)+"px":0})}else{if(this.options.position.length){var f=$value(this.options.position[1])+$value(this.options.offsetTop);var e=$value(this.options.position[0])+$value(this.options.offsetLeft);this.container.setStyle({top:(h.height<=c.height)?(this.options.constrainToViewport?Math.max(0,Math.min(c.height-(h.height),f)):f)+"px":0,left:(h.width<=c.width)?(this.options.constrainToViewport?Math.max(0,Math.min(c.width-(h.width),e)):e)+"px":0})}}}if(this.iFrameShim){this.updateIFrameShimZIndex()}},ensureInBounds:function(){if(!this.isOpen){return}var a=document.viewport.getDimensions();var c=this.container.cumulativeOffset();var b=this.container.getDimensions();if(c.left+b.width>a.width){this.container.setStyle({left:(Math.max(0,a.width-b.width))+"px"})}if(c.top+b.height>a.height){this.container.setStyle({top:(Math.max(0,a.height-b.height))+"px"})}},bringToFront:function(){Control.Window.bringToFront(this);this.notify("bringToFront")},destroy:function(){this.container.stopObserving("mousedown",this.bringToFrontHandler);if(this.draggable){Draggables.removeObserver(this.container);this.draggable.handle.stopObserving("mousedown",this.bringToFrontHandler);this.draggable.destroy()}if(this.resizable){Resizables.removeObserver(this.container);this.resizable.handle.stopObserving("mousedown",this.bringToFrontHandler);this.resizable.destroy()}if(this.container&&!this.sourceContainer){this.container.remove()}if(this.sourceContainer){if(this.options.hover){this.sourceContainer.stopObserving("mouseenter",this.sourceContainerOpenHandler);this.sourceContainer.stopObserving("mouseleave",this.sourceContainerCloseHandler);if(this.options.position=="mouse"){this.sourceContainer.stopObserving("mousemove",this.sourceContainerMouseMoveHandler)}}else{this.sourceContainer.stopObserving("click",this.sourceContainerOpenHandler)}}if(this.iFrameShim){this.iFrameShim.destroy()}Event.stopObserving(window,"resize",this.outOfBoundsPositionHandler);Control.Window.windows=Control.Window.windows.without(this);this.notify("afterDestroy")},applyResizable:function(){if(this.options.resizable){if(typeof(Resizable)=="undefined"){throw"Control.Window requires resizable.js to be loaded."}var a=null;if(this.options.resizable===true){a=new Element("div",{className:"resizable_handle"});this.container.insert(a)}else{a=$(this.options.resziable)}this.resizable=new Resizable(this.container,{handle:a,minHeight:this.options.minHeight,minWidth:this.options.minWidth,maxHeight:this.options.constrainToViewport?function(b){return(document.viewport.getDimensions().height-parseInt(b.style.top||0))-(b.getHeight()-parseInt(b.style.height||0))}:this.options.maxHeight,maxWidth:this.options.constrainToViewport?function(b){return(document.viewport.getDimensions().width-parseInt(b.style.left||0))-(b.getWidth()-parseInt(b.style.width||0))}:this.options.maxWidth});this.resizable.handle.observe("mousedown",this.bringToFrontHandler);Resizables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){if(this.iFrameShim){this.updateIFrameShimZIndex()}this.notify("onResize")}.bind(this)))}},applyDraggable:function(){if(this.options.draggable){if(typeof(Draggables)=="undefined"){throw"Control.Window requires dragdrop.js to be loaded."}var a=null;if(this.options.draggable===true){a=new Element("div",{className:"draggable_handle"});this.container.insert(a)}else{a=$(this.options.draggable)}this.draggable=new Draggable(this.container,{handle:a,constrainToViewport:this.options.constrainToViewport,zindex:this.container.getStyle("z-index"),starteffect:function(){if(Prototype.Browser.IE){this.old_onselectstart=document.onselectstart;document.onselectstart=function(){return false}}}.bind(this),endeffect:function(){document.onselectstart=this.old_onselectstart}.bind(this)});this.draggable.handle.observe("mousedown",this.bringToFrontHandler);Draggables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){if(this.iFrameShim){this.updateIFrameShimZIndex()}this.notify("onDrag")}.bind(this)))}},createDefaultContainer:function(a){if(!this.container){this.container=new Element("div",{id:"control_window_"+this.numberInSequence});$(document.body).insert(this.container);if(typeof(a)=="string"&&$(a)==null&&!a.match(/^#(.+)$/)&&!a.match(Control.Window.uriRegex)){this.container.update(a)}}},finishOpen:function(a){this.bringToFront();if(this.options.fade){if(typeof(Effect)=="undefined"){throw"Control.Window requires effects.js to be loaded."}if(this.effects.fade){this.effects.fade.cancel()}this.effects.appear=new Effect.Appear(this.container,{queue:{position:"end",scope:"Control.Window."+this.numberInSequence},from:0,to:1,duration:this.options.fadeDuration/2,afterFinish:function(){if(this.iFrameShim){this.updateIFrameShimZIndex()}this.isOpen=true;this.notify("afterOpen")}.bind(this)})}else{this.container.show()}this.position(a);if(!(this.options.draggable||this.options.resizable)&&this.options.position=="center"){Event.observe(window,"resize",this.positionHandler,false)}if(!this.options.draggable&&this.options.position=="center"){Event.observe(window,"scroll",this.positionHandler,false)}if(!this.options.fade){this.isOpen=true;this.notify("afterOpen")}return true},showIndicator:function(){this.showIndicatorTimeout=window.setTimeout(function(){if(this.options.fade){this.indicatorEffects.appear=new Effect.Appear(this.indicator,{queue:{position:"front",scope:"Control.Window.indicator."+this.numberInSequence},from:0,to:1,duration:this.options.fadeDuration/2})}else{this.indicator.show()}}.bind(this),Control.Window.indicatorTimeout)},hideIndicator:function(){if(this.showIndicatorTimeout){window.clearTimeout(this.showIndicatorTimeout)}this.indicator.hide()},getRemoteContentInsertionTarget:function(){return typeof(this.options.insertRemoteContentAt)=="string"?this.container.down(this.options.insertRemoteContentAt):$(this.options.insertRemoteContentAt)},updateIFrameShimZIndex:function(){if(this.iFrameShim){this.iFrameShim.positionUnder(this.container)}}});Object.extend(Control.Window,{windows:[],baseZIndex:9999,indicatorTimeout:250,iframeTemplate:new Template('<iframe src="#{href}" width="100%" height="100%" frameborder="0"></iframe>'),uriRegex:/^(\/|\#|https?\:\/\/|[\w]+\/)/,bringToFront:function(a){Control.Window.windows=Control.Window.windows.without(a);Control.Window.windows.push(a);Control.Window.windows.each(function(c,d){var b=Control.Window.baseZIndex+d;c.container.setStyle({zIndex:b});if(c.isOpen){if(c.iFrameShim){c.updateIFrameShimZIndex()}}if(c.options.draggable){c.draggable.options.zindex=b}})},open:function(b,c){var a=new Control.Window(b,c);a.open();return a},initialZIndexForWindow:function(a){return Control.Window.baseZIndex+(Control.Window.windows.length-1)}});Object.Event.extend(Control.Window);Control.Window.LayoutUpdateObserver=Class.create({initialize:function(a,b){this.w=a;this.element=$(a.container);this.observer=b},onStart:Prototype.emptyFunction,onEnd:function(b,a){if(a.element==this.element&&this.iFrameShim){this.w.updateIFrameShimZIndex()}},onResize:function(b,a){if(a.element==this.element){this.observer(this.element)}},onDrag:function(b,a){if(a.element==this.element){this.observer(this.element)}}});Control.Overlay={id:"control_overlay",loaded:false,container:false,lastOpacity:0,styles:{position:"absolute",top:0,left:0,zIndex:9998},effects:{fade:false,appear:false},load:function(){if(Control.Overlay.loaded){return false}Control.Overlay.loaded=true;Control.Overlay.container=new Element("div",{id:Control.Overlay.id});$(document.body).insert(Control.Overlay.container);Control.Overlay.container.setStyle(Control.Overlay.styles);var a=Lightbox.prototype.getPageSize();Control.Overlay.container.setStyle({width:a[0]+"px",height:a[1]+"px"});Control.Overlay.iFrameShim=new IframeShim();Control.Overlay.iFrameShim.hide();Event.observe(window,"resize",Control.Overlay.positionIFrameShim);Control.Overlay.container.hide();return true},unload:function(){if(!Control.Overlay.loaded){return false}Event.stopObserving(window,"resize",Control.Overlay.positionIFrameShim);Control.Overlay.iFrameShim.destroy();Control.Overlay.container.remove();Control.Overlay.loaded=false;return true},show:function(a,b){if(Control.Overlay.notify("beforeShow")===false){return false}Control.Overlay.lastOpacity=a;Control.Overlay.positionIFrameShim();Control.Overlay.iFrameShim.show();if(b){if(typeof(Effect)=="undefined"){throw"Control.Window requires effects.js to be loaded."}if(Control.Overlay.effects.fade){Control.Overlay.effects.fade.cancel()}Control.Overlay.effects.appear=new Effect.Appear(Control.Overlay.container,{queue:{position:"end",scope:"Control.Overlay"},afterFinish:function(){Control.Overlay.notify("afterShow")},from:0,to:Control.Overlay.lastOpacity,duration:(b===true?0.75:b)/2})}else{Control.Overlay.container.setStyle({opacity:a||1});Control.Overlay.container.show();Control.Overlay.notify("afterShow")}return true},hide:function(a){if(Control.Overlay.notify("beforeHide")===false){return false}if(Control.Overlay.effects.appear){Control.Overlay.effects.appear.cancel()}Control.Overlay.iFrameShim.hide();if(a){Control.Overlay.effects.fade=new Effect.Fade(Control.Overlay.container,{queue:{position:"front",scope:"Control.Overlay"},afterFinish:function(){Control.Overlay.notify("afterHide")},from:Control.Overlay.lastOpacity,to:0,duration:(a===true?0.75:a)/2})}else{Control.Overlay.container.hide();Control.Overlay.notify("afterHide")}return true},positionIFrameShim:function(){if(Control.Overlay.container.visible()){Control.Overlay.iFrameShim.positionUnder(Control.Overlay.container)}}};Object.Event.extend(Control.Overlay);Control.ToolTip=Class.create(Control.Window,{initialize:function($super,a,c,b){$super(c,Object.extend(Object.extend(Object.clone(Control.ToolTip.defaultOptions),b||{}),{position:"mouse",hover:a}))}});Object.extend(Control.ToolTip,{defaultOptions:{offsetLeft:10}});Control.Modal=Class.create(Control.Window,{initialize:function($super,a,b){Control.Modal.InstanceMethods.beforeInitialize.bind(this)();$super(a,Object.extend(Object.clone(Control.Modal.defaultOptions),b||{}))},closeWithoutOverlay:function(){this.keepOverlay=true;this.close()}});Object.extend(Control.Modal,{defaultOptions:{overlayOpacity:0.5,closeOnClick:"overlay"},current:false,open:function(a,b){var c=new Control.Modal(a,b);c.open();return c},close:function(){if(Control.Modal.current){Control.Modal.current.close()}},InstanceMethods:{beforeInitialize:function(){Control.Overlay.load();this.observe("beforeOpen",Control.Modal.Observers.beforeOpen.bind(this));this.observe("afterOpen",Control.Modal.Observers.afterOpen.bind(this));this.observe("afterClose",Control.Modal.Observers.afterClose.bind(this))}},Observers:{beforeOpen:function(){Control.Window.windows.without(this).each(function(a){if(a.closeWithoutOverlay&&a.isOpen){a.closeWithoutOverlay()}else{a.close()}});if(!Control.Overlay.overlayFinishedOpening){Control.Overlay.observeOnce("afterShow",function(){Control.Overlay.overlayFinishedOpening=true;this.open()}.bind(this));Control.Overlay.show(this.options.overlayOpacity,this.options.fade?this.options.fadeDuration:false);throw $break}},afterOpen:function(){Control.Overlay.show(this.options.overlayOpacity);Control.Overlay.overlayFinishedOpening=true;Control.Modal.current=this},afterClose:function(){if(!this.keepOverlay){Control.Overlay.hide(this.options.fade?this.options.fadeDuration:false);Control.Overlay.overlayFinishedOpening=false}this.keepOverlay=false;Control.Modal.current=false}}});Control.LightBox=Class.create(Control.Window,{initialize:function($super,a,b){this.allImagesLoaded=false;if(b.modal){var b=Object.extend(Object.clone(Control.LightBox.defaultOptions),b||{});b=Object.extend(Object.clone(Control.Modal.defaultOptions),b);b=Control.Modal.InstanceMethods.beforeInitialize.bind(this)(b);$super(a,b)}else{$super(a,Object.extend(Object.clone(Control.LightBox.defaultOptions),b||{}))}this.hasRemoteContent=this.href&&!this.options.iframe;if(this.hasRemoteContent){this.observe("onRemoteContentLoaded",Control.LightBox.Observers.onRemoteContentLoaded.bind(this))}else{this.applyImageObservers()}this.observe("beforeOpen",Control.LightBox.Observers.beforeOpen.bind(this))},applyImageObservers:function(){var a=this.getImages();this.numberImagesToLoad=a.length;this.numberofImagesLoaded=0;a.each(function(b){b.observe("load",function(c){++this.numberofImagesLoaded;if(this.numberImagesToLoad==this.numberofImagesLoaded){this.allImagesLoaded=true;this.onAllImagesLoaded()}}.bind(this,b));b.hide()}.bind(this))},onAllImagesLoaded:function(){this.getImages().each(function(a){this.showImage(a)}.bind(this));if(this.hasRemoteContent){if(this.options.indicator){this.hideIndicator()}this.finishOpen()}else{this.open()}},getImages:function(){return this.container.select(Control.LightBox.imageSelector)},showImage:function(a){a.show()}});Object.extend(Control.LightBox,{imageSelector:"img",defaultOptions:{},Observers:{beforeOpen:function(){if(!this.hasRemoteContent&&!this.allImagesLoaded){throw $break}},onRemoteContentLoaded:function(){this.applyImageObservers();if(!this.allImagesLoaded){throw $break}}}});
