﻿// JScript File

function Get_Height() {
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		//alert('ht1');
		return window.innerHeight;
	} else if( document.documentElement &&
		( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		//alert('ht2b');
		return document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		//alert('ht3');
		return document.body.clientHeight;
	}
}

var InResize = 0;
function Align_Footer() {
	var ht = Get_Height();
	ht = GreaterValue(ht, document.body.parentNode.clientHeight);
	ht = GreaterValue(ht, document.documentElement.scrollHeight);
	var maxHt = 2000;
	if (ht > maxHt) ht = maxHt;
	var gutter = 0;

	//return;

	if (document.getElementById) { 
		var BodBot = document.getElementById("Body_Bottom");
		var Foot = document.getElementById("Foot");
		var BSpace = document.getElementById("BSpacer");
		var Container = document.getElementById("Container");
		var ContainerR = document.getElementById("ContainerR");
		var MainContent = document.getElementById("MainContent");
		var Main2 = document.getElementById("Main");
		var MainNav = document.getElementById("VertNavLeft");
		var Menu = document.getElementById("Menu");
		var Header = document.getElementById("Header");
		if (Header) {
			HeadHt = Header.scrollHeight;
			HeadTop = 174;
		} else {
			HeadHt = 0;
			HeadTop = 174;
		}
		if ((MainContent)) {
			// Flag to prevent recursion
			if (InResize == 0){
				InResize = 1;
				mHt = 0;
				mTop = 0;
				x = 0;
				if (Header) {
					x = GreaterValue(Header.scrollHeight, Header.offsetHeight);
					//alert('5 Header.style.height=' +  Header.style.height + ', Header.scrollHeight=' + Header.scrollHeight + ' Header.offsetHeight=' + Header.offsetHeight);	
					Header.style.height = x;
					mHt = mHt + x;
					mTop = x;
				}

				// FootHeight from CSS + border
				footHt = 155;
				fHt = footHt + 2;
				fTop = 0;
				if (Foot) {
					fHt = GreaterValue(GreaterValue(Foot.offsetHeight, Foot.scrollHeight), fHt);
					//alert('9 Foot.offsetTop=' + Foot.offsetTop + ' Foot.scrollTop=' + Foot.scrollTop + '  GreaterValue(Foot.scrollTop, Foot.offsetTop)=');	
					fTop = GreaterValue(Foot.offsetTop, Foot.scrollTop);
					//alert('9 Foot.style.height=' +  Foot.style.height + ', Foot.scrollHeight=' + Foot.scrollHeight + ' FootoffsetHeight=' + Foot.offsetHeight + '  GreaterValue(Foot.scrollHeight, Foot.offsetHeight)=' + x);	
					Foot.style.height = fHt;
				}
				
				if (Main2) {
					x = GreaterValue(Main2.scrollHeight, Main2.offsetHeight);
					y = 0;
					if (MainNav) y = GreaterValue(MainNav.scrollHeight, MainNav.offsetHeight);
					z = GreaterValue(ht - fTop - fHt - gutter - x, 0); 
					/*alert('ht=' + ht + '\n' + 
						'HeadTop=' +  HeadTop + '\n' + 
						'fTop=' +  fTop + '\n' + 
						'fHt=' +  fHt + '\n' + 
						'gutter=' +  gutter + '\n' + 
						'x=' +  x);
					*/
					x = GreaterValue(x, y) + z;
					//alert('6 Main2.style.height=' +  Main2.style.height + ', Main2.scrollHeight=' + Main2.scrollHeight + ' Main2.offsetHeight=' + Main2.offsetHeight + ' Greatervalue=' + x + ',  z = ' + z);	
					//Main2.offsetTop = 200;
					Main2.style.height = x;
					mHt = mHt + x;
					mTop = mTop + x;
				}

				if (MainNav) {
					x = GreaterValue(GreaterValue(MainNav.scrollHeight, MainNav.offsetHeight), mHt);
					//alert('7 MainNav.style.height=' +  MainNav.style.height + ', MainNav.scrollHeight=' + MainNav.scrollHeight + ' MainNav.offsetHeight=' + MainNav.offsetHeight);	
					MainNav.style.height = x;
					//mHt = GreaterValue(x, mHt);
				}
				
				if (browser=navigator.appName != 'Microsoft Internet Explorer'){
					if (MainContent) {
						//alert('8 setting MainContent.style.height to mHt = ' + mHt)
						MainContent.style.height = mHt;
					}
					if (Container){
						x = GreaterValue(Container.scrollHeight, Container.offsetHeight);
						//alert('10 setting Container.style.height to mHt(' + mHt + ') + HeadTop(' + HeadTop + ') = ' + (mHt + HeadTop));
						Container.style.height = mHt + fHt + HeadTop;
					}
				} else {
					if (Foot) Foot.style.height = fHt;
				}
				InResize = 0;
			}
		} else if (document.layers) {
			var t = eval('document.BSpacer');
			ht = ht - t.pageY;
			t.height = ht - gutter; 

			var BSpace2 = eval('document.BSpacer2');
			if (BSpace2) {
				ht = ht - BSpace2.pageY;
				BSpace2.height = ht - gutter; 
			}
		} else {
			var t = document.all['BSpacer'];
			ht = ht - t.y;
			t.height = ht - gutter; 

			var BSpace2 = document.all['BSpacer2'];
			if (BSpace2) {
				ht = ht - BSpace2.y;
				BSpace2.height = ht - gutter; 
			}
		}
	}
	return true;
}

function GreaterValue(Val1, Val2)
{
	if (Val1 > Val2) return Val1;
	else return Val2;
}

function jsClockTimeZone(){
	// Copyright 1999 - 2001 by Ray Stott
	// OK to use if this copyright is included
	// Script available at http://www.crays.com/jsc
	//var TimezoneOffset = -7  // adjust for time zone
	var localTime = new Date();
	var TimezoneOffset = 0;
	var time =  new Date();
	var hour = time.getHours(); 
	var minute = time.getMinutes();
	var second = time.getSeconds();
	var temp = "" + ((hour > 12) ? hour - 12 : hour);
	if(hour==0) temp = "12";
	if(temp.length==1) temp = " " + temp;
	temp += ((minute < 10) ? ":0" : ":") + minute;
	temp += ((second < 10) ? ":0" : ":") + second;
	temp += (hour >= 12) ? " PM" : " AM";
	WriteDiv("Clock", temp);
	setTimeout("jsClockTimeZone()",1000);
}

function WriteDiv(DName, DVal){
		if (document.getElementById) { 
		var t = document.getElementById(DName);
		if (t) t.innerHTML = DVal;
	} else if (document.layers) {
		var tLayer = eval('document.'+DName);
		if (tLayer){
			tLayer.document.open();
			tLayer.document.write(DVal);
			tLayer.document.close();
		}
		RightAlignDiv(DName);
	} else {
		var t = document.all[DName];
		if (t) t.innerHTML = DVal;
	}
	return true;
}


function SetStatus(Tx){
	window.status=Tx;
	return true;
}

function openChild(file, window, width, height, options, loadingPage) {
	if (options){
		opts = options
	} else {
		opts = 'resizable=1'
	}

	if (loadingPage){
		loading = loadingPage
	} else {
		loading = ''
	}

	var childWindow;
	//alert(childWindow.name);
	//if (childWindow) childWindow.close;
	
	try {
		childWindow=open(loading,window,opts+',width=' + width + ',height=' + height,false);
		childWindow.focus();
	}
	catch(err) {
		//Handle errors here
	}
	//return false;
		
	childWindow=open(file,window,opts+',width=' + width + ',height=' + height,false);

	try {
		childWindow.focus();
	}
	catch(err) {
		//Handle errors here
	}
	return false;
}

function LoadParent(url, closeSelf){
	var opnr = self.opener;
	if (! opnr) opnr = self;
	if (url) {
		try {
			opnr.location = url;
		}
		catch(err) {
			//Handle errors here
			//alert('problem going to [' + eurl + ']');
		}
	}
	opnr.focus();
	if ((closeSelf) && (opnr != self)) { 
		self.close(); 
	}
}
