var isIE=Browser.Engine.trident;var isIE6=false;try{isIE6=false
}catch(e){isIE6=false}Element.Events.click={base:"click",onAdd:function(){if(!isIE&&this.getStyle&&this.getStyle("cursor")!="pointer"&&this.getStyle("cursor")!="text"){this.store("original-cursor",this.getStyle("cursor"));
this.setStyle("cursor","pointer")}},onRemove:function(){if(!isIE&&this.setStyle){this.setStyle("cursor",this.retrieve("original-cursor",this.getStyle("cursor")))}}};var ToolBox=new Class({initialize:function(){this.myTimer=new GlobalTimer();this.onLoadFunctions=new Array();
this.onLoadVars=new Array();this.dynContentCache=new Object();this.objectStore=new Object();this.jsonRequests=new Object()},getTimerObject:function(){return this.myTimer},getContentCache:function(){return this.dynContentCache},getObjectStore:function(){return this.objectStore
},registerOnLoadFunc:function(a,b){this.onLoadFunctions.push(a);this.onLoadVars.push(b)},execOnLoadFuncs:function(){for(var a=0;a<this.onLoadFunctions.length;a++){this.onLoadFunctions[a].run(this.onLoadVars[a])}}});var GlobalTimer=new Class({initialize:function(){this.numTimers=0;
this.timers=new Object()},addTimer:function(b,a){this.timers[a]=b;this.numTimers++},clearTimer:function(a){this.timers[a]=$clear(this.timers[a]);this.numTimers--}});var TopScroller=new Class({initialize:function(){this.topScrollBox=new Element("a",{id:"topScrollBox",text:"Top of the page",href:"#top",styles:{position:"fixed",bottom:5,right:5,zIndex:300,padding:"7px 7px 7px 20px"}});
if(isIE6){this.topScrollBox.pin()}$(document.body).grab(this.topScrollBox);this.topScrollBox.fade("hide");window.addEvent("scroll",function(a){$("topScrollBox").fade((document.body.getScroll().y>200)?"in":"out")})},toElement:function(){return this.topScrollBox
}});var ScrollSlider=new Class({Implements:[Options],options:{horizontal:false,ignoreMouse:false,smoothScroll:false,offsets:{x:0,y:0}},toElement:function(){return this.scrollbar},initialize:function(b,a){if(!$defined(b)){return}this.setOptions(a);this.steps=(this.options.horizontal?(b.getScrollSize().x-b.getSize().x):(b.getScrollSize().y-b.getSize().y));
if(this.steps<=0){return}this.content=b;this.scrollbar=new Element("div",{"class":"scroll"+(this.options.horizontal?"Horizontal":"Vertical")});this.handle=new Element("span",{text:"Scroll me!"});this.scrollbar.grab(this.handle);this.content.getParent().grab(this.scrollbar);
this.enableSlider()},destroy:function(){if(this.scrollbar){this.scrollbar.destroy()}this.scrollbar=null},enableSlider:function(){this.scrollbar.setStyle("height",this.content.getStyle("height").toInt()-5-this.options.offsets.y);this.scrollbar.position({relativeTo:this.content,position:{x:"right",y:"top"},edge:{x:"center",y:"top"},offset:this.options.offsets});
this.slider=new Slider(this.scrollbar,this.handle,{steps:this.steps,mode:(this.options.horizontal?"horizontal":"vertical"),onChange:function(b){var a=(this.options.horizontal?b:0);var c=(this.options.horizontal?0:b);this.content.scrollTo(a,c)}.bindWithEvent(this)}).set(0);
if(!this.options.ignoreMouse){$$(this.content,this.scrollbar).addEvent("mousewheel",function(b){b.stop();var a=this.slider.step-b.wheel*30;this.slider.set(a)}.bindWithEvent(this))}$(document.body).addEvent("mouseleave",function(){this.slider.drag.stop()
}.bindWithEvent(this))},getDimensions:function(){if(this.scrollbar){return this.scrollbar.getSize()}else{return{x:0,y:0}}}});var NoteBox=new Class({Implements:[Options],options:{skinType:"dark",instanceName:"nB"+new Date().getTime(),relativeTo:document.body,position:{x:"center",y:"center"},edge:false,offset:{x:0,y:0},showPointer:false,showCloser:false,isResizable:false,isDraggable:false,isScrollable:false,animate:false},toElement:function(){return this.theElement
},initialize:function(a){this.setOptions(a);this.timer=new GlobalTimer();this.theElement=new Element("div",{"class":"noteBox",styles:{position:"absolute",top:0,left:0}}).grab(new Element("span",{"class":"divot"}));this.theElement.adopt(new Element("h2").appendText("Note Title here"),new Element("a",{events:{click:function(b){this.fade("out")
}.bindWithEvent(this)},"class":"closer"}),new Element("a",{"class":"resizer"}),new Element("p",{text:"Note Text here",load:{onComplete:function(b){this.makeScrollable()}.bindWithEvent(this)}}));$(document.body).grab(this.theElement);this.theElement.fade("hide");
if(this.options.skinType!="user"){this.setStyle()}this.setPosition();document.addEvent("keydown",this.onKeyEvent.bind(this))},setStyle:function(){if(this.options.skinType.test("dark","i")){var f="#333";var c="#FFF";var b="1px solid #FAFAFA";var a="1px solid #777"
}else{var f="#FAFAFA";var c="#000";var b="1px solid #333";var a="1px solid #333"}var d=(this.options.skinType.test("border","i")>=0)?true:false;this.theElement.setStyles({background:f,color:c,border:(d?a:"0")});this.theElement.getElement("span").setStyles({background:"url(/assets/img/"+this.options.skinType+(d?"_divotB.png":"_divot.png")+") no-repeat top center"});
this.theElement.getElement("h2").setStyles({"border-bottom":b,color:c});this.theElement.getElement("a.closer").setStyles({background:"url(/assets/img/"+this.options.skinType+"_x.png) no-repeat top left"});this.theElement.getElement("a.resizer").setStyles({background:"url(/assets/img/"+this.options.skinType+"_resizer.png) no-repeat top left"});
this.theElement.getElement("p").addClass(this.options.skinType)},setText:function(a,b){if(typeof(a)=="object"){this.theElement.getElement("p").empty().grab(a)}else{if(b||isIE6){this.theElement.getElement("p").set("html",a)}else{this.theElement.getElement("p").set("text",a)
}}},setTitle:function(a,b){this.theElement.getElement("h2").setStyles({display:"block"});if(b||isIE6){this.theElement.getElement("h2").set("html",a)}else{this.theElement.getElement("h2").set("text",a)}},removeText:function(a){this.theElement.getElement("p").set("text","")
},removeTitle:function(a){this.theElement.getElement("h2").setStyle("display","none")},setDimension:function(c){var b=($defined(c.width)?c.width:this.theElement.getStyle("width"));var a=($defined(c.height)?c.height:this.theElement.getStyle("height"));
if(this.options.edge.x=="left"){var f=this.theElement.getStyle("left")}else{if(this.options.edge.x=="right"){var f=this.theElement.getStyle("left")-((this.theElement.getStyle("width")-b))}else{var f=this.theElement.getStyle("left")-((this.theElement.getStyle("width")-b)/2)
}}f=(f<0)?0:f;if(this.options.edge.y=="top"){var d=this.theElement.getStyle("top")}else{if(this.options.edge.y=="bottom"){var d=this.theElement.getStyle("top")-((this.theElement.getStyle("height")-a))}else{var d=this.theElement.getStyle("top")-((this.theElement.getStyle("height")-a)/2)
}}d=(d<0)?0:d;if(this.options.animate){this.theElement.morph({width:b,height:a,top:d,left:f})}else{this.theElement.setStyles({width:b,height:a,top:d,left:f})}this.theElement.getElement("p").setStyle("height",a-35);this.makeScrollable()},makeScrollable:function(){if(this.options.isScrollable){if(this.scroller){this.scroller.destroy();
this.scroller=null}this.scroller=new ScrollSlider(this.theElement.getElement("p"),{horizontal:false,ignoreMouse:false,offsets:{x:-5,y:10}});if(this.scroller.toElement()){this.theElement.getElement("p").setStyle("paddingRight",this.scroller.getDimensions().x-5)
}}},setPosition:function(d,b,f,g){this.options.relativeTo=($defined(d)?d:this.options.relativeTo);this.options.position=($defined(b)?b:this.options.position);this.options.edge=($defined(f)?f:this.options.edge);this.options.offset=($defined(g)?g:this.options.offset);
var a=function(h){if($type(h)!="string"){return h}h=h.toLowerCase();var i={};if(h.test("left")){i.x="left"}else{if(h.test("right")){i.x="right"}else{i.x="center"}}if(h.test("upper")||h.test("top")){i.y="top"}else{if(h.test("bottom")){i.y="bottom"}else{i.y="center"
}}return i};this.options.position=a(this.options.position);this.options.edge=a(this.options.edge);if(!this.options.edge){if(this.options.position.x=="center"&&this.options.position.y=="center"){this.options.edge={x:"center",y:"center"}}else{this.options.edge={x:"left",y:"top"}
}}if(this.options.edge.x=="left"||this.options.edge.x=="right"){var c={width:11,height:22,"background-position":this.options.edge.y+" "+this.options.edge.x}}else{var c={width:22,height:11,"background-position":this.options.edge.y+" "+this.options.edge.x}
}this.theElement.getElement("span").setStyles(c);this.theElement.getElement("a.closer").fade((this.options.showCloser?"show":"hide"));if(this.options.isDraggable){this.theElement.makeDraggable({handle:this.theElement.getElement("h2"),snap:5,precalculate:true,onStart:function(h){h.getElement("h2").setStyle("cursor","move");
h.fade(0.5)},onComplete:function(h){h.getElement("h2").setStyle("cursor","default");h.fade(1)}})}if(this.options.isResizable){this.theElement.makeResizable({handle:this.theElement.getElement("a.resizer"),limit:{x:[this.theElement.getSize().x,(window.getSize().x-50)],y:[this.theElement.getSize().y,(window.getSize().y-50)]},onStart:function(h){h.setStyle("opacity",h.fade(0.8))
},onComplete:function(h){h.setStyle("opacity",h.fade(1))}});this.theElement.getElement("a.resizer").setStyle("cursor","nw-resize");this.theElement.getElement("a.resizer").fade("show");this.theElement.setStyle("padding-bottom: 20px;")}else{this.theElement.getElement("a.resizer").fade("hide");
this.theElement.setStyle("padding-bottom: 6px;")}this.theElement.position({relativeTo:this.options.relativeTo,position:this.options.position,edge:this.options.edge,offset:this.options.offset});if(this.options.showPointer){this.theElement.getElement("span").fade("show");
this.theElement.getElement("span").position({relativeTo:this.theElement,position:this.options.edge,edge:this.options.position,ignoreMargins:true,allowNegative:true,offset:{x:((this.options.edge.x=="right")?-2:0),y:((this.options.edge.y=="top")?0:((this.options.edge.y=="bottom")?-2:-1))}})
}else{this.theElement.getElement("span").fade("hide")}},fade:function(d,b,c){if(d=='out')darkAlpha.hide();if($defined(this.timer[this.instanceName])){this.timer.clearTimer(this.instanceName)}b=($defined(b)?b:false);c=($defined(c)?c:500);if(b){this.timer.clearTimer(this.instanceName);
var a=function(){this.theElement.fade(b)}.bind(this);this.timer.addTimer(a.delay(c),this.instanceName)}this.theElement.fade(d)},onKeyEvent:function(a){if(this.theElement.getStyle("visibility")!="hidden"){switch(a.key){case"esc":this.fade("out")}a.stop()
}}});var FormMagic=new Class({Implements:[Options],options:{fancify:false,checkPreSubmit:true,notifications:{display:true,fade:true,skinType:"dark",position:"bottom",showTitle:false},defaults:{}},toElement:function(){return this.myFormElement},initialize:function(b,a){if(!$defined(b)||!$defined(b.getElement("input[type=submit]"))){return false
}this.setOptions(a);this.myFormElement=b;this.myFormElement.grab(new Element("input",{type:"hidden",name:this.myFormElement.getElement("input[type=submit]").get("name"),value:this.myFormElement.getElement("input[type=submit]").get("value")}));this.myTextInputs=b.getElements("input[type=text]").combine(b.getElements("input[type=password]"));
this.myTextInputs.each(function(d){if(d.hasClass("toggleEmpty")){d.store("defaultValue",d.get("value"));d.addEvents({focus:function(f){if(this.get("value")==this.retrieve("defaultValue")){this.set("value","")}},blur:function(f){if(this.get("value")==""){this.set("value",this.retrieve("defaultValue"))
}}})}var c=this.options.defaults[d.get("name")];if(d.hasClass("ignore")){d.store("ignore",true)}else{if($defined(c)){d.store("defaultValue",c)}else{if(d.hasClass("checkEmpty")){d.store("defaultValue","")}}}}.bind(this));this.myNoteBox=new NoteBox({skinType:this.options.notifications.skinType,showPointer:true});
if(this.options.checkPreSubmit){this.enableFormCheck()}if(this.options.fancify){this.fancify()}this.fixIEbugs()},enableFormCheck:function(){this.myFormElement.addEvent("submit",this.checkFormFields.bindWithEvent(this))},fixIEbugs:function(){if(isIE){if(this.myFormElement.getElement("input[type=submit]").getStyle("text-indent").toInt()<0){this.myFormElement.getElement("input[type=submit]").set("value","")
}this.myTextInputs.filter("input[type=password]").setStyle("font-family","tahoma, verdana, arial, helvetica, sans-serif")}},checkFormFields:function(d){d.stop();switch(this.options.notifications.position){case"top":var a="top";var b="bottom";var c={x:0,y:-10};
break;case"bottom":var a="bottom";var b="top";var c={x:0,y:10};break;case"left":var a="left";var b="right";var c={x:-13,y:0};break;case"right":var a="right";var b="left";var c={x:13,y:0};break}this.myFormElement.store("isClean",true);this.myTextInputs.each(function(g){if(g.retrieve("ignore")||!$defined(g.retrieve("defaultValue"))){return
}if(this.myFormElement.retrieve("isClean")){if(g.get("value")==g.retrieve("defaultValue")||g.get("value").clean()==""){var f=this.myFormElement.getElement("label[for="+g.get("name")+"]");if(f!=null&&this.options.showTitle){this.myNoteBox.setTitle(f.get("text"))
}else{this.myNoteBox.removeTitle()}this.myNoteBox.setText($("fieldCheck").get("text"));this.myNoteBox.setDimension({width:((this.options.notifications.position=="top"||this.options.notifications.position=="bottom")?g.getSize().x:150)});this.myNoteBox.setPosition(g,a,b,c);
this.myFormElement.store("isClean",false)}}}.bind(this));if(this.myFormElement.retrieve("isClean")){this.myFormElement.submit()}else{this.myNoteBox.fade("in","out",2000);this.myFormElement.set("isClean",true)}}});

