// JavaScript Document

function checkForm(contact_form)
{
	
	// First Name Validation
	if(contact_form.name.value=="")
	{
		contact_form.name.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please enter your Contact Name.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.name.focus();
		return false;
	}
	else {
		contact_form.name.className = "success";
		document.getElementById("errorMsg").style.display = "none";		
	}

	// First Company Name Validation
	if(contact_form.compname.value=="")
	{
		contact_form.compname.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please enter your Company Name.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.compname.focus();
		return false;
	}
	else {
		contact_form.compname.className = "success";
		document.getElementById("errorMsg").style.display = "none";		
	}

	// First Employee Number Validation
	if(contact_form.employeenumber.value=="")
	{
		contact_form.employeenumber.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please enter your Company Name.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.employeenumber.focus();
		return false;
	}
	if (isNaN(contact_form.employeenumber.value)==true)
	{
		document.getElementById("errorMsg").innerHTML = "Please enter a valid Number.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.employeenumber.focus();
		contact_form.employeenumber.value = "";
		return false;
	}
	else {
		contact_form.employeenumber.className = "success";
		document.getElementById("errorMsg").style.display = "none";		
	}
	
	// First Company Name Validation
	if(contact_form.payrollcalculated.value=="")
	{
		contact_form.payrollcalculated.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please select your Payroll calculation method.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.payrollcalculated.focus();
		return false;
	}
	else {
		contact_form.payrollcalculated.className = "success";
		document.getElementById("errorMsg").style.display = "none";		
	}

	// First Company Name Validation
	if(contact_form.statenumber.value=="")
	{
		contact_form.statenumber.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please enter your Company Name.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.statenumber.focus();
		return false;
	}
	else {
		contact_form.statenumber.className = "success";
		document.getElementById("errorMsg").style.display = "none";		
	}

	// Email Validation
	if(contact_form.email.value=="")
	{
		contact_form.email.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please enter your Email ID.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.email.focus();
		return false;
	}
		if (!contact_form.email.value.match(/^[\w\.\-]+@([\w\-]+\.)+[a-zA-Z]+$/))
		{
			contact_form.email.className = "error";
			document.getElementById("errorMsg").innerHTML = "Please enter a valid Email ID.";
			document.getElementById("errorMsg").style.display = "block";
			contact_form.email.focus();
			contact_form.email.value = "";
			return false;
		}
		else {
			contact_form.email.className = "success";
			document.getElementById("errorMsg").style.display = "none";
		}
	
	// Home Phone Validation
	if(contact_form.phone.value=="")
	{
		contact_form.phone.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please enter your Phone Number.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.phone.focus();
		return false;
	}
	if (isNaN(contact_form.phone.value)==true)
	{
		document.getElementById("errorMsg").innerHTML = "Please enter a valid Phone Number.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.phone.focus();
		contact_form.phone.value = "";
		return false;
	}
	else {
		contact_form.phone.className = "success";
		document.getElementById("errorMsg").style.display = "none";
	}
	
	// First Company Name Validation
	if(contact_form.address.value=="")
	{
		contact_form.address.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please enter your Address.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.address.focus();
		return false;
	}
	else {
		contact_form.address.className = "success";
		document.getElementById("errorMsg").style.display = "none";		
	}

	// First Company Name Validation
	if(contact_form.city.value=="")
	{
		contact_form.city.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please enter your City.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.city.focus();
		return false;
	}
	else {
		contact_form.city.className = "success";
		document.getElementById("errorMsg").style.display = "none";		
	}

	// First Company Name Validation
	if(contact_form.state.value=="")
	{
		contact_form.state.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please select your State.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.state.focus();
		return false;
	}
	else {
		contact_form.state.className = "success";
		document.getElementById("errorMsg").style.display = "none";		
	}

	// Home Phone Validation
	if(contact_form.zip.value=="")
	{
		contact_form.zip.className = "error";
		document.getElementById("errorMsg").innerHTML = "Please enter your Zip Code.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.zip.focus();
		return false;
	}
	if (isNaN(contact_form.zip.value)==true)
	{
		document.getElementById("errorMsg").innerHTML = "Please enter a valid Zip Code.";
		document.getElementById("errorMsg").style.display = "block";
		contact_form.zip.focus();
		contact_form.zip.value = "";
		return false;
	}
	else {
		contact_form.zip.className = "success";
		document.getElementById("errorMsg").style.display = "none";
	}

	return;
}
