var Popup=Class.create();Popup.prototype={popup:null,popupLoading:null,popupLoadingImg:null,popupContent:null,iframe:null,hiddenSelects:null,initialize:function(A){this.options={url:"#",width:676,height:267,method:"get",header:true,center:false,onLoad:null,draggable:false,destroyOnClose:true,loadingImg:null};Object.extend(this.options,A||{});$$("embed").each(function(B){B.writeAttribute("wmode","transparent")});this.popup=document.createElement("div");this.popup.id="popup";Element.addClassName(this.popup,"popup");if(this.options.header){this.popupContent=document.createElement("div");this.popup.appendChild(this.popupContent);if(this.options.draggable){new Draggable(this.popup,{handle:header,starteffect:null,endeffect:null})}if(this.options.loadingImg){this.popupLoadingImg=new Image();this.popupLoadingImg.src=this.options.loadingImg;this.popupLoading=document.createElement("div");Element.addClassName(this.popupLoading,"popupLoading");header.appendChild(this.popupLoading)}}Element.hide(this.popup);document.getElementsByTagName("body")[0].appendChild(this.popup);this.show();this.loadContent()},startLoading:function(){if(this.popupLoading&&this.popupLoadingImg){this.popupLoading.appendChild(this.popupLoadingImg)}},stopLoading:function(){if(this.popupLoading){this.popupLoading.innerHTML=""}},show:function(){this.popup.style.width=this.options.width+"px";this.popup.style.height=this.options.height+"px";if(this.options.center){Element.addClassName(this.popup,"popup");if(self.innerWidth){frameWidth=self.innerWidth;frameHeight=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientWidth){frameWidth=document.documentElement.clientWidth;frameHeight=document.documentElement.clientHeight}else{if(document.body){frameWidth=document.body.clientWidth;frameHeight=document.body.clientHeight}}}var A=this.realScrolled();this.popup.style.left=(frameWidth-this.options.width)/2+A[0]+"px";this.popup.style.top=(frameHeight-this.options.height)/2+A[1]+"px"}if(self.innerWidth){frameWidth=self.innerWidth;frameHeight=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientWidth){frameWidth=document.documentElement.clientWidth;frameHeight=document.documentElement.clientHeight}else{if(document.body){frameWidth=document.body.clientWidth;frameHeight=document.body.clientHeight}}}var A=this.realScrolled();this.popup.style.left=(frameWidth-800)/2+A[0]+"px";this.popup.style.top=(frameHeight-267)/2+A[1]+"px";if(this.popup.getClientRects){this.hideSelectsUnderPopup()}Element.show(this.popup)},hideSelectsUnderPopup:function(){this.hiddenSelects=new Array();var B=0;var C=0;if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){B=document.body.scrollTop;C=document.body.scrollLeft}var G=document.getElementsByTagName("select");var D=parseInt(this.popup.style.left,10)-C;var H=parseInt(this.popup.style.top,10)-B;var I=D+this.options.width;var A=H+this.options.height;for(var F=0;F<G.length;F++){if(G[F].getClientRects){var J=G[F].getClientRects();for(var E=0;E<J.length;E++){if(J[E].top<A&&H<J[E].bottom&&J[E].left<I&&D<J[E].right&&G[F].style.visibility!="hidden"){G[F].style.visibility="hidden";this.hiddenSelects[this.hiddenSelects.length]=G[F];break}}}}},unHideSelectsUnderPopup:function(){if(this.hiddenSelects){for(var A=0;A<this.hiddenSelects.length;A++){this.hiddenSelects[A].style.visibility="visible"}}},closePopup:function(){if(this.options.destroyOnClose){Element.remove(this.popup);this.popup=null}else{Element.hide(this.popup)}this.unHideSelectsUnderPopup()},loadContent:function(A){this.startLoading();new Ajax.Updater(this.popupContent,A||this.options.url,{method:this.options.method,evalScripts:true,onSuccess:this.onLoadedContent.bind(this),onFailure:this.onError.bind(this)})},onLoadedContent:function(){this.stopLoading();if(this.options.onLoad){this.options.onLoad()}},onError:function(){this.stopLoading();showError()},realScrolled:function(){var A,B;if(self.pageYOffset){A=self.pageXOffset;B=self.pageYOffset}else{if(document.documentElement&&document.documentElement.scrollTop){A=document.documentElement.scrollLeft;B=document.documentElement.scrollTop}else{if(document.body){A=document.body.scrollLeft;B=document.body.scrollTop}}}return[A,B]}}