
window.status = "Welcome to ADgility";

// contact us popup window
function contactPop(url) {
quizWin=window.open(url, '', 'toolbar=no,directories=no,status=no,location=0,resizable=no,scrollbars=no,menubar=no,width=600,height=550,screenY=25,screenX=25,top=25,left=25');
}

function copyPop(url) {
quizWin=window.open(url, '', 'toolbar=no,directories=no,status=no,location=0,resizable=no,scrollbars=no,menubar=no,width=450,height=210,screenY=25,screenX=25,top=25,left=25'); 
}

function popWindow() {
	window.open('/address.html','win1','resizable=0,scrollbars=no,width=500,height=240,screenX=25,screenY=25,top=25,left=25');
}

function checkMainForm(form) {
	var incomplete;
	incomplete=0;
	var alertMsg;
	alertMsg = "The following fields are required:\n";

	if(form.name.value == "") {
		incomplete++;
		alertMsg = alertMsg +"Name\n";
	}

	if(form.email.value == "") {
		incomplete++;
		alertMsg = alertMsg +"Email Address\n";
	}
	if(form.comment.value == "") {
		incomplete++;
		alertMsg = alertMsg +"Message\n";
	}	
	
	if (incomplete > 0){
		alert(alertMsg);
		return false;
	}

	if (checkEmail(form.email.value) == false) {
			form.email.focus();
			return false;
	}

	return true;
}

function checkEmail(addr) {
//  Will check for @, period after @ and text in between
	
	var in_space = addr.indexOf(" ");
	if (in_space != -1)
	{ alert ("Email address should contain no spaces and be of the form jdoe\@aol.com");
			return false;  }

	var len = addr.length;
	var alpha = addr.indexOf("@");
	var last_alpha = addr.lastIndexOf("@");

	if (alpha != last_alpha)
	 {  alert ("Bad email address. Should contain only one @ and be of the form jdoe\@aol.com");
			 return false; }

	// No @, in first position, or name too short
	if (alpha == -1 || alpha == 0 || len<6 )
	 {  alert ("Bad email address. Should contain an @ and be of the form jdoe\@aol.com");
			 return false; }

	var last_p = addr.lastIndexOf(".");
			// Be sure period at least two spaces after @, but not last char.
			
	if (last_p - alpha < 2 || last_p == (len - 1) )
		{  alert ("Bad email address. Should contain a period after the @ and be of the form jdoe\@aol.com");
				return false; }
}