﻿// JScript File
function Align_Footer_Reset() {
	if (document.getElementById) { 
		var BSpace = document.getElementById("BSpacer");
		if (BSpace) BSpace.height = 1;
		var BodBot = document.getElementById("Body_Bottom");
		if (BodBot) BodBot.style.height = "auto";
		var Foot = document.getElementById("footer");
		if (Foot) Foot.style.height = "auto";
		var MainContent = document.getElementById("Content");
		var SideBar = document.getElementById("SideBar");
		if ((MainContent) && (SideBar)){
			if (MainContent.style.height) MainContent.style.height = "auto";
			if (SideBar.style.height) SideBar.style.height = "auto";
		}
		var Container = document.getElementById("Container");
		if (Container) Container.style.height = "auto";
	} else if (document.layers) {
		var t = eval('document.BSpacer');
		t.height = 1; 
	} else {
		var t = document.all['BSpacer'];
		t.height = 1; 
	}
	return true;
}

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 SEOText;
	if (document.getElementById) { SEOText = document.getElementById("SEOText"); }
	if (SEOText) {
		SEOText.style.height = 1 + 'px';
	}

	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("footer");
		var BSpace = document.getElementById("BSpacer");
		var Container = document.getElementById("Container");
		var MainContent = document.getElementById("Content");
		var Sidebar = document.getElementById("SideBar");
		var TopNav = document.getElementById("TopNav");
		
		if (TopNav) {
			HeadHt = GreaterValue(TopNav.scrollHeight, TopNav.offsetHeight);
			HeadTop = TopNav.offsetTop;
		} else {
			HeadHt = 0;
			HeadTop = 0;
		}

        var y = ht - BodBot.offsetTop - Foot.offsetHeight - HeadHt - 3; 
		//alert('ht='+ht+', BodBot.offsetTop='+BodBot.offsetTop+', Foot.offsetHeight='+Foot.offsetHeight+', HeadHt='+HeadHt+', SEOText.offsetHeight'+SEOText.offsetHeight+' \n'+
		//	'y='+y+', setting BodBot.style.height to'+((y - gutter)));
		
        if (y) {
	        if ((ht > y) && (y > 0)) {
		        if (BodBot){
			        try {
				        BodBot.style.height = (y - gutter) + 'px'; 
			        }
			        catch (error) {
				        // Nothing
				        fail = 0;
			        }
		        } else { 
					if (BSpace) ResizeImg(BSpace, y, gutter);
		        }
	        }
        }

		if ((MainContent)) {
			// Flag to prevent recursion
			if (InResize == 0){
				InResize = 1;
				mHt = 0;
				mTop = 0;
				x = 0;
				if (TopNav) {
					HeadHt = GreaterValue(TopNav.scrollHeight, TopNav.offsetHeight);
					//alert('5 Header.style.height=' +  Header.style.height + ', Header.scrollHeight=' + Header.scrollHeight + ' Header.offsetHeight=' + Header.offsetHeight);	
					//TopNav.style.height = HeadHt + 'px';
					mHt = mHt + HeadHt;
					mTop = HeadHt;
				}

				if (MainContent) {
					MainHt = GreaterValue(MainContent.scrollHeight, MainContent.offsetHeight);
					MainContent.style.height = MainHt + 'px';
					mHt = mHt + MainHt;
                }
                
                //alert('HeadHt='+HeadHt+', MainHt='+MainHt+' ');
                if (Sidebar) {
					x = GreaterValue(Sidebar.scrollHeight, Sidebar.offsetHeight);
					y = GreaterValue(mHt, x);
					//alert('x='+x+', y='+y+' ');
   					if (mHt > x){
						//alert('mHt > x, mHt='+mHt+', x='+x+', HeadHt='+HeadHt+', MainHt='+MainHt);
					    Sidebar.style.height = mHt+ 'px';
						//alert('Sidebar.style.height='+Sidebar.style.height+' ');
					    ContentHt = mHt;
					} else {
						//alert('mHt <= x, mHt='+mHt+', x='+x+' ');
					    MainContent.style.height = (x - HeadHt) + 'px';
					    ContentHt = x + 'px';
				    }
				}

				if (browser=navigator.appName != 'Microsoft Internet Explorer'){
					if (Container) {
						//alert('8 setting MainContent.style.height to mHt = ' + mHt)
						Container.style.height = 'auto';
					}
				}
				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 ResizeImg(t, y, gutter) {
    try {
        t.height = (y - gutter); 
    }
    catch (error) {
        // Nothing
        fail = 0;
    }
}

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);
		t.innerHTML = DVal;
	} else if (document.layers) {
		var tLayer = eval('document.'+DName);
		tLayer.document.open();
		tLayer.document.write(DVal);
		tLayer.document.close();
		RightAlignDiv(DName);
	} else {
		var t = document.all[DName];
		t.innerHTML = DVal;
	}
	return true;
}


function SetStatus(Tx){
	window.status=Tx;
	return true;
}

function openChild(file, window, width, height, options) {
	if (options){
		opts = options
	} else {
		opts = 'resizable=yes'
	}
	var childWindow;
	if (childWindow == null || childWindow.closed){
			childWindow=open(file,window,opts+',width=' + width + ',height=' + height,false);
			if (childWindow.opener == null) childWindow.opener = self;
	} else {
		if ((childWindow.width != width) || (childWindow.height != height)) {
			childWindow.resizeTo(width,height);
		}
		childWindow.location=file;
		childWindow.focus();
	}
	return false;
}

function WriteFlash(DivName, FlashPath, width, height, version, bgcolor){
	if (typeof(flashobj)=='undefined'){
		var flashobj = new SWFObject(FlashPath, 'Flash_' + DivName, width, height, version, bgcolor);
	}
	flashobj.addVariable("MM_ComponentVersion", "1");
	flashobj.addParam("allowScriptAccess", "sameDomain");
	flashobj.addParam("autoPlay", "true");
	flashobj.addParam("autoRewind", "true");
	flashobj.write(DivName);
	return true;
}
