5 GreyBox=new AJS.Class({init:function(_1){
8 this.overlay_click_close=false;
10 this.root_dir=GB_ROOT_DIR;
12 this.reload_on_close=false;
13 this.src_loader=this.root_dir+"loader_frame.html";
14 var _2=window.location.hostname.indexOf("www");
15 var _3=this.src_loader.indexOf("www");
17 this.src_loader=this.src_loader.replace("://","://www.");
20 this.src_loader=this.src_loader.replace("://www.","://");
22 this.show_loading=true;
24 },addCallback:function(fn){
26 this.callback_fns.push(fn);
31 var _6=[AJS.$bytc("object"),AJS.$bytc("select")];
32 AJS.map(AJS.flattenList(_6),function(_7){
33 _7.style.visibility="hidden";
35 this.createElements();
38 var _8=this.callback_fns;
40 AJS.map(_8,function(fn){
47 AJS.fx.fadeOut(this.overlay,{onComplete:function(){
48 AJS.removeElement(_a);
51 AJS.removeElement(this.g_window);
53 AJS.removeElement(this.g_window,this.overlay);
56 AJS.REV(window,"scroll",_GB_setOverlayDimension);
57 AJS.REV(window,"resize",_GB_update);
58 var _b=[AJS.$bytc("object"),AJS.$bytc("select")];
59 AJS.map(AJS.flattenList(_b),function(_c){
60 _c.style.visibility="visible";
63 if(this.reload_on_close){
64 window.location.reload();
67 this.setOverlayDimension();
69 this.setWindowPosition();
70 },createElements:function(){
72 this.g_window=AJS.DIV({"id":"GB_window"});
73 AJS.hideElement(this.g_window);
74 AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling);
80 AJS.fx.fadeIn(this.overlay,{duration:300,to:0.7,onComplete:function(){
82 AJS.showElement(me.g_window);
86 AJS.setOpacity(this.overlay,0.7);
87 AJS.showElement(this.g_window);
91 AJS.AEV(window,"scroll",_GB_setOverlayDimension);
92 AJS.AEV(window,"resize",_GB_update);
93 },removeFrame:function(){
95 AJS.removeElement(this.iframe);
100 },startLoading:function(){
101 this.iframe.src=this.src_loader+"?s="+this.salt++;
102 AJS.showElement(this.iframe);
103 },setOverlayDimension:function(){
104 var _e=AJS.getWindowSize();
105 if(AJS.isMozilla()||AJS.isOpera()){
106 AJS.setWidth(this.overlay,"100%");
108 AJS.setWidth(this.overlay,_e.w);
110 var _f=Math.max(AJS.getScrollTop()+_e.h,AJS.getScrollTop()+this.height);
111 if(_f<AJS.getScrollTop()){
112 AJS.setHeight(this.overlay,_f);
114 AJS.setHeight(this.overlay,AJS.getScrollTop()+_e.h);
116 },initOverlay:function(){
117 this.overlay=AJS.DIV({"id":"GB_overlay"});
118 if(this.overlay_click_close){
119 AJS.AEV(this.overlay,"click",GB_hide);
121 AJS.setOpacity(this.overlay,0);
122 AJS.getBody().insertBefore(this.overlay,AJS.getBody().firstChild);
123 },initFrame:function(){
125 var d={"name":"GB_frame","class":"GB_frame","frameBorder":0};
126 this.iframe=AJS.IFRAME(d);
127 this.middle_cnt=AJS.DIV({"class":"content"},this.iframe);
128 this.top_cnt=AJS.DIV();
129 this.bottom_cnt=AJS.DIV();
130 AJS.ACN(this.g_window,this.top_cnt,this.middle_cnt,this.bottom_cnt);
134 },setFrameSize:function(){
135 },setWindowPosition:function(){
136 },initHook:function(){
138 _GB_update=function(){
143 _GB_setOverlayDimension=function(){
145 GB_CURRENT.setOverlayDimension();
148 AJS.preloadImages(GB_ROOT_DIR+"indicator.gif");
151 function decoGreyboxLinks(){
152 var as=AJS.$bytc("a");
153 AJS.map(as,function(a){
154 if(a.getAttribute("href")&&a.getAttribute("rel")){
155 var rel=a.getAttribute("rel");
156 if(rel.indexOf("gb_")==0){
157 var _14=rel.match(/\w+/)[0];
158 var _15=rel.match(/\[(.*)\]/)[1];
160 var _17={"caption":a.title||"","url":a.href};
161 if(_14=="gb_pageset"||_14=="gb_imageset"){
165 GB_SETS[_15].push(_17);
166 _16=GB_SETS[_15].length;
168 if(_14=="gb_pageset"){
169 a.onclick=function(){
170 GB_showFullScreenSet(GB_SETS[_15],_16);
174 if(_14=="gb_imageset"){
175 a.onclick=function(){
176 GB_showImageSet(GB_SETS[_15],_16);
181 a.onclick=function(){
182 GB_showImage(_17.caption,_17.url);
187 a.onclick=function(){
188 var sp=_15.split(/, ?/);
189 GB_show(_17.caption,_17.url,parseInt(sp[1]),parseInt(sp[0]));
193 if(_14=="gb_page_fs"){
194 a.onclick=function(){
195 GB_showFullScreen(_17.caption,_17.url);
199 if(_14=="gb_page_center"){
200 a.onclick=function(){
201 var sp=_15.split(/, ?/);
202 GB_showCenter(_17.caption,_17.url,parseInt(sp[1]),parseInt(sp[0]));
210 AJS.AEV(window,"load",decoGreyboxLinks);
211 GB_showImage=function(_1a,url,_1c){
212 var _1d={width:300,height:300,type:"image",fullscreen:false,center_win:true,caption:_1a,callback_fn:_1c};
213 var win=new GB_Gallery(_1d);
214 return win.show(url);
216 GB_showPage=function(_1f,url,_21){
217 var _22={type:"page",caption:_1f,callback_fn:_21,fullscreen:true,center_win:false};
218 var win=new GB_Gallery(_22);
219 return win.show(url);
221 GB_Gallery=GreyBox.extend({init:function(_24){
223 this.img_close=this.root_dir+"g_close.gif";
224 AJS.update(this,_24);
225 this.addCallback(this.callback_fn);
226 },initHook:function(){
227 AJS.addClass(this.g_window,"GB_Gallery");
228 var _25=AJS.DIV({"class":"inner"});
229 this.header=AJS.DIV({"class":"GB_header"},_25);
230 AJS.setOpacity(this.header,0);
231 AJS.getBody().insertBefore(this.header,this.overlay.nextSibling);
232 var _26=AJS.TD({"id":"GB_caption","class":"caption","width":"40%"},this.caption);
233 var _27=AJS.TD({"id":"GB_middle","class":"middle","width":"20%"});
234 var _28=AJS.IMG({"src":this.img_close});
235 AJS.AEV(_28,"click",GB_hide);
236 var _29=AJS.TD({"class":"close","width":"40%"},_28);
237 var _2a=AJS.TBODY(AJS.TR(_26,_27,_29));
238 var _2b=AJS.TABLE({"cellspacing":"0","cellpadding":0,"border":0},_2a);
241 AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
243 AJS.AEV(window,"scroll",AJS.$b(this._setHeaderPos,this));
245 },setFrameSize:function(){
246 var _2c=this.overlay.offsetWidth;
247 var _2d=AJS.getWindowSize();
250 this.height=_2d.h-80;
252 AJS.setWidth(this.iframe,this.width);
253 AJS.setHeight(this.iframe,this.height);
254 AJS.setWidth(this.header,_2c);
255 },_setHeaderPos:function(){
256 AJS.setTop(this.header,AJS.getScrollTop()+10);
257 },setWindowPosition:function(){
258 var _2e=this.overlay.offsetWidth;
259 var _2f=AJS.getWindowSize();
260 AJS.setLeft(this.g_window,((_2e-50-this.width)/2));
261 var _30=AJS.getScrollTop()+55;
262 if(!this.center_win){
263 AJS.setTop(this.g_window,_30);
265 var fl=((_2f.h-this.height)/2)+20+AJS.getScrollTop();
272 AJS.setTop(this.g_window,fl);
274 this._setHeaderPos();
276 AJS.removeElement(this.header);
277 AJS.removeClass(this.g_window,"GB_Gallery");
280 AJS.fx.fadeIn(this.header,{to:1});
282 AJS.setOpacity(this.header,1);
285 AJS.preloadImages(GB_ROOT_DIR+"g_close.gif");
286 GB_showFullScreenSet=function(set,_33,_34){
287 var _35={type:"page",fullscreen:true,center_win:false};
288 var _36=new GB_Sets(_35,set);
289 _36.addCallback(_34);
293 GB_showImageSet=function(set,_38,_39){
294 var _3a={type:"image",fullscreen:false,center_win:true,width:300,height:300};
295 var _3b=new GB_Sets(_3a,set);
296 _3b.addCallback(_39);
300 GB_Sets=GB_Gallery.extend({init:function(_3c,set){
303 this.img_next=this.root_dir+"next.gif";
306 this.img_prev=this.root_dir+"prev.gif";
308 this.current_set=set;
309 },showSet:function(_3e){
310 this.current_index=_3e;
311 var _3f=this.current_set[this.current_index];
313 this._setCaption(_3f.caption);
314 this.btn_prev=AJS.IMG({"class":"left",src:this.img_prev});
315 this.btn_next=AJS.IMG({"class":"right",src:this.img_next});
316 AJS.AEV(this.btn_prev,"click",AJS.$b(this.switchPrev,this));
317 AJS.AEV(this.btn_next,"click",AJS.$b(this.switchNext,this));
318 GB_STATUS=AJS.SPAN({"class":"GB_navStatus"});
319 AJS.ACN(AJS.$("GB_middle"),this.btn_prev,GB_STATUS,this.btn_next);
321 },updateStatus:function(){
322 AJS.setHTML(GB_STATUS,(this.current_index+1)+" / "+this.current_set.length);
323 if(this.current_index==0){
324 AJS.addClass(this.btn_prev,"disabled");
326 AJS.removeClass(this.btn_prev,"disabled");
328 if(this.current_index==this.current_set.length-1){
329 AJS.addClass(this.btn_next,"disabled");
331 AJS.removeClass(this.btn_next,"disabled");
333 },_setCaption:function(_40){
334 AJS.setHTML(AJS.$("GB_caption"),_40);
335 },updateFrame:function(){
336 var _41=this.current_set[this.current_index];
337 this._setCaption(_41.caption);
340 },switchPrev:function(){
341 if(this.current_index!=0){
342 this.current_index--;
346 },switchNext:function(){
347 if(this.current_index!=this.current_set.length-1){
348 this.current_index++;
353 AJS.AEV(window,"load",function(){
354 AJS.preloadImages(GB_ROOT_DIR+"next.gif",GB_ROOT_DIR+"prev.gif");
356 GB_show=function(_42,url,_44,_45,_46){
357 var _47={caption:_42,height:_44||500,width:_45||500,fullscreen:false,callback_fn:_46};
358 var win=new GB_Window(_47);
359 return win.show(url);
361 GB_showCenter=function(_49,url,_4b,_4c,_4d){
362 var _4e={caption:_49,center_win:true,height:_4b||500,width:_4c||500,fullscreen:false,callback_fn:_4d};
363 var win=new GB_Window(_4e);
364 return win.show(url);
366 GB_showFullScreen=function(_50,url,_52){
367 var _53={caption:_50,fullscreen:true,callback_fn:_52};
368 var win=new GB_Window(_53);
369 return win.show(url);
371 GB_Window=GreyBox.extend({init:function(_55){
373 this.img_header=this.root_dir+"header_bg.gif";
374 this.img_close=this.root_dir+"w_close.gif";
375 this.show_close_img=true;
376 AJS.update(this,_55);
377 this.addCallback(this.callback_fn);
378 },initHook:function(){
379 AJS.addClass(this.g_window,"GB_Window");
380 this.header=AJS.TABLE({"class":"header"});
381 this.header.style.backgroundImage="url("+this.img_header+")";
382 var _56=AJS.TD({"class":"caption"},this.caption);
383 var _57=AJS.TD({"class":"close"});
384 if(this.show_close_img){
385 var _58=AJS.IMG({"src":this.img_close});
386 var _59=AJS.SPAN("Close");
387 var btn=AJS.DIV(_58,_59);
388 AJS.AEV([_58,_59],"mouseover",function(){
389 AJS.addClass(_59,"on");
391 AJS.AEV([_58,_59],"mouseout",function(){
392 AJS.removeClass(_59,"on");
394 AJS.AEV([_58,_59],"mousedown",function(){
395 AJS.addClass(_59,"click");
397 AJS.AEV([_58,_59],"mouseup",function(){
398 AJS.removeClass(_59,"click");
400 AJS.AEV([_58,_59],"click",GB_hide);
403 tbody_header=AJS.TBODY();
404 AJS.ACN(tbody_header,AJS.TR(_56,_57));
405 AJS.ACN(this.header,tbody_header);
406 AJS.ACN(this.top_cnt,this.header);
408 AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
410 },setFrameSize:function(){
412 var _5b=AJS.getWindowSize();
414 this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10);
415 this.height=Math.round(overlay_h-(overlay_h/100)*10);
417 AJS.setWidth(this.header,this.width+6);
418 AJS.setWidth(this.iframe,this.width);
419 AJS.setHeight(this.iframe,this.height);
420 },setWindowPosition:function(){
421 var _5c=AJS.getWindowSize();
422 AJS.setLeft(this.g_window,((_5c.w-this.width)/2)-13);
423 if(!this.center_win){
424 AJS.setTop(this.g_window,AJS.getScrollTop());
426 var fl=((_5c.h-this.height)/2)-20+AJS.getScrollTop();
430 AJS.setTop(this.g_window,fl);
433 AJS.preloadImages(GB_ROOT_DIR+"w_close.gif",GB_ROOT_DIR+"header_bg.gif");