var loc=window.location;var GB_ROOT_DIR=loc.protocol+"//"+loc.host+"/static/greybox/";var GB_LOADING=false;var GB_CURRENT=[];GB_hide=function(a){GB_CURRENT.pop().hide(a)};GB_getLast=function(){return AJS.getLast(GB_CURRENT)};GreyBox=new AJS.Class({init:function(c){this.use_fx=AJS.fx;this.type="page";this.overlay_click_close=false;this.salt=0;this.root_dir=GB_ROOT_DIR;this.callback_fns=[];this.overlay_opacity=false;this.reload_on_close=false;this.src_loader=this.root_dir+"loader_frame.html";this.cur_zindex=10000;var b=window.location.hostname.indexOf("www");var a=this.src_loader.indexOf("www");if(b!=-1&&a==-1){this.src_loader=this.src_loader.replace("://","://www.")}if(b==-1&&a!=-1){this.src_loader=this.src_loader.replace("://www.","://")}this.show_loading=true;AJS.update(this,c)},addCallback:function(a){if(a){this.callback_fns.push(a)}},show:function(b){if(GB_LOADING){return false}try{top.window.scroll(0,0)}catch(c){}GB_LOADING=true;if(GB_getLast()){this.cur_zindex=GB_getLast().cur_zindex+500}GB_CURRENT.push(this);this.url=b;var a=[AJS.$bytc("object"),AJS.$bytc("select")];AJS.map(AJS.flattenList(a),function(d){if(d.style.visibility!="hidden"){d._gb_vis=1;d.style.visibility="hidden"}});this.createElements();setTimeout(function(){GB_LOADING=false},100);return false},hide:function(a){var b=this;setTimeout(function(){var e=b.callback_fns;if(e!=[]){AJS.map(e,function(f){f()})}b.onHide();if(b.use_fx){var d=b.overlay;AJS.fx.fadeOut(b.overlay,{onComplete:function(){AJS.removeElement(d);d=null},duration:300});AJS.removeElement(b.g_window)}else{AJS.removeElement(b.g_window,b.overlay)}b.removeFrame();AJS.REV(window,"scroll",_GB_setOverlayDimension);AJS.REV(window,"resize",_GB_update);var c=[AJS.$bytc("object"),AJS.$bytc("select")];AJS.map(AJS.flattenList(c),function(f){if(f._gb_vis==1){f._gb_vis=0;f.style.visibility="visible"}});if(b.reload_on_close&&GB_CURRENT.length==0){window.location.reload()}if(AJS.isFunction(a)){a()}},10)},update:function(){this.setOverlayDimension();this.setFrameSize();this.setWindowPosition()},createElements:function(){this.initOverlay();this.g_window=AJS.DIV({"class":"GB_window"});if(this.win_class){AJS.addClass(this.g_window,this.win_class)}this.g_window.style.zIndex=this.cur_zindex+100;AJS.hideElement(this.g_window);AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling);this.initFrame();this.initHook();this.update();var a=this;if(this.use_fx){AJS.fx.fadeIn(this.overlay,{duration:300,to:0.7,onComplete:function(){a.onShow();AJS.showElement(a.g_window);a.startLoading()}})}else{if(this.overlay_opacity){AJS.setOpacity(this.overlay,this.overlay_opacity)}AJS.showElement(this.g_window);this.onShow();this.startLoading()}AJS.AEV(window,"scroll",_GB_setOverlayDimension);AJS.AEV(window,"resize",_GB_update)},removeFrame:function(){try{AJS.discardElement(this.iframe)}catch(a){}this.iframe=null},startLoading:function(){this.iframe.src=this.src_loader+"?s="+this.salt++;setTimeout("AJS.showElement(this.iframe)",1000)},setOverlayDimension:function(){var b=AJS.getWindowSize();AJS.setWidth(this.overlay,"100%");var a=Math.max(AJS.getScrollTop()+b.h,AJS.getScrollTop()+this.height);if(a<AJS.getScrollTop()){AJS.setHeight(this.overlay,a)}else{AJS.setHeight(this.overlay,AJS.getScrollTop()+b.h)}},initOverlay:function(){this.overlay=AJS.DIV({"class":"GB_overlay"});this.overlay.style.zIndex=this.cur_zindex;if(this.overlay_click_close){AJS.AEV(this.overlay,"click",GB_hide)}if(this.overlay_opacity){AJS.setOpacity(this.overlay,0)}this.overlay.style.backgroundColor="transparent";AJS.getBody().insertBefore(this.overlay,AJS.getBody().firstChild)},initFrame:function(){if(!this.iframe){var a={name:"GB_frame","class":"GB_frame",frameBorder:0,id:"settingFrame",scrolling:"no"};if(AJS.isIe()){a.src='javascript:false;document.write("");'}this.iframe=AJS.IFRAME(a);this.middle_cnt=AJS.DIV({"class":"content"},DIV({c:"iframe_holder"},this.iframe));this.top_cnt=AJS.DIV();this.bottom_cnt=AJS.DIV();AJS.ACN(this.g_window,this.top_cnt,this.middle_cnt,this.bottom_cnt)}},onHide:function(){},onShow:function(){},setFrameSize:function(){},setWindowPosition:function(){},initHook:function(){}});_GB_update=function(){if(GB_getLast()){GB_getLast().update()}};_GB_setOverlayDimension=function(){if(GB_getLast()){GB_getLast().setOverlayDimension()}};script_loaded=true;var GB_SETS={};function decoGreyboxLinks(){var a=AJS.$bytc("a");AJS.map(a,function(d){if(d.getAttribute("href")&&d.getAttribute("rel")){var b=d.getAttribute("rel");if(b.indexOf("gb_")==0){var f=b.match(/\w+/)[0];var e=b.match(/\[(.*)\]/)[1];var c=0;var g={caption:d.title||"",url:d.href};if(f=="gb_pageset"||f=="gb_imageset"){if(!GB_SETS[e]){GB_SETS[e]=[]}GB_SETS[e].push(g);c=GB_SETS[e].length}if(f=="gb_pageset"){d.onclick=function(){GB_showFullScreenSet(GB_SETS[e],c);return false}}if(f=="gb_imageset"){d.onclick=function(){GB_showImageSet(GB_SETS[e],c);return false}}if(f=="gb_image"){d.onclick=function(){GB_showImage(g.caption,g.url);return false}}if(f=="gb_page"){d.onclick=function(){var h=e.split(/, ?/);GB_show(g.caption,g.url,parseInt(h[1]),parseInt(h[0]));return false}}if(f=="gb_page_fs"){d.onclick=function(){GB_showFullScreen(g.caption,g.url);return false}}if(f=="gb_page_center"){d.onclick=function(){var h=e.split(/, ?/);GB_showCenter(g.caption,g.url,parseInt(h[1]),parseInt(h[0]));return false}}}}})}AJS.AEV(window,"load",decoGreyboxLinks);GB_show=function(d,e,b,c,a){var g={caption:d,height:b||500,width:c||500,fullscreen:false,callback_fn:a};var f=new GB_Window(g);return f.show(e)};GB_showCenter=function(g,b,e,d,c){var a={caption:g,center_win:true,height:e||500,width:d||500,fullscreen:false,callback_fn:c};var f=new GB_Window(a);return f.show(b)};GB_showFullScreen=function(d,b,c){var a={caption:d,fullscreen:true,callback_fn:c};var e=new GB_Window(a);return e.show(b)};GB_Window=GreyBox.extend({init:function(a){this.parent({});this.img_header=this.root_dir+"header_bg.gif";this.show_close_img=true;AJS.update(this,a);this.addCallback(this.callback_fn)},initHook:function(){AJS.addClass(this.g_window,"GB_Window");this.header=AJS.TABLE({"class":"header"});this.header.style.backgroundImage="url("+this.img_header+")";var b=AJS.setHTML(AJS.TD({"class":"caption"}),this.caption);var a=AJS.TD({"class":"close"});if(this.show_close_img){var d=AJS.SPAN(".");var c=AJS.DIV(d);AJS.AEV([d],"mouseover",function(){AJS.addClass(d,"on")});AJS.AEV([d],"mouseout",function(){AJS.removeClass(d,"on")});AJS.AEV([d],"mousedown",function(){AJS.addClass(d,"click")});AJS.AEV([d],"mouseup",function(){AJS.removeClass(d,"click")});AJS.AEV([d],"click",GB_hide);AJS.ACN(a,c)}tbody_header=AJS.TBODY();AJS.ACN(tbody_header,AJS.TR(b,a));AJS.ACN(this.header,tbody_header);AJS.ACN(this.top_cnt,this.header);if(this.fullscreen){AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this))}},setFrameSize:function(){if(this.fullscreen){var d=AJS.getWindowSize();overlay_h=d.h;this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10);this.height=Math.round(overlay_h-(overlay_h/100)*10)}var c=AJS.$bytc("div","iframe_holder");var a=AJS.$bytc("div","content");var e=AJS.$bytc("div","GB_Window");var b=this.width;AJS.setWidth(this.header,b+2);AJS.setWidth(this.iframe,b);AJS.setHeight(this.iframe,this.height)},setWindowPosition:function(){var b=AJS.getWindowSize();AJS.setLeft(this.g_window,((b.w-this.width)/2)-13);if(!this.center_win){AJS.setTop(this.g_window,AJS.getScrollTop()+30)}else{var a=((b.h-this.height)/2)-20+AJS.getScrollTop();if(a<0){a=0}AJS.setTop(this.g_window,a)}}});GB_showHTML=function(c,e,a,f,h,b){var d={caption:c,height:a||500,width:f||500,overlay_click_close:true,fullscreen:false,callback_fn:h,overlay_opacity:0,use_fx:false,center_win:b};var g=new GB_HTMLWindow(e,d);return g.show()};GB_HTMLWindow=GB_Window.extend({init:function(b,a){this.elm=b;this.parent(a);this.overlay_opacity=0},initFrame:function(){if(!this.iframe){this.iframe=AJS.DIV(this.elm);this.middle_cnt=AJS.DIV({"class":"content"},DIV({c:"iframe_holder"},this.iframe));this.top_cnt=AJS.DIV();this.bottom_cnt=AJS.DIV();AJS.ACN(this.g_window,this.top_cnt,this.middle_cnt,this.bottom_cnt)}},initOverlay:function(){this.parent();this.overlay.style.backgroundColor="transparent"},setFrameSize:function(){var a=AJS.$bytc("div","content");var c=AJS.$bytc("div","GB_Window");var b=this.width;AJS.setWidth(this.header,b-2);AJS.setWidth(this.iframe,b-4)}});function setPngBg(b,a){b.style.background=a}function GB_openExternal(b){var c=getLast(GB_CURRENT);var a=Math.min(450,c.height);window.open(b,c.caption,"width="+c.width+"&height="+a);top.GB_hide()}script_loaded=true;GB_showImage=function(a,c,e){var b={width:300,height:300,type:"image",fullscreen:false,overlay_click_close:true,caption:a,callback_fn:e};var d=new GB_Gallery(b);return d.show(c)};GB_Gallery=GreyBox.extend({init:function(a){this.parent({});this.img_close=this.root_dir+"w_close1.gif";AJS.update(this,a);this.addCallback(this.callback_fn)},initHook:function(){AJS.addClass(this.g_window,"GB_Gallery");var a;appendToTop(this.middle_cnt,a=DIV({s:"text-align: right"},IMG({src:this.img_close,s:"cursor: pointer; padding: 3px;"})));a.onclick=GB_hide},setFrameSize:function(){var b=this.overlay.offsetWidth;var a=AJS.getWindowSize();if(this.fullscreen){this.width=b-40;this.height=a.h-80}AJS.setWidth(this.iframe,this.width);AJS.setHeight(this.iframe,this.height)},setWindowPosition:function(){var b=this.overlay.offsetWidth;var a=AJS.getWindowSize();AJS.setLeft(this.g_window,((b-50-this.width)/2));var c=AJS.getScrollTop();AJS.setTop(this.g_window,c+25)},onHide:function(){AJS.removeClass(this.g_window,"GB_Gallery")}});
