AC.OverlayPanel=Class.create();Object.extend(AC.OverlayPanel.prototype,AC.ViewMaster.Viewer.prototype);
Object.extend(AC.OverlayPanel.prototype,Event.Listener);Object.extend(AC.OverlayPanel.prototype,Event.Publisher);
Object.extend(AC.OverlayPanel.prototype,{closeBtn:null,overlay:null,overlayShadow:null,overlayId:"",overlayClasses:"",overlayContents:"",overlayShadowId:"",overlayShadowClasses:"",_overlayShadowSrc:null,_defaultOverlayShadowSrc:"./global/elements/overlay/overlay_panel_default.png",defaultOverlayShadowSrc:function(){var d=document.getElementsByTagName("base")[0],f=d?d.href:"",e=this._defaultOverlayShadowSrc;
if(!f||(f&&f.lastIndexOf("/")!==(f.length-1))){e="/"+e}return f+e},order:0,setOverlayShadowImageSrc:function(b){this._overlayShadowSrc=(b)?b:this.defaultOverlayShadowSrc();
this.overlayshadowImage.src=this._overlayShadowSrc;if(this.isIE7()){this.overlayshadowImage.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this._overlayShadowSrc+"',sizingMethod='scale')";
this.overlayshadowImage.src="/global/elements/blank.gif"}},overlayShadowImageSrc:function(){return(this._overlayShadowSrc)?this._overlayShadowSrc:this.defaultOverlayShadowSrc()
},initialize:function(h,f,g,e){this.overlayId="OverlayPanel";this.overlayShadowId="OverlayPanelShadow";
this.createOverlay();if(typeof(e)=="undefined"){e={}}if(e.silentTriggers==null){e.silentTriggers=true
}g=g||"OverlayPanel";AC.ViewMaster.Viewer.prototype.initialize.call(this,null,this.swapViewElement,g,e);
this.options.shouldAnimateContentChange=false;this.bindPositionOverlay=this.positionOverlay.bind(this)
},createOverlay:function(){this.closeBtnContainer=document.createElement("div");
this.closeBtnContainer.className="closeButtonContainer";this.closeBtn=document.createElement("a");
this.closeBtn.href="#close";this.closeBtn.className="close";this.closeBtn.appendChild(document.createTextNode("Close"));
this.closeBtnContainer.appendChild(this.closeBtn);Event.observe(this.closeBtn,"click",this.close.bindAsEventListener(this),false);
this.swapViewElement=Builder.node("div",{"class":"overlayPanelContent"});this.overlayshadowImage=Builder.node("img",{src:this.overlayShadowImageSrc(),alt:"",border:0,"class":"overlayPanelShadowImage"});
if(this.isIE7()){this.overlayshadowImage.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.overlayShadowImageSrc()+"',sizingMethod='scale')";
this.overlayshadowImage.src="/global/elements/blank.gif"}this.overlayshadow=Builder.node("div",{id:this.overlayShadowId,"class":"overlaypanelshadow "+this.overlayShadowClasses},[this.overlayshadowImage,this.swapViewElement]);
this.overlay=$(Builder.node("div",{id:this.overlayId,"class":"overlaypanel "+this.overlayClasses,style:"left:-99999px; top:0;"},[this.closeBtnContainer,this.overlayshadowImage,this.swapViewElement]))
},isIE7:function(){return(AC.Detector.isIEStrict()&&navigator.appVersion.indexOf("MSIE 6.0")>=0)
},setDefaults:function(){this.defaultWidth=this.overlay.offsetWidth;this.padleft=parseInt(Element.getStyle(this.overlay,"marginLeft").replace(/px/i,""));
this.padright=parseInt(Element.getStyle(this.overlay,"marginRight").replace(/px/i,""));
this.defaultHeight=this.overlay.offsetHeight;this.padtop=parseInt(Element.getStyle(this.overlay,"marginTop").replace(/px/,""));
this.padbottom=parseInt(Element.getStyle(this.overlay,"marginBottom").replace(/px/,""))
},setItemAttributes:function(){},registerOverlay:function(){Event.observe(document,"click",this.onClick.bindAsEventListener(this),false)
},isContentLoaded:function(c,d){return false},superContentDidLoad:AC.ViewMaster.Viewer.prototype.contentDidLoad,contentDidLoad:function(f,d){document.body.appendChild(this.overlay);
this.superContentDidLoad(f,d);f.content.show();f.content.style.visibility="hidden";
f.content.removeClassName("overlaydescription");this.overlay.addClassName(f.id);
this.setOriginFromEvent(this.currentSectionEvent);this.setDefaults();var e=this;
this._isDisplaying=true;setTimeout(function(){e._display(f)},100)},_isDisplaying:false,_display:function(c){this.setDefaults();
this.setDimensions(this.currentSectionEvent,c.content);var d=this;return this.pop(this.defaultWidth,this.popPosition().top,this.defaultHeight,this.popPosition().left)
},superWillShow:AC.ViewMaster.Viewer.prototype.willShow,willShow:function(d,f,e){return this.superWillShow(d,f,e)
},superTriggerClicked:AC.ViewMaster.Viewer.prototype.triggerClicked,triggerClicked:function(d,c){if(d){Event.stop(d)
}this.superTriggerClicked(d,c);if(this._isDisplaying){return}this.setOverlayShadowImageSrc(null);
this._popPosition=null;this.currentSectionEvent=d},superShouldAnimateContentChange:AC.ViewMaster.Viewer.prototype.shouldAnimateContentChange,shouldAnimateContentChange:function(f,d,e){if(AC.Detector.isMobile()){return false
}return this.superShouldAnimateContentChange(f,d,e)},willAnimate:function(e,h,f,g){},setOriginFromEvent:function(b){if(!b){return
}this.left=b.pageX||b.clientX+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft);
this.top=b.pageY||b.clientY+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)
},setDimensions:function(d,f){this._width=(f.offsetWidth>80)?80:f.offsetWidth;this.defaultWidth=f.offsetWidth;
var e=null;if(d){e=Element.cumulativeOffset(d.element())}if(e){this.left=e.left
}this.left=this.left||document.body.getDimensions().width/2;this.defaultHeight=f.offsetHeight;
this._height=Math.round((this._width*this.defaultHeight)/this.defaultWidth);if(e){this.top=e.top
}this.top=this.top||document.body.getDimensions().height/2;this.padleft=parseInt(Element.getStyle(f,"marginLeft").replace(/px/i,""));
this.padright=parseInt(Element.getStyle(f,"marginRight").replace(/px/i,""));this.padtop=parseInt(Element.getStyle(f,"marginTop").replace(/px/,""));
this.padbottom=parseInt(Element.getStyle(f,"marginBottom").replace(/px/,""))},windowSize:function(){var h=document.clientWidth||(document.documentElement.clientWidth||document.body.clientWidth);
var e=document.clientHeight||(document.documentElement.clientHeight||document.body.clientHeight);
var f=window.pageXOffset||(window.document.documentElement.scrollLeft||window.document.body.scrollLeft);
var g=window.pageYOffset||(window.document.documentElement.scrollTop||window.document.body.scrollTop);
if(AC.Detector.isMobile()){h=parseInt(980);e=parseInt(1212)}return{width:h,height:e,x:f,y:g}
},popPosition:function(e){if(!this._popPosition||e){var g,h=null;var f=this.windowSize();
g=f.x+(f.width-this.defaultWidth-this.padleft-this.padright)/2;if(f.width<this.defaultWidth+this.padleft+this.padright){g=f.x-(this.padtop-this.closeBtnContainer.offsetWidth)
}h=(f.y+(f.height-this.defaultHeight-this.padtop-this.padbottom)/2);if(f.height<this.defaultHeight+this.padtop+this.padbottom){h=f.y-(this.padtop-this.closeBtnContainer.offsetHeight)
}if(h<0||h<20){h=20}this._popPosition={left:g,top:h}}return this._popPosition},setWidth:function(b){this.defaultWidth=b;
this.overlay.style.width=b+"px"},width:function(){return this.defaultWidth},setHeight:function(b){this.defaultHeight=b;
this.overlay.style.height=b+"px"},height:function(){return this.defaultHeight},prepPop:function(){},beforePop:function(){Element.addClassName(this.overlay,"isanim");
Element.addClassName(this.overlayshadow,"isanim");Element.addClassName(this.overlay,"popped");
Element.addClassName(this.overlayshadow,"popped");if(AC.Detector.isIEStrict()){}this.dispatchEvent("beforePop",this)
},pop:function(g,i,h,j,k){Element.setOpacity(this.overlay,0);Element.setOpacity(this.overlayshadow,0);
this._height=this._width*h/g;this.overlay.style.width=this._width+"px";this.overlay.style.height=this._height+"px";
this.overlay.style.left=this.left-this.padleft+"px";this.overlay.style.top=this.top-this.padtop+"px";
this.overlay.style.display="";var l=(100*g)/this._width;new Effect.Parallel([new Effect.MoveBy(this.overlay,i-this.top+this.padtop,j-this.left+this.padleft,{sync:true}),new Effect.Scale(this.overlay,l,{sync:true,scaleContent:false,scaleMode:{originalWidth:this._width,originalHeight:this._height}}),new Effect.Appear(this.overlay,{sync:true})],{duration:0.3,beforeStart:this.beforePop.bind(this),afterFinish:this.afterPop.bind(this)})
},afterPop:function(c,d){this.closeBtnContainer.style.display="block";this.currentSection.content.style.visibility="visible";
this.setPoppedClass();Event.observe((document.onresize?document:window),"resize",this.bindPositionOverlay);
this.dispatchEvent("afterPop",this)},positionOverlay:function(){var b=this.popPosition(true);
this.overlay.setStyle({top:b.top+"px",left:b.left+"px"})},superWillClose:AC.ViewMaster.Viewer.prototype.willClose,willClose:function(){this.dispatchEvent("beforeClose",this);
this.superWillClose(this,this.currentSection);if(this.currentSection){this.currentSection.willClose()
}},resetOverlay:function(){this.overlay.style.width="";this.overlay.style.height="";
this.overlay.setOpacity("")},setPoppedClass:function(){Element.removeClassName(this.overlay,"isanim");
Element.removeClassName(this.overlayshadow,"isanim");Element.addClassName(this.overlay,"popped");
Element.addClassName(this.overlayshadow,"popped")},setIsanimClass:function(){Element.addClassName(this.overlay,"isanim");
Element.addClassName(this.overlayshadow,"isanim");Element.removeClassName(this.overlay,"popped");
Element.removeClassName(this.overlayshadow,"popped")},close:function(f){if(f){Event.stop(f)
}var j=this.defaultWidth;var h=this.overlay.offsetLeft;var g=this.defaultHeight;
var i=this.overlay.offsetTop;if(h>=0&&i>=0){this.willClose(this);setTimeout(this._closeOpenOverlay.bind(this,j,h,g,i),10)
}},_closeOpenOverlay:function(f,h,g,i){if(!AC.Detector.isMobile()){var j=(100*this._width)/f;
new Effect.Parallel([new Effect.MoveBy(this.overlay,this.top-this.padtop-i,this.left-this.padleft-h,{sync:true}),new Effect.Scale(this.overlay,j,{sync:true,scaleContent:false,scaleMode:{originalWidth:f,originalHeight:g}}),new Effect.Fade(this.overlay,{sync:true})],{duration:0.3,afterFinish:this.afterClose.bind(this)});
Event.stopObserving((document.onresize?document:window),"resize",this.bindPositionOverlay)
}else{this.afterClose()}},afterClose:function(){Element.removeClassName(this.overlay,"isanim");
Element.removeClassName(this.overlayshadow,"isanim");Element.removeClassName(this.overlay,"popped");
Element.removeClassName(this.overlayshadow,"popped");this.overlay.removeClassName(this.currentSection.id);
this.setOverlayShadowImageSrc(null);this.overlay.style.width="";this.overlayshadow.style.width="";
this.overlay.style.height="";this.overlayshadow.style.height="";this.overlay.style.left="-99999px";
this.overlayshadow.style.left="";this.overlay.style.top="0";this.overlayshadow.style.top="";
this.overlay.style.display="";this.overlayshadow.style.display="";this.dispatchEvent("afterClose",this);
if(AC.Detector.isWebKit()){this.fixSafarisScrollBars()}this.show(null,true);document.body.removeChild(this.overlay);
this._isDisplaying=false},fixSafarisScrollBars:function(){var d=1;var c=this.windowSize();
window.scroll(c.x+d,c.y+d);window.scroll(c.x,c.y)}});Event.onDOMReady(function(){AC.OverlayPanel.overlay=new AC.OverlayPanel()
});
