var pageObject,_pageReady,_pageReadyEvents;_pageReady=false;_pageReadyEvents=[];window.addEvent("domready",function(){_pageReady=true;if(_pageReadyEvents.length>0){_pageReadyEvents.each(function(A){A()})}});Page=new Class({queueOnReady:function(A){if(_pageReady){A()}else{_pageReadyEvents.push(A)}},initialize:function(){this.queueOnReady(function(){this.DecorateElement($("page"),128,{center:false,plan:function(B,A){this.left=(B.right-231);this.top=(B.top+282);this.width=215;this.height=155},header:function(B,A){this.left=B.left;this.top=B.top;this.width=940;this.height=285},image:function(B,A){this.left=(B.left+27);this.top=(B.top+60);this.width=896;this.height=217},shine:function(B,A){this.left=(B.left+24);this.top=(B.top+280);this.width=(B.width-40);this.height=(B.height-327)},inner:function(B,A){this.left=(B.left+24);this.top=(B.top+280);this.width=(B.width-40);this.height=(B.height-327)}});this.ImageMenu($("menu"));this.ParseHeaders($("page"));this.ParseFormControls($("page"));this.ParseRepeater($$("#orderAwaitingSketches dl.initial")[0]);this.ParseRepeater($$("#orderPreliminaryPlan dl.initial")[0]);this.ParsePrintAnchors($("page"))}.bind(this))},InformationBar:function(A,I,F,G){if(!_pageReady){this.queueOnReady(this.InformationBar.bind(this,[A,I,F,G]));return false}var B,J,D,E,C,H;B=$("information-bar");if(!B){B=new Element("div",{id:"information-bar"});J=new Element("span",{"class":"message"});J.inject(B);B.inject(document.body);if(Browser.Engine.trident&&Browser.Engine.version==4){B.setStyle("top",(document.body.scrollTop||document.documentElement.scrollTop));window.addEvent("scroll",function(){this.setStyle("top",(document.body.scrollTop||document.documentElement.scrollTop))}.bind(B))}D=new Fx.Tween(B,"margin-top",{duration:350,transition:Fx.Transitions.Sine.easeInOut,onCancel:function(){if(this.to>0&&this.to<-B.getSize().y){B.store("completeFn",null)}},onComplete:function(){var K;barFxCompleteFn=B.retrieve("completeFn");if(typeof (barFxCompleteFn)=="function"){barFxCompleteFn();B.store("completeFn",null)}}});D.set(-B.getSize().y);B.store("fx",D);B.addEvent("selectstart",function(K){K.stop();return false}.bindWithEvent(B));B.addEvent("mouseenter",function(){this.retrieve("fx").cancel().start(0)}.bind(B));B.addEvent("mouseleave",function(){if(!this.retrieve("isSticky")){this.retrieve("fx").cancel().start(-this.getSize().y)}}.bind(B))}else{J=B.getElement(".message");D=B.retrieve("fx")}H=function(){D.cancel().start(-B.getSize().y)};E=function(K){J.empty();new Element("span",{html:I}).inject(J);if(!!K){new Element("span",{"class":"close",title:"Close message",events:{click:function(){B.store("completeFn",J.empty.bind(J));H()},mousedown:function(){this.addClass("close-down")},mouseup:function(){this.removeClass("close-down")},mouseenter:function(){this.addClass("close-hover")},mouseleave:function(){this.removeClass("close-hover").removeClass("close-down")}}}).inject(J)}};C=function(K){B.store("isSticky",(!A&&!G));if(J.firstChild!==null&&J.get("text")!=I){B.store("completeFn",function(){J.empty();C((K||false))});H()}else{E((K||false));B.set("class",("information-bar"+(!!F?("-"+F):"")));D.cancel().start(0)}};if(!!A){A.addEvent("mouseenter",C.bind(null,[false]));A.addEvent("mouseleave",H)}else{if(!!G){C(false);H.delay(G)}else{C(true)}}return true},ImageMenu:function(B,C){var A;B=$(B);if(B===null){return false}A=(B.get("id")||B.get("class").split(" ")[0]);if(!C){C=("includes/templates/plansmadeeasy/images/background_{id}_{text}.png")}B.getElements("li").each(function(G){var D,H,F,E,I;H=G.getElement("a");if(!H){return false}F=H.getElement("span");if(!F){return false}spanText=F.get("text").trim().toLowerCase().replace(/\W+/g,"_");E=C.replace("{id}",A).replace("{text}",spanText);I={};I.backgroundColor="transparent";I.backgroundImage=("url("+E+")");I.backgroundRepeat="no-repeat";if(Browser.Engine.trident&&Browser.Engine.version==4){if("static"==H.getComputedStyle("position")){H.setStyle("position","relative")}I.filter=('progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+E+'", sizingMethod="scale")');I.backgroundImage="none"}F.setStyles(I);return true});return true},ParseHeaders:function(A){A=$(A);if(A===null){return false}A.getElements("h1, h2, h3, h4, h5, h6").each(function(B){if(!!B.get("id")){return false}B.set("id",B.get("text").trim().toLowerCase().replace(/\W+/g,"-"));return true});return true},ParseFormControls:function(A){A=$(A);if(A===null){return false}A.getElements("input").each(function(B){var C;C=B.get("type").toLowerCase();B.addClass(C);if(["submit","reset","button"].contains(C)){B.addClass(C+"-"+B.get("value").trim().toLowerCase().replace(/\W+/g,"-"))}else{if("file"==C){this.ParseFileUpload(B)}}return true}.bind(this));return true},ParseFileUpload:function(B){var A,C,D;B=$(B);if(B===null){return false}A=new Element("div");A.set("class","file file-wrapper");C=new Element("span");C.set("class","value");C.set("html",B.get("value"));C.inject(A);D=new Element("button");D.set("html","Choose File");D.inject(A);A.inject(B.getParent());B.inject(A);B.addEvent("change",function(E){E.set("html",this.get("value"))}.bind(B,[C]));return true},ParseRepeater:function(E){var G,H,I,C,A,F,B,D;E=$(E);if(E===null){return false}G=E.getElements("dt.upload");H=E.getElements("dd.upload");I=E.getElements("dd.remove");C=0;A=E.getElement("dt.add");F=function(K){var J;J=[G[K],H[K],I[K]];J.each(function(L){var M;M=L.retrieve("REPEATER_elementFx");if(M===null){M=new Fx.Tween(L,"opacity",{duration:250});L.store("REPEATER_elementFx",M)}M.cancel().set(0)});J.each(function(L){L.inject(A,"before")});J.each(function(L){L.setStyle("display","block")});J.each(function(L,M){var N;N=L.retrieve("REPEATER_elementFx");N.start.delay(M*175,N,[1])})};B=function(L){var J,K;K=H[L].getElement("input");K.set("disabled",true);J=[G[L],H[L],I[L]];J.each(function(M,N){var O;O=M.retrieve("REPEATER_elementFx");O.cancel().start.delay((J.length*175)-N*175,O,[0])});J.each.delay((J.length+1)*175,J,[function(M){M.setStyle("display","none")}])};D=E.getElements("button");D=D[D.length-1];D.addEvent("click",function(){var N,M,J,K,L;if(C>=G.length){return false}N=null;G.each(function(O,P){if(N===null&&O.getStyle("display")=="none"){N=P}});if(N===null){return false}F(N);M=H[N].getElement("input");J=I[N].getElement("a");K=function(O){this.removeEvent("click",K);C--;D.focus();B(N);if(C<G.length){D.set("disabled",false)}return false}.bind(J);J.addEvent("click",K);if(J.retrieve("REPEATER_elementFx")===null){L=new Fx.Tween(J,"opacity",{duration:250});L.cancel().set(0.6);J.addEvent("mouseover",function(){L.cancel().start(1)});J.addEvent("mouseout",function(){L.cancel().start(0.6)});J.store("REPEATER_elementFx",L)}C++;if(C>=G.length){this.set("disabled",true)}M.set("disabled",false);(function(){$try(this.focus)}).delay(250,M);if(typeof (M.click)=="function"){M.click.delay(250,M)}return false}.bind(D));return true},ParsePrintAnchors:function(A){A=$(A);if(A===null){return false}A.getElements("a[target=_print]").each(function(B){B.addEvent("click",function(C){var D;D=$("_print-frame");if(!D){D=new Element("iframe",{id:"_print-frame",src:"about:blank",frameBorder:0,styles:{position:"absolute",top:-128,left:-128,width:128,height:128}});D.inject(document.body)}(D.contentWindow||D).location.replace(this.href);C.stop();return false}.bindWithEvent(B))});return true},DecorateElement:function(H,I,L,G){var D,J,M,A,F,E,B,K,C;H=$(H);if(H===null){return false}D=$H({"top-left":function(O,N){this.left=O.left;this.top=O.top;this.width=N;this.height=N},top:function(O,N){this.left=(O.left+N);this.top=O.top;this.width=(O.width-(N*2));this.height=N},"top-right":function(O,N){this.left=(O.right-N);this.top=O.top;this.width=N;this.height=N},left:function(O,N){this.left=O.left;this.top=(O.top+N);this.width=N;this.height=(O.height-(N*2))},center:function(O,N){this.left=(O.left+N);this.top=(O.top+N);this.width=(O.width-(N*2));this.height=(O.height-(N*2))},right:function(O,N){this.left=(O.right-N);this.top=(O.top+N);this.width=N;this.height=(O.height-(N*2))},"bottom-left":function(O,N){this.left=O.left;this.top=(O.bottom-N);this.width=N;this.height=N},bottom:function(O,N){this.left=(O.left+N);this.top=(O.bottom-N);this.width=(O.width-(N*2));this.height=N},"bottom-right":function(O,N){this.left=(O.right-N);this.top=(O.bottom-N);this.width=N;this.height=N}});D.extend(L);J=[];M=[];D.getKeys().each(function(N){if($type(D[N])=="function"){M.push(N)}});A=(M.length+1);F=H.getComputedStyle("z-index").toInt();F=(isNaN(F)?A:Math.max(A,F));H.setStyle("z-index",F);if("static"==H.getComputedStyle("position")){H.setStyle("position","relative")}if(!G){G=("includes/templates/plansmadeeasy/images/background_{id}_{decorator}.{ext}")}E=(H.get("id")||H.get("class").split(" ")[0]);M.each(function(R,Q){var N,P,O;N=new Element("div");N.set("id",(E+"-decorator-"+R));N.addClass("decorator");N.addClass("decorator-"+R);N.addClass(N.get("id"));P={position:"absolute",zIndex:(F-(Q+1))};O=G.replace("{id}",E).replace("{decorator}",R.replace("-","")).replace("{ext}",(R.indexOf("image")<0?"png":"jpg"));P.backgroundColor="transparent";P.backgroundImage=("url("+O+")");P.backgroundRepeat=(["top","bottom","left","right","inner"].contains(R)?"repeat":"no-repeat");if(Browser.Engine.trident&&Browser.Engine.version==4){P.filter=('progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+O+'", sizingMethod="'+(P.backgroundRepeat=="repeat"?"scale":"crop")+'")');P.backgroundImage="none"}N.setStyles(P);N.inject(H,"before")});K=H.getParent();while(K!==null&&K.getComputedStyle("position")=="static"){K=K.getParent()}C=function(){var N;N=H.getCoordinates(K);if(!!B&&B.top==N.top&&B.right==N.right&&B.bottom==N.bottom&&B.left==N.left&&B.width==N.width&&B.height==N.height){return false}M.each(function(P){var O;O=$(E+"-decorator-"+P);decoratorStyles={};D[P].bind(decoratorStyles,[N,I])();$try(O.setStyles.bind(O,[decoratorStyles]))});B=N;return true};window.addEvent("resize",C);C.periodical(250);C();H.addClass("decorators-applied");H.addClass(E+"-decorators-applied");return true},PromptBox:function(D,L,E){var K,J,I,B,F,C,H,M,G,A;K=$("prompt-box");if(!!K){J=$("prompt-shim");I=$("prompt-close");B=K.getElement("h2");F=K.getElement("textarea");C=K.getElement("input")}else{K=new Element("div");K.set("id","prompt-box");K.inject(document.body);J=new Element("div");J.set("id","prompt-shim");J.inject(document.body);I=new Element("div");I.set("id","prompt-close");I.inject(document.body);B=new Element("h2");B.inject(K);F=new Element("textarea");F.inject(K);C=new Element("input");C.set("value","Send");C.inject(K);[K,J,I].each(function(N){N.setStyle("display","none")})}B.set("html",L);A=K.retrieve("fx");if(!A){A=new Fx.Tween(K,"opacity",{duration:400});K.store("fx",A)}A.cancel().set(0);J.setStyle("display","block");K.setStyle("display","block");A.start(1).chain(function(){I.setStyle("display","block");F.set("disabled",false);F.focus();F.select()});H=function(){I.removeEvent("click",H);I.setStyle("display","none");A.cancel().start(0).chain(function(){J.setStyle("display","none");K.setStyle("display","none");if($type(D.focus)=="function"){$try(D.focus.bind(D))}})};I.addEvent("click",H);M=function(){var N;C.removeEvent("click",M);N=F.get("value").trim();if(N.length>0){$(E).set("value",N);F.set("disabled",true);if(!!D.form){new Element("input",{type:"hidden",name:D.get("name"),value:D.get("value")}).inject(D.form);D.form.submit()}}else{H()}};C.addEvent("click",M);G=function(N){document.body.removeEvent("keypress",G);if("esc"==N.key){H()}}.bindWithEvent();document.body.addEvent("keypress",G);return true}});pageObject=new Page();
