image0 = new Image(); image0.src = "images/nav/homepg_on.gif";
image1 = new Image(); image1.src = "images/nav/about_on.gif";
image2 = new Image(); image2.src = "images/nav/ministry_on.gif";
image3 = new Image(); image3.src = "images/nav/video_on.gif";
image4 = new Image(); image4.src = "images/nav/free_session_on.gif";
image5 = new Image(); image5.src = "images/nav/contact_on.gif";

isw3c = (document.getElementById) ? true : false;
imgs = (document.images) ? true : false;
isExplorer = (navigator.appName.indexOf('Microsoft')!=-1) ? true : false;
isMac = (navigator.appVersion.indexOf('Mac')!=-1) ? true : false;

pagename = "";

function gObj(me) {
	if (isw3c) {
	return document.getElementById(me);
	}
}

function gImg(me) {
	if (imgs) {
	return document.images[me];
	}
}

function imgOn(a) {		
	gImg(a).src = "images/nav/" + a + "_on.gif";
}

function imgOff(b) {
	if ((pagename == b) && (window.name == "td_visited")) {
	gImg(b).src = "images/nav/" + b + "_on.gif";
	}
	else {
	gImg(b).src = "images/nav/" + b + "_off.gif";
	}
}

function allOff() {
	var picArr = new Array('homepg','about','ministry','video','free_session','contact');
	for (i=0; i<picArr.length; i++) {
	var b = picArr[i];
	gImg(i).src = "images/nav/" + b + "_off.gif";
	}
}

// form page functions 

function keyCheck(field, event) {
  var keyCode = (event.keyCode) ? event.keyCode : 
                event.which ? event.which : event.charCode;
	if (keyCode != 13 && keyCode != 3) {
    	return true;
	}
	else {
    	return false;
	}
}

// begin set of functions to set bottom division to move to bottom of window and size table height


function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}

function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
		windowWidth = window.innerWidth;
	}
	else {
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
	}
	return windowWidth;
}

function setMainDiv() {
	if (isw3c) {
		var windowHeight = getWindowHeight();
		var windowWidth = getWindowWidth();
		var main = gObj('mainDiv');
		if ((windowHeight<main.offsetHeight) || (isExplorer&&isMac)) {
			main.style.marginTop = main.style.top = "0";
		} else {
			main.style.top = "50%";
			main.style.marginTop = "-323px";
		}
		if (windowWidth<main.offsetWidth) {
			main.style.marginLeft = main.style.left = "0";
		} else {
			main.style.left = "50%";
			main.style.marginLeft = "-465px";
		}	
	}
}

window.onload = function() {
	setMainDiv();
}

window.onresize = function() {
	setMainDiv();
}

window.onscroll = function() {
	setMainDiv();
}
