﻿// JScript File
var isIE = (document.getElementById && document.all)?true:false;
var isNS4 = (document.layers)?true:false;
var isNS6 = (document.getElementById && !document.all)?true:false;

function myGetElementById (id)
{
    if ( isIE )
    {
	var str = "document.all('" + id + "')";
	var o = eval(str);
	return o;
    }

    return document.getElementById(id);
}

/*
 * this is called after a new page loads. id is the main content div
 * that has just been loaded and contains a special tag like:
 * <SPAN ID="PAGE_BACKGROUND" SRC="url" WIDTH="width" HEIGHT="height"></SPAN>
 */
function updateBackground (id)
{
    var obj = myGetElementById(id);
    if ( obj )
    {
	var newBgObj = myGetElementById("ctl00_Background1_PAGE_BACKGROUND");
	var bgObj = myGetElementById("ctl00_Background1_background_image");

	if ( newBgObj && bgObj )
	{
	    var src = newBgObj.getAttribute("src");

	    if ( src )
	    {
		setBackground (src,
		    newBgObj.getAttribute("width"),
		    newBgObj.getAttribute("height"));
	    }
	}
    }
}

function setBackground (url, width, height)
{
    var obj = myGetElementById ('ctl00_Background1_background_image');
    if ( obj )
    {
	obj.onload = function () { 
	    if ( width ) this.style.width = width;
	    if ( height ) this.style.height = height;
	    findDimensions();
	}
	obj.src = url;
    }
}

// these globals that can be used from other routines
var pageWidth;
var pageHeight;

// window.onload	= function() { findDimensions(); };
// window.onresize	= function() { findDimensions(); };

function findDimensions ()
{
    var frameWidth;
    var frameHeight;
    var obj;

    if (self.innerWidth)
    {
	frameWidth = self.innerWidth;
	frameHeight = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientWidth)
    {
	frameWidth = document.documentElement.clientWidth;
	frameHeight = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
	frameWidth = document.body.clientWidth;
	frameHeight = document.body.clientHeight;
    }
    else
	return;

    // if there's valid info, update the globals so they can be used elsehere
    pageWidth = frameWidth;
    pageHeight = frameHeight;
	
    if ( (obj = myGetElementById('ctl00_Background1_background_image')) )
    {
	var iWidth = obj.width; 
	var iHeight = obj.height;
	var iRatio = iWidth / iHeight;
	var fRatio = frameWidth / frameHeight;	
	
		if ( frameWidth > 990 ) 
		{
		obj.style.width = frameWidth;
		obj.style.height = frameWidth / iRatio;
		myGetElementById('background').style.width = "100%";
		}
		else
		{
		obj.style.width = 990;
		obj.style.height = 990 / iRatio;
		myGetElementById('background').style.width = 990;
		}
    }
}

function setAttribute(node, name, value) {
    var i;
    for (i = 0; i < node.attributes.length; i++)
    {
        if (node.attributes[i].name == name)
        {
            node.attributes[i].value = value;
        }
    }
} 

function clearDefaultText(e)
{
    if (e.defaultValue==e.value) 
        e.value = "";
}