//FUNCTION: validateEmail
//Contains a least one character procedding the @
//Contains a "@" following the procedding character(s)
//Contains at least one character following the @, followed by a dot (.), 
//	followed by either a two character or three character string 
//	(a two character country code or the standard three character US code, such as com, edu etc)
function validateEmail(sEmailAddress){
	//create the regexp to test the email address text
	var oEmailRegExp = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	//perform the test and return success as appropriate
	if (oEmailRegExp.test(sEmailAddress)){
		return true;
	}else{
		return false;
	}
}

function validateSurveyForm(){
	if(document.getElementById("txtName").value == ""){
		alert("Please enter your name.");
		document.getElementById("txtName").focus();
		return false;
	}
	if(!validateEmail(document.getElementById("txtEmail").value)){
		alert("Please enter a valid email address.");
		document.getElementById("txtEmail").focus();
		return false;
	}
	if(!document.getElementById("agreeTerms").checked){
		alert("You must agree to the Terms and Conditions before submitting the survey");
		return false;
	}
	return true;
}
function layerVisibility (id, vis) {
	if(document.getElementById(id)){
		document.getElementById(id).style.visibility=vis;
	}
}
function changeLayerVisibility (id) {
	if (document.getElementById(id).style.display == "none") {
		document.getElementById(id).style.display = "block";
	} else {
		document.getElementById(id).style.display = "none";
	}
}

function setLyr(obj,lyr)
{
	var coors = findPos(obj);
	if (lyr == 'testP') coors[1] -= 50;
	var x = document.getElementById(lyr);
	x.style.top = 14+coors[1] + 'px';
	x.style.left = coors[0]-60 + 'px';
}

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function showLoadingTicker(){
	document.getElementById("loadingTicker").style.display = "inline";
}
function hideLoadingTicker(){
	window.setTimeout('document.getElementById("loadingTicker").style.display = "none";', 400);
}
function positionTicker(leftPos, topPos){
	var oTicker = document.getElementById("loadingTicker");
	
	oTicker.style.left = leftPos;
	oTicker.style.top = topPos;
}

function refineSearch(){	
	window.history.back();
}
