var GB_CURRENT=null;var GB_ONLY_ONE=null;function GreyBox(){this.type="page";this.overlay_click_close=true;this.img_dir="greybox/";this.overlay_color="dark";this.center_window=false;this.g_window=null;this.g_container=null;this.iframe=null;this.overlay=null;this.timeout=null;this.defaultSize();this.url="";this.caption=""}GreyBox.prototype.setDimension=function(b,a){this.height=a;this.width=b};GreyBox.prototype.setFullScreen=function(a){this.full_screen=a};GreyBox.prototype.setType=function(a){this.type=a};GreyBox.prototype.setCenterWindow=function(a){this.center_window=a};GreyBox.prototype.setImageDir=function(a){this.img_dir=a};GreyBox.prototype.setOverlayCloseClick=function(a){this.overlay_click_close=a};GreyBox.prototype.setOverlayColor=function(a){this.overlay_color=a};GreyBox.prototype.setCallback=function(a){this.callback_fn=a};GreyBox.prototype.show=function(a,b){GB_CURRENT=this;this.url=b;this.caption=a;AJS.map(AJS.$bytc("div","GB_dummy"),function(c){AJS.removeElement(c)});AJS.map(AJS.$bytc("div","GB_loader"),function(c){AJS.removeElement(c)});if(AJS.isIe()){AJS.map(AJS.$bytc("select"),function(c){c.style.visibility="hidden"})}AJS.map(AJS.$bytc("object"),function(c){c.style.visibility="hidden"});this.initOverlayIfNeeded();this.setOverlayDimension();AJS.showElement(this.overlay);this.setFullScreenOption();this.initIfNeeded();AJS.hideElement(this.g_window);if(this.type=="page"){AJS.ACN(this.g_container,this.iframe)}else{this.dummy_holder=AJS.DIV({"class":"GB_dummy",style:"width: 200px; height: 200px; background-color: #fff;"});AJS.ACN(this.g_container,this.dummy_holder)}if(a==""){a="&nbsp;"}this.div_caption.innerHTML=a;AJS.showElement(this.g_window);this.setVerticalPosition();this.setTopNLeft();this.setWidthNHeight();this.showLoader();GB_CURRENT.startLoading();return false};GreyBox.prototype.hide=function(){AJS.hideElement(this.g_window,this.overlay);try{AJS.removeElement(this.iframe)}catch(a){}this.iframe=null;if(this.type=="image"){this.width=200;this.height=200}if(AJS.isIe()){AJS.map(AJS.$bytc("select"),function(b){b.style.visibility="visible"})}AJS.map(AJS.$bytc("object"),function(b){b.style.visibility="visible"});if(GB_CURRENT.callback_fn){GB_CURRENT.callback_fn()}GB_CURRENT=null};GB_initOneIfNeeded=function(){if(!GB_ONLY_ONE){GB_ONLY_ONE=new GreyBox();GB_ONLY_ONE.setImageDir(GB_IMG_DIR)}};GB_show=function(b,c,a,d,e){GB_ONLY_ONE.defaultSize();GB_ONLY_ONE.setFullScreen(false);GB_ONLY_ONE.setType("page");GB_ONLY_ONE.setCallback(e);GB_ONLY_ONE.setImageDir(GB_IMG_DIR);GB_ONLY_ONE.setDimension(d,a);GB_ONLY_ONE.show(b,c);return false};GB_showFullScreen=function(a,b,c){GB_ONLY_ONE.defaultSize();GB_ONLY_ONE.setType("page");GB_ONLY_ONE.setCallback(c);GB_ONLY_ONE.setImageDir(GB_IMG_DIR);GB_ONLY_ONE.setFullScreen(true);GB_ONLY_ONE.show(a,b);return false};GB_showImage=function(a,b){GB_ONLY_ONE.defaultSize();GB_ONLY_ONE.setFullScreen(false);GB_ONLY_ONE.setType("image");GB_ONLY_ONE.setImageDir(GB_IMG_DIR);GB_ONLY_ONE.show(a,b);return false};GB_hide=function(){GB_CURRENT.hide()};GreyBox.preloadGreyBoxImages=function(){var b=[];var a=function(d){var c=new Image();c.src=GB_IMG_DIR+d;b.push(c)};AJS.map(["indicator.gif","blank.gif","close.gif","header_bg.gif","overlay_light.png","overlay_dark.png"],AJS.$b(a,this))};GreyBox.prototype.getOverlayImage=function(){return"overlay_"+this.overlay_color+".png"};GreyBox.prototype.initOverlayIfNeeded=function(){this.overlay=AJS.DIV({id:"GB_overlay"});if(AJS.isIe()){this.overlay.style.backgroundColor="#000000";this.overlay.style.backgroundColor="transparent";this.overlay.style.backgroundImage="url("+this.img_dir+"blank.gif)";this.overlay.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.img_dir+this.getOverlayImage()+"',sizingMethod='scale')"}else{this.overlay.style.backgroundImage="url("+this.img_dir+this.getOverlayImage()+")"}if(this.overlay_click_close){AJS.AEV(this.overlay,"click",GB_hide)}AJS.getBody().insertBefore(this.overlay,AJS.getBody().firstChild)};GreyBox.prototype.initIfNeeded=function(){this.init();this.setWidthNHeight=AJS.$b(this.setWidthNHeight,this);this.setTopNLeft=AJS.$b(this.setTopNLeft,this);this.setFullScreenOption=AJS.$b(this.setFullScreenOption,this);this.setOverlayDimension=AJS.$b(this.setOverlayDimension,this);GreyBox.addOnWinResize(this.setWidthNHeight,this.setTopNLeft,this.setFullScreenOption,this.setOverlayDimension);if(this.type=="page"){this.g_container.style.marginBottom="-3px"}var a=function(){this.setOverlayDimension();this.setVerticalPosition();this.setTopNLeft();this.setWidthNHeight()};AJS.AEV(window,"scroll",AJS.$b(a,this));if(!this.iframe){var b;var c={name:"GB_frame","class":"GB_frame",frameBorder:0};if(this.type=="page"){b=AJS.IFRAME(c);AJS.hideElement(b)}else{b=new Image()}this.iframe=b}};GreyBox.prototype.init=function(){this.g_window=AJS.DIV({id:"GB_window"});var d=AJS.TABLE({"class":"GB_t_frame",frameborder:0});var b=AJS.TBODY();AJS.ACN(d,b);var e=AJS.TD({"class":"GB_content"});this.td_middle_m=e;AJS.ACN(b,AJS.TR(e));var h=AJS.DIV({"class":"GB_header"});this.header=h;var a=AJS.DIV({"class":"GB_caption"});this.div_caption=a;var c=AJS.IMG({src:this.img_dir+"close.gif"});var g=AJS.DIV({"class":"GB_close"},c,"");AJS.AEV(g,"click",GB_hide);h.style.backgroundImage="url("+this.img_dir+"header_bg.gif)";var f=AJS.SPAN();f.innerHTML="&nbsp;";AJS.ACN(h,g,a,f);AJS.ACN(e,h);this.g_container=AJS.DIV({"class":"GB_container"});AJS.ACN(e,this.g_container);AJS.ACN(this.g_window,d);AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling)};GreyBox.prototype.startLoading=function(){this.iframe.src=this.url;if(AJS.isIe()){var a=function(){if(this.iframe.readyState=="complete"){GreyBox.loaded()}else{AJS.callLater(AJS.$b(a,this),30)}};AJS.callLater(AJS.$b(a,this),30)}else{if(AJS.isSafari()||AJS.isOpera()&&this.type=="image"){AJS.callLater(GreyBox.loaded,250)}else{this.iframe.onload=GreyBox.loaded}}};GreyBox.loaded=function(){var d=GB_CURRENT;if(d){AJS.removeElement(d.loader);if(d.type=="page"){AJS.showElement(d.iframe);d.setIframeWidthNHeight()}if(d.type=="image"){var b=AJS.IMG({src:d.url});var e=function(){AJS.ACN(GB_CURRENT.g_container,b);GB_CURRENT.iframe=b};var c=0;var a=function(){if(c>10){return}this.width=this.iframe.width;this.height=this.iframe.height;if(this.width==0||this.height==0){c++;AJS.callLater(AJS.$b(a,d),100);return}if(AJS.isSafari()){this.overlay.style.backgroundColor="transparent"}this.setTopNLeft();this.setWidthNHeight();AJS.removeElement(this.dummy_holder);AJS.callLater(AJS.$b(e,d),50);c++};AJS.callLater(AJS.$b(a,d),100)}}};GreyBox.prototype.showLoader=function(){this.loader=AJS.DIV({"class":"GB_loader"});AJS.setWidth(this.loader,this.width);AJS.setHeight(this.loader,this.height-3);var a=AJS.IMG({src:this.img_dir+"indicator.gif"});AJS.ACN(this.loader,AJS.BR(),a,AJS.BR(),AJS.BR(),AJS.SPAN("LOADING..."));if(this.type!="page"){AJS.RCN(this.dummy_holder,this.loader);AJS.setTop(this.loader,AJS.absolutePosition(this.dummy_holder).y)}else{AJS.ACN(this.g_container,this.loader);AJS.setTop(this.loader,AJS.absolutePosition(this.iframe).y);AJS.showElement(this.loader)}};GreyBox.prototype.setIframeWidthNHeight=function(){try{AJS.setWidth(this.iframe,this.width);AJS.setHeight(this.iframe,this.height-3)}catch(a){}};GreyBox.prototype.setOverlayDimension=function(){var b=GreyBox.getWindowSize();if((navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)){AJS.setWidth(this.overlay,"100%")}else{AJS.setWidth(this.overlay,b[0])}var a=Math.max(AJS.getScrollTop()+b[1],AJS.getScrollTop()+this.height);if(a<AJS.getScrollTop()){AJS.setHeight(this.overlay,a)}else{AJS.setHeight(this.overlay,AJS.getScrollTop()+b[1])}};GreyBox.prototype.setWidthNHeight=function(){AJS.setWidth(this.g_window,this.width);AJS.setHeight(this.g_window,this.height);AJS.setWidth(this.g_container,this.width);AJS.setHeight(this.g_container,this.height);if(this.type=="page"){this.setIframeWidthNHeight()}AJS.setWidth(this.td_middle_m,this.width+10)};GreyBox.prototype.setTopNLeft=function(){var a=GreyBox.getWindowSize();AJS.setLeft(this.g_window,((a[0]-this.width)/2)-13);if(this.center_window){var b=((a[1]-this.height)/2)-15;AJS.setTop(this.g_window,b)}else{if(this.g_window.offsetHeight<a[1]){AJS.setTop(this.g_window,AJS.getScrollTop())}}};GreyBox.prototype.setVerticalPosition=function(){var b=GreyBox.getWindowSize();var a=AJS.getScrollTop();if(this.g_window.offsetWidth<=b[1]||a<=this.g_window.offsetTop){AJS.setTop(this.g_window,a)}};GreyBox.prototype.setFullScreenOption=function(){if(this.full_screen){var a=GreyBox.getWindowSize();overlay_h=a[1];this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10);this.height=Math.round(overlay_h-(overlay_h/100)*10)}};GreyBox.prototype.defaultSize=function(){this.width=300;this.height=300};GreyBox.getWindowSize=function(){var a,b;if(self.innerHeight){a=self.innerWidth;b=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){a=document.documentElement.clientWidth;b=document.documentElement.clientHeight}else{if(document.body){a=document.body.clientWidth;b=document.body.clientHeight}}}return[a,b]};GreyBox.addOnWinResize=function(a){a=AJS.$A(a);AJS.map(a,function(b){AJS.AEV(window,"resize",b)})};GB_ONLY_ONE=new GreyBox();