var Window=Class.create();Window.keepMultiModalWindow=false;Window.hasEffectLib=(typeof Effect!="undefined");Window.resizeEffectDuration=0.4;Window.prototype={initialize:function(){var c;var b=0;if(arguments.length>0){if(typeof arguments[0]=="string"){c=arguments[0];b=1}else{c=arguments[0]?arguments[0].id:null}}if(!c){c="window_"+new Date().getTime()}if($(c)){alert("Window "+c+" is already registered in the DOM! Make sure you use setDestroyOnClose() or destroyOnClose: true in the constructor")}this.options=Object.extend({className:"alphacube",blurClassName:null,minWidth:100,minHeight:20,resizable:false,closable:true,minimizable:false,maximizable:false,draggable:true,userData:null,showEffect:(Window.hasEffectLib?Effect.Appear:Element.show),hideEffect:(Window.hasEffectLib?Effect.Fade:Element.hide),showEffectOptions:{},hideEffectOptions:{},effectOptions:null,parent:document.body,title:"&nbsp;",url:null,onload:Prototype.emptyFunction,width:200,height:300,opacity:1,recenterAuto:true,wiredDrag:false,closeCallback:null,destroyOnClose:false,gridX:1,gridY:1,zIndex:100},arguments[b]||{});if(this.options.blurClassName){this.options.focusClassName=this.options.className}if(typeof this.options.top=="undefined"&&typeof this.options.bottom=="undefined"){this.options.top=this._round(Math.random()*500,this.options.gridY)}if(typeof this.options.left=="undefined"&&typeof this.options.right=="undefined"){this.options.left=this._round(Math.random()*500,this.options.gridX)}if(this.options.effectOptions){Object.extend(this.options.hideEffectOptions,this.options.effectOptions);Object.extend(this.options.showEffectOptions,this.options.effectOptions);if(this.options.showEffect==Element.Appear){this.options.showEffectOptions.to=this.options.opacity}}if(Window.hasEffectLib){if(this.options.showEffect==Effect.Appear){this.options.showEffectOptions.to=this.options.opacity}if(this.options.hideEffect==Effect.Fade){this.options.hideEffectOptions.from=this.options.opacity}}if(this.options.hideEffect==Element.hide){this.options.hideEffect=function(){Element.hide(this.element);if(this.options.destroyOnClose){this.destroy()}}.bind(this)}if(this.options.parent!=document.body){this.options.parent=$(this.options.parent)}this.element=this._createWindow(c);this.element.win=this;this.eventMouseDown=this._initDrag.bindAsEventListener(this);this.eventMouseUp=this._endDrag.bindAsEventListener(this);this.eventMouseMove=this._updateDrag.bindAsEventListener(this);this.eventOnLoad=this._getWindowBorderSize.bindAsEventListener(this);this.eventMouseDownContent=this.toFront.bindAsEventListener(this);this.eventResize=this._recenter.bindAsEventListener(this);this.topbar=$(this.element.id+"_top");this.bottombar=$(this.element.id+"_bottom");this.content=$(this.element.id+"_content");Event.observe(this.topbar,"mousedown",this.eventMouseDown);Event.observe(this.bottombar,"mousedown",this.eventMouseDown);Event.observe(this.content,"mousedown",this.eventMouseDownContent);Event.observe(window,"load",this.eventOnLoad);Event.observe(window,"resize",this.eventResize);Event.observe(window,"scroll",this.eventResize);Event.observe(this.options.parent,"scroll",this.eventResize);if(this.options.draggable){var a=this;[this.topbar,this.topbar.up().previous(),this.topbar.up().next()].each(function(d){d.observe("mousedown",a.eventMouseDown);d.addClassName("top_draggable")});[this.bottombar.up(),this.bottombar.up().previous(),this.bottombar.up().next()].each(function(d){d.observe("mousedown",a.eventMouseDown);d.addClassName("bottom_draggable")})}if(this.options.resizable){this.sizer=$(this.element.id+"_sizer");Event.observe(this.sizer,"mousedown",this.eventMouseDown)}this.useLeft=null;this.useTop=null;if(typeof this.options.left!="undefined"){this.element.setStyle({left:parseFloat(this.options.left)+"px"});this.useLeft=true}else{this.element.setStyle({right:parseFloat(this.options.right)+"px"});this.useLeft=false}if(typeof this.options.top!="undefined"){this.element.setStyle({top:parseFloat(this.options.top)+"px"});this.useTop=true}else{this.element.setStyle({bottom:parseFloat(this.options.bottom)+"px"});this.useTop=false}this.storedLocation=null;this.setOpacity(this.options.opacity);if(this.options.zIndex){this.setZIndex(this.options.zIndex)}if(this.options.destroyOnClose){this.setDestroyOnClose(true)}this._getWindowBorderSize();this.width=this.options.width;this.height=this.options.height;this.visible=false;this.constraint=false;this.constraintPad={top:0,left:0,bottom:0,right:0};if(this.width&&this.height){this.setSize(this.options.width,this.options.height)}this.setTitle(this.options.title);Windows.register(this)},destroy:function(){this._notify("onDestroy");Event.stopObserving(this.topbar,"mousedown",this.eventMouseDown);Event.stopObserving(this.bottombar,"mousedown",this.eventMouseDown);Event.stopObserving(this.content,"mousedown",this.eventMouseDownContent);Event.stopObserving(window,"load",this.eventOnLoad);Event.stopObserving(window,"resize",this.eventResize);Event.stopObserving(window,"scroll",this.eventResize);Event.stopObserving(this.content,"load",this.options.onload);if(this._oldParent){var c=this.getContent();var a=null;for(var b=0;b<c.childNodes.length;b++){a=c.childNodes[b];if(a.nodeType==1){break}a=null}if(a){this._oldParent.appendChild(a)}this._oldParent=null}if(this.sizer){Event.stopObserving(this.sizer,"mousedown",this.eventMouseDown)}if(this.options.url){this.content.src=null}if(this.iefix){Element.remove(this.iefix)}Element.remove(this.element);Windows.unregister(this)},setCloseCallback:function(a){this.options.closeCallback=a},getContent:function(){return this.content},setContent:function(h,g,b){var a=$(h);if(null==a){throw"Unable to find element '"+h+"' in DOM"}this._oldParent=a.parentNode;var f=null;var e=null;if(g){f=Element.getDimensions(a)}if(b){e=Position.cumulativeOffset(a)}var c=this.getContent();this.setHTMLContent("");c=this.getContent();c.appendChild(a);a.show();if(g){this.setSize(f.width,f.height)}if(b){this.setLocation(e[1]-this.heightN,e[0]-this.widthW)}},setHTMLContent:function(a){if(this.options.url){this.content.src=null;this.options.url=null;var b='<div id="'+this.getId()+'_content" class="'+this.options.className+'_content"> </div>';$(this.getId()+"_table_content").innerHTML=b;this.content=$(this.element.id+"_content")}this.getContent().innerHTML=a},setAjaxContent:function(b,a,d,c){this.showFunction=d?"showCenter":"show";this.showModal=c||false;a=a||{};this.setHTMLContent("");this.onComplete=a.onComplete;if(!this._onCompleteHandler){this._onCompleteHandler=this._setAjaxContent.bind(this)}a.onComplete=this._onCompleteHandler;console.log("window.js: setAjaxContent: url="+b+" options="+a);new Ajax.Request(b,a);console.log("window.js: setAjaxContent: AjaxRequest was created");a.onComplete=this.onComplete},_setAjaxContent:function(a){Element.update(this.getContent(),a.responseText);if(this.onComplete){this.onComplete(a)}this.onComplete=null;this[this.showFunction](this.showModal)},setURL:function(a){if(this.options.url){this.content.src=null}this.options.url=a;var b="<iframe frameborder='0' name='"+this.getId()+"_content'  id='"+this.getId()+"_content' src='"+a+"' width='"+this.width+"' height='"+this.height+"'> </iframe>";$(this.getId()+"_table_content").innerHTML=b;this.content=$(this.element.id+"_content")},getURL:function(){return this.options.url?this.options.url:null},refresh:function(){if(this.options.url){$(this.element.getAttribute("id")+"_content").src=this.options.url}},setCookie:function(b,c,o,e,a){b=b||this.element.id;this.cookie=[b,c,o,e,a];var m=WindowUtilities.getCookie(b);if(m){var n=m.split(",");var k=n[0].split(":");var j=n[1].split(":");var l=parseFloat(n[2]),f=parseFloat(n[3]);var g=n[4];var d=n[5];this.setSize(l,f);if(g=="true"){this.doMinimize=true}else{if(d=="true"){this.doMaximize=true}}this.useLeft=k[0]=="l";this.useTop=j[0]=="t";this.element.setStyle(this.useLeft?{left:k[1]}:{right:k[1]});this.element.setStyle(this.useTop?{top:j[1]}:{bottom:j[1]})}},getId:function(){return this.element.id},setDestroyOnClose:function(){this.options.destroyOnClose=true},setConstraint:function(a,b){this.constraint=a;this.constraintPad=Object.extend(this.constraintPad,b||{});if(this.useTop&&this.useLeft){this.setLocation(parseFloat(this.element.style.top),parseFloat(this.element.style.left))}},_initDrag:function(b){if(Event.element(b)==this.sizer&&this.isMinimized()){return}if(Event.element(b)!=this.sizer&&this.isMaximized()){return}if(Prototype.Browser.IE&&this.heightN==0){this._getWindowBorderSize()}this.pointer=[this._round(Event.pointerX(b),this.options.gridX),this._round(Event.pointerY(b),this.options.gridY)];if(this.options.wiredDrag){this.currentDrag=this._createWiredElement()}else{this.currentDrag=this.element}if(Event.element(b)==this.sizer){this.doResize=true;this.widthOrg=this.width;this.heightOrg=this.height;this.bottomOrg=parseFloat(this.element.getStyle("bottom"));this.rightOrg=parseFloat(this.element.getStyle("right"));this._notify("onStartResize")}else{this.doResize=false;var a=$(this.getId()+"_close");if(a&&Position.within(a,this.pointer[0],this.pointer[1])){this.currentDrag=null;return}this.toFront();if(!this.options.draggable){return}this._notify("onStartMove")}Event.observe(document,"mouseup",this.eventMouseUp,false);Event.observe(document,"mousemove",this.eventMouseMove,false);WindowUtilities.disableScreen("__invisible__","__invisible__",this.overlayOpacity);document.body.ondrag=function(){return false};document.body.onselectstart=function(){return false};this.currentDrag.show();Event.stop(b)},_round:function(b,a){return a==1?b:b=Math.floor(b/a)*a},_updateDrag:function(b){var a=[this._round(Event.pointerX(b),this.options.gridX),this._round(Event.pointerY(b),this.options.gridY)];var l=a[0]-this.pointer[0];var k=a[1]-this.pointer[1];if(this.doResize){var j=this.widthOrg+l;var d=this.heightOrg+k;l=this.width-this.widthOrg;k=this.height-this.heightOrg;if(this.useLeft){j=this._updateWidthConstraint(j)}else{this.currentDrag.setStyle({right:(this.rightOrg-l)+"px"})}if(this.useTop){d=this._updateHeightConstraint(d)}else{this.currentDrag.setStyle({bottom:(this.bottomOrg-k)+"px"})}this.setSize(j,d);this._notify("onResize")}else{this.pointer=a;if(this.useLeft){var c=parseFloat(this.currentDrag.getStyle("left"))+l;var g=this._updateLeftConstraint(c);this.pointer[0]+=g-c;this.currentDrag.setStyle({left:g+"px"})}else{this.currentDrag.setStyle({right:parseFloat(this.currentDrag.getStyle("right"))-l+"px"})}if(this.useTop){var f=parseFloat(this.currentDrag.getStyle("top"))+k;var e=this._updateTopConstraint(f);this.pointer[1]+=e-f;this.currentDrag.setStyle({top:e+"px"})}else{this.currentDrag.setStyle({bottom:parseFloat(this.currentDrag.getStyle("bottom"))-k+"px"})}this._notify("onMove")}if(this.iefix){this._fixIEOverlapping()}this._removeStoreLocation();Event.stop(b)},_endDrag:function(a){WindowUtilities.enableScreen("__invisible__");if(this.doResize){this._notify("onEndResize")}else{this._notify("onEndMove")}Event.stopObserving(document,"mouseup",this.eventMouseUp,false);Event.stopObserving(document,"mousemove",this.eventMouseMove,false);Event.stop(a);this._hideWiredElement();this._saveCookie();document.body.ondrag=null;document.body.onselectstart=null},_updateLeftConstraint:function(b){if(this.constraint&&this.useLeft&&this.useTop){var a=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;if(b<this.constraintPad.left){b=this.constraintPad.left}if(b+this.width+this.widthE+this.widthW>a-this.constraintPad.right){b=a-this.constraintPad.right-this.width-this.widthE-this.widthW}}return b},_updateTopConstraint:function(c){if(this.constraint&&this.useLeft&&this.useTop){var a=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var b=this.height+this.heightN+this.heightS;if(c<this.constraintPad.top){c=this.constraintPad.top}if(c+b>a-this.constraintPad.bottom){c=a-this.constraintPad.bottom-b}}return c},_updateWidthConstraint:function(a){if(this.constraint&&this.useLeft&&this.useTop){var b=this.options.parent==document.body?WindowUtilities.getPageSize().windowWidth:this.options.parent.getDimensions().width;var c=parseFloat(this.element.getStyle("left"));if(c+a+this.widthE+this.widthW>b-this.constraintPad.right){a=b-this.constraintPad.right-c-this.widthE-this.widthW}}return a},_updateHeightConstraint:function(b){if(this.constraint&&this.useLeft&&this.useTop){var a=this.options.parent==document.body?WindowUtilities.getPageSize().windowHeight:this.options.parent.getDimensions().height;var c=parseFloat(this.element.getStyle("top"));if(c+b+this.heightN+this.heightS>a-this.constraintPad.bottom){b=a-this.constraintPad.bottom-c-this.heightN-this.heightS}}return b},_createWindow:function(a){var f=this.options.className;var d=document.createElement("div");d.setAttribute("id",a);d.className="window-dialog";var e;if(this.options.url){e='<iframe frameborder="0" name="'+a+'_content"  id="'+a+'_content" src="'+this.options.url+'"> </iframe>'}else{e='<div id="'+a+'_content" class="'+f+'_content"> </div>'}var g=this.options.closable?"<div class='"+f+"_close' id='"+a+"_close' onclick='Windows.close(\""+a+"\", event)'> </div>":"";var h=this.options.minimizable?"<div class='"+f+"_minimize' id='"+a+"_minimize' onclick='Windows.minimize(\""+a+"\", event)'> </div>":"";var j=this.options.maximizable?"<div class='"+f+"_maximize' id='"+a+"_maximize' onclick='Windows.maximize(\""+a+"\", event)'> </div>":"";var c=this.options.resizable?"class='"+f+"_sizer' id='"+a+"_sizer'":"class='"+f+"_se'";var b="../themes/default/blank.gif";d.innerHTML=g+h+j+"      <table id='"+a+"_row1' class=\"top table_window\">        <tr>          <td class='"+f+"_nw'></td>          <td class='"+f+"_n'><div id='"+a+"_top' class='"+f+"_title title_window'>"+this.options.title+"</div></td>          <td class='"+f+"_ne'></td>        </tr>      </table>      <table id='"+a+"_row2' class=\"mid table_window\">        <tr>          <td class='"+f+"_w'></td>            <td id='"+a+"_table_content' class='"+f+"_content' valign='top'>"+e+"</td>          <td class='"+f+"_e'></td>        </tr>      </table>        <table id='"+a+"_row3' class=\"bot table_window\">        <tr>          <td class='"+f+"_sw'></td>            <td class='"+f+"_s'><div id='"+a+"_bottom' class='status_bar'><span style='float:left; width:1px; height:1px'></span></div></td>            <td "+c+"></td>        </tr>      </table>    ";Element.hide(d);this.options.parent.insertBefore(d,this.options.parent.firstChild);Event.observe($(a+"_content"),"load",this.options.onload);return d},changeClassName:function(a){var b=this.options.className;var c=this.getId();$A(["_close","_minimize","_maximize","_sizer","_content"]).each(function(d){this._toggleClassName($(c+d),b+d,a+d)}.bind(this));this._toggleClassName($(c+"_top"),b+"_title",a+"_title");$$("#"+c+" td").each(function(d){d.className=d.className.sub(b,a)});this.options.className=a},_toggleClassName:function(c,b,a){if(c){c.removeClassName(b);c.addClassName(a)}},setLocation:function(c,b){c=this._updateTopConstraint(c);b=this._updateLeftConstraint(b);var a=this.currentDrag||this.element;a.setStyle({top:c+"px"});a.setStyle({left:b+"px"});this.useLeft=true;this.useTop=true},getLocation:function(){var a={};if(this.useTop){a=Object.extend(a,{top:this.element.getStyle("top")})}else{a=Object.extend(a,{bottom:this.element.getStyle("bottom")})}if(this.useLeft){a=Object.extend(a,{left:this.element.getStyle("left")})}else{a=Object.extend(a,{right:this.element.getStyle("right")})}return a},getSize:function(){return{width:this.width,height:this.height}},setSize:function(c,b,a){c=parseFloat(c);b=parseFloat(b);if(!this.minimized&&c<this.options.minWidth){c=this.options.minWidth}if(!this.minimized&&b<this.options.minHeight){b=this.options.minHeight}if(this.options.maxHeight&&b>this.options.maxHeight){b=this.options.maxHeight}if(this.options.maxWidth&&c>this.options.maxWidth){c=this.options.maxWidth}if(this.useTop&&this.useLeft&&Window.hasEffectLib&&Effect.ResizeWindow&&a){new Effect.ResizeWindow(this,null,null,c,b,{duration:Window.resizeEffectDuration})}else{this.width=c;this.height=b;var f=this.currentDrag?this.currentDrag:this.element;f.setStyle({width:c+this.widthW+this.widthE+"px"});f.setStyle({height:b+this.heightN+this.heightS+"px"});if(!this.currentDrag||this.currentDrag==this.element){var d=$(this.element.id+"_content");d.setStyle({height:b+"px"});d.setStyle({width:c+"px"})}}},updateHeight:function(){this.setSize(this.width,this.content.scrollHeight,true)},updateWidth:function(){this.setSize(this.content.scrollWidth,this.height,true)},toFront:function(){if(this.element.style.zIndex<Windows.maxZIndex){this.setZIndex(Windows.maxZIndex+1)}if(this.iefix){this._fixIEOverlapping()}},getBounds:function(b){if(!this.width||!this.height||!this.visible){this.computeBounds()}var a=this.width;var c=this.height;if(!b){a+=this.widthW+this.widthE;c+=this.heightN+this.heightS}var d=Object.extend(this.getLocation(),{width:a+"px",height:c+"px"});return d},computeBounds:function(){if(!this.width||!this.height){var a=WindowUtilities._computeSize(this.content.innerHTML,this.content.id,this.width,this.height,0,this.options.className);if(this.height){this.width=a+5}else{this.height=a+5}}this.setSize(this.width,this.height);if(this.centered){this._center(this.centerTop,this.centerLeft)}},show:function(b){this.visible=true;if(b){if(typeof this.overlayOpacity=="undefined"){var a=this;setTimeout(function(){a.show(b)},10);return}Windows.addModalWindow(this);this.modal=true;this.setZIndex(Windows.maxZIndex+1);Windows.unsetOverflow(this)}else{if(!this.element.style.zIndex){this.setZIndex(Windows.maxZIndex+1)}}if(this.oldStyle){this.getContent().setStyle({overflow:this.oldStyle})}this.computeBounds();this._notify("onBeforeShow");if(this.options.showEffect!=Element.show&&this.options.showEffectOptions){this.options.showEffect(this.element,this.options.showEffectOptions)}else{this.options.showEffect(this.element)}this._checkIEOverlapping();WindowUtilities.focusedWindow=this;this._notify("onShow")},showCenter:function(a,c,b){this.centered=true;this.centerTop=c;this.centerLeft=b;this.show(a)},isVisible:function(){return this.visible},_center:function(c,b){var d=WindowUtilities.getWindowScroll(this.options.parent);var a=WindowUtilities.getPageSize(this.options.parent);if(typeof c=="undefined"){c=(a.windowHeight-(this.height+this.heightN+this.heightS))/2}c+=d.top;if(typeof b=="undefined"){b=(a.windowWidth-(this.width+this.widthW+this.widthE))/2}b+=d.left;this.setLocation(c,b);this.toFront()},_recenter:function(b){if(this.centered){var a=WindowUtilities.getPageSize(this.options.parent);var c=WindowUtilities.getWindowScroll(this.options.parent);if(this.pageSize&&this.pageSize.windowWidth==a.windowWidth&&this.pageSize.windowHeight==a.windowHeight&&this.windowScroll.left==c.left&&this.windowScroll.top==c.top){return}this.pageSize=a;this.windowScroll=c;if($("overlay_modal")){$("overlay_modal").setStyle({height:(a.pageHeight+"px")})}if(this.options.recenterAuto&&this.visible){this._center(this.centerTop,this.centerLeft)}}},hide:function(){this.visible=false;if(this.modal){Windows.removeModalWindow(this);Windows.resetOverflow()}this.oldStyle=this.getContent().getStyle("overflow")||"auto";this.getContent().setStyle({overflow:"hidden"});this.options.hideEffect(this.element,this.options.hideEffectOptions);if(this.iefix){this.iefix.hide()}if(!this.doNotNotifyHide){this._notify("onHide")}},close:function(){if(this.visible){if(this.options.closeCallback&&!this.options.closeCallback(this)){return}if(this.options.destroyOnClose){var a=this.destroy.bind(this);if(this.options.hideEffectOptions.afterFinish){var b=this.options.hideEffectOptions.afterFinish;this.options.hideEffectOptions.afterFinish=function(){b();a()}}else{this.options.hideEffectOptions.afterFinish=function(){a()}}}Windows.updateFocusedWindow();this.doNotNotifyHide=true;this.hide();this.doNotNotifyHide=false;this._notify("onClose")}},minimize:function(){if(this.resizing){return}var a=$(this.getId()+"_row2");var d=null;var b=null;var c=null;if(!this.minimized){this.minimized=true;d=a.getDimensions().height;this.r2Height=d;c=this.element.getHeight()-d;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,null,null,null,this.height-d,{duration:Window.resizeEffectDuration})}else{this.height-=d;this.element.setStyle({height:c+"px"});a.hide()}if(!this.useTop){b=parseFloat(this.element.getStyle("bottom"));this.element.setStyle({bottom:(b+d)+"px"})}}else{this.minimized=false;d=this.r2Height;this.r2Height=null;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,null,null,null,this.height+d,{duration:Window.resizeEffectDuration})}else{c=this.element.getHeight()+d;this.height+=d;this.element.setStyle({height:c+"px"});a.show()}if(!this.useTop){b=parseFloat(this.element.getStyle("bottom"));this.element.setStyle({bottom:(b-d)+"px"})}this.toFront()}this._notify("onMinimize");this._saveCookie()},maximize:function(){if(this.isMinimized()||this.resizing){return}if(Prototype.Browser.IE&&this.heightN==0){this._getWindowBorderSize()}if(this.storedLocation!=null){this._restoreLocation();if(this.iefix){this.iefix.hide()}}else{this._storeLocation();Windows.unsetOverflow(this);var g=WindowUtilities.getWindowScroll(this.options.parent);var b=WindowUtilities.getPageSize(this.options.parent);var f=g.left;var e=g.top;if(this.options.parent!=document.body){g={top:0,left:0,bottom:0,right:0};var d=this.options.parent.getDimensions();b.windowWidth=d.width;b.windowHeight=d.height;e=0;f=0}if(this.constraint){b.windowWidth-=Math.max(0,this.constraintPad.left)+Math.max(0,this.constraintPad.right);b.windowHeight-=Math.max(0,this.constraintPad.top)+Math.max(0,this.constraintPad.bottom);f+=Math.max(0,this.constraintPad.left);e+=Math.max(0,this.constraintPad.top)}var c=b.windowWidth-this.widthW-this.widthE;var a=b.windowHeight-this.heightN-this.heightS;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,e,f,c,a,{duration:Window.resizeEffectDuration})}else{this.setSize(c,a);this.element.setStyle(this.useLeft?{left:f}:{right:f});this.element.setStyle(this.useTop?{top:e}:{bottom:e})}this.toFront();if(this.iefix){this._fixIEOverlapping()}}this._notify("onMaximize");this._saveCookie()},isMinimized:function(){return this.minimized},isMaximized:function(){return(this.storedLocation!=null)},setOpacity:function(a){if(Element.setOpacity){Element.setOpacity(this.element,a)}},setZIndex:function(a){this.element.setStyle({zIndex:a});Windows.updateZindex(a,this)},setTitle:function(a){if(!a||a==""){a="&nbsp;"}Element.update(this.element.id+"_top",a)},getTitle:function(){return $(this.element.id+"_top").innerHTML},setStatusBar:function(b){var a=$(this.getId()+"_bottom");if(typeof(b)=="object"){if(this.bottombar.firstChild){this.bottombar.replaceChild(b,this.bottombar.firstChild)}else{this.bottombar.appendChild(b)}}else{this.bottombar.innerHTML=b}},_checkIEOverlapping:function(){if(!this.iefix&&(navigator.appVersion.indexOf("MSIE")>0)&&(navigator.userAgent.indexOf("Opera")<0)&&(this.element.getStyle("position")=="absolute")){new Insertion.After(this.element.id,'<iframe id="'+this.element.id+'_iefix" style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" src="javascript:false;" frameborder="0" scrolling="no"></iframe>');this.iefix=$(this.element.id+"_iefix")}if(this.iefix){setTimeout(this._fixIEOverlapping.bind(this),50)}},_fixIEOverlapping:function(){Position.clone(this.element,this.iefix);this.iefix.style.zIndex=this.element.style.zIndex-1;this.iefix.show()},_getWindowBorderSize:function(b){var c=this._createHiddenDiv(this.options.className+"_n");this.heightN=Element.getDimensions(c).height;c.parentNode.removeChild(c);c=this._createHiddenDiv(this.options.className+"_s");this.heightS=Element.getDimensions(c).height;c.parentNode.removeChild(c);c=this._createHiddenDiv(this.options.className+"_e");this.widthE=Element.getDimensions(c).width;c.parentNode.removeChild(c);c=this._createHiddenDiv(this.options.className+"_w");this.widthW=Element.getDimensions(c).width;c.parentNode.removeChild(c);c=document.createElement("div");c.className="overlay_"+this.options.className;document.body.appendChild(c);var a=this;setTimeout(function(){a.overlayOpacity=($(c).getStyle("opacity"));c.parentNode.removeChild(c)},10);if(Prototype.Browser.IE){this.heightS=$(this.getId()+"_row3").getDimensions().height;this.heightN=$(this.getId()+"_row1").getDimensions().height}if(Prototype.Browser.WebKit&&Prototype.Browser.WebKitVersion<420){this.setSize(this.width,this.height)}if(this.doMaximize){this.maximize()}if(this.doMinimize){this.minimize()}},_createHiddenDiv:function(b){var a=document.body;var c=document.createElement("div");c.setAttribute("id",this.element.id+"_tmp");c.className=b;c.style.display="none";c.innerHTML="";a.insertBefore(c,a.firstChild);return c},_storeLocation:function(){if(this.storedLocation==null){this.storedLocation={useTop:this.useTop,useLeft:this.useLeft,top:this.element.getStyle("top"),bottom:this.element.getStyle("bottom"),left:this.element.getStyle("left"),right:this.element.getStyle("right"),width:this.width,height:this.height}}},_restoreLocation:function(){if(this.storedLocation!=null){this.useLeft=this.storedLocation.useLeft;this.useTop=this.storedLocation.useTop;if(this.useLeft&&this.useTop&&Window.hasEffectLib&&Effect.ResizeWindow){new Effect.ResizeWindow(this,this.storedLocation.top,this.storedLocation.left,this.storedLocation.width,this.storedLocation.height,{duration:Window.resizeEffectDuration})}else{this.element.setStyle(this.useLeft?{left:this.storedLocation.left}:{right:this.storedLocation.right});this.element.setStyle(this.useTop?{top:this.storedLocation.top}:{bottom:this.storedLocation.bottom});this.setSize(this.storedLocation.width,this.storedLocation.height)}Windows.resetOverflow();this._removeStoreLocation()}},_removeStoreLocation:function(){this.storedLocation=null},_saveCookie:function(){if(this.cookie){var a="";if(this.useLeft){a+="l:"+(this.storedLocation?this.storedLocation.left:this.element.getStyle("left"))}else{a+="r:"+(this.storedLocation?this.storedLocation.right:this.element.getStyle("right"))}if(this.useTop){a+=",t:"+(this.storedLocation?this.storedLocation.top:this.element.getStyle("top"))}else{a+=",b:"+(this.storedLocation?this.storedLocation.bottom:this.element.getStyle("bottom"))}a+=","+(this.storedLocation?this.storedLocation.width:this.width);a+=","+(this.storedLocation?this.storedLocation.height:this.height);a+=","+this.isMinimized();a+=","+this.isMaximized();WindowUtilities.setCookie(a,this.cookie)}},_createWiredElement:function(){if(!this.wiredElement){if(Prototype.Browser.IE){this._getWindowBorderSize()}var b=document.createElement("div");b.className="wired_frame "+this.options.className+"_wired_frame";b.style.position="absolute";this.options.parent.insertBefore(b,this.options.parent.firstChild);this.wiredElement=$(b)}if(this.useLeft){this.wiredElement.setStyle({left:this.element.getStyle("left")})}else{this.wiredElement.setStyle({right:this.element.getStyle("right")})}if(this.useTop){this.wiredElement.setStyle({top:this.element.getStyle("top")})}else{this.wiredElement.setStyle({bottom:this.element.getStyle("bottom")})}var a=this.element.getDimensions();this.wiredElement.setStyle({width:a.width+"px",height:a.height+"px"});this.wiredElement.setStyle({zIndex:Windows.maxZIndex+30});return this.wiredElement},_hideWiredElement:function(){if(!this.wiredElement||!this.currentDrag){return}if(this.currentDrag==this.element){this.currentDrag=null}else{if(this.useLeft){this.element.setStyle({left:this.currentDrag.getStyle("left")})}else{this.element.setStyle({right:this.currentDrag.getStyle("right")})}if(this.useTop){this.element.setStyle({top:this.currentDrag.getStyle("top")})}else{this.element.setStyle({bottom:this.currentDrag.getStyle("bottom")})}this.currentDrag.hide();this.currentDrag=null;if(this.doResize){this.setSize(this.width,this.height)}}},_notify:function(a){if(this.options[a]){this.options[a](this)}else{Windows.notify(a,this)}}};var Windows={windows:[],modalWindows:[],observers:[],focusedWindow:null,maxZIndex:0,overlayShowEffectOptions:{duration:0.5},overlayHideEffectOptions:{duration:0.5},addObserver:function(a){this.removeObserver(a);this.observers.push(a)},removeObserver:function(a){this.observers=this.observers.reject(function(b){return b==a})},notify:function(a,b){this.observers.each(function(c){if(c[a]){c[a](a,b)}})},getWindow:function(a){return this.windows.detect(function(b){return b.getId()==a})},getFocusedWindow:function(){return this.focusedWindow},updateFocusedWindow:function(){this.focusedWindow=this.windows.length>=2?this.windows[this.windows.length-2]:null},register:function(a){this.windows.push(a)},addModalWindow:function(a){if(this.modalWindows.length==0){WindowUtilities.disableScreen(a.options.className,"overlay_modal",a.overlayOpacity,a.getId(),a.options.parent)}else{if(Window.keepMultiModalWindow){$("overlay_modal").style.zIndex=Windows.maxZIndex+1;Windows.maxZIndex+=1;WindowUtilities._hideSelect(this.modalWindows.last().getId())}else{this.modalWindows.last().element.hide()}WindowUtilities._showSelect(a.getId())}this.modalWindows.push(a)},removeModalWindow:function(a){this.modalWindows.pop();if(this.modalWindows.length==0){WindowUtilities.enableScreen()}else{if(Window.keepMultiModalWindow){this.modalWindows.last().toFront();WindowUtilities._showSelect(this.modalWindows.last().getId())}else{this.modalWindows.last().element.show()}}},unregister:function(a){this.windows=this.windows.reject(function(b){return b==a})},closeAll:function(){this.windows.each(function(a){Windows.close(a.getId())})},closeAllModalWindows:function(){WindowUtilities.enableScreen();this.modalWindows.each(function(a){if(a){a.close()}})},minimize:function(c,a){var b=this.getWindow(c);if(b&&b.visible){b.minimize()}Event.stop(a)},maximize:function(c,a){var b=this.getWindow(c);if(b&&b.visible){b.maximize()}Event.stop(a)},close:function(c,a){var b=this.getWindow(c);if(b){b.close()}if(a){Event.stop(a)}},blur:function(b){var a=this.getWindow(b);if(!a){return}if(a.options.blurClassName){a.changeClassName(a.options.blurClassName)}if(this.focusedWindow==a){this.focusedWindow=null}a._notify("onBlur")},focus:function(b){var a=this.getWindow(b);if(!a){return}if(this.focusedWindow){this.blur(this.focusedWindow.getId())}if(a.options.focusClassName){a.changeClassName(a.options.focusClassName)}this.focusedWindow=a;a._notify("onFocus")},unsetOverflow:function(a){this.windows.each(function(b){b.oldOverflow=b.getContent().getStyle("overflow")||"auto";b.getContent().setStyle({overflow:"hidden"})});if(a&&a.oldOverflow){a.getContent().setStyle({overflow:a.oldOverflow})}},resetOverflow:function(){this.windows.each(function(a){if(a.oldOverflow){a.getContent().setStyle({overflow:a.oldOverflow})}})},updateZindex:function(a,b){if(a>this.maxZIndex){this.maxZIndex=a;if(this.focusedWindow){this.blur(this.focusedWindow.getId())}}this.focusedWindow=b;if(this.focusedWindow){this.focus(this.focusedWindow.getId())}}};var Dialog={dialogId:null,onCompleteFunc:null,callFunc:null,parameters:null,confirm:function(d,c){if(d&&typeof d!="string"){Dialog._runAjaxRequest(d,c,Dialog.confirm);return}d=d||"";c=c||{};var f=c.okLabel?c.okLabel:"Ok";var a=c.cancelLabel?c.cancelLabel:"Cancel";c=Object.extend(c,c.windowParameters||{});c.windowParameters=c.windowParameters||{};c.className=c.className||"alert";var b="class ='"+(c.buttonClass?c.buttonClass+" ":"")+" ok_button'";var e="class ='"+(c.buttonClass?c.buttonClass+" ":"")+" cancel_button'";d="      <div class='"+c.className+"_message'>"+d+"</div>        <div class='"+c.className+"_buttons'>          <input type='button' value='"+f+"' onclick='Dialog.okCallback()' "+b+"/>          <input type='button' value='"+a+"' onclick='Dialog.cancelCallback()' "+e+"/>        </div>    ";return this._openDialog(d,c)},alert:function(c,b){if(c&&typeof c!="string"){Dialog._runAjaxRequest(c,b,Dialog.alert);return}c=c||"";b=b||{};var d=b.okLabel?b.okLabel:"Ok";b=Object.extend(b,b.windowParameters||{});b.windowParameters=b.windowParameters||{};b.className=b.className||"alert";var a="class ='"+(b.buttonClass?b.buttonClass+" ":"")+" ok_button'";c="      <div class='"+b.className+"_message'>"+c+"</div>        <div class='"+b.className+"_buttons'>          <input type='button' value='"+d+"' onclick='Dialog.okCallback()' "+a+"/>        </div>";return this._openDialog(c,b)},info:function(b,a){if(b&&typeof b!="string"){Dialog._runAjaxRequest(b,a,Dialog.info);return}b=b||"";a=a||{};a=Object.extend(a,a.windowParameters||{});a.windowParameters=a.windowParameters||{};a.className=a.className||"alert";b="<div id='modal_dialog_message' class='"+a.className+"_message'>"+b+"</div>";if(a.showProgress){b+="<div id='modal_dialog_progress' class='"+a.className+"_progress'>  </div>"}a.ok=null;a.cancel=null;return this._openDialog(b,a)},setInfoMessage:function(a){$("modal_dialog_message").update(a)},closeInfo:function(){Windows.close(this.dialogId)},_openDialog:function(e,d){var c=d.className;if(!d.height&&!d.width){d.width=WindowUtilities.getPageSize(d.options.parent||document.body).pageWidth/2}if(d.id){this.dialogId=d.id}else{var b=new Date();this.dialogId="modal_dialog_"+b.getTime();d.id=this.dialogId}if(!d.height||!d.width){var a=WindowUtilities._computeSize(e,this.dialogId,d.width,d.height,5,c);if(d.height){d.width=a+5}else{d.height=a+5}}d.resizable=d.resizable||false;d.minimizable=d.minimizable||false;d.maximizable=d.maximizable||false;d.draggable=d.draggable||false;d.closable=d.closable||false;var f=new Window(d);f.getContent().innerHTML=e;f.showCenter(true,d.top,d.left);f.setDestroyOnClose();f.cancelCallback=d.onCancel||d.cancel;f.okCallback=d.onOk||d.ok;return f},_getAjaxContent:function(a){Dialog.callFunc(a.responseText,Dialog.parameters)},_runAjaxRequest:function(c,b,a){if(c.options==null){c.options={}}Dialog.onCompleteFunc=c.options.onComplete;Dialog.parameters=b;Dialog.callFunc=a;c.options.onComplete=Dialog._getAjaxContent;new Ajax.Request(c.url,c.options)},okCallback:function(){var a=Windows.focusedWindow;if(!a.okCallback||a.okCallback(a)){$$("#"+a.getId()+" input").each(function(b){b.onclick=null});a.close()}},cancelCallback:function(){var a=Windows.focusedWindow;$$("#"+a.getId()+" input").each(function(b){b.onclick=null});a.close();if(a.cancelCallback){a.cancelCallback(a)}}};if(Prototype.Browser.WebKit){var array=navigator.userAgent.match(new RegExp(/AppleWebKit\/([\d\.\+]*)/));Prototype.Browser.WebKitVersion=parseFloat(array[1])}var WindowUtilities={getWindowScroll:function(parent){var T,L,W,H;parent=parent||document.body;if(parent!=document.body){T=parent.scrollTop;L=parent.scrollLeft;W=parent.scrollWidth;H=parent.scrollHeight}else{var w=window;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}},getPageSize:function(d){d=d||document.body;var c,g;var e,b;if(d!=document.body){c=d.getWidth();g=d.getHeight();b=d.scrollWidth;e=d.scrollHeight}else{var f,a;if(window.innerHeight&&window.scrollMaxY){f=document.body.scrollWidth;a=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){f=document.body.scrollWidth;a=document.body.scrollHeight}else{f=document.body.offsetWidth;a=document.body.offsetHeight}}if(self.innerHeight){c=self.innerWidth;g=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){c=document.documentElement.clientWidth;g=document.documentElement.clientHeight}else{if(document.body){c=document.body.clientWidth;g=document.body.clientHeight}}}if(a<g){e=g}else{e=a}if(f<c){b=c}else{b=f}}return{pageWidth:b,pageHeight:e,windowWidth:c,windowHeight:g}},disableScreen:function(c,a,d,e,b){WindowUtilities.initLightbox(a,c,function(){this._disableScreen(c,a,d,e)}.bind(this),b||document.body)},_disableScreen:function(c,b,e,f){var d=$(b);var a=WindowUtilities.getPageSize(d.parentNode);if(f&&Prototype.Browser.IE){WindowUtilities._hideSelect();WindowUtilities._showSelect(f)}d.style.height=(a.pageHeight+"px");d.style.display="none";if(b=="overlay_modal"&&Window.hasEffectLib&&Windows.overlayShowEffectOptions){d.overlayOpacity=e;new Effect.Appear(d,Object.extend({from:0,to:e},Windows.overlayShowEffectOptions))}else{d.style.display="block"}},enableScreen:function(b){b=b||"overlay_modal";var a=$(b);if(a){if(b=="overlay_modal"&&Window.hasEffectLib&&Windows.overlayHideEffectOptions){new Effect.Fade(a,Object.extend({from:a.overlayOpacity,to:0},Windows.overlayHideEffectOptions))}else{a.style.display="none";a.parentNode.removeChild(a)}if(b!="__invisible__"){WindowUtilities._showSelect()}}},_hideSelect:function(a){if(Prototype.Browser.IE){a=a==null?"":"#"+a+" ";$$(a+"select").each(function(b){if(!WindowUtilities.isDefined(b.oldVisibility)){b.oldVisibility=b.style.visibility?b.style.visibility:"visible";b.style.visibility="hidden"}})}},_showSelect:function(a){if(Prototype.Browser.IE){a=a==null?"":"#"+a+" ";$$(a+"select").each(function(b){if(WindowUtilities.isDefined(b.oldVisibility)){try{b.style.visibility=b.oldVisibility}catch(c){b.style.visibility="visible"}b.oldVisibility=null}else{if(b.style.visibility){b.style.visibility="visible"}}})}},isDefined:function(a){return typeof(a)!="undefined"&&a!=null},initLightbox:function(e,c,a,b){if($(e)){Element.setStyle(e,{zIndex:Windows.maxZIndex+1});Windows.maxZIndex++;a()}else{var d=document.createElement("div");d.setAttribute("id",e);d.className="overlay_"+c;d.style.display="none";d.style.position="absolute";d.style.top="0";d.style.left="0";d.style.zIndex=Windows.maxZIndex+1;Windows.maxZIndex++;d.style.width="100%";b.insertBefore(d,b.firstChild);if(Prototype.Browser.WebKit&&e=="overlay_modal"){setTimeout(function(){a()},10)}else{a()}}},setCookie:function(b,a){document.cookie=a[0]+"="+escape(b)+((a[1])?"; expires="+a[1].toGMTString():"")+((a[2])?"; path="+a[2]:"")+((a[3])?"; domain="+a[3]:"")+((a[4])?"; secure":"")},getCookie:function(c){var b=document.cookie;var e=c+"=";var d=b.indexOf("; "+e);if(d==-1){d=b.indexOf(e);if(d!=0){return null}}else{d+=2}var a=document.cookie.indexOf(";",d);if(a==-1){a=b.length}return unescape(b.substring(d+e.length,a))},_computeSize:function(e,a,b,g,d,f){var j=document.body;var c=document.createElement("div");c.setAttribute("id",a);c.className=f+"_content";if(g){c.style.height=g+"px"}else{c.style.width=b+"px"}c.style.position="absolute";c.style.top="0";c.style.left="0";c.style.display="none";c.innerHTML=e;j.insertBefore(c,j.firstChild);var h;if(g){h=$(c).getDimensions().width+d}else{h=$(c).getDimensions().height+d}j.removeChild(c);return h}};Effect.ResizeWindow=Class.create();Object.extend(Object.extend(Effect.ResizeWindow.prototype,Effect.Base.prototype),{initialize:function(g,f,e,d,a){this.window=g;this.window.resizing=true;var c=g.getSize();this.initWidth=parseFloat(c.width);this.initHeight=parseFloat(c.height);var b=g.getLocation();this.initTop=parseFloat(b.top);this.initLeft=parseFloat(b.left);this.width=d!=null?parseFloat(d):this.initWidth;this.height=a!=null?parseFloat(a):this.initHeight;this.top=f!=null?parseFloat(f):this.initTop;this.left=e!=null?parseFloat(e):this.initLeft;this.dx=this.left-this.initLeft;this.dy=this.top-this.initTop;this.dw=this.width-this.initWidth;this.dh=this.height-this.initHeight;this.r2=$(this.window.getId()+"_row2");this.content=$(this.window.getId()+"_content");this.contentOverflow=this.content.getStyle("overflow")||"auto";this.content.setStyle({overflow:"hidden"});if(this.window.options.wiredDrag){this.window.currentDrag=g._createWiredElement();this.window.currentDrag.show();this.window.element.hide()}this.start(arguments[5])},update:function(b){var c=Math.floor(this.initWidth+this.dw*b);var a=Math.floor(this.initHeight+this.dh*b);var e=Math.floor(this.initTop+this.dy*b);var d=Math.floor(this.initLeft+this.dx*b);if(window.ie){if(Math.floor(a)==0){this.r2.hide()}else{if(Math.floor(a)>1){this.r2.show()}}}this.r2.setStyle({height:a});this.window.setSize(c,a);this.window.setLocation(e,d)},finish:function(a){if(this.window.options.wiredDrag){this.window._hideWiredElement();this.window.element.show()}this.window.setSize(this.width,this.height);this.window.setLocation(this.top,this.left);this.r2.setStyle({height:null});this.content.setStyle({overflow:this.contentOverflow});this.window.resizing=false}});Effect.ModalSlideDown=function(b){var c=WindowUtilities.getWindowScroll();var a=b.getStyle("height");b.setStyle({top:-(parseFloat(a)-c.top)+"px"});b.show();return new Effect.Move(b,Object.extend({x:0,y:parseFloat(a)},arguments[1]||{}))};Effect.ModalSlideUp=function(b){var a=b.getStyle("height");return new Effect.Move(b,Object.extend({x:0,y:-parseFloat(a)},arguments[1]||{}))};PopupEffect=Class.create();PopupEffect.prototype={initialize:function(a){this.html=$(a);this.options=Object.extend({className:"popup_effect",duration:0.4},arguments[1]||{})},show:function(d,b){var a=Position.cumulativeOffset(this.html);var c=this.html.getDimensions();var f=d.win.getBounds();this.window=d.win;if(!this.div){this.div=document.createElement("div");this.div.className=this.options.className;this.div.style.height=c.height+"px";this.div.style.width=c.width+"px";this.div.style.top=a[1]+"px";this.div.style.left=a[0]+"px";this.div.style.position="absolute";document.body.appendChild(this.div)}if(this.options.fromOpacity){this.div.setStyle({opacity:this.options.fromOpacity})}this.div.show();var e="top:"+f.top+";left:"+f.left+";width:"+f.width+";height:"+f.height;if(this.options.toOpacity){e+=";opacity:"+this.options.toOpacity}new Effect.Morph(this.div,{style:e,duration:this.options.duration,afterFinish:this._showWindow.bind(this)})},hide:function(d,b){var a=Position.cumulativeOffset(this.html);var c=this.html.getDimensions();this.window.visible=true;var f=this.window.getBounds();this.window.visible=false;this.window.element.hide();this.div.style.height=f.height;this.div.style.width=f.width;this.div.style.top=f.top;this.div.style.left=f.left;if(this.options.toOpacity){this.div.setStyle({opacity:this.options.toOpacity})}this.div.show();var e="top:"+a[1]+"px;left:"+a[0]+"px;width:"+c.width+"px;height:"+c.height+"px";if(this.options.fromOpacity){e+=";opacity:"+this.options.fromOpacity}new Effect.Morph(this.div,{style:e,duration:this.options.duration,afterFinish:this._hideDiv.bind(this)})},_showWindow:function(){this.div.hide();this.window.element.show()},_hideDiv:function(){this.div.hide()}};var tabdropdown={disappeardelay:200,disablemenuclick:false,enableiframeshim:1,dropmenuobj:null,ie:document.all,firefox:document.getElementById&&!document.all,previousmenuitem:null,currentpageurl:window.location.href.replace("http://"+window.location.hostname,"").replace(/^\//,""),getposOffset:function(d,c){var b=(c=="left")?d.offsetLeft:d.offsetTop;var a=d.offsetParent;while(a!=null){b=(c=="left")?b+a.offsetLeft:b+a.offsetTop;a=a.offsetParent}return b},showhide:function(c,b,a){if(this.ie||this.firefox){this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"}if(b.type=="click"&&c.visibility==hidden||b.type=="mouseover"){if(a.parentNode.className.indexOf("default")==-1){a.parentNode.className="selected"}c.visibility="visible"}else{if(b.type=="click"){c.visibility="hidden"}}},iecompattest:function(){return(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body},clearbrowseredge:function(e,c){var b=0;var d=null;if(c=="rightedge"){d=this.ie&&!window.opera?this.standardbody.scrollLeft+this.standardbody.clientWidth-15:window.pageXOffset+window.innerWidth-15;this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth;if(d-this.dropmenuobj.x<this.dropmenuobj.contentmeasure){b=this.dropmenuobj.contentmeasure-e.offsetWidth}}else{var a=this.ie&&!window.opera?this.standardbody.scrollTop:window.pageYOffset;d=this.ie&&!window.opera?this.standardbody.scrollTop+this.standardbody.clientHeight-15:window.pageYOffset+window.innerHeight-18;this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight;if(d-this.dropmenuobj.y<this.dropmenuobj.contentmeasure){b=this.dropmenuobj.contentmeasure+e.offsetHeight;if((this.dropmenuobj.y-a)<this.dropmenuobj.contentmeasure){b=this.dropmenuobj.y+e.offsetHeight-a}}this.dropmenuobj.firstlink.style.borderTopWidth=(b==0)?0:"1px"}return b},dropit:function(c,b,a){if(this.dropmenuobj!=null){this.dropmenuobj.style.visibility="hidden";if(this.previousmenuitem!=null&&this.previousmenuitem!=c){if(this.previousmenuitem.parentNode.className.indexOf("default")==-1){this.previousmenuitem.parentNode.className=""}}}this.clearhidemenu();if(this.ie||this.firefox){c.onmouseout=function(){tabdropdown.delayhidemenu(c)};c.onclick=function(){return !tabdropdown.disablemenuclick};this.dropmenuobj=document.getElementById(a);this.dropmenuobj.onmouseover=function(){tabdropdown.clearhidemenu()};this.dropmenuobj.onmouseout=function(d){tabdropdown.dynamichide(d,c)};this.dropmenuobj.onclick=function(){tabdropdown.delayhidemenu(c)};this.showhide(this.dropmenuobj.style,b,c);this.dropmenuobj.x=this.getposOffset(c,"left");this.dropmenuobj.y=this.getposOffset(c,"top");this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(c,"rightedge")+"px";this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(c,"bottomedge")+c.offsetHeight+1+"px";this.previousmenuitem=c;this.positionshim()}},contains_firefox:function(d,c){while(c.parentNode){if((c=c.parentNode)==d){return true}}return false},dynamichide:function(c,b){var a=window.event?window.event:c;if(this.ie&&!this.dropmenuobj.contains(a.toElement)){this.delayhidemenu(b)}else{if(this.firefox&&c.currentTarget!=a.relatedTarget&&!this.contains_firefox(a.currentTarget,a.relatedTarget)){this.delayhidemenu(b)}}},delayhidemenu:function(a){this.delayhide=setTimeout(function(){tabdropdown.dropmenuobj.style.visibility="hidden";if(a.parentNode.className.indexOf("default")==-1){a.parentNode.className=""}},this.disappeardelay)},clearhidemenu:function(){if(this.delayhide!="undefined"){clearTimeout(this.delayhide)}},positionshim:function(){if(this.enableiframeshim&&typeof this.shimobject!="undefined"){if(this.dropmenuobj.style.visibility=="visible"){this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px";this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px";this.shimobject.style.left=this.dropmenuobj.style.left;this.shimobject.style.top=this.dropmenuobj.style.top}this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")?"block":"none"}},hideshim:function(){if(this.enableiframeshim&&typeof this.shimobject!="undefined"){this.shimobject.style.display="none"}},isSelected:function(a){var b=a.replace("http://"+a.hostname,"").replace(/^\//,"");return(tabdropdown.currentpageurl==b)},init:function(e,c){this.standardbody=(document.compatMode=="CSS1Compat")?document.documentElement:document.body;var f=document.getElementById(e).getElementsByTagName("a");for(var d=0;d<f.length;d++){if(f[d].getAttribute("rel")){var a=f[d].getAttribute("rel");document.getElementById(a).firstlink=document.getElementById(a).getElementsByTagName("a")[0];f[d].onmouseover=function(h){var g=typeof h!="undefined"?h:window.event;tabdropdown.dropit(this,g,this.getAttribute("rel"))}}if(c=="auto"&&typeof b=="undefined"&&this.isSelected(f[d].href)){f[d].parentNode.className+=" selected default";var b=true}else{if(parseInt(c,10)==d){f[d].parentNode.className+=" selected default"}}}}};function Yetii(){this.defaults={id:null,active:1,timeout:null,interval:null,tabclass:"tab",activeclass:"active"};for(var c in arguments[0]){this.defaults[c]=arguments[0][c]}this.getTabs=function(){var e=[];var d=document.getElementById(this.defaults.id).getElementsByTagName("*");var g=new RegExp("(^|\\s)"+this.defaults.tabclass.replace(/\-/g,"\\-")+"(\\s|$)");for(var f=0;f<d.length;f++){if(g.test(d[f].className)){e.push(d[f])}}return e};this.links=document.getElementById(this.defaults.id+"-nav").getElementsByTagName("a");this.show=function(d){for(var e=0;e<this.tabs.length;e++){this.tabs[e].style.display=((e+1)==d)?"block":"none";this.links[e].className=((e+1)==d)?this.defaults.activeclass:""}};this.rotate=function(e){this.show(this.defaults.active);this.defaults.active++;if(this.defaults.active>this.tabs.length){this.defaults.active=1}var d=this;this.defaults.timeout=setTimeout(function(){d.rotate(e)},e*1000)};this.tabs=this.getTabs();this.show(this.defaults.active);var b=this;for(var a=0;a<this.links.length;a++){this.links[a].customindex=a+1;this.links[a].onclick=function(){if(b.defaults.timeout){clearTimeout(b.defaults.timeout)}b.show(this.customindex);return false}}if(this.defaults.interval){this.rotate(this.defaults.interval)}}AIM={frame:function(g){var f="aim_upload_iframe_target";if(!$(f)){var e=$(document.createElement("div"));e.setAttribute("style","display:none");e.update('<iframe src="about:blank" style="display:none" id="'+f+'" name="'+f+'" onload="AIM.loaded(\''+f+"')\"></iframe>");document.body.appendChild(e);var b=document.createElement("div");b.setAttribute("id","aim_upload_dump");e.appendChild(b);AIM.dump=$(b)}var a=$(f);if(g&&typeof(g.onComplete)=="function"){a.onComplete=g.onComplete}return f},form:function(b,a){b.setAttribute("target",a);b.setAttribute("enctype","multipart/form-data")},submit:function(a,b){AIM.form($(a),AIM.frame(b));return(b&&typeof(b.onStart)=="function")?b.onStart():true},loaded:function(f){var b=$(f);var e=null;if(b.contentDocument){e=b.contentDocument}else{if(b.contentWindow){e=b.contentWindow.document}else{e=window.frames[f].document}}if(e.location.href=="about:blank"){return}if(typeof(b.onComplete)=="function"){var c=e.body;AIM.dump.update("<div>"+c.innerHTML+"</div>");c=AIM.dump;console.log("AIM response: ",c);AIM.attachProperties.bind(c).call();try{b.onComplete(c)}catch(a){console.error("AIM onComplete threw an error: ",a)}AIM.dump.update()}},attachProperties:function(){this.getHeader=this.down().hasClassName;this.responseText=this.innerHTML;this.responseXML=this.down()}};var horizontal_offset="9px";var vertical_offset="0";var ie=document.all;var ns6=document.getElementById&&!document.all;function getposOffset(d,c){var b=(c=="left")?d.offsetLeft:d.offsetTop;var a=d.offsetParent;while(a!=null){b=(c=="left")?b+a.offsetLeft:b+a.offsetTop;a=a.offsetParent}return b}function iecompattest(){return(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body}function clearbrowseredge(d,b){var a=(b=="rightedge")?parseInt(horizontal_offset)*-1:parseInt(vertical_offset)*-1;var c=null;if(b=="rightedge"){c=ie&&!window.opera?iecompattest().scrollLeft+iecompattest().clientWidth-30:window.pageXOffset+window.innerWidth-40;dropmenuobj.contentmeasure=dropmenuobj.offsetWidth;if(c-dropmenuobj.x<dropmenuobj.contentmeasure){a=dropmenuobj.contentmeasure+d.offsetWidth+parseInt(horizontal_offset)}}else{c=ie&&!window.opera?iecompattest().scrollTop+iecompattest().clientHeight-15:window.pageYOffset+window.innerHeight-18;dropmenuobj.contentmeasure=dropmenuobj.offsetHeight;if(c-dropmenuobj.y<dropmenuobj.contentmeasure){a=dropmenuobj.contentmeasure-d.offsetHeight}}return a}function showhint(d,c,b,a){if((ie||ns6)&&document.getElementById("hintbox")){dropmenuobj=document.getElementById("hintbox");dropmenuobj.innerHTML=d;dropmenuobj.style.left=dropmenuobj.style.top=-500;if(a!=""){dropmenuobj.widthobj=dropmenuobj.style;dropmenuobj.widthobj.width=a}dropmenuobj.x=getposOffset(c,"left");dropmenuobj.y=getposOffset(c,"top");dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(c,"rightedge")+c.offsetWidth+"px";dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(c,"bottomedge")+"px";dropmenuobj.style.visibility="visible";c.onmouseout=hidetip}}function hidetip(a){dropmenuobj.style.visibility="hidden";dropmenuobj.style.left="-500px"}function createhintbox(){var a=document.createElement("div");a.setAttribute("id","hintbox");document.body.appendChild(a)}if(window.addEventListener){window.addEventListener("load",createhintbox,false)}else{if(window.attachEvent){window.attachEvent("onload",createhintbox)}else{if(document.getElementById){window.onload=createhintbox}}}if(typeof Effect=="undefined"){throw ("accordion.js requires including script.aculo.us' effects.js library!")}var accordion=Class.create();accordion.prototype={showAccordion:null,currentAccordion:null,duration:null,effects:[],animating:false,initialize:function(b,c){if(!$(b)){throw (b+" doesn't exist!");return false}b=$(b);this.options=Object.extend({resizeSpeed:8,classNames:{toggle:"accordion_toggle",toggleActive:"accordion_toggle_active",content:"accordion_content"},defaultSize:{height:null,width:null},direction:"vertical",onEvent:"click",onComplete:function(){},onStart:function(){}},c||{});this.duration=((11-this.options.resizeSpeed)*0.15);var a=b.immediateDescendants().filter(function(d){return d.hasClassName(this.options.classNames.toggle)}.bind(this));a.each(function(d){Event.observe(d,this.options.onEvent,this.activate.bind(this,d),false);if(this.options.onEvent=="click"){d.onclick=function(){return false}}if(this.options.direction=="horizontal"){var e={width:"0px",display:"none"}}else{var e={height:"0px",display:"none"}}this.currentAccordion=$(d.next(0)).setStyle(e)}.bind(this))},activate:function(a){if(this.animating){return false}try{this.options.onStart(this.currentAccordion)}catch(b){console.error(b)}this.effects=[];this.currentAccordion=$(a.next(0));this.currentAccordion.setStyle({display:"block"});this.currentAccordion.previous(0).addClassName(this.options.classNames.toggleActive);if(this.options.direction=="horizontal"){this.scaling=$H({scaleX:true,scaleY:false})}else{this.scaling=$H({scaleX:false,scaleY:true})}if(this.currentAccordion==this.showAccordion){this.deactivate()}else{this._handleAccordion()}},deactivate:function(){var a=$H({duration:this.duration,scaleContent:false,transition:Effect.Transitions.sinoidal,queue:{position:"end",scope:"accordionAnimation"},scaleMode:{originalHeight:this.options.defaultSize.height?this.options.defaultSize.height:this.currentAccordion.scrollHeight,originalWidth:this.options.defaultSize.width?this.options.defaultSize.width:this.currentAccordion.scrollWidth},beforeStart:function(){this.currentAccordion.setStyle({overflow:"hidden"})}.bind(this),afterFinish:function(){this.showAccordion.setStyle({display:"none"});try{this.options.onComplete(this.currentAccordion)}catch(b){console.error(b)}this.showAccordion=null;this.animating=false}.bind(this)});this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);new Effect.Scale(this.showAccordion,0,a.update(this.scaling).toObject())},_handleAccordion:function(){var a=$H({sync:true,scaleFrom:0,scaleContent:false,transition:Effect.Transitions.sinoidal,scaleMode:{originalHeight:this.options.defaultSize.height?this.options.defaultSize.height:this.currentAccordion.scrollHeight,originalWidth:this.options.defaultSize.width?this.options.defaultSize.width:this.currentAccordion.scrollWidth}});a.merge(this.scaling);this.effects.push(new Effect.Scale(this.currentAccordion,100,a.update(this.scaling).toObject()));if(this.showAccordion){this.showAccordion.previous(0).removeClassName(this.options.classNames.toggleActive);a=$H({sync:true,scaleContent:false,transition:Effect.Transitions.sinoidal});a.merge(this.scaling);this.effects.push(new Effect.Scale(this.showAccordion,0,a.update(this.scaling).toObject()))}new Effect.Parallel(this.effects,{duration:this.duration,queue:{position:"end",scope:"accordionAnimation"},beforeStart:function(){this.animating=true;if(this.showAccordion){this.showAccordion.setStyle({overflow:"hidden"})}}.bind(this),afterFinish:function(){if(this.showAccordion){this.showAccordion.setStyle({display:"none"})}$(this.currentAccordion).setStyle({height:"auto",overflow:"visible"});this.options.onComplete(this.currentAccordion);this.showAccordion=this.currentAccordion;this.animating=false}.bind(this)})}};if(typeof app=="undefined"){app={account:{addAddrLine:function(d,f){var g=d.up();var e=g.up().up();var c=app.$N("dt");var a=app.$N("dd");var h=f+"addressLines";var b=1;for(i=0;item=e.down("input",i);i++){if(item.getAttribute("name").startsWith(h)){b++}}c.update('<label for="'+h+b+'" />Line '+b+"</label>");a.update('<input id="'+h+b+'" type="text" size="30" name="'+h+b+'" />');g.up().insertBefore(c,g);g.up().insertBefore(a,g)},addPhoneLine:function(e,g){var c=e.up();var f=c.up().up();var d=app.$N("dt");var a=app.$N("dd");var h=g+"phone_";var b=1;for(i=0;item=f.down("input",i);i++){if(item.getAttribute("name").startsWith(h)){b++}}h=g+"phone_"+b;d.update("<input type='text' size='10' name='"+h+"' value='business' 'title='phone number label'/>");a.update("<input type='text' size='18' maxlength='20' name='"+h+"' + title='Format: 555-555-5555' />");c.up().insertBefore(d,c);c.up().insertBefore(a,c)},changePassword:function(a){$("passwd").disabled=!a;$("confirmPasswd").disabled=!a}},design:{updatePreview:function(a){a.stop();var b=$("imageUploadForm");AIM.submit(b,{onComplete:function(f){var d=f.responseXML;var e=f.responseXML.down();if(e.src){$("previewImg").src=e.src;$("previewImg").alt=e.alt;if(d.childNodes.length>2){$("topbottom").appendChild(d.childNodes[2])}app.dialog.close();$("updating").fade();this.activateNextBlock()}else{app.dialogMsg(e)}}.bind(app.design)});$("updating").appear();var c=a.element().next();if(c.hasClassName("spinner")){c.appear()}b.submit()},updatePartialPreview:function(a){var c=$("designForm");var b=this.updateURL;$("updating").appear();new Ajax.Request(b,{parameters:c.serialize(),onComplete:function(f){var e=$("asyncLoadContainer");e.update(f.responseText);var d=new Image();d.src=e.down("img").src;$("previewImg").src=d.src;$("topbottom").update(e.down("div"));e.update("");$("updating").fade()}});$("formFields").down(".formField_acc_selected").addClassName("complete")},toggleOverlay:function(d,a){var c={duration:0.3,queue:"end"};c.to=a?0.5:0;var b=$("blockOverlayContainer").down("div",d);if(!b){return}if(b.visible()&&!a&&this.getOverlayOptVal()!="show"){Effect.Fade(b,c)}else{if(!b.visible()&&a&&this.getOverlayOptVal()!="hide"){Effect.Appear(b,c)}}},activateBlock:function(c,a){var b=$("formFields").down(".formField_acc_header",c);console.log("block: ",b);app.design.formAccordion.activate(b)},hideOverlays:function(){$("blockOverlayContainer").down().childElements().invoke("hide")},getOverlayOptVal:function(){return $A($("designForm").overlayDisplayOpt).find(function(a){return a.checked}).value},toggleOverlays:function(e){var c=$("formFields").select(".formField_acc_header.formField_acc_selected");var b=this.getOverlayOptVal();var a=$("formFields").select(".formField_acc_header");var d=this.toggleOverlay.bind(this);for(i=0;i<a.length;i++){if(a[i].hasClassName("formField_acc_selected")){d(i,b!="hide")}else{d(i,b=="show")}}},activateNextBlock:function(b){var c=$("formFields").down(".formField_acc_selected");c.addClassName("complete");var a=c.next(".formField_acc_header");if(a){app.design.formAccordion.activate(a)}else{app.design.formAccordion.activate($("formFields").down(".formField_acc_selected"))}},waitForAsync:function(a){if(Ajax.activeRequestCount>0){if(a){a.stop();app.design.asyncEvent=a}window.setTimeout(app.design.waitForAsync,1000)}else{if(typeof a!="object"){a=app.design.asyncEvent;var b=a.element();if(b.tagName=="IMG"){b=b.up()}window.location=b.href}}},toggleAccordion:function(){var a=$("formFields");var b=a.visible()?"auto":"240px";$("image-content").setStyle({marginLeft:b});$("btnTLC").setStyle({marginLeft:b});a.toggle()},toggleInstructions:function(b){var a=$("instructions");a.toggle();b.stop()},showFilesDialog:function(b){b.stop();var a=b.element();var c=app.showDialog(a,{title:"Select or Upload File",minWidth:550,minHeight:600,onShow:function(e){$("imagesList").select(".list td a").invoke("observe","click",app.design.dialogFileSelect);$("uploadImageFile").observe("click",app.design.updatePreview);var d=$("imageUploadForm");d.appendChild(app.$N("input",{type:"hidden",name:"ppid",value:$("ppid").value}));d.appendChild(app.$N("input",{type:"hidden",name:"ppgid",value:$("ppgid").value}));$("filename").name=e.forField;e.content.down(".paginateButtonsMyAccount").select("a").invoke("observe","click",app.design.showFilesDialog);e.content.down(".xhttpcolumn").select("a").invoke("observe","click",app.design.showFilesDialog)}});c.forField=a.previous().name},dialogFileSelect:function(b){b.stop();var a=b.element();if(a.tagName!="A"){a=a.up()}app.design.hideOverlays();new Ajax.Request(a.href,{parameters:{field:app.dialog.forField,ppid:$("ppid").value,ppgid:$("ppgid").value},onComplete:function(c){$("previewImg").src=c.responseText;$("updating").fade();this.activateNextBlock()}.bind(app.design)});app.dialog.close();$("updating").appear()},saveAsDialog:function(a){a.stop();var b=new Window({title:"Save a Copy",minWidth:280,minHeight:120});b.setContent("saveAsDialog",true,false);b.content.down(".message").hide();b.showCenter(true);app.dialog=b},saveAs:function(a){var b=a.element();new Ajax.Request(b.action,{parameters:b.serialize(),onSuccess:function(e){app.dialog.close();var d=e.responseText.evalJSON().model;app.showMessage(d.message);$("designNameSpan").update(d.designName);$("ppid").setValue(d.ppid)},onFailure:function(d){app.dialogMsg(d,true)},onComplete:function(d){app.dialog.content.down(".spinner").fade()}});a.stop();var c=b.down(".spinner");if(c.hasClassName("spinner")){c.appear()}},imageDir:null,fieldOver:function(b){var a=b.element();if(a.tagName!="IMG"){a=a.down()}a.src=app.design.imageDir+a.className+"-over.png"},fieldOut:function(b){var a=b.element();if(a.tagName!="IMG"){a=a.down()}a.src=app.design.imageDir+a.className+".png"}},order:{updateOptions:function(a){var b=a.element();console.log("updateOptions: form="+b);var c=b.down(".spinner");if(c){c.appear()}new Ajax.Request(b.action,{parameters:b.serialize(),onSuccess:function(e){if(app.ajaxRedirect(e)){return}if(app.ajaxDialog(e)){return}if(app.order.updateMultiSection(e)){return}var g=b.up(".options");var d=g;if(e.getHeader("agmMultiForm")){console.log("multiform");g=g.down();var f=app.$N("div",{});g.insert({after:f});f.update(e.responseText);d=g.next()}else{d=g.previous(".current-status");d.update(e.responseText);app.order.registerEventHandlers(d.up(".section"));console.log("normal update",d)}Effect.BlindDown(d);Effect.BlindUp(g)},onFailure:app.showErrorMsg,onComplete:function(){c.fade()}});a.stop()},refreshPrintOptions:function(b){var a=b.element();console.log(a);var c=a.next(".spinner-r").appear();new Ajax.Updater({success:"printOptions"},this.refreshPrintOptionsURL,{method:"get",parameters:$("printOptionsForm").serialize(),evalScripts:true,onFailure:function(d){c.fade();app.showErrorMsg(d)}})},refreshPrintOptionsURL:null,updateMultiSection:function(b){if(!b.getHeader("agmMultiSection")){return false}var a=app.$N("div",{},b.responseText).down();console.log("multiSection",a);a.immediateDescendants().each(function(d){var e=$(d.getAttribute("name"));console.log(e);e.update().insert({top:d});if(!e.visible()){Effect.BlindDown(e)}var c=e.up(".section, .section2");if(!c){return}app.order.registerEventHandlers(c);e=e.next(".options");if(e.visible()){Effect.BlindUp(e)}});if(app.dialog){app.dialog.close()}console.log("done multisection update");return true},registerEventHandlers:function(a,b){if(!b){b=a}a.select("a.nav-link").invoke("observe","click",app.navigateToAnchor.curry(b,".ac"));a.select(".current-status a.load").invoke("observe","click",app.loadContentInSection.curry(".current-status"));a.select(".options a.load").invoke("observe","click",app.loadContentInSection.curry(".options"))},modifyDesignDialog:function(a){a.stop();var b=a.element();if(b.tagName=="IMG"){b=b.up()}app.showDialog(b,{title:"Modify Design",minWidth:650,minHeight:420,onShow:function(c){c.content.down("form").observe("submit",this.modifyDesign);app.dialog=c;b.next().hide()}.bind(app.order)})},modifyDesign:function(a){a.stop();var b=a.element();new Ajax.Request(b.action,{parameters:b.serialize(),onComplete:function(d){var c=d.responseText.evalJSON().model;if(c.redirect){window.location=c.url}else{new Ajax.Updater(app.dialog.content,c.url,{method:"GET",evalScripts:true})}}});b.down(".spinner").appear()},selectDesign:function(b){b.stop();var a=b.findElement("a");new Ajax.Request(a.href,{onComplete:function(c){$("designFlowContents").update(c.responseText);app.dialog.close()}})},uploadDesign:function(a){a.stop();var b=a.findElement("form");AIM.submit(b,{onComplete:function(d){var e=d.down();if(e.hasClassName("error")){app.dialogMsg(e)}else{$("designFlowContents").update().appendChild(d.down());app.dialog.close()}}.bind(app.order)});var c=b.down(".spinner");if(c.hasClassName("spinner")){c.appear()}b.submit()}},help:{openPopup:function(a){a.stop();var b=window.open(a.element().href,"help","width=650, height=610, scrollbars=yes");if(b.focus){b.focus()}}},printing:{updatePrice:function(){var b="not found";var a=$("printFamily").getValue()+".";a+=$("pageSize").getValue()+".";a+=$("colors").getValue()+".";a+=$("paperType").getValue()+".";a+=$("printTurnaround").getValue()+".";a+=$("printShipQuantity").getValue();b=priceMap[a];$("priceSpan").update(b)}},navigateToAnchor:function(d,b,f){var c=f.element();if(!b){b=".section"}var j=c.up(b);var e=c.getAttribute("href");e=e.substring(e.indexOf("#")+1,e.length);var h=d.select('a[name="'+e+'"]')[0];var g=h.up(b);if(h.href){new Ajax.Request(h.href,{method:"get",onSuccess:function(a){h.nextSiblings().invoke("remove");h.insert({after:a.responseText});Effect.BlindDown(g);Effect.BlindUp(j)},onFailure:app.showErrorMsg,onComplete:function(){c.removeClassName("spinner-r")}})}else{Effect.BlindDown(g);Effect.BlindUp(j)}f.stop()},loadContentInSection:function(d,c){var b=c.element();var e=d?b.up(d):null;new Ajax.Request(b.href,{method:"get",onSuccess:function(f){var a=$(b.target).update(f.responseText);if(!a.visible()){Effect.BlindDown(a)}if(e){Effect.BlindUp(e)}},onFailure:app.showErrorMsg,onComplete:function(){b.removeClassName("spinner-r")}});c.stop()},editText:function(d){var c=d.element();if(c.tagName!="INPUT"){var h=c.next();var f=c.getText();h.value=f;h.size=f.length;c.hide();h.show();h.focus()}else{var b=c.previous();var a=c.value;if(a.length<1){a="My Design"}b.update(a);c.hide();b.show();var g={text:a,field:c.id};var e=$("ppid");if(e){g.ppid=e.value}new Ajax.Request(c.name,{parameters:g,onFailure:app.showErrorMsg,onSuccess:app.showMessage})}},ajaxRedirect:function(a){if(!a.getHeader("agmRedirect")){return false}window.location=a.getHeader("agmURL");return true},ajaxDialog:function(xhr){if(!xhr.getHeader("agmDialog")){return false}var win=(app.dialog&&app.dialog.visible)?app.dialog:new Window();app.dialog=win;win.setHTMLContent(xhr.responseText);win.getContent().select("script").each(function(s){try{eval(s.innerHTML)}catch(ex){console.error(ex)}});win.setDestroyOnClose(true);console.log("Dialog: ",win);if(!win.visible){win.showCenter(true)}return true},dialogMsg:function(d,b){var a=app.dialog.getContent().down(".message");if(d.responseXML){d=app.$N("div",{},d.responseText).down()}if(d.tagName){if(a){if(b){a.addClassName("error")}a.update(d.innerHTML);if(!a.visible()){a.appear()}}else{app.dialog.getContent().insert(d,"first")}return}if(!a){a=app.$N("div",{"class":"message"});app.dialog.getContent().insert(a,"first")}if(b||d.tagName&&d.hasClassName("error")){a.addClassName("error")}var c=d.tagName?d.getText():d.responseText?d.responseText:d;a.update(c);if(!a.visible()){a.show()}console.log("Dialog error msg: ",c)},closeDialog:function(){if(!app.dialog){return}app.dialog.close();app.dialog=null},showErrorMsg:function(a){app.showMessage(a,"error")},showMessage:function(c,a){if(app.dialog){app.dialogMsg(c);return}var b=$("mainMsgContainer");if(!b){return}if(c.responseXML){c=app.$N("div",{},c.responseText).down()}if(c.tagName){b.update().insert(c,"first");b.scrollIntoView();return}if(typeof c!="string"){c=c.responseText}if(!a){a=""}b.update().appendChild(app.$N("div",{"class":"message "+a},c));b.scrollIntoView()},popUpText:function(c){var b=c.element();var a=b.previous("textarea");a.value=b.value;a.show();a.focus()},popUpTextDone:function(b){var a=b.element();var c=a.next("textarea");c.value=a.value},expandableFieldset:function(a){var b=function(c){c=$(c);if(c.tagName!="FIELDSET"){c=c.down("fieldset")}var d=c.down("legend");var e=d.next();e.addClassName("toggle-handle");d.addClassName(e.visible()?"open":"closed");d.observe("click",app.toggleHandle)};if(window.document){b(a)}else{Event.observe(window,"load",b.curry(a))}},toggleHandle:function(a){if(a.element){a=a.element()}Effect.toggle(a.next(".toggle-handle"),"blind",{duration:0.1,queue:"end"});a.toggleClassName("closed");a.toggleClassName("open")},showDialog:function(c,b){var f=c.next();if(f){f.appear()}if(!b.destroyOnClose){b.destroyOnClose=true}var a=(app.dialog&&app.dialog.visible)?app.dialog:null;if(a){a.close();b.showEffect=Element.show;console.log("showDialog: changed opts:",b)}var e=new Window(b);e.eventSource=c;app.dialog=e;var d=c.href+"?foo="+(new Date().getTime());e.setAjaxContent(d,{method:"GET",onComplete:function(){var g=this.eventSource.next();if(g&&g.tagName=="IMG"){g.fade()}}},true,true);return e},toggleFormFields:function(a,b){$(a).select("input").each(function(c){c.disabled=b})},$N:function(b,a,c){var d=Element.extend(document.createElement(b));if(a){a=$H(a);a.each(function(e){if(e.key=="class"){d.className=e.value}else{d.setAttribute(e.key,e.value)}})}if(c){if(typeof c=="function"){c=c()}if(c instanceof Array){$A(c).each(function(e){d.appendChild(e)})}else{if(c.nodeType){d.appendChild(c)}else{d.update(c)}}}return d}}}if(typeof(console)=="undefined"){console={log:function(){},debug:function(){},error:function(){}}}if(!console.debug){console.debug=console.log}Ajax.Responders.register({onException:function(b,a){console.error("Uncaught exception",a,b)}});Element.addMethods({lastChildElement:function(a){var b=$(a).childElements();return b[b.length-1]},getText:function(a){return a.textContent||a.innerText||a.innerHTML}});
