// JavaScript Document
function enableOthers(){
	if(document.contact.relationship.value == "Others"){
		document.contact.relationshipOther.disabled = false;
		document.contact.relationshipOther.focus();
		document.contact.relationshipOther.select();
	}
	else{
		document.contact.relationshipOther.disabled = true;
		document.contact.relationshipOther.value = "";
		document.contact.relationship.focus();
	}
}

function doValidation()
{

	var lastName,firstName,email,subject,comments;
	firstName=document.getElementById("firstName").value;
	lastName=document.getElementById("lastName").value;
	email=document.getElementById("email").value;
	phone=document.getElementById("phone").value;
	country=document.getElementById("country").value;
	company=document.getElementById("company").value;
	industry=document.getElementById("industry").value;
	subject=document.getElementById("subject").value;
	relationship=document.getElementById("relationship").value;
	comments=document.getElementById("comments").value;
	relationshipOther=document.getElementById("relationshipOther").value;

	emailVal = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;

	if(firstName=="")
	{
		alert("First Name field is blank.");
		document.getElementById("firstName").focus();
	}
	else if(lastName=="")
	{
		alert("Last Name field is blank.");
		document.getElementById("lastName").focus();
	}
	else if(email=="")
	{
		alert("Email Address field is blank.");
		document.getElementById("email").focus();
	}
	else if(!emailVal.test(email))
	{
		alert("Email Address is not a valid format.");
		document.getElementById("email").focus();
	}
	else if(phone==""){
		alert("Phone Number field is blank");
		document.getElementById("phone").focus();
	}
	else if(country=="NONE"){
		alert("Please select a country");
	}
	else if(industry=="NONE"){
		alert("Please select an Industry/Field");
	}
	else if(company==""){
		alert("Company Name field is blank");
		document.getElementById("company").focus();
	}
	else if(relationship.toLowerCase()=="others" && relationshipOther==""){
			alert("Please select relationship in ADEC Finance and Accounting Solutions");
	}
	else if(comments=="")
	{
		alert("Comments field is blank.");
		document.getElementById("comments").focus();
	}
	else
	{
		document.forms['contact'].action = "email.php";
		document.forms['contact'].enctype = "multipart/form-data";
		document.forms['contact'].method = "POST";
		document.forms['contact'].target = "_self";
		document.forms['contact'].submit();
		//alert("Thank You! Your email has been sent.");
	}

}

function doValidationForRequest()
{	

	var lastName,firstName,email,subject,comments;
	firstName=document.getElementById("firstName").value;
	lastName=document.getElementById("lastName").value;
	email=document.getElementById("email").value;
	phone=document.getElementById("phone").value;
	country=document.getElementById("country").value;
	company=document.getElementById("company").value;
	jobtitle=document.getElementById("jobtitle").value;	
	relationship=document.getElementById("relationship").value;
	comments=document.getElementById("comments").value;
	relationshipOther=document.getElementById("relationshipOther").value;

	emailVal = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/;
	
	if(firstName=="")
	{
		alert("First Name field is blank.");
		document.getElementById("firstName").focus();
	}
	else if(lastName=="")
	{
		alert("Last Name field is blank.");
		document.getElementById("lastName").focus();	
	}
	else if(email=="")
	{
		alert("Email Address field is blank.");
		document.getElementById("email").focus();
	}
	else if(!emailVal.test(email))
	{
		alert("Email Address is not a valid format.");
		document.getElementById("email").focus();
	}
	else if(phone==""){
		alert("Phone Number field is blank");
		document.getElementById("phone").focus();
	}
	else if(country=="NONE"){
		alert("Please select a country");
	}
	else if(industry=="NONE"){
		alert("Please select an Industry/Field");
	}
	else if(company==""){
		alert("Company Name field is blank");
		document.getElementById("company").focus();
	}
	else if(relationship=="Others"){
		if(relationshipOther==""){
			alert("Please select relationship in ADEC Finance and Accounting Solutions");
		}
	}
	else if(comments=="")
	{
		alert("Comments field is blank.");
		document.getElementById("comments").focus();
	}
	else
	{
		document.forms['contact'].action = "thankyou.php";
		document.forms['contact'].enctype = "multipart/form-data";
		document.forms['contact'].method = "POST";
		document.forms['contact'].target = "_self";
		document.forms['contact'].submit();
//		alert("Thank You! Your email has been sent.");
	}
}