var Scriptaculous={Version:"1.8.2",require:function(a){document.write('<script type="text/javascript" src="'+a+'"><\/script>')
},REQUIRED_PROTOTYPE:"1.6.0.3",load:function(){function a(c){var d=c.replace(/_.*|\./g,"");
d=parseInt(d+"0".times(4-d.length));
return c.indexOf("_")>-1?d-1:d
}if((typeof Prototype=="undefined")||(typeof Element=="undefined")||(typeof Element.Methods=="undefined")||(a(Prototype.Version)<a(Scriptaculous.REQUIRED_PROTOTYPE))){throw ("script.aculo.us requires the Prototype JavaScript framework >= "+Scriptaculous.REQUIRED_PROTOTYPE)
}var b=/scriptaculous\.js(\?.*)?$/;
$$("head script[src]").findAll(function(c){return c.src.match(b)
}).each(function(d){var e=d.src.replace(b,""),c=d.src.match(/\?.*load=([a-z,]*)/);
(c?c[1]:"builder,effects,dragdrop,controls,slider,sound").split(",").each(function(f){Scriptaculous.require(e+f+".js")
})
})
}};
Scriptaculous.load();if(Object.isUndefined(Effect)){throw ("dragdrop.js requires including script.aculo.us' effects.js library")
}var Droppables={drops:[],remove:function(a){this.drops=this.drops.reject(function(b){return b.element==$(a)
})
},add:function(b){b=$(b);
var a=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});
if(a.containment){a._containers=[];
var c=a.containment;
if(Object.isArray(c)){c.each(function(d){a._containers.push($(d))
})
}else{a._containers.push($(c))
}}if(a.accept){a.accept=[a.accept].flatten()
}Element.makePositioned(b);
a.element=b;
this.drops.push(a)
},findDeepestChild:function(a){deepest=a[0];
for(i=1;
i<a.length;
++i){if(Element.isParent(a[i].element,deepest.element)){deepest=a[i]
}}return deepest
},isContained:function(b,a){var c;
if(a.tree){c=b.treeNode
}else{c=b.parentNode
}return a._containers.detect(function(d){return c==d
})
},isAffected:function(a,c,b){return((b.element!=c)&&((!b._containers)||this.isContained(c,b))&&((!b.accept)||(Element.classNames(c).detect(function(d){return b.accept.include(d)
})))&&Position.within(b.element,a[0],a[1]))
},deactivate:function(a){if(a.hoverclass){Element.removeClassName(a.element,a.hoverclass)
}this.last_active=null
},activate:function(a){if(a.hoverclass){Element.addClassName(a.element,a.hoverclass)
}this.last_active=a
},show:function(a,c){if(!this.drops.length){return
}var b,d=[];
this.drops.each(function(e){if(Droppables.isAffected(a,c,e)){d.push(e)
}});
if(d.length>0){b=Droppables.findDeepestChild(d)
}if(this.last_active&&this.last_active!=b){this.deactivate(this.last_active)
}if(b){Position.within(b.element,a[0],a[1]);
if(b.onHover){b.onHover(c,b.element,Position.overlap(b.overlap,b.element))
}if(b!=this.last_active){Droppables.activate(b)
}}},fire:function(b,a){if(!this.last_active){return
}Position.prepare();
if(this.isAffected([Event.pointerX(b),Event.pointerY(b)],a,this.last_active)){if(this.last_active.onDrop){this.last_active.onDrop(a,this.last_active.element,b);
return true
}}},reset:function(){if(this.last_active){this.deactivate(this.last_active)
}}};
var Draggables={drags:[],observers:[],register:function(a){if(this.drags.length==0){this.eventMouseUp=this.endDrag.bindAsEventListener(this);
this.eventMouseMove=this.updateDrag.bindAsEventListener(this);
this.eventKeypress=this.keyPress.bindAsEventListener(this);
Event.observe(document,"mouseup",this.eventMouseUp);
Event.observe(document,"mousemove",this.eventMouseMove);
Event.observe(document,"keypress",this.eventKeypress)
}this.drags.push(a)
},unregister:function(a){this.drags=this.drags.reject(function(b){return b==a
});
if(this.drags.length==0){Event.stopObserving(document,"mouseup",this.eventMouseUp);
Event.stopObserving(document,"mousemove",this.eventMouseMove);
Event.stopObserving(document,"keypress",this.eventKeypress)
}},activate:function(a){if(a.options.delay){this._timeout=setTimeout(function(){Draggables._timeout=null;
window.focus();
Draggables.activeDraggable=a
}.bind(this),a.options.delay)
}else{window.focus();
this.activeDraggable=a
}},deactivate:function(){this.activeDraggable=null
},updateDrag:function(a){if(!this.activeDraggable){return
}var b=[Event.pointerX(a),Event.pointerY(a)];
if(this._lastPointer&&(this._lastPointer.inspect()==b.inspect())){return
}this._lastPointer=b;
this.activeDraggable.updateDrag(a,b)
},endDrag:function(a){if(this._timeout){clearTimeout(this._timeout);
this._timeout=null
}if(!this.activeDraggable){return
}this._lastPointer=null;
this.activeDraggable.endDrag(a);
this.activeDraggable=null
},keyPress:function(a){if(this.activeDraggable){this.activeDraggable.keyPress(a)
}},addObserver:function(a){this.observers.push(a);
this._cacheObserverCallbacks()
},removeObserver:function(a){this.observers=this.observers.reject(function(b){return b.element==a
});
this._cacheObserverCallbacks()
},notify:function(b,a,c){if(this[b+"Count"]>0){this.observers.each(function(d){if(d[b]){d[b](b,a,c)
}})
}if(a.options[b]){a.options[b](a,c)
}},_cacheObserverCallbacks:function(){["onStart","onEnd","onDrag"].each(function(a){Draggables[a+"Count"]=Draggables.observers.select(function(b){return b[a]
}).length
})
}};
var Draggable=Class.create({initialize:function(b){var c={handle:false,reverteffect:function(f,e,d){var g=Math.sqrt(Math.abs(e^2)+Math.abs(d^2))*0.02;
new Effect.Move(f,{x:-d,y:-e,duration:g,queue:{scope:"_draggable",position:"end"}})
},endeffect:function(e){var d=Object.isNumber(e._opacity)?e._opacity:1;
new Effect.Opacity(e,{duration:0.2,from:0.7,to:d,queue:{scope:"_draggable",position:"end"},afterFinish:function(){Draggable._dragging[e]=false
}})
},zindex:1000,revert:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false,delay:0};
if(!arguments[1]||Object.isUndefined(arguments[1].endeffect)){Object.extend(c,{starteffect:function(d){d._opacity=Element.getOpacity(d);
Draggable._dragging[d]=true;
new Effect.Opacity(d,{duration:0.2,from:d._opacity,to:0.7})
}})
}var a=Object.extend(c,arguments[1]||{});
this.element=$(b);
if(a.handle&&Object.isString(a.handle)){this.handle=this.element.down("."+a.handle,0)
}if(!this.handle){this.handle=$(a.handle)
}if(!this.handle){this.handle=this.element
}if(a.scroll&&!a.scroll.scrollTo&&!a.scroll.outerHTML){a.scroll=$(a.scroll);
this._isScrollChild=Element.childOf(this.element,a.scroll)
}Element.makePositioned(this.element);
this.options=a;
this.dragging=false;
this.eventMouseDown=this.initDrag.bindAsEventListener(this);
Event.observe(this.handle,"mousedown",this.eventMouseDown);
Draggables.register(this)
},destroy:function(){Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);
Draggables.unregister(this)
},currentDelta:function(){return([parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")])
},initDrag:function(a){if(!Object.isUndefined(Draggable._dragging[this.element])&&Draggable._dragging[this.element]){return
}if(Event.isLeftClick(a)){var c=Event.element(a);
if((tag_name=c.tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){return
}var b=[Event.pointerX(a),Event.pointerY(a)];
var d=Position.cumulativeOffset(this.element);
this.offset=[0,1].map(function(e){return(b[e]-d[e])
});
Draggables.activate(this);
Event.stop(a)
}},startDrag:function(b){this.dragging=true;
if(!this.delta){this.delta=this.currentDelta()
}if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);
this.element.style.zIndex=this.options.zindex
}if(this.options.ghosting){this._clone=this.element.cloneNode(true);
this._originallyAbsolute=(this.element.getStyle("position")=="absolute");
if(!this._originallyAbsolute){Position.absolutize(this.element)
}this.element.parentNode.insertBefore(this._clone,this.element)
}if(this.options.scroll){if(this.options.scroll==window){var a=this._getWindowScroll(this.options.scroll);
this.originalScrollLeft=a.left;
this.originalScrollTop=a.top
}else{this.originalScrollLeft=this.options.scroll.scrollLeft;
this.originalScrollTop=this.options.scroll.scrollTop
}}Draggables.notify("onStart",this,b);
if(this.options.starteffect){this.options.starteffect(this.element)
}},updateDrag:function(event,pointer){if(!this.dragging){this.startDrag(event)
}if(!this.options.quiet){Position.prepare();
Droppables.show(pointer,this.element)
}Draggables.notify("onDrag",this,event);
this.draw(pointer);
if(this.options.change){this.options.change(this)
}if(this.options.scroll){this.stopScrolling();
var p;
if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){p=[left,top,left+width,top+height]
}}else{p=Position.page(this.options.scroll);
p[0]+=this.options.scroll.scrollLeft+Position.deltaX;
p[1]+=this.options.scroll.scrollTop+Position.deltaY;
p.push(p[0]+this.options.scroll.offsetWidth);
p.push(p[1]+this.options.scroll.offsetHeight)
}var speed=[0,0];
if(pointer[0]<(p[0]+this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[0]+this.options.scrollSensitivity)
}if(pointer[1]<(p[1]+this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[1]+this.options.scrollSensitivity)
}if(pointer[0]>(p[2]-this.options.scrollSensitivity)){speed[0]=pointer[0]-(p[2]-this.options.scrollSensitivity)
}if(pointer[1]>(p[3]-this.options.scrollSensitivity)){speed[1]=pointer[1]-(p[3]-this.options.scrollSensitivity)
}this.startScrolling(speed)
}if(Prototype.Browser.WebKit){window.scrollBy(0,0)
}Event.stop(event)
},finishDrag:function(b,f){this.dragging=false;
if(this.options.quiet){Position.prepare();
var e=[Event.pointerX(b),Event.pointerY(b)];
Droppables.show(e,this.element)
}if(this.options.ghosting){if(!this._originallyAbsolute){Position.relativize(this.element)
}delete this._originallyAbsolute;
Element.remove(this._clone);
this._clone=null
}var g=false;
if(f){g=Droppables.fire(b,this.element);
if(!g){g=false
}}if(g&&this.options.onDropped){this.options.onDropped(this.element)
}Draggables.notify("onEnd",this,b);
var a=this.options.revert;
if(a&&Object.isFunction(a)){a=a(this.element)
}var c=this.currentDelta();
if(a&&this.options.reverteffect){if(g==0||a!="failure"){this.options.reverteffect(this.element,c[1]-this.delta[1],c[0]-this.delta[0])
}}else{this.delta=c
}if(this.options.zindex){this.element.style.zIndex=this.originalZ
}if(this.options.endeffect){this.options.endeffect(this.element)
}Draggables.deactivate(this);
Droppables.reset()
},keyPress:function(a){if(a.keyCode!=Event.KEY_ESC){return
}this.finishDrag(a,false);
Event.stop(a)
},endDrag:function(a){if(!this.dragging){return
}this.stopScrolling();
this.finishDrag(a,true);
Event.stop(a)
},draw:function(a){var g=Position.cumulativeOffset(this.element);
if(this.options.ghosting){var c=Position.realOffset(this.element);
g[0]+=c[0]-Position.deltaX;
g[1]+=c[1]-Position.deltaY
}var f=this.currentDelta();
g[0]-=f[0];
g[1]-=f[1];
if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){g[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;
g[1]-=this.options.scroll.scrollTop-this.originalScrollTop
}var e=[0,1].map(function(d){return(a[d]-g[d]-this.offset[d])
}.bind(this));
if(this.options.snap){if(Object.isFunction(this.options.snap)){e=this.options.snap(e[0],e[1],this)
}else{if(Object.isArray(this.options.snap)){e=e.map(function(d,h){return(d/this.options.snap[h]).round()*this.options.snap[h]
}.bind(this))
}else{e=e.map(function(d){return(d/this.options.snap).round()*this.options.snap
}.bind(this))
}}}var b=this.element.style;
if((!this.options.constraint)||(this.options.constraint=="horizontal")){b.left=e[0]+"px"
}if((!this.options.constraint)||(this.options.constraint=="vertical")){b.top=e[1]+"px"
}if(b.visibility=="hidden"){b.visibility=""
}},stopScrolling:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);
this.scrollInterval=null;
Draggables._lastScrollPointer=null
}},startScrolling:function(a){if(!(a[0]||a[1])){return
}this.scrollSpeed=[a[0]*this.options.scrollSpeed,a[1]*this.options.scrollSpeed];
this.lastScrolled=new Date();
this.scrollInterval=setInterval(this.scroll.bind(this),10)
},scroll:function(){var current=new Date();
var delta=current-this.lastScrolled;
this.lastScrolled=current;
if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){if(this.scrollSpeed[0]||this.scrollSpeed[1]){var d=delta/1000;
this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1])
}}}else{this.options.scroll.scrollLeft+=this.scrollSpeed[0]*delta/1000;
this.options.scroll.scrollTop+=this.scrollSpeed[1]*delta/1000
}Position.prepare();
Droppables.show(Draggables._lastPointer,this.element);
Draggables.notify("onDrag",this);
if(this._isScrollChild){Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);
Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*delta/1000;
Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*delta/1000;
if(Draggables._lastScrollPointer[0]<0){Draggables._lastScrollPointer[0]=0
}if(Draggables._lastScrollPointer[1]<0){Draggables._lastScrollPointer[1]=0
}this.draw(Draggables._lastScrollPointer)
}if(this.options.change){this.options.change(this)
}},_getWindowScroll:function(w){var T,L,W,H;
with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;
L=documentElement.scrollLeft
}else{if(w.document.body){T=body.scrollTop;
L=body.scrollLeft
}}if(w.innerWidth){W=w.innerWidth;
H=w.innerHeight
}else{if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;
H=documentElement.clientHeight
}else{W=body.offsetWidth;
H=body.offsetHeight
}}}return{top:T,left:L,width:W,height:H}
}});
Draggable._dragging={};
var SortableObserver=Class.create({initialize:function(b,a){this.element=$(b);
this.observer=a;
this.lastValue=Sortable.serialize(this.element)
},onStart:function(){this.lastValue=Sortable.serialize(this.element)
},onEnd:function(){Sortable.unmark();
if(this.lastValue!=Sortable.serialize(this.element)){this.observer(this.element)
}}});
var Sortable={SERIALIZE_RULE:/^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,sortables:{},_findRootElement:function(a){while(a.tagName.toUpperCase()!="BODY"){if(a.id&&Sortable.sortables[a.id]){return a
}a=a.parentNode
}},options:function(a){a=Sortable._findRootElement($(a));
if(!a){return
}return Sortable.sortables[a.id]
},destroy:function(a){a=$(a);
var b=Sortable.sortables[a.id];
if(b){Draggables.removeObserver(b.element);
b.droppables.each(function(c){Droppables.remove(c)
});
b.draggables.invoke("destroy");
delete Sortable.sortables[b.element.id]
}},create:function(c){c=$(c);
var b=Object.extend({element:c,tag:"li",dropOnEmpty:false,tree:false,treeTag:"ul",overlap:"vertical",constraint:"vertical",containment:c,handle:false,only:false,delay:0,hoverclass:null,ghosting:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,format:this.SERIALIZE_RULE,elements:false,handles:false,onChange:Prototype.emptyFunction,onUpdate:Prototype.emptyFunction},arguments[1]||{});
this.destroy(c);
var a={revert:true,quiet:b.quiet,scroll:b.scroll,scrollSpeed:b.scrollSpeed,scrollSensitivity:b.scrollSensitivity,delay:b.delay,ghosting:b.ghosting,constraint:b.constraint,handle:b.handle};
if(b.starteffect){a.starteffect=b.starteffect
}if(b.reverteffect){a.reverteffect=b.reverteffect
}else{if(b.ghosting){a.reverteffect=function(f){f.style.top=0;
f.style.left=0
}
}}if(b.endeffect){a.endeffect=b.endeffect
}if(b.zindex){a.zindex=b.zindex
}var d={overlap:b.overlap,containment:b.containment,tree:b.tree,hoverclass:b.hoverclass,onHover:Sortable.onHover};
var e={onHover:Sortable.onEmptyHover,overlap:b.overlap,containment:b.containment,hoverclass:b.hoverclass};
Element.cleanWhitespace(c);
b.draggables=[];
b.droppables=[];
if(b.dropOnEmpty||b.tree){Droppables.add(c,e);
b.droppables.push(c)
}(b.elements||this.findElements(c,b)||[]).each(function(h,f){var g=b.handles?$(b.handles[f]):(b.handle?$(h).select("."+b.handle)[0]:h);
b.draggables.push(new Draggable(h,Object.extend(a,{handle:g})));
Droppables.add(h,d);
if(b.tree){h.treeNode=c
}b.droppables.push(h)
});
if(b.tree){(Sortable.findTreeElements(c,b)||[]).each(function(f){Droppables.add(f,e);
f.treeNode=c;
b.droppables.push(f)
})
}this.sortables[c.id]=b;
Draggables.addObserver(new SortableObserver(c,b.onUpdate))
},findElements:function(b,a){return Element.findChildren(b,a.only,a.tree?true:false,a.tag)
},findTreeElements:function(b,a){return Element.findChildren(b,a.only,a.tree?true:false,a.treeTag)
},onHover:function(e,d,a){if(Element.isParent(d,e)){return
}if(a>0.33&&a<0.66&&Sortable.options(d).tree){return
}else{if(a>0.5){Sortable.mark(d,"before");
if(d.previousSibling!=e){var b=e.parentNode;
e.style.visibility="hidden";
d.parentNode.insertBefore(e,d);
if(d.parentNode!=b){Sortable.options(b).onChange(e)
}Sortable.options(d.parentNode).onChange(e)
}}else{Sortable.mark(d,"after");
var c=d.nextSibling||null;
if(c!=e){var b=e.parentNode;
e.style.visibility="hidden";
d.parentNode.insertBefore(e,c);
if(d.parentNode!=b){Sortable.options(b).onChange(e)
}Sortable.options(d.parentNode).onChange(e)
}}}},onEmptyHover:function(e,g,h){var j=e.parentNode;
var a=Sortable.options(g);
if(!Element.isParent(g,e)){var f;
var c=Sortable.findElements(g,{tag:a.tag,only:a.only});
var b=null;
if(c){var d=Element.offsetSize(g,a.overlap)*(1-h);
for(f=0;
f<c.length;
f+=1){if(d-Element.offsetSize(c[f],a.overlap)>=0){d-=Element.offsetSize(c[f],a.overlap)
}else{if(d-(Element.offsetSize(c[f],a.overlap)/2)>=0){b=f+1<c.length?c[f+1]:null;
break
}else{b=c[f];
break
}}}}g.insertBefore(e,b);
Sortable.options(j).onChange(e);
a.onChange(e)
}},unmark:function(){if(Sortable._marker){Sortable._marker.hide()
}},mark:function(b,a){var d=Sortable.options(b.parentNode);
if(d&&!d.ghosting){return
}if(!Sortable._marker){Sortable._marker=($("dropmarker")||Element.extend(document.createElement("DIV"))).hide().addClassName("dropmarker").setStyle({position:"absolute"});
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker)
}var c=Position.cumulativeOffset(b);
Sortable._marker.setStyle({left:c[0]+"px",top:c[1]+"px"});
if(a=="after"){if(d.overlap=="horizontal"){Sortable._marker.setStyle({left:(c[0]+b.clientWidth)+"px"})
}else{Sortable._marker.setStyle({top:(c[1]+b.clientHeight)+"px"})
}}Sortable._marker.show()
},_tree:function(e,b,f){var d=Sortable.findElements(e,b)||[];
for(var c=0;
c<d.length;
++c){var a=d[c].id.match(b.format);
if(!a){continue
}var g={id:encodeURIComponent(a?a[1]:null),element:e,parent:f,children:[],position:f.children.length,container:$(d[c]).down(b.treeTag)};
if(g.container){this._tree(g.container,b,g)
}f.children.push(g)
}return f
},tree:function(d){d=$(d);
var c=this.options(d);
var b=Object.extend({tag:c.tag,treeTag:c.treeTag,only:c.only,name:d.id,format:c.format},arguments[1]||{});
var a={id:null,parent:null,children:[],container:d,position:0};
return Sortable._tree(d,b,a)
},_constructIndex:function(b){var a="";
do{if(b.id){a="["+b.position+"]"+a
}}while((b=b.parent)!=null);
return a
},sequence:function(b){b=$(b);
var a=Object.extend(this.options(b),arguments[1]||{});
return $(this.findElements(b,a)||[]).map(function(c){return c.id.match(a.format)?c.id.match(a.format)[1]:""
})
},setSequence:function(b,c){b=$(b);
var a=Object.extend(this.options(b),arguments[2]||{});
var d={};
this.findElements(b,a).each(function(e){if(e.id.match(a.format)){d[e.id.match(a.format)[1]]=[e,e.parentNode]
}e.parentNode.removeChild(e)
});
c.each(function(e){var f=d[e];
if(f){f[1].appendChild(f[0]);
delete d[e]
}})
},serialize:function(c){c=$(c);
var b=Object.extend(Sortable.options(c),arguments[1]||{});
var a=encodeURIComponent((arguments[1]&&arguments[1].name)?arguments[1].name:c.id);
if(b.tree){return Sortable.tree(c,arguments[1]).children.map(function(d){return[a+Sortable._constructIndex(d)+"[id]="+encodeURIComponent(d.id)].concat(d.children.map(arguments.callee))
}).flatten().join("&")
}else{return Sortable.sequence(c,arguments[1]).map(function(d){return a+"[]="+encodeURIComponent(d)
}).join("&")
}}};
Element.isParent=function(b,a){if(!b.parentNode||b==a){return false
}if(b.parentNode==a){return true
}return Element.isParent(b.parentNode,a)
};
Element.findChildren=function(d,b,a,c){if(!d.hasChildNodes()){return null
}c=c.toUpperCase();
if(b){b=[b].flatten()
}var e=[];
$A(d.childNodes).each(function(g){if(g.tagName&&g.tagName.toUpperCase()==c&&(!b||(Element.classNames(g).detect(function(h){return b.include(h)
})))){e.push(g)
}if(a){var f=Element.findChildren(g,b,a,c);
if(f){e.push(f)
}}});
return(e.length>0?e.flatten():[])
};
Element.offsetSize=function(a,b){return a["offset"+((b=="vertical"||b=="height")?"Height":"Width")]
};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._observers[g][c],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(g){if(a.notify){var b=$A(arguments).slice(1);
b.unshift(this);
b.unshift(g);
a.notify.apply(a,b)
}this._objectEventSetup(g);
var b=$A(arguments).slice(1);
var d=[];
try{if(this.options&&this.options[g]&&typeof(this.options[g])=="function"){d.push(this.options[g].apply(this,b)||null)
}for(var c=0;
c<this._observers[g].length;
++c){d.push(this._observers[g][c].apply(this._observers[g][c],b)||null)
}}catch(f){if(f==$break){return false
}else{throw f
}}return d
}
}}};
Element.addMethods({observeOnce:function(c,d,b){var a=function(){b.apply(this,arguments);
Element.stopObserving(c,d,a)
};
Element.observe(c,d,a)
}});
Object.extend(Event,(function(){var b=Event.cache;
function c(j){if(j._prototypeEventID){return j._prototypeEventID[0]
}arguments.callee.id=arguments.callee.id||1;
return j._prototypeEventID=[++arguments.callee.id]
}function g(j){if(j&&j.include(":")){return"dataavailable"
}if(!Prototype.Browser.IE){j={mouseenter:"mouseover",mouseleave:"mouseout"}[j]||j
}return j
}function a(j){return b[j]=b[j]||{}
}function f(l,j){var k=a(l);
return k[j]=k[j]||[]
}function h(k,j,l){var o=c(k);
var n=f(o,j);
if(n.pluck("handler").include(l)){return false
}var m=function(p){if(!Event||!Event.extend||(p.eventName&&p.eventName!=j)){return false
}Event.extend(p);
l.call(k,p)
};
if(!(Prototype.Browser.IE)&&["mouseenter","mouseleave"].include(j)){m=m.wrap(function(r,q){var p=q.relatedTarget;
var s=q.currentTarget;
if(p&&p.nodeType==Node.TEXT_NODE){p=p.parentNode
}if(p&&p!=s&&!p.descendantOf(s)){return r(q)
}})
}m.handler=l;
n.push(m);
return m
}function i(m,j,k){var l=f(m,j);
return l.find(function(n){return n.handler==k
})
}function d(m,j,k){var l=a(m);
if(!l[j]){return false
}l[j]=l[j].without(i(m,j,k))
}function e(){for(var k in b){for(var j in b[k]){b[k][j]=null
}}}if(window.attachEvent){window.attachEvent("onunload",e)
}return{observe:function(l,j,m){l=$(l);
var k=g(j);
var n=h(l,j,m);
if(!n){return l
}if(l.addEventListener){l.addEventListener(k,n,false)
}else{l.attachEvent("on"+k,n)
}return l
},stopObserving:function(l,j,m){l=$(l);
var o=c(l),k=g(j);
if(!m&&j){f(o,j).each(function(p){l.stopObserving(j,p.handler)
});
return l
}else{if(!j){Object.keys(a(o)).each(function(p){if(l.stopObserving){l.stopObserving(p)
}});
return l
}}var n=i(o,j,m);
if(!n){return l
}if(l.removeEventListener){l.removeEventListener(k,n,false)
}else{l.detachEvent("on"+k,n)
}d(o,j,m);
return l
},fire:function(l,k,j){l=$(l);
if(l==document&&document.createEvent&&!l.dispatchEvent){l=document.documentElement
}var m;
if(document.createEvent){m=document.createEvent("HTMLEvents");
m.initEvent("dataavailable",true,true)
}else{m=document.createEventObject();
m.eventType="ondataavailable"
}m.eventName=k;
m.memo=j||{};
if(document.createEvent){l.dispatchEvent(m)
}else{l.fireEvent(m.eventType,m)
}return Event.extend(m)
}}
})());
Object.extend(Event,Event.Methods);
Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});
Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize()});
(function(){function a(c){var d;
if(c.wheelDelta){d=c.wheelDelta/120
}else{if(c.detail){d=-c.detail/3
}}if(!d){return
}var b=Event.element(c).fire("mouse:wheel",{delta:d});
if(b.stopped){Event.stop(c);
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(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.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:"fixed",top:0,left:0,width:"100%",height:"100%",zIndex:9998},ieStyles:{position:"absolute",top:0,left:0,zIndex:9998},effects:{fade:false,appear:false},load:function(){if(Control.Overlay.loaded){return false
}Control.Overlay.loaded=true;
Control.Overlay.container=new Element("div",{id:Control.Overlay.id});
$(document.body).insert(Control.Overlay.container);
if(Prototype.Browser.IE){Control.Overlay.container.setStyle(Control.Overlay.ieStyles);
Event.observe(window,"scroll",Control.Overlay.positionOverlay);
Event.observe(window,"resize",Control.Overlay.positionOverlay);
Control.Overlay.observe("beforeShow",Control.Overlay.positionOverlay)
}else{Control.Overlay.container.setStyle(Control.Overlay.styles)
}Control.Overlay.iFrameShim=new IframeShim();
Control.Overlay.iFrameShim.hide();
Event.observe(window,"resize",Control.Overlay.positionIFrameShim);
Control.Overlay.container.hide();
return true
},unload:function(){if(!Control.Overlay.loaded){return false
}Event.stopObserving(window,"resize",Control.Overlay.positionOverlay);
Control.Overlay.stopObserving("beforeShow",Control.Overlay.positionOverlay);
Event.stopObserving(window,"resize",Control.Overlay.positionIFrameShim);
Control.Overlay.iFrameShim.destroy();
Control.Overlay.container.remove();
Control.Overlay.loaded=false;
return true
},show:function(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)
}},positionOverlay:function(){Control.Overlay.container.setStyle({width:document.body.clientWidth+"px",height:document.body.clientHeight+"px"})
}};
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||{}))
}});
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.overlayFinishedOpening=false;
this.observe("beforeOpen",Control.Modal.Observers.beforeOpen.bind(this));
this.observe("afterOpen",Control.Modal.Observers.afterOpen.bind(this));
this.observe("afterClose",Control.Modal.Observers.afterClose.bind(this))
}},Observers:{beforeOpen:function(){if(!this.overlayFinishedOpening){Control.Overlay.observeOnce("afterShow",function(){this.overlayFinishedOpening=true;
this.open()
}.bind(this));
Control.Overlay.show(this.options.overlayOpacity,this.options.fade?this.options.fadeDuration:false);
throw $break
}else{Control.Window.windows.without(this).invoke("close")
}},afterOpen:function(){Control.Modal.current=this
},afterClose:function(){Control.Overlay.hide(this.options.fade?this.options.fadeDuration:false);
Control.Modal.current=false;
this.overlayFinishedOpening=false
}}});
Control.LightBox=Class.create(Control.Window,{initialize:function($super,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
}}}});
