// also uses CrossBrowserDHTML.js

var ad_bannerID = 'a3221421';
var ad_islandID = 'ad00383f';
var ad_leftBannerID = 'flashtowerad';

function show(tag1, tag2)
{
    // this is my attempt at creating an overlay
    var tag1obj = getRefToDiv(tag1);
    if (tag1obj != null) 
    {
        var bannerheight = getDivHeight("TopBanner");
        var ds = tag1obj.style;
        ds.left = 0;
        ds.top = bannerheight;
        ds.width = getWindowWidth();
        ds.height = getPageHeight() - findTop(getRefToDiv('div_dummy')) + getDivHeight( tag2) ;
        ds.visibility = "visible";
        if (getRefToDiv(tag2) != null) 
        {
            getRefToDiv(tag2).style.height = getWindowHeight() - findTop(getRefToDiv('div_dummy')) + getDivHeight( tag2) ;
        }
        if (getRefToDiv(ad_bannerID) != null) 
        {
            getRefToDiv(ad_bannerID).style.visibility = "hidden";
        }
        if (getRefToDiv(ad_islandID) != null) 
        {
            getRefToDiv(ad_islandID).style.visibility = "hidden";
        }
        if (getRefToDiv(ad_leftBannerID) != null) 
        {
            getRefToDiv(ad_leftBannerID).style.visibility = "hidden";
        }
    }
}

// we need to use the /original size/ of the disclaimer tag area. Not the current. WHich is why 420px is hardcoded in
function resizeDisclaimer(DisclaimerTag,DisclaimerEndTag) {
    if (getRefToDiv(DisclaimerTag) != null && getRefToDiv(DisclaimerEndTag) != null) {
        rSDiv(DisclaimerTag,getDivWidth(DisclaimerTag),Math.max(0,getWindowHeight() - 420 + findTop(getRefToDiv(DisclaimerEndTag))));
    }
	if(document.getElementById('btnAgree') != undefined) {
		document.getElementById('btnAgree').disabled = false;
	}
}            

function displayDisclaimer(TermsTag, ContentTag, DisclaimerTag,DisclaimerEndTag) {
    // this is my attempt at creating an overlay
    if (getRefToDiv(TermsTag) != null)      {               
        var bannerheight = getDivHeight("TopBanner");
        var ds = getRefToDiv(TermsTag).style;
        if (ds.visibility != "hidden") {
            ds.visibility = "visible";
            ds.top = bannerheight;
            resizeDisclaimer(DisclaimerTag,DisclaimerEndTag);
            if (getRefToDiv(ContentTag) != null) {
                //getRefToDiv(ContentTag).style.visibility = "hidden";
                getRefToDiv(ContentTag).style.display = "none";
                document.getElementById("btnAgree").focus();
            }   
        }                
    }
}

function hidDisclaimer(DisclamerTag, ContentTag)
{
    // this is my attempt at creating an overlay
    if (getRefToDiv(DisclamerTag) != null) {
        if (getRefToDiv(ContentTag) != null) {
	        getRefToDiv(DisclamerTag).style.display = "none";
            getRefToDiv(ContentTag).style.display = "block";
            //getRefToDiv(ContentTag).style.visibility = "visible";
        }
    }
}

function resize(tag1, tag2)
{
    // resizes the overlay if the window size changes
    if (getRefToDiv(tag1) != null) {
        getRefToDiv(tag1).style.width = getWindowWidth();
    }
    if (getRefToDiv(tag2) != null) {
        getRefToDiv(tag2).style.height = getWindowHeight() - 155;
    }
}

function close(tag)
{

    // the following information was found at http://jibbering.com/2002/4/httprequest.html

    var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
    try 
    {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } 
    catch (e) 
    {
        try 
        {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } 
        catch (E) 
        {
            xmlhttp = false;
        }
    }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        xmlhttp = new XMLHttpRequest();
    }

    // make the request
    xmlhttp.open("GET", "posts_session50.asp",true);
    xmlhttp.send(null)

    // make the terms invisible and the adds visible
    if (getRefToDiv(tag) != null) 
    {
        getRefToDiv(tag).style.visibility = "hidden";
        if (getRefToDiv(ad_bannerID) != null)
        {
            getRefToDiv(ad_bannerID).style.visibility = "visible";
        }
        if (getRefToDiv(ad_islandID) != null)
        {
            getRefToDiv(ad_islandID).style.visibility = "visible";
        }
        if (getRefToDiv(ad_leftBannerID) != null) 
        {
            getRefToDiv(ad_leftBannerID).style.visibility = "visible";
        }
    }
}
