﻿//framebreaker
if (top != self) top.location.href = location.href;

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 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 Copy(a_content, a_target)
{
    document.all(a_target).innerHTML = document.all(a_content).innerHTML;
}

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);
}

var spotlightItems = 0;
var spotlightCItem = 0;
var spotlightPItem = 0;
var spotlightTimerOn = 0;

function spotlightShow(a_id) {
    if (spotlightCItem != a_id) {
        spotlightPItem = spotlightCItem;
        spotlightCItem = a_id;

        document.getElementById('spotlightThumb' + spotlightPItem).className = "";
        document.getElementById('spotlightThumb' + spotlightCItem).className = "active";
        
        $("#spotlightItem" + spotlightPItem).hide();

        $("#spotlightItem" + spotlightCItem).fadeIn("slow");

        $("#spotlightItem" + spotlightCItem).show();
        spotlightHide();
    }
}

function spotlightInitiate() {
    for (l_i = 0; l_i < 20; l_i++) {
        if (document.getElementById('spotlightThumb' + l_i) && document.getElementById('spotlightItem' + l_i)) {
            spotlightItems++;
        }
        else {
            break;
        }
    }
    
    if (spotlightItems > 0) {
        spotlightCItem = spotlightItems - 1;
        spotlightShow(0);
        spotlightTimerToggle();
    }
}

function spotlightHide() {
    for (l_i = 0; l_i < spotlightItems; l_i++) {
        if (l_i != spotlightPItem && l_i != spotlightCItem) {
            $("#spotlightItem" + l_i).hide();
        }
    }
}

function spotlightTimerToggle() {
    if (spotlightTimerOn == 0) {
        spotlightTimerInterval = setInterval("spotlightNext()", 4000);
        spotlightTimerOn = 1;
    }
    else {
        clearInterval(spotlightTimerInterval);
        spotlightTimerOn = 0;
    }
}

function spotlightNext() {
    if (spotlightCItem == spotlightItems - 1) {//start at first
        spotlightShow(0);
    }
    else {//show the next one
        spotlightShow(spotlightCItem + 1);
    }
}



function ShowGutters() {
    var l_contentWidth = 1024;
    var l_width = 0;
    var l_height = 0;

    if (typeof window.innerWidth != 'undefined') {
        l_width = (window.innerWidth - l_contentWidth) / 2;
        l_height = window.innerHeight;
    }
    else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
        l_width = (document.documentElement.clientWidth - l_contentWidth) / 2;
        l_height = document.documentElement.clientHeight;
    }
    else {// older versions of IE
        l_width = (document.getElementsByTagName('body')[0].clientWidth - l_contentWidth) / 2;
        l_height = document.getElementsByTagName('body')[0].clientHeight;
    }

    if (l_width > 0 && l_width * 2 < l_contentWidth) {
        if (document.layers) {
            document.layers('leftGutter').style.position = "absolute";
            document.layers('leftGutter').style.top = "0px";
            document.layers('leftGutter').style.left = "0px";
            document.layers('leftGutter').style.width = l_width;
            document.layers('leftGutter').style.height = l_height;

            document.layers('rightGutter').style.position = "absolute";
            document.layers('rightGutter').style.top = "0px";
            document.layers('rightGutter').style.right = "0px";
            document.layers('rightGutter').style.width = l_width;
            document.layers('rightGutter').style.height = l_height;
        }
        else {
            document.getElementById('leftGutter').style.position = "absolute";
            document.getElementById('leftGutter').style.top = "0px";
            document.getElementById('leftGutter').style.left = "0px";
            document.getElementById('leftGutter').style.width = l_width;
            document.getElementById('leftGutter').style.height = l_height;

            document.getElementById('rightGutter').style.position = "absolute";
            document.getElementById('rightGutter').style.top = "0px";
            document.getElementById('rightGutter').style.right = "0px";
            document.getElementById('rightGutter').style.width = l_width;
            document.getElementById('rightGutter').style.height = l_height;
        }

        document.leftGutterImage.width = l_width;
        document.leftGutterImage.height = l_height;

        document.rightGutterImage.width = l_width;
        document.rightGutterImage.height = l_height;
    }
    else {//hide the gutters
        if (document.layers) {
            document.layers('leftGutter').style.display = "none";
        }
        else {
            document.getElementById('leftGutter').style.display = "none";
        }
    }
}
