﻿function Resize() {
    var TheBody = document.getElementById("TheBody");
    var MainPageTable = document.getElementById("MainPageTable");

	var x = TheBody.offsetWidth / 2 - MainPageTable.offsetWidth / 2;
	var y = TheBody.offsetHeight / 2 - MainPageTable.offsetHeight / 2;

	if (MainPageTable.offsetWidth > GetPageWidth())
	    x = GetPageWidth() - MainPageTable.offsetWidth;
	if (x < 0) x = 0;

	if (MainPageTable.offsetHeight > GetPageHeight())
	    y = GetPageHeight() - MainPageTable.offsetHeight;
	if (y < 0) y = 0;

    MainPageTable.style.position = 'absolute';
    MainPageTable.style.left = x;
    MainPageTable.style.top = y;
}

function GetPageWidth() {
    
	var width = document.body.clientWidth;

	if (width <= 0)
	{
	    width = document.documentElement.clientWidth;
	}

	return width;
}

function GetPageHeight() {

    var height = document.body.clientHeight;

    if (height <= 0) {
        height = document.documentElement.clientHeight;
    }

    return height;
}

function Setup() {

    window.onresize = Resize;

    Resize();

    if (navigator.appVersion.indexOf('MSIE 7.0') !== -1 || navigator.appName === "Netscape" || navigator.appName === "Opera") {
        document.write("<style type='text/css'>.TopShadowRow{height: 10px;background-image: url(Images2/Invariant/shadow_top.png);background-repeat: repeat-x;}.LeftShadowColumn{width: 10px;background-image: url(Images2/Invariant/shadow_left.png);background-repeat: repeat-y;}.RightShadowColumn{width: 10px;background-image: url(Images2/Invariant/shadow_right.png);background-repeat: repeat-y;}.BottomShadowRow{height: 10px;background-image: url(Images2/Invariant/shadow_bottom.png);background-repeat: repeat-x;}.TopLeftShadowCorner{width: 10px;height: 10px;background-image: url(Images2/Invariant/shadow_top_left.png);}.TopRightShadowCorner{width: 10px;height: 10px;background-image: url(Images2/Invariant/shadow_top_right.png);}.BottomRightShadowCorner{width: 10px;height: 10px;background-image: url(Images2/Invariant/shadow_bottom_right.png);}.BottomLeftShadowCorner{width: 10px;height: 10px;background-image: url(Images2/Invariant/shadow_bottom_left.png);}</style>");
    }
}

function HighlightUp() {
    var navigateUp = document.getElementById("NavigateUp");
    navigateUp.src = "Images2/Invariant/navigate_up_o.png";
}

function HighlightDown() {
    var navigateDown = document.getElementById("NavigateDown");
    navigateDown.src = "Images2/Invariant/navigate_down_o.png";
}

function LowlightUp() {
    var navigateUp = document.getElementById("NavigateUp");
    navigateUp.src = "Images2/Invariant/navigate_up.png";
}

function LowlightDown() {
    var navigateDown = document.getElementById("NavigateDown");
    navigateDown.src = "Images2/Invariant/navigate_down.png";
}

function DownDown() {
    var navigateDown = document.getElementById("NavigateDown");
    navigateDown.src = "Images2/Invariant/navigate_down_d.png";
}

function DownUp() {
    var navigateUp = document.getElementById("NavigateUp");
    navigateUp.src = "Images2/Invariant/navigate_up_d.png";
}

function SetText(clientId, html) {

    var control = $get(clientId);

    control.innerHTML = html.replace(/&apos;/g, '\'');

}