﻿function popUp(url,width,height,scroll,resize)
{
	var left = screen.width/2 - width/2;
	var top = screen.height/2 - height/2;
	var popWin = window.open(url, "pop", "left=" + left + ",top=" + top + ",width=" + width + ",height=" + height + ",scrollbars=" + scroll + ",resizable=" + resize);
}

function GoogleSearch()
{
    this.document.forms["googleSearchFRM"].q.value = this.document.forms["aspnetForm"].q.value;
    for (l_i = 0; l_i < document.forms["aspnetForm"].sitesearch.length; l_i++ )
    {
        if (document.forms["aspnetForm"].sitesearch[l_i].checked == true )
        {
            this.document.forms["googleSearchFRM"].sitesearch.value = document.forms["aspnetForm"].sitesearch[l_i].value;
        }
    }
    this.document.forms["googleSearchFRM"].submit();
}

function ShowHide(a_show,a_hide)
{
    if (document.layers)
    {
        document.layers(a_show).style.display = "block";
        document.layers(a_hide).style.display = "none";
    }
    else
    {
        document.getElementById(a_show).style.display = "block";
        document.getElementById(a_hide).style.display = "none";
    }
}

function ShowHeadlines(a_show)
{
    var l_headlines = new Array("hMainHeadlines", "hNews", "hScoops", "hEditorials", "hFeatures", "hInterviews", "hFanfic", "hReviews");
    var l_images = new Array("whatsNewBTN", "newsBTN", "scoopsBTN", "editorialsBTN", "featuresBTN", "interviewsBTN", "fanficBTN", "reviewsBTN");
    var l_index = 0;
    
    //hide all of the layers
    for (l_i = 0; l_i < l_headlines.length; l_i++)
    {
        if (a_show == l_headlines[l_i])
        {//store this so we know which image to highlight
            l_index = l_i;
        }
        
        if (document.layers)
        {
            document.layers(l_headlines[l_i]).style.display = "none";
        }
        else
        {
            document.getElementById(l_headlines[l_i]).style.display = "none";
        }
        
        document[l_images[l_i]].src = document[l_images[l_i]].src.replace("2","1");
    }
    
    //now show the one we want to see
    document[l_images[l_index]].src = document[l_images[l_index]].src.replace("1","2");
    
    if (document.layers)
    {
        document.layers(a_show).style.display = "block";
    }
    else
    {
        document.getElementById(a_show).style.display = "block";
    }
}

function Show(a_show)
{
    if (document.layers)
    {
        if (document.layers(a_show).style.display.toLowerCase() != "block")
        {//show it
            document.layers(a_show).style.display = "block";
        }
        else
        {//hide it
            document.layers(a_show).style.display = "none";
        }
    }
    else
    {
        if (document.getElementById(a_show).style.display.toLowerCase() != "block")
        {//show it
            document.getElementById(a_show).style.display = "block";
        }
        else
        {//hide it
            document.getElementById(a_show).style.display = "none";
        }
    }
}

function Hide(a_hide)
{
    if (document.layers)
    {
        document.layers(a_hide).style.display = "none";
    }
    else
    {
        document.getElementById(a_hide).style.display = "none";
    }
}

function ShowHelp(a_show)
{
    //figure out y offset
    var yOffset = 0;
    if (self.pageYOffset) // all except Explorer
	{
		yOffset = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		yOffset = document.documentElement.scrollTop;
	}
	else if (document.body.scrollTop) // all other Explorers
	{
		yOffset = document.body.clientHeight;
	}


    if (document.layers)
    {
        if (document.layers(a_show).style.display.toLowerCase() != "block")
        {//show it
            document.layers(a_show).style.display = "block";
            document.layers(a_show).style.position = "absolute";
            
            document.layer(a_show).style.left = window.screen.width/2 - 200 + "px";
            document.layers(a_show).style.top = window.screen.height/2 - (400 - yOffset) + "px";
        }
        else
        {//hide it
            document.layers(a_show).style.display = "none";
        }
    }
    else
    {
        if (document.getElementById(a_show).style.display.toLowerCase() != "block")
        {//show it
            document.getElementById(a_show).style.display = "block";
            document.getElementById(a_show).style.position = "absolute";
            document.getElementById(a_show).style.left = window.screen.width/2 - 200 + "px";
            document.getElementById(a_show).style.top = window.screen.height/2 - (400 - yOffset) + "px";
        }
        else
        {//hide it
            document.getElementById(a_show).style.display = "none";
        }
    }
}

//these can be set on a page by page basis if needed
var processingIMG = "";
var processingSRC = "";

function ShowWorking(a_show, a_hide)
{
    ShowHide(a_show,a_hide);
    setTimeout("ProgressBar()", 100);
} 

function ProgressBar()
{
    document[processingIMG].src = processingSRC; 
}

function ShowInterstitial()
{
    if (document.layers)
    {
        if (document.layers("interstitial").style.display.toLowerCase() != "block")
        {//show it
            document.layers("interstitial").style.display = "block";
            document.layers("page").style.display = "none";
        }
        else
        {//hide it
            document.layers("interstitial").style.display = "none";
            document.layers("page").style.display = "block";
        }
    }
    else
    {
        if (document.getElementById("interstitial").style.display.toLowerCase() != "block")
        {//show it
            document.getElementById("interstitial").style.display = "block";
            document.getElementById("page").style.display = "none";
        }
        else
        {//hide it
            document.getElementById("interstitial").style.display = "none";
            document.getElementById("page").style.display = "block";
        }    
    }
}

function showPreroll() {
    if (document.layers) {
        document.layers("videoPlayer").style.display = "none";
        document.layers("videoPreroll").style.display = "block";
    }
    else {
        document.getElementById("videoPlayer").style.display = "none";
        document.getElementById("videoPreroll").style.display = "block";
    }
}

function hidePreroll()
{
    if (document.layers)
    {
        document.layers("videoPlayer").style.display = "block";
        document.layers("videoPreroll").style.display = "none";
    }
    else
    {
        document.getElementById("videoPlayer").style.display = "block";
        document.getElementById("videoPreroll").style.display = "none";
    }
}