var GB_CURRENT=null;
GB_hide=function(){
GB_CURRENT.hide();
};
GreyBox=new AJS.Class({init:function(_1){
this.type="page";
this.overlay_click_close=false;
this.salt=0;
this.root_dir=GB_ROOT_DIR;
this.callback_fns=[];
this.reload_on_close=false;
AJS.update(this,_1);
},addCallback:function(fn){
if(fn){
this.callback_fns.push(fn);
}
},show:function(_3){
GB_CURRENT=this;
this.url=_3;
var _4=[AJS.$bytc("object"),AJS.$bytc("embed")];
if(AJS.isIe()){
_4.push(AJS.$bytc("select"));
}
AJS.map(AJS.flattenList(_4),function(_5){
_5.style.visibility="hidden";
});
this.createElements();
return false;
},hide:function(){
this.onHide();
AJS.removeElement(this.g_window,this.overlay);
this.removeFrame();
AJS.REV(window,"scroll",_GB_setOverlayDimension);
AJS.REV(window,"resize",_GB_update);
if(AJS.isIe()){
AJS.map(AJS.$bytc("select"),function(_6){
_6.style.visibility="visible";
});
}
AJS.map(AJS.$bytc("object"),function(_7){
_7.style.visibility="visible";
});
var _8=this.callback_fns;
if(_8!=[]){
AJS.map(_8,function(fn){
fn();
});
}
GB_CURRENT=null;
if(this.reload_on_close){
window.location.reload();
}
},update:function(){
this.setOverlayDimension();
this.setFrameSize();
this.setWindowPosition();
},createElements:function(){
this.initOverlay();
this.g_window=AJS.DIV({"id":"GB_window"});
AJS.hideElement(this.g_window);
AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling);
this.initFrame();
this.initHook();
this.update();
var me=this;
if(AJS.fx){
AJS.fx.fadeIn(this.overlay,{duration:300,to:0.7,onComplete:function(){
me.onShow();
AJS.showElement(me.g_window);
me.startLoading();
}});
}else{
AJS.setOpacity(this.overlay,0.7);
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.removeElement(this.iframe);
}
catch(e){
}
this.iframe=null;
},startLoading:function(){
this.iframe.src=this.root_dir+"loader_frame.html?s="+this.salt++;
AJS.showElement(this.iframe);
},setOverlayDimension:function(){
var _b=AJS.getWindowSize();
if(AJS.isMozilla()){
AJS.setWidth(this.overlay,"100%");
}else{
AJS.setWidth(this.overlay,_b.w);
}
var _c=Math.max(AJS.getScrollTop()+_b.h,AJS.getScrollTop()+this.height);
if(_c<AJS.getScrollTop()){
AJS.setHeight(this.overlay,_c);
}else{
AJS.setHeight(this.overlay,AJS.getScrollTop()+_b.h);
}
},initOverlay:function(){
this.overlay=AJS.DIV({"id":"GB_overlay"});
if(this.overlay_click_close){
AJS.AEV(this.overlay,"click",GB_hide);
}
AJS.setOpacity(this.overlay,0);
AJS.getBody().insertBefore(this.overlay,AJS.getBody().firstChild);
},initFrame:function(){
if(!this.iframe){
var d={"name":"GB_frame","class":"GB_frame","frameBorder":0};
this.iframe=AJS.IFRAME(d);
this.middle_cnt=AJS.DIV({"class":"content"},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_CURRENT){
GB_CURRENT.update();
}
};
_GB_setOverlayDimension=function(){
if(GB_CURRENT){
GB_CURRENT.setOverlayDimension();
}
};
script_loaded=true;
var GB_SETS={};
function decoGreyboxLinks(){
var as=AJS.$bytc("a");
AJS.map(as,function(a){
if(a.getAttribute("href")&&a.getAttribute("rel")){
var rel=a.getAttribute("rel");
if(rel.indexOf("gb_")==0){
var _11=rel.match(/\w+/)[0];
var _12=rel.match(/\[(.*)\]/)[1];
var _13=0;
var _14={"caption":a.title||"","url":a.href};
if(_11=="gb_pageset"||_11=="gb_imageset"){
if(!GB_SETS[_12]){
GB_SETS[_12]=[];
}
GB_SETS[_12].push(_14);
_13=GB_SETS[_12].length;
}
if(_11=="gb_pageset"){
a.onclick=function(){
GB_showFullScreenSet(GB_SETS[_12],_13);
return false;
};
}
if(_11=="gb_imageset"){
a.onclick=function(){
GB_showImageSet(GB_SETS[_12],_13);
return false;
};
}
if(_11=="gb_image"){
a.onclick=function(){
GB_showImage(_14.caption,_14.url);
return false;
};
}
if(_11=="gb_page"){
a.onclick=function(){
var sp=_12.split(/, ?/);
GB_show(_14.caption,_14.url,parseInt(sp[0]),parseInt(sp[1]));
return false;
};
}
if(_11=="gb_page_fs"){
a.onclick=function(){
GB_showFullScreen(_14.caption,_14.url);
return false;
};
}
}
}
});
}
AJS.AEV(window,"load",decoGreyboxLinks);
GB_showImage=function(_16,url,_18){
var _19={width:300,height:300,type:"image",fullscreen:false,center_win:true,caption:_16,callback_fn:_18};
var win=new GB_Gallery(_19);
return win.show(url);
};
GB_showPage=function(_1b,url,_1d){
var _1e={type:"page",caption:_1b,callback_fn:_1d,fullscreen:true,center_win:false};
var win=new GB_Gallery(_1e);
return win.show(url);
};
GB_Gallery=GreyBox.extend({init:function(_20){
this.parent({});
AJS.update(this,_20);
this.addCallback(this.callback_fn);
},initHook:function(){
AJS.addClass(this.g_window,"GB_Gallery");
var _21=AJS.DIV({"class":"inner"});
this.header=AJS.DIV({"class":"GB_header"},_21);
AJS.setOpacity(this.header,0);
AJS.getBody().insertBefore(this.header,this.overlay.nextSibling);
var _22=AJS.TD({"id":"GB_caption","class":"caption","width":"40%"},this.caption);
var _23=AJS.TD({"id":"GB_middle","class":"middle","width":"20%"});
var _24=AJS.IMG({"src":this.root_dir+"g_close.gif"});
AJS.AEV(_24,"click",GB_hide);
var _25=AJS.TD({"class":"close","width":"40%"},_24);
var _26=AJS.TBODY(AJS.TR(_22,_23,_25));
var _27=AJS.TABLE({"cellspacing":"0","cellpadding":0,"border":0},_26);
AJS.ACN(_21,_27);
AJS.AEV(window,"scroll",AJS.$b(this._setHeaderPos,this));
},setFrameSize:function(){
var _28=this.overlay.offsetWidth;
var _29=AJS.getWindowSize();
if(this.fullscreen){
this.width=_28-40;
this.height=_29.h-80;
}
AJS.setWidth(this.iframe,this.width);
AJS.setHeight(this.iframe,this.height);
AJS.setWidth(this.header,_28);
},_setHeaderPos:function(){
AJS.setTop(this.header,AJS.getScrollTop()+10);
},setWindowPosition:function(){
var _2a=this.overlay.offsetWidth;
var _2b=AJS.getWindowSize();
AJS.setLeft(this.g_window,((_2a-50-this.width)/2));
if(!this.center_win){
AJS.setTop(this.g_window,AJS.getScrollTop()+55);
}else{
var fl=((_2b.h-this.height)/2)-20+AJS.getScrollTop();
if(fl<0){
fl=0;
}
AJS.setTop(this.g_window,fl);
}
this._setHeaderPos();
},onHide:function(){
AJS.removeElement(this.header);
AJS.removeClass(this.g_window,"GB_Gallery");
},onShow:function(){
if(AJS.fx){
AJS.fx.fadeIn(this.header,{to:1});
}else{
AJS.setOpacity(this.header,1);
}
}});
GB_showFullScreenSet=function(set,_2e,_2f){
var _30={type:"page",fullscreen:true,center_win:false};
var _31=new GB_Sets(_30,set);
_31.addCallback(_2f);
_31.showSet(_2e-1);
return false;
};
GB_showImageSet=function(set,_33,_34){
var _35={type:"image",fullscreen:false,center_win:true,width:300,height:300};
var _36=new GB_Sets(_35,set);
_36.addCallback(_34);
_36.showSet(_33-1);
return false;
};
GB_Sets=GB_Gallery.extend({init:function(_37,set){
this.parent(_37);
this.current_set=set;
},showSet:function(_39){
this.current_index=_39;
var _3a=this.current_set[this.current_index];
this.show(_3a.url);
this._setCaption(_3a.caption);
this.btn_prev=AJS.IMG({"class":"left",src:this.root_dir+"prev.gif"});
this.btn_next=AJS.IMG({"class":"right",src:this.root_dir+"next.gif"});
AJS.AEV(this.btn_prev,"click",AJS.$b(this.switchPrev,this));
AJS.AEV(this.btn_next,"click",AJS.$b(this.switchNext,this));
GB_STATUS=AJS.SPAN({"class":"GB_navStatus"});
AJS.ACN(AJS.$("GB_middle"),this.btn_prev,GB_STATUS,this.btn_next);
this.updateStatus();
},updateStatus:function(){
AJS.setHTML(GB_STATUS,(this.current_index+1)+" / "+this.current_set.length);
if(this.current_index==0){
AJS.addClass(this.btn_prev,"disabled");
}else{
AJS.removeClass(this.btn_prev,"disabled");
}
if(this.current_index==this.current_set.length-1){
AJS.addClass(this.btn_next,"disabled");
}else{
AJS.removeClass(this.btn_next,"disabled");
}
},_setCaption:function(_3b){
AJS.setHTML(AJS.$("GB_caption"),_3b);
},updateFrame:function(){
var _3c=this.current_set[this.current_index];
this._setCaption(_3c.caption);
this.url=_3c.url;
this.startLoading();
},switchPrev:function(){
if(this.current_index!=0){
this.current_index--;
this.updateFrame();
this.updateStatus();
}
},switchNext:function(){
if(this.current_index!=this.current_set.length-1){
this.current_index++;
this.updateFrame();
this.updateStatus();
}
}});
script_loaded=true;
GB_show=function(_3d,url,_3f,_40,_41){
var _42={caption:_3d,height:_3f||500,width:_40||500,fullscreen:false,callback_fn:_41};
var win=new GB_Window(_42);
return win.show(url);
};
GB_showFullScreen=function(_44,url,_46){
var _47={caption:_44,fullscreen:true,callback_fn:_46};
var win=new GB_Window(_47);
return win.show(url);
};
GB_Window=GreyBox.extend({init:function(_49){
this.parent({});
this.show_close_img=true;
AJS.update(this,_49);
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.root_dir+"header_bg.gif)";
var _4a=AJS.TD({"class":"caption"},this.caption);
var _4b=AJS.TD({"class":"close"});
if(this.show_close_img){
var _4c=AJS.IMG({"src":this.root_dir+"w_close.gif"});
var _4d=AJS.SPAN("Close");
var btn=AJS.DIV(_4c,_4d);
AJS.AEV([_4c,_4d],"mouseover",function(){
AJS.addClass(_4d,"on");
});
AJS.AEV([_4c,_4d],"mouseout",function(){
AJS.removeClass(_4d,"on");
});
AJS.AEV([_4c,_4d],"mousedown",function(){
AJS.addClass(_4d,"click");
});
AJS.AEV([_4c,_4d],"mouseup",function(){
AJS.removeClass(_4d,"click");
});
AJS.AEV([_4c,_4d],"click",GB_hide);
AJS.ACN(_4b,btn);
}
tbody_header=AJS.TBODY();
AJS.ACN(tbody_header,AJS.TR(_4a,_4b));
AJS.ACN(this.header,tbody_header);
AJS.ACN(this.top_cnt,this.header);
AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
},setFrameSize:function(){
if(this.fullscreen){
var _4f=AJS.getWindowSize();
overlay_h=_4f.h;
this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10);
this.height=Math.round(overlay_h-(overlay_h/100)*10);
}
AJS.setWidth(this.header,this.width+6);
AJS.setWidth(this.iframe,this.width);
AJS.setHeight(this.iframe,this.height);
},setWindowPosition:function(){
var _50=AJS.getWindowSize();
AJS.setLeft(this.g_window,((_50.w-this.width)/2)-13);
if(!this.center_win){
AJS.setTop(this.g_window,AJS.getScrollTop());
}else{
var fl=((_50.h-this.height)/2)-20+AJS.getScrollTop();
if(fl<0){
fl=0;
}
AJS.setTop(this.g_window,fl);
}
}});

