// correct format for email address
function IsEmailAddress (string)
{
	var addressPattern = 
		/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	return addressPattern.test(string);
}

// radio button selection
function IsRadioSelected(theForm, name)
{
	var i;
	for(i = 0; i < theForm.elements.length; i++)
	{
		if(theForm.elements[i].type == "radio" && theForm.elements[i].name == name &&
			theForm.elements[i].checked == true)
		{
			return true;
		}
	}
	return false;
}

// get radio button value
function GetRadioValue(theForm, name) 
{ 
	var i; 
	for(i = 0; i < theForm.elements.length; i++) 
	{ 
		if(theForm.elements[i].type == "radio" && theForm.elements[i].name == name && 
		theForm.elements[i].checked == true) 
		{ 
			return theForm.elements[i].value; 
		} 
	} 
	return ""; 
}

function validate(theForm) {
	if(theForm.varchar000.value == "")
	{
		alert("Please enter your FULL NAME.");
		theForm.varchar000.focus();
		return false;
	}
	if((parseInt(navigator.appVersion) >= 4 && IsEmailAddress(theForm.varchar072.value) == false) ||
		(parseInt(navigator.appVersion) < 4 && 
		 	(theForm.varchar072.value.length < 7 || theForm.varchar072.value.indexOf("@") == -1 ||
			theForm.varchar072.value.indexOf(".") == -1)))
	{
		alert("Please enter a valid EMAIL ADDRESS.");
		theForm.varchar072.focus();
		return false;
	}
	if(theForm.varchar006.value == "")
	{
		alert("Please enter your CITY.");
		theForm.varchar006.focus();
		return false;
	}
	if(theForm.text005.selectedIndex <= 0)
	{
		alert("Please choose your CITY.");
		return false;
	}
	if(theForm.varchar001.value == "")
	{
		alert("Please enter your PHONE NUMBER.");
		theForm.varchar001.focus();
		return false;
	}
	if(theForm.double000.value == "")
	{
		alert("Please enter your YEARS EXPERIENCE.");
		theForm.double000.focus();
		return false;
	}
	if(theForm.text001.value == "" && theForm.varchar036.value == "")
	{
		alert("Please include your RESUME.");
		return false;
	}
	if(theForm.text072-Yes.checked == false && theForm.text072-No.checked == false)
	{
		alert("Please select your RELOCATION preference.");
		return false;
	}
	if(theForm.text038.selectedIndex <= 0)
	{
		alert("Please choose a DISCIPLINE.");
		return false;
	}
	return true;
}