  
  

 function setCookie(name, value, expires, path) {
        document.cookie= name + '=' + escape(value) +
            ((expires) ? '; expires=' + expires.toGMTString() : '') +
            ((path) ? '; path=' + path : '; path=/');
    }

    function getCookie(name) {
        var dc = document.cookie;
        var prefix = name + '=';
        var begin = dc.indexOf('; ' + prefix);
        if (begin == -1) {
            begin = dc.indexOf(prefix);
            if (begin != 0) return null;
        } else {
            begin += 2;
        }
        var end = document.cookie.indexOf(';', begin);
        if (end == -1) {
            end = dc.length;
        }
        return unescape(dc.substring(begin + prefix.length, end));
    }

   /* TODO: JM remove this for 144
 * only used for banner element
 */
function iframeShim(theDiv){
    var self = this;
    this.div = theDiv;
    if (this.div.currentStyle){
        //We only need this in IE
        //Initialize iframe
        var frame = document.createElement("iframe");
        frame.src = "javascript: ''";
        frame.frameBorder = "0";
        frame.scrolling = "no";
        frame.style.zIndex = this.div.currentStyle.zIndex - 1;
        frame.style.left = this.div.currentStyle.left;
        frame.style.width = this.div.offsetWidth;
        frame.style.top = this.div.currentStyle.top;
        frame.style.bottom = this.div.currentStyle.bottom;
        frame.style.height = this.div.offsetHeight;
        frame.style.position = "absolute";
        frame.style.display = this.div.currentStyle.display;
        this.iframe = frame;

        this.div.parentNode.insertBefore(this.iframe, this.div);

        this.setStyle = this.setStyleIE;
    } else {
        //Non IE, just pass calls through
        this.setStyle = this.setStyleNonIE;
    }
}

iframeShim.prototype = {
    setStyleNonIE : function(prop, val){
                        this.div.style[prop] = val;
                    },

    setStyleIE : function(prop, val){
                        this.div.style[prop] = val;
                        this.iframe.style[prop] = val;
                        //Refresh iframe's width and height from the browser calculated offsets.
                        this.iframe.style.width = this.div.offsetWidth + "px";
                        this.iframe.style.height = this.div.offsetHeight + "px";
                 },
    getStyle : function(prop) {
        return this.div.style[prop];
    }
}

function displayGSbanner() {
    if (!getCookie('customtourn1')) {
	    GSbanner = new iframeShim(GSbanner);
		GSbanner.bannerY = -50;
        GSbanner.setStyle('display', 'block');
        GSbanner.fadingIn = setTimeout(GSfadeIn, 0);
		GSgoAway(false);
    }
}
function GSgoAway(clicked) {
    if (clicked) {
        if (GSbanner.fadingIn) {
            clearTimeout(GSbanner.fadingIn);
            GSbanner.fadingIn = null;
        }
        GSbanner.div.onmouseover = null;
        GSbanner.div.onmouseout = null;
        GSbanner.div.onmouseclick = null;
        var expires = new Date();
        expires.setDate(expires.getDate() + 90);
        setCookie('customtourn1', 1, expires);
        GSfadeOut();
    } else {
        GSbanner.fadingOut = setTimeout(GSfadeOut, 4000);
    }
}
function GSinterrupt() {
    if (GSbanner.fadingOut) {;
        clearTimeout(GSbanner.fadingOut);
        GSbanner.fadingOut = null;
        if (!GSbanner.fadingOut) {;
            GSbanner.fadingIn = setTimeout(GSfadeIn, 0);
        }
    }
}
function GSfadeOut() {
    if (GSbanner.fadingOut) {
        clearTimeout(GSbanner.fadingOut);
        GSbanner.fadingOut = null;
    }
    if (GSbanner.bannerY > -50) {
//    if (GSbanner.bannerY > -202) {
        GSbanner.bannerY += -5;
        GSbanner.setStyle('top', GSbanner.bannerY + 'px');
        GSbanner.fadingOut = setTimeout(GSfadeOut, 40);
    } else {
        GSbanner.div.onmouseover = null;
    }
}
function GSfadeIn() {


    if (GSbanner.fadingIn) {
	   clearTimeout(GSbanner.fadingIn);
        GSbanner.fadingIn = null;
    }
	
    if (GSbanner.bannerY < 0) {
        GSbanner.bannerY -= -5;
        GSbanner.setStyle('top', GSbanner.bannerY + 'px');
        GSbanner.fadingIn = setTimeout(GSfadeIn, 30);
    }
}
