5 GreyBox=new AJS.Class({init:function(_2){
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 _3=window.location.hostname.indexOf("www");
15 var _4=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 _7=[AJS.$bytc("object"),AJS.$bytc("select")];
32 AJS.map(AJS.flattenList(_7),function(_8){
33 _8.style.visibility="hidden";
35 this.createElements();
39 AJS.callLater(function(){
40 var _b=me.callback_fns;
42 AJS.map(_b,function(fn){
49 AJS.fx.fadeOut(me.overlay,{onComplete:function(){
50 AJS.removeElement(_d);
53 AJS.removeElement(me.g_window);
55 AJS.removeElement(me.g_window,me.overlay);
58 AJS.REV(window,"scroll",_GB_setOverlayDimension);
59 AJS.REV(window,"resize",_GB_update);
60 var _e=[AJS.$bytc("object"),AJS.$bytc("select")];
61 AJS.map(AJS.flattenList(_e),function(_f){
62 _f.style.visibility="visible";
65 if(me.reload_on_close){
66 window.location.reload();
68 if(AJS.isFunction(cb)){
73 this.setOverlayDimension();
75 this.setWindowPosition();
76 },createElements:function(){
78 this.g_window=AJS.DIV({"id":"GB_window"});
79 AJS.hideElement(this.g_window);
80 AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling);
86 AJS.fx.fadeIn(this.overlay,{duration:300,to:0.7,onComplete:function(){
88 AJS.showElement(me.g_window);
92 AJS.setOpacity(this.overlay,0.7);
93 AJS.showElement(this.g_window);
97 AJS.AEV(window,"scroll",_GB_setOverlayDimension);
98 AJS.AEV(window,"resize",_GB_update);
99 },removeFrame:function(){
101 AJS.removeElement(this.iframe);
106 },startLoading:function(){
107 this.iframe.src=this.src_loader+"?s="+this.salt++;
108 AJS.showElement(this.iframe);
109 },setOverlayDimension:function(){
110 var _11=AJS.getWindowSize();
111 if(AJS.isMozilla()||AJS.isOpera()){
112 AJS.setWidth(this.overlay,"100%");
114 AJS.setWidth(this.overlay,_11.w);
116 var _12=Math.max(AJS.getScrollTop()+_11.h,AJS.getScrollTop()+this.height);
117 if(_12<AJS.getScrollTop()){
118 AJS.setHeight(this.overlay,_12);
120 AJS.setHeight(this.overlay,AJS.getScrollTop()+_11.h);
122 },initOverlay:function(){
123 this.overlay=AJS.DIV({"id":"GB_overlay"});
124 if(this.overlay_click_close){
125 AJS.AEV(this.overlay,"click",GB_hide);
127 AJS.setOpacity(this.overlay,0);
128 AJS.getBody().insertBefore(this.overlay,AJS.getBody().firstChild);
129 },initFrame:function(){
131 var d={"name":"GB_frame","class":"GB_frame","frameBorder":0};
133 d.src="javascript:false;document.write(\"\");";
135 this.iframe=AJS.IFRAME(d);
136 this.middle_cnt=AJS.DIV({"class":"content"},this.iframe);
137 this.top_cnt=AJS.DIV();
138 this.bottom_cnt=AJS.DIV();
139 AJS.ACN(this.g_window,this.top_cnt,this.middle_cnt,this.bottom_cnt);
143 },setFrameSize:function(){
144 },setWindowPosition:function(){
145 },initHook:function(){
147 _GB_update=function(){
152 _GB_setOverlayDimension=function(){
154 GB_CURRENT.setOverlayDimension();
157 AJS.preloadImages(GB_ROOT_DIR+"indicator.gif");
160 function decoGreyboxLinks(){
161 var as=AJS.$bytc("a");
162 AJS.map(as,function(a){
163 if(a.getAttribute("href")&&a.getAttribute("rel")){
164 var rel=a.getAttribute("rel");
165 if(rel.indexOf("gb_")==0){
166 var _17=rel.match(/\w+/)[0];
167 var _18=rel.match(/\[(.*)\]/)[1];
169 var _1a={"caption":a.title||"","url":a.href};
170 if(_17=="gb_pageset"||_17=="gb_imageset"){
174 GB_SETS[_18].push(_1a);
175 _19=GB_SETS[_18].length;
177 if(_17=="gb_pageset"){
178 a.onclick=function(){
179 GB_showFullScreenSet(GB_SETS[_18],_19);
183 if(_17=="gb_imageset"){
184 a.onclick=function(){
185 GB_showImageSet(GB_SETS[_18],_19);
190 a.onclick=function(){
191 GB_showImage(_1a.caption,_1a.url);
196 a.onclick=function(){
197 var sp=_18.split(/, ?/);
198 GB_show(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
202 if(_17=="gb_page_fs"){
203 a.onclick=function(){
204 GB_showFullScreen(_1a.caption,_1a.url);
208 if(_17=="gb_page_center"){
209 a.onclick=function(){
210 var sp=_18.split(/, ?/);
211 GB_showCenter(_1a.caption,_1a.url,parseInt(sp[1]),parseInt(sp[0]));
219 AJS.AEV(window,"load",decoGreyboxLinks);
220 GB_showImage=function(_1d,url,_1f){
221 var _20={width:300,height:300,type:"image",fullscreen:false,center_win:true,caption:_1d,callback_fn:_1f};
222 var win=new GB_Gallery(_20);
223 return win.show(url);
225 GB_showPage=function(_22,url,_24){
226 var _25={type:"page",caption:_22,callback_fn:_24,fullscreen:true,center_win:false};
227 var win=new GB_Gallery(_25);
228 return win.show(url);
230 GB_Gallery=GreyBox.extend({init:function(_27){
232 this.img_close=this.root_dir+"g_close.gif";
233 AJS.update(this,_27);
234 this.addCallback(this.callback_fn);
235 },initHook:function(){
236 AJS.addClass(this.g_window,"GB_Gallery");
237 var _28=AJS.DIV({"class":"inner"});
238 this.header=AJS.DIV({"class":"GB_header"},_28);
239 AJS.setOpacity(this.header,0);
240 AJS.getBody().insertBefore(this.header,this.overlay.nextSibling);
241 var _29=AJS.TD({"id":"GB_caption","class":"caption","width":"40%"},this.caption);
242 var _2a=AJS.TD({"id":"GB_middle","class":"middle","width":"20%"});
243 var _2b=AJS.IMG({"src":this.img_close});
244 AJS.AEV(_2b,"click",GB_hide);
245 var _2c=AJS.TD({"class":"close","width":"40%"},_2b);
246 var _2d=AJS.TBODY(AJS.TR(_29,_2a,_2c));
247 var _2e=AJS.TABLE({"cellspacing":"0","cellpadding":0,"border":0},_2d);
250 AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
252 AJS.AEV(window,"scroll",AJS.$b(this._setHeaderPos,this));
254 },setFrameSize:function(){
255 var _2f=this.overlay.offsetWidth;
256 var _30=AJS.getWindowSize();
259 this.height=_30.h-80;
261 AJS.setWidth(this.iframe,this.width);
262 AJS.setHeight(this.iframe,this.height);
263 AJS.setWidth(this.header,_2f);
264 },_setHeaderPos:function(){
265 AJS.setTop(this.header,AJS.getScrollTop()+10);
266 },setWindowPosition:function(){
267 var _31=this.overlay.offsetWidth;
268 var _32=AJS.getWindowSize();
269 AJS.setLeft(this.g_window,((_31-50-this.width)/2));
270 var _33=AJS.getScrollTop()+55;
271 if(!this.center_win){
272 AJS.setTop(this.g_window,_33);
274 var fl=((_32.h-this.height)/2)+20+AJS.getScrollTop();
281 AJS.setTop(this.g_window,fl);
283 this._setHeaderPos();
285 AJS.removeElement(this.header);
286 AJS.removeClass(this.g_window,"GB_Gallery");
289 AJS.fx.fadeIn(this.header,{to:1});
291 AJS.setOpacity(this.header,1);
294 AJS.preloadImages(GB_ROOT_DIR+"g_close.gif");
295 GB_showFullScreenSet=function(set,_36,_37){
296 var _38={type:"page",fullscreen:true,center_win:false};
297 var _39=new GB_Sets(_38,set);
298 _39.addCallback(_37);
302 GB_showImageSet=function(set,_3b,_3c){
303 var _3d={type:"image",fullscreen:false,center_win:true,width:300,height:300};
304 var _3e=new GB_Sets(_3d,set);
305 _3e.addCallback(_3c);
309 GB_Sets=GB_Gallery.extend({init:function(_3f,set){
312 this.img_next=this.root_dir+"next.gif";
315 this.img_prev=this.root_dir+"prev.gif";
317 this.current_set=set;
318 },showSet:function(_41){
319 this.current_index=_41;
320 var _42=this.current_set[this.current_index];
322 this._setCaption(_42.caption);
323 this.btn_prev=AJS.IMG({"class":"left",src:this.img_prev});
324 this.btn_next=AJS.IMG({"class":"right",src:this.img_next});
325 AJS.AEV(this.btn_prev,"click",AJS.$b(this.switchPrev,this));
326 AJS.AEV(this.btn_next,"click",AJS.$b(this.switchNext,this));
327 GB_STATUS=AJS.SPAN({"class":"GB_navStatus"});
328 AJS.ACN(AJS.$("GB_middle"),this.btn_prev,GB_STATUS,this.btn_next);
330 },updateStatus:function(){
331 AJS.setHTML(GB_STATUS,(this.current_index+1)+" / "+this.current_set.length);
332 if(this.current_index==0){
333 AJS.addClass(this.btn_prev,"disabled");
335 AJS.removeClass(this.btn_prev,"disabled");
337 if(this.current_index==this.current_set.length-1){
338 AJS.addClass(this.btn_next,"disabled");
340 AJS.removeClass(this.btn_next,"disabled");
342 },_setCaption:function(_43){
343 AJS.setHTML(AJS.$("GB_caption"),_43);
344 },updateFrame:function(){
345 var _44=this.current_set[this.current_index];
346 this._setCaption(_44.caption);
349 },switchPrev:function(){
350 if(this.current_index!=0){
351 this.current_index--;
355 },switchNext:function(){
356 if(this.current_index!=this.current_set.length-1){
357 this.current_index++;
362 AJS.AEV(window,"load",function(){
363 AJS.preloadImages(GB_ROOT_DIR+"next.gif",GB_ROOT_DIR+"prev.gif");
365 GB_show=function(_45,url,_47,_48,_49){
366 var _4a={caption:_45,height:_47||500,width:_48||500,fullscreen:false,callback_fn:_49};
367 var win=new GB_Window(_4a);
368 return win.show(url);
370 GB_showCenter=function(_4c,url,_4e,_4f,_50){
371 var _51={caption:_4c,center_win:true,height:_4e||500,width:_4f||500,fullscreen:false,callback_fn:_50};
372 var win=new GB_Window(_51);
373 return win.show(url);
375 GB_showFullScreen=function(_53,url,_55){
376 var _56={caption:_53,fullscreen:true,callback_fn:_55};
377 var win=new GB_Window(_56);
378 return win.show(url);
380 GB_Window=GreyBox.extend({init:function(_58){
382 this.img_header=this.root_dir+"header_bg.gif";
383 this.img_close=this.root_dir+"w_close.gif";
384 this.show_close_img=true;
385 AJS.update(this,_58);
386 this.addCallback(this.callback_fn);
387 },initHook:function(){
388 AJS.addClass(this.g_window,"GB_Window");
389 this.header=AJS.TABLE({"class":"header"});
390 this.header.style.backgroundImage="url("+this.img_header+")";
391 var _59=AJS.TD({"class":"caption"},this.caption);
392 var _5a=AJS.TD({"class":"close"});
393 if(this.show_close_img){
394 var _5b=AJS.IMG({"src":this.img_close});
395 var _5c=AJS.SPAN("Close");
396 var btn=AJS.DIV(_5b,_5c);
397 AJS.AEV([_5b,_5c],"mouseover",function(){
398 AJS.addClass(_5c,"on");
400 AJS.AEV([_5b,_5c],"mouseout",function(){
401 AJS.removeClass(_5c,"on");
403 AJS.AEV([_5b,_5c],"mousedown",function(){
404 AJS.addClass(_5c,"click");
406 AJS.AEV([_5b,_5c],"mouseup",function(){
407 AJS.removeClass(_5c,"click");
409 AJS.AEV([_5b,_5c],"click",GB_hide);
412 tbody_header=AJS.TBODY();
413 AJS.ACN(tbody_header,AJS.TR(_59,_5a));
414 AJS.ACN(this.header,tbody_header);
415 AJS.ACN(this.top_cnt,this.header);
417 AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this));
419 },setFrameSize:function(){
421 var _5e=AJS.getWindowSize();
423 this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10);
424 this.height=Math.round(overlay_h-(overlay_h/100)*10);
426 AJS.setWidth(this.header,this.width+6);
427 AJS.setWidth(this.iframe,this.width);
428 AJS.setHeight(this.iframe,this.height);
429 },setWindowPosition:function(){
430 var _5f=AJS.getWindowSize();
431 AJS.setLeft(this.g_window,((_5f.w-this.width)/2)-13);
432 if(!this.center_win){
433 AJS.setTop(this.g_window,AJS.getScrollTop());
435 var fl=((_5f.h-this.height)/2)-20+AJS.getScrollTop();
439 AJS.setTop(this.g_window,fl);
442 AJS.preloadImages(GB_ROOT_DIR+"w_close.gif",GB_ROOT_DIR+"header_bg.gif");