///////////////////////////////////////////////////////////////////////////////
//base.js//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
var GB_CURRENT = null;

GB_hide = function(cb) {
    GB_CURRENT.hide(cb);
}

GB_show = function(urla){
	this.g = new GreyBox({url:urla, caption:"a", type:"page"});
	//GreyBox.show("http://www.google.de");
}

GreyBox = new AJS.Class({
    init: function(options) {
        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.reload_on_close = false;
        //this.src_loader = this.root_dir + 'loader_frame.html';
        this.src_loader = 'http://www.enricopense.de/greybox/loader_frame.html';
        
        //Solve the www issue
        var h_www = window.location.hostname.indexOf('www');
        var src_www = this.src_loader.indexOf('www');
        if(h_www != -1 && src_www == -1)
            this.src_loader = this.src_loader.replace('://', '://www.');

        if(h_www == -1 && src_www != -1)
            this.src_loader = this.src_loader.replace('://www.', '://');

        this.show_loading = true;
        AJS.update(this, options);
    },

    addCallback: function(fn) {
        if(fn) this.callback_fns.push(fn);
    },

    show: function(url) {
        GB_CURRENT = this;
        this.url = url;

        var elms = [AJS.$bytc("object"), AJS.$bytc("select")];
        AJS.map(AJS.flattenList(elms), function(elm) {
            elm.style.visibility = "hidden";
        });

        this.createElements();
        return false;
    },

    hide: function(cb) {
        var me = this;
        //IE SSL fix
        AJS.callLater(function() {
            var c_bs = me.callback_fns;
            if(c_bs != []) {
                AJS.map(c_bs, function(fn) { 
                    fn();
                });
            }

            me.onHide();
            if(me.use_fx) {
                var elm = me.overlay;
                AJS.fx.fadeOut(me.overlay, {
                    onComplete: function() {
                        AJS.removeElement(elm);
                        elm = null;
                    },
                    duration: 300
                });
                AJS.removeElement(me.g_window);
            }
            else {
                AJS.removeElement(me.g_window, me.overlay);
            }

            me.removeFrame();

            AJS.REV(window, "scroll", _GB_setOverlayDimension);
            AJS.REV(window, "resize", _GB_update);

            var elms = [AJS.$bytc("object"), AJS.$bytc("select")];
            AJS.map(AJS.flattenList(elms), function(elm) {
                elm.style.visibility = "visible";
            });

            GB_CURRENT = null;

            if(me.reload_on_close)
                window.location.reload();

            if(AJS.isFunction(cb))
                cb();
        }, 10);
    },

    update: function() {
        this.setOverlayDimension();
        this.setFrameSize();
        this.setWindowPosition();
    },

    createElements: function() {
        this.initOverlay();

				/////////////////////NEW CAPTION POS//////////////////////////////////////////////////////
        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(this.use_fx) {
            AJS.fx.fadeIn(this.overlay, {
                duration: 600,
                to: 0.8,
                onComplete: function() {
                    me.onShow();
                    AJS.showElement(me.g_window);
                    me.startLoading();
                }
            });
        }
        else {
            AJS.setOpacity(this.overlay, 0);
            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() {
    	  if(this.iframe)
    	  {
	        this.iframe.src = this.src_loader + '?s='+this.salt++;
	        AJS.showElement(this.iframe);
	      }
    },

    setOverlayDimension: function() {
        var page_size = AJS.getWindowSize();
        if(AJS.isMozilla() || AJS.isOpera())
            AJS.setWidth(this.overlay, "100%");
        else
            AJS.setWidth(this.overlay, page_size.w);

        var max_height = Math.max(AJS.getScrollTop()+page_size.h, AJS.getScrollTop()+this.height);

        if(max_height < AJS.getScrollTop())
            AJS.setHeight(this.overlay, max_height);
        else
            AJS.setHeight(this.overlay, AJS.getScrollTop()+page_size.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) {
        		//NEW CAPTION POS////////////////////////////////////
        		this.newCaption = AJS.DIV({'id': 'GB_caption', 'class': 'caption'}, this.caption);
        	
            var d = {'name': 'GB_frame', 'class': 'GB_frame', 'frameBorder': 0};
            if(AJS.isIe())
                d.src = "javascript:false;document.write(\"\");";
            this.iframe = AJS.IFRAME(d);
           
            this.middle_cnt = AJS.DIV({'id':'content', 'class': 'content'}, this.newCaption, this.iframe);

            this.bottom_cnt = AJS.DIV();

            AJS.ACN(this.g_window, this.middle_cnt, this.bottom_cnt);
        }
    },

    /* Can be implemented */
    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(); }

AJS.preloadImages(GB_ROOT_DIR+'rotation.gif');

script_loaded = true;

///////////////////////////////////////////////////////////////////////////////
//auto_deco.js/////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
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 name = rel.match(/\w+/)[0];
                var attrs = rel.match(/\[(.*)\]/)[1];
                var index = 0;

                var item = {
                    'caption': a.title || '',
                    'url': a.href
                }
                        

                //Set up GB_SETS
                if(name == 'gb_pageset' || name == 'gb_imageset') {
                    if(!GB_SETS[attrs]) { GB_SETS[attrs] = []; }
                    GB_SETS[attrs].push(item);
                    index = GB_SETS[attrs].length;
                }

                //Append onclick
                if(name == 'gb_pageset') {
                    a.onclick = function() {
                        GB_showFullScreenSet(GB_SETS[attrs], index);
                        return false;
                    };
                }
                if(name == 'gb_imageset') {
                    a.onclick = function() {
                        GB_showImageSet(GB_SETS[attrs], index);
                        return false;
                    };
                }
                if(name == 'gb_image') {
                    a.onclick = function() {
                        GB_showImage(item.caption, item.url);
                        return false;
                    };
                }
                if(name == 'gb_page') {
                    a.onclick = function() {
                        var sp = attrs.split(/, ?/);
                        GB_showPage(item.caption, item.url, parseInt(sp[1]), parseInt(sp[0]));
                        return false;
                    };
                }
                if(name == 'gb_page_fs') {
                    a.onclick = function() {
                        GB_showFullScreen(item.caption, item.url);
                        return false;
                    };
                }
                if(name == 'gb_page_center') {
                    a.onclick = function() {
                        var sp = attrs.split(/, ?/);
                        GB_showCenter(item.caption, item.url, parseInt(sp[1]), parseInt(sp[0]));
                        return false;
                    };
                }
            }
        }});
}

AJS.AEV(window, 'load', decoGreyboxLinks);

///////////////////////////////////////////////////////////////////////////////
//gallery.js///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
GB_showImage = function(caption, url, callback_fn) {
    var options = {
        width: 300,
        height: 300,
        type: 'image',

        fullscreen: false,
        center_win: true,
        caption: caption,
        callback_fn: callback_fn
    }
    var win = new GB_Gallery(options);
    return win.show(url);
}

GB_showPage = function(caption, url, callback_fn) {
    var options = {
        type: 'page',
		
        callback_fn: callback_fn,
        fullscreen: true,
        center_win: false,
        caption: caption
    }
    var win = new GB_Gallery(options);
    return win.show(url);
}

GB_Gallery = GreyBox.extend({
    init: function(options) {
        this.parent({});
        this.img_close = this.root_dir + 'new_close.png';
        AJS.update(this, options);
        this.addCallback(this.callback_fn);
    },

    initHook: function() {
        AJS.addClass(this.g_window, 'GB_Gallery');

        
        this.imageRotHelper = AJS.DIV({id:'imageRotatorHelper', 'class': 'imageRotatorHelper'});
        this.imageRot = AJS.DIV({id:'imageRotator', 'class': 'imageRotator'}, this.imageRotHelper);
        //AJS.setOpacity(this.imageRot, 1);
        
        var inner = AJS.DIV({'class': 'inner'});
        this.header = AJS.DIV({'class': 'GB_header'}, inner);
        
        AJS.setOpacity(this.header, 0);
        AJS.getBody().insertBefore(this.header, this.overlay.nextSibling);


		//Tabelle, 3 spalten, 1 zeile, zentriert:
		this.td_rot_left = AJS.TD({'id': 'rot_left', 'class': 'rot_left', 'width': '40%'}, '');
        this.td_rot_middle = AJS.TD({'id': 'rot_middle', 'class': 'rot_middle', 'width': '20%'});
		this.td_rot_right = AJS.TD({'id':'rot_right', 'class': 'rot_right', 'width': '40%'});
		var tbody_rot = AJS.TBODY(AJS.TR(this.td_rot_left, this.td_rot_middle, this.td_rot_right));
        var table_rot = AJS.TABLE({'cellspacing': '0', 'cellpadding': 0, 'border': 0}, tbody_rot);
        AJS.ACN(this.imageRot, table_rot);


        //var td_caption = AJS.TD({'id': 'GB_caption', 'class': 'caption', 'width': '40%'}, this.caption);
        var td_captionOld = AJS.TD({'id': 'GB_spacer', 'class': 'captionOld', 'width': '40%'}, '');
        var td_middle = AJS.TD({'id': 'GB_middle', 'class': 'middle', 'width': '20%'}, this.imageRot);

        var img_close = AJS.IMG({'src': this.img_close});
        AJS.AEV(img_close, 'click', GB_hide);
        var td_close = AJS.TD({'class': 'close', 'width': '40%'}, img_close);

        var tbody = AJS.TBODY(AJS.TR(td_captionOld, td_middle, td_close));
        
        var table = AJS.TABLE({'cellspacing': '0', 'cellpadding': 0, 'border': 0}, tbody);
        AJS.ACN(inner, table);

        if(this.fullscreen)
            AJS.AEV(window, 'scroll', AJS.$b(this.setWindowPosition, this));
        else
            AJS.AEV(window, 'scroll', AJS.$b(this._setHeaderPos, this));
    },

    setFrameSize: function() {
        var overlay_w = this.overlay.offsetWidth;
        var page_size = AJS.getWindowSize();

        if(this.fullscreen) {
            this.width = overlay_w-40;
            this.height = page_size.h-80;
        }
        AJS.setWidth(this.iframe, this.width);
        AJS.setHeight(this.iframe, this.height);

        AJS.setWidth(this.header, overlay_w);
    },

    _setHeaderPos: function() {
        AJS.setTop(this.header, AJS.getScrollTop()+10);
    },

    setWindowPosition: function() {
        var overlay_w = this.overlay.offsetWidth;
        var page_size = AJS.getWindowSize();
        AJS.setLeft(this.g_window, ((overlay_w - 50 - this.width)/2));
        AJS.setWidth(this.g_window, this.width+6);
        AJS.setHeight(this.g_window, this.height);

        var header_top = AJS.getScrollTop()+55;
        if(!this.center_win) {
            AJS.setTop(this.g_window, header_top);
        }
        else {
            var fl = ((page_size.h - this.height) /2) + 20 + AJS.getScrollTop();
            if(fl < 0) fl = 0;
            if(header_top > fl) {
                fl = header_top;
            }
            AJS.setTop(this.g_window, fl);
        }
        this._setHeaderPos();
    },

    onHide: function() {
        AJS.removeElement(this.header);
        AJS.removeClass(this.g_window, 'GB_Gallery');
    },

    onShow: function() {
        if(this.use_fx)
            AJS.fx.fadeIn(this.header, {to: 1});
        else
            AJS.setOpacity(this.header, 1);
    }
});

AJS.preloadImages(GB_ROOT_DIR+'new_close.png');

///////////////////////////////////////////////////////////////////////////////
//set.js///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

GB_showFullScreenSet = function(set, start_index, callback_fn) {
    var options = {
        type: 'page',
        fullscreen: true,
        center_win: false
    }
    this.gb_sets = new GB_Sets(options, set);
    this.gb_sets.addCallback(callback_fn);
    this.gb_sets.showSet(start_index-1);
    return false;
}

GB_showImageSet = function(set, start_index, callback_fn) {
    var options = {
        type: 'image',
        fullscreen: false,
        center_win: true,
        width: 300,
        height: 300
    }
    this.gb_sets = new GB_Sets(options, set);
    this.gb_sets.addCallback(callback_fn);
    this.gb_sets.showSet(start_index-1);
    return false;
}

GB_Sets = GB_Gallery.extend({
    init: function(options, set) {
        this.parent(options);
        if(!this.img_next) this.img_next = this.root_dir + 'new_right.png';
        if(!this.img_prev) this.img_prev = this.root_dir + 'new_left.png';
        this.current_set = set;
        this.nrImagesToShow = 9; //muss immer ungerade sein!
        this.showArr = Array(this.nrImagesToShow);
        this.radius = (this.nrImagesToShow-1)/2;
        
        
        /**EDIT Phil **********************************************/
        var blnDOM = false, blnIE4 = false, blnNN4 = false; 
        if (document.layers) blnNN4 = true;
		else if (document.all) blnIE4 = true;
		else if (document.getElementById) blnDOM = true;
		
		//gets the pressed keycode for all browsers:
		function getKeycode(e)
		{
		  if (blnNN4 || blnDOM) return e.which
		  if (blnIE4) return event.keyCode
		}
		
		document.onkeydown = getKeycode
		if (blnNN4) document.captureEvents(Event.KEYDOWN)
		
        var ref = this;
        function onkeydown(e)
        {
        	if(getKeycode(e)==37) ref.switchPrev();
			
			else if(getKeycode(e)==39) ref.switchNext();
			
			else if(getKeycode(e)==27) GB_hide();
		}
		
		if(document.attachEvent)
		{
			document.onkeydown = onkeydown; //register event in IE
		}
		else 
		{ 
			document.addEventListener("keydown", onkeydown, false); //all other browsers
		}
		/************************************************/
    },

    showSet: function(start_index) {
        this.current_index = start_index;

        var item = this.current_set[this.current_index];
        this.show(item.url);
        
        this._setCaption(item.caption); ////////////////////////////////////////////////////////////////

        this.btn_prev = AJS.IMG({'class': 'left', 'id':'left', src: this.img_prev});
        this.btn_next = AJS.IMG({'class': 'right', 'id':'right', src: this.img_next});

        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', 'id':'GB_navStatus'});
  		this.navContainer = AJS.DIV({id:'navContainer', 'class': 'navContainer'}, this.btn_prev, GB_STATUS, this.btn_next);
        AJS.ACN(AJS.$('GB_middle'), this.navContainer);
        
        /** REGEXP: "xyz.jpg" => "xyz_thumb.jpg" */
				this.regExp2 = /(.*?).(jpg|png)/g;
				
				/*Save all small images to Array*/
				
				this.smallIMGs = Array(this.current_set.length);
				this.imageIDs = Array(this.current_set.length);
				for(var i=0; i<this.current_set.length; i++)
				{
					var smallUrl = this.current_set[i].url.replace(this.regExp2, "$1_thumb.$2");
					var imgElem = AJS.IMG({id:'rotImage', 'class': 'rotImage', src: smallUrl});
					AJS.setOpacity(imgElem, 0.5);
					this.smallIMGs[i] = imgElem;
					var imgA = AJS.A({id:'rotImgLink'+i, 'class':'rotImgLink', href:'javascript:gb_sets.jumpToImage('+i+');'}, imgElem);
					AJS.setOpacity(imgA, 1);
					this.imageIDs[i] = imgA;
					
					var container = AJS.getElement('imageRotatorHelper');
					
					container.appendChild(imgA);
				}
				
				this.jumpToImage(start_index);

    },

    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(caption) {
        AJS.setHTML(AJS.$('GB_caption'), caption);
    },

    updateFrame: function() {
        var item = this.current_set[this.current_index];
        this._setCaption(item.caption); ///////////////////////////////////////////////////////////////////////////
        this.url = item.url;
        this.startLoading();
    },

    switchPrev: function() {
        if(this.current_index != 0) {
            this.current_index--;
            this.jumpToImage(this.current_index);
        }
    },

    switchNext: function() {
        if(this.current_index != this.current_set.length-1) {
            this.current_index++
            this.jumpToImage(this.current_index);
        }
    },
    
    jumpToImage: function(imgIndex){
    	if(imgIndex >= 0
    	&& imgIndex <this.current_set.length)
    	{
    		this.current_index = imgIndex;
    		this.updateFrame();
        	this.updateStatus();
        
        	new AJS.fx.fadeIn(this.smallIMGs[imgIndex], {from: 0.5, to: 1, duration: 500});
    		if(this.smallImageBeforeIndex!=null && this.smallImageBeforeIndex!="undefined")
    		{
    			new AJS.fx.fadeOut(this.smallIMGs[this.smallImageBeforeIndex], {from: 1, to: 0.5});
			}
        
        	//set the image array to show:
        	this.updateShowArr(this.current_index);
        	
        	this.smallImageBeforeIndex = imgIndex;
        	
    	}
    },
    
    updateShowArr: function(imgIndex){
    	try
    	{
    		var result = "";
	    	if(!this.current_set.length >= this.nrImagesToShow)
	    	{
	    		this.radius = this.current_set.length;
	    		if(this.radius % 2 == 0)
	    		{
	    			//var imgElmL = this.imageIDs[imgIndex-i];
	    			//var spacer = AJS.DIV({'id':'placeholder','style':'width:'+AJS.$(imgElmL).width+'; height:'+AJS.$(imgElmL).height+';'});
	    			//this.imageIDs.push(spacer);
	    		}
	    	}
	    		//alert("this.imageArr:"+this.imageIDs.length+" imgIndex:"+imgIndex);
	    		for(var i=this.radius; i > 0; i--)
	    		{
		    		if(imgIndex-i >= 0)
		    		{
						var imgElmL = this.imageIDs[imgIndex-i];
						//result+= AJS.$(imgElmL).id+" "; 
						this.addLeft(AJS.$(imgElmL));
		    		}
	    		}

	    		var imgElmM = this.imageIDs[imgIndex];
	    		this.addMiddle(AJS.$(imgElmM));
	    		//result+= "["+AJS.$(imgElmM).id+"] ";
	    		
	    		this.moveAllChildren(AJS.$('rot_right'), AJS.$('imageRotatorHelper'));
	    		for(var j=0; j < this.radius; j++)
	    		{
		    		if(imgIndex+1+j < this.imageIDs.length)
		    		{
						var imgElmR = this.imageIDs[imgIndex+1+j];
						this.addRight(AJS.$(imgElmR));
						//result+= AJS.$(imgElmR).id+" ";
		    		}
	    		}
	    		//move all elms from id(rot_left) back to invisible id(imageRotatorHelper)
	    		//this.moveAllChildren(AJS.$('rot_left'), AJS.$('imageRotatorHelper'));
		    	//this.addAll(AJS.$('rot_left'), this.showArrL);
		    	
	    		//alert("result: "+result);
	    		
	    	
    	}catch(e){alert("Exception: updateShowArray() "+e);}
    	//this.showArr
    },
    
    addLeft: function(img){
    	var nL = AJS.$('rot_left').childNodes.length;
    	if(nL>=this.radius)
    	{
	    	if(AJS.$('rot_left').firstChild)
	    		this.rem(AJS.$('rot_left').firstChild);
    	}
    	AJS.ACN(AJS.$('rot_left'), img);
    },
    
    addRight: function(img){
    	try
    	{
	    	var nR = AJS.$('rot_right').childNodes.length;
	    	
	    	if(nR>=this.radius)
	    	{
		    	if(this.getIncrement()>0) //next
		    	{	
		    		if(AJS.$('rot_right').firstChild)
		    			this.rem(AJS.$('rot_right').firstChild);
		    	}
		    	else if(this.getIncrement()<0)//prev
		    	{
		    		if(AJS.$('rot_right').childNodes[nR-1])
		    			this.rem(AJS.$('rot_right').childNodes[nR-1]);
		    	}
		    	else //start or direct click
		    	{
		    		
		    	}	
	    	}
	    	
	    	if(this.getIncrement()>0) //next
	    		AJS.ACN(AJS.$('rot_right'), img);
	    	else if(this.getIncrement()>0){//prev
	    		if(nR == 0)
	    			AJS.ACN(AJS.$('rot_right'), img);
	    		else
	    			AJS.insertBefore(img, AJS.$('rot_right').firstChild);
	    	}
	    	else //start
	    		AJS.ACN(AJS.$('rot_right'), img);
    		
    	}catch(e){alert("Exception: addRight() "+e);}
    
    },
    
    /**
     * Returns int, If negative a lower image was chosen.
     */
    getIncrement: function(){
    	var n = this.current_index - this.smallImageBeforeIndex;
    	if(isNaN(this.current_index) && isNaN(this.smallImageBeforeIndex))
    		n = 0;
    	else if(isNaN(this.current_index))
    		n = -this.smallImageBeforeIndex;
    	else if(isNaN(this.smallImageBeforeIndex))
    		n = this.current_index;
    		
    	if(isNaN(n))
    		n = 0;
    	return n;
    },
    
    addMiddle: function(img){
    	if(AJS.$('rot_middle').firstChild)
    		this.rem(AJS.$('rot_middle').firstChild);
    	
    	AJS.ACN(AJS.$('rot_middle'), img);
    },
    
    
    rem: function(img){
    	AJS.$('imageRotatorHelper').appendChild(img);
    },
    
    
    
    /**
     * Moves all children from src element to dest element
     */
    moveAllChildren: function(src, dest){
    	try
    	{
    		var child;
    		while ((child = src.firstChild))
            	dest.appendChild(child);
    		
    	}catch(e){alert("moveAllChildren(): "+e);}
    },
    
    removeAllChildren: function(elm){
    	try
    	{
    		var child;
    		while ((child = elm.firstChild))
            	elm.removeChild(child);
    		
    	}catch(e){alert("removeAllChildren(): "+e);}
    },
    
    addAll: function(elm, childArr){
    	try{
    	for(var i=0; i<childArr.length; i++){
    		alert("add to "+"elm.id="+elm.id+" id:"+childArr[i].id);
    		var child = AJS.$(childArr[i].id);
    		AJS.ACN(elm, child);
    	}
    	}catch(e){alert("addAll(): i="+i+": "+e);}
    }
    
});

AJS.AEV(window, 'load', function() {
    AJS.preloadImages(GB_ROOT_DIR+'new_right.png', GB_ROOT_DIR+'new_left.png');
});



