// -------------------------------------------------------
//  functions for form validation
//
/*
function validateForm(whichForm) {
	if (whichForm == 1) {
		if (document.getElementById("postalcode").value.length == 0) {
			alert("Please enter a zip code")
			return false;
		} else {
			showCoverLayer();
		}
	}

	if (whichForm == 2) {
		if (document.getElementById("city").value.length == 0) {
			alert("Please enter a city")
			return false;
		} else {
			showCoverLayer();
		}
	}
	return;
}
*/

function showCoverLayer() {
	if (document.getElementById("coverLayer")) {
 		document.getElementById("searchRadius").style.visibility = "hidden";
 		document.getElementById("state").style.visibility = "hidden";
 		document.getElementById("coverLayer").style.visibility = "visible";
		document.getElementById("searchInProgress").style.visibility = "visible";
	}
}

// -------------------------------------------------------
//  function for positioning "search in progress" layer
//
function positionCoverLayer() {
//	alert("2")
	if (!document.getElementById("coverLayer")) {
		return;
	}

	var x, y;
	if (self.innerHeight) { // all except Explorer
		x = self.innerWidth;
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		// Explorer 6 Strict Mode
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	elm = document.getElementById("coverLayer");
	elm.style.width = x + "px";
	elm.style.height = y + "px";

	elm = document.getElementById("searchInProgress");
//	a = parseInt((x - parseFloat(elm.offsetWidth)) / 2) + "px"
//	elm.style.left = a;
	elm.style.left = parseInt((x - parseFloat(elm.offsetWidth)) / 2) + "px";
}

// -------------------------------------------------------
//  functions for positioning footers correctly
//
function contactInformationPop(queryString) {
	s = "contact_information.aspx" + queryString;
	window.open(s, "contactInfo", "width=375,height=340,scrollbars")
}

function mapInformationPop(queryString) {
	s = "map_information.aspx" + queryString;
	window.open(s, "mapInfo", "width=560,height=625,scrollbars")
}

// -------------------------------------------------------
//  functions for positioning footers correctly
//
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 setFooter() {
	if (!document.getElementById("footer")) {
		return;
	}
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			var contentHeight = document.getElementById("pageContainer").offsetHeight + document.getElementById("mainContainerMeasure").offsetHeight;
			var footerElement = document.getElementById("footer");
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.position = "fixed";
				footerElement.style.top = (windowHeight - footerHeight - 20) + "px";
			} else {
				footerElement.style.position = "fixed";
			}
		}
	}
}

function popWin(thepage) {
	window.open(thepage, "settings",'toolbar=0,location=0,directories=0,status=0,scrollbars=yes, menubar=0,width=380,height=450');
}

function checkFlash() {
	if (document.getElementById("adBanner")) {
		if (!ff.flashCheck(6)) {
			document.getElementById("adBanner").innerHTML = "<a href=\"http://www.nobelbiocare.com/global/en/newPatientInformation/default.htm\"><img src=\"images/banner_nedp.gif\" /></a>";
		}
	}
	return;
}

function init() {
	setFooter();
	positionCoverLayer();
//	checkFlash();
}

window.onload = init;

window.onresize = function() {
	setFooter();
	positionCoverLayer()
}
