/* -- Interview Tune-Up Script */

function agreeCheck()
{
	var cb = document.getElementById("agreeBox");
	if (cb.checked)
	{
		return true;
	}
	else
	{
		alert ("You must agree to the DISCLAIMER and PRIVACY POLICY");
		return false;
	}
}

function LoadForm() 
{
	return;
}

function closePopupWin() {
	if (window.location.search && window.location.search.indexOf('noesc') != -1) {
		window.history.go(-1);
	}
	else
	{
		self.close();
	}
}

function openPopupWin (URL)
{
	var yframe = 30;
	var xframe = 12;
	var height = 600;
	var width = 540;

	// adjust size and position of popup window if necessary
	var top = (window.screen.availHeight - height)/2;
	var left = (window.screen.availWidth - width)/2;
	if (window.screen.availHeight < height + yframe)
	{
		height = window.screen.availHeight - yframe;
		top = 0;
	}
	if (window.screen.availWidth < width + xframe)
	{
		width = window.screen.availWidth - xframe;
		left = 0;
	}
	
	var aWindow = window.open(URL,"", "height=" + height + ", width=" + width + ", top=" + top + ", left=" + left + ",menubar=no,location=no,toolbar=no,status=no,directories=no,scrollbars=yes,resizable=no");
	if (!aWindow) {
		// popup windows disabled
		var newPath = URL;
		if (window.location.search.indexOf('noesc') == -1)
		{
			if (window.location.search.indexOf('?') == -1) 
			{
				newPath += "?noesc";
			}
			else
			{
				newPath += "&noesc";
			}
		}
		window.location.pathname = newPath;
	}
}

function check(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(h=0; h < e.length ;h++){
		if(ok.indexOf(e.charAt(h))<0){ 
			return (false);
		}		
	} 
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}

function checkUploadForm(f){
	if(f.fname.value < 1){
		alert("Please type your first name");
		f.fname.focus();
		return (false);
	}
	if(f.lname.value < 1){
		alert("Please type your last name");
		f.lname.focus();
		return (false);
	}
	if(!check(f.email.value)){
		alert("Please type a valid e-mail address");
		f.email.focus();
		return (false);
	}
	
	if(f.FILE1.value < 1){
		alert("Please select your completed Questionnaire document by pressing the browse button");
		f.FILE1.focus();
		return (false);
	}
		
}

