function isValidEmail(email_str)
{
   return (email_str.indexOf(".") > 2) && (email_str.indexOf("@") > 0);
}


function checkform(form_id)
{
	
	
	if (document.forms[form_id].elements["name"].value == 0)
	{
		// something is wrong
		alert('Please fill the name field');
		document.forms[form_id].elements["name"].focus();
		document.forms[form_id].elements["name"].style.borderColor = "#FF0000";
		return false;
	}
	else 
	{ 
		str1 = document.forms[form_id].elements["phone"].value ;
		if (str1 == 0)
		{
		// something else is wrong
		alert('Please fill the phone field');
		document.forms[form_id].elements["phone"].focus();
		document.forms[form_id].elements["phone"].style.borderColor = "#FF0000";
		return false;
                }
		
		
	}
        
	// If the script gets this far through all of your fields
	// without problems, it's ok and you can submit the form

	return true;
}

function check_vendor_form(form_id)
{
   //alert("hello");
   company = document.forms[form_id].elements["company"].value;
   vendor_name = document.forms[form_id].elements["name"].value;
   address = document.forms[form_id].elements["address"].value;
   city = document.forms[form_id].elements["city"].value;
   province = document.forms[form_id].elements["province"].value;
   postal_code = document.forms[form_id].elements["postal_code"].value;
   country = document.forms[form_id].elements["country"].value;
   phone = document.forms[form_id].elements["phone"].value;
   fax = document.forms[form_id].elements["fax"].value;
	
	if (company == 0)
	{
		// something is wrong
		alert('Please fill the Company field');
		document.forms[form_id].elements["company"].focus();
		document.forms[form_id].elements["company"].style.borderColor = "#FF0000";
		return false;
	}
        
        
        if (vendor_name == 0)
	{
		// something is wrong
		alert('Please fill the Contact Name field');
		document.forms[form_id].elements["name"].focus();
		document.forms[form_id].elements["name"].style.borderColor = "#FF0000";
		return false;
	}
        if (address == 0)
	{
		// something is wrong
		alert('Please fill the address field');
		document.forms[form_id].elements["address"].focus();
		document.forms[form_id].elements["address"].style.borderColor = "#FF0000";
		return false;
	}
        if (city == 0)
	{
		// something is wrong
		alert('Please fill the City field');
		document.forms[form_id].elements["city"].focus();
		document.forms[form_id].elements["city"].style.borderColor = "#FF0000";
		return false;
	}
        if (province == 0)
	{
		// something is wrong
		alert('Please fill the Province/State field');
		document.forms[form_id].elements["province"].focus();
		document.forms[form_id].elements["province"].style.borderColor = "#FF0000";
		return false;
	}
        if (postal_code == 0)
	{
		// something is wrong
		alert('Please fill the Postal/Zip Code field');
		document.forms[form_id].elements["postal_code"].focus();
		document.forms[form_id].elements["postal_code"].style.borderColor = "#FF0000";
		return false;
	}
        
        if (country == 0)
	{
		// something is wrong
		alert('Please fill the Country field');
		document.forms[form_id].elements["country"].focus();
		document.forms[form_id].elements["country"].style.borderColor = "#FF0000";
		return false;
	}
        if (phone == 0)
	{
		// something is wrong
		alert('Please fill the Phone field');
		document.forms[form_id].elements["phone"].focus();
		document.forms[form_id].elements["phone"].style.borderColor = "#FF0000";
		return false;
	}
        if (fax == 0)
	{
		// something is wrong
		alert('Please fill the Fax field');
		document.forms[form_id].elements["fax"].focus();
		document.forms[form_id].elements["fax"].style.borderColor = "#FF0000";
		return false;
	}
	
        
	// If the script gets this far through all of your fields
	// without problems, it's ok and you can submit the form

	return true;
}

function check_customer_form(form_id)
{
   //alert("hello");
   company = document.forms[form_id].elements["company"].value;
   customer_name = document.forms[form_id].elements["name"].value;
   address = document.forms[form_id].elements["address"].value;
   city = document.forms[form_id].elements["city"].value;
   province = document.forms[form_id].elements["province"].value;
   postal_code = document.forms[form_id].elements["postal_code"].value;
   country = document.forms[form_id].elements["country"].value;
   phone = document.forms[form_id].elements["phone"].value;
   fax = document.forms[form_id].elements["fax"].value;
   contact1 = document.forms[form_id].elements["contact1"].value;
   /*contact2 = document.forms[form_id].elements["contact2"].value;*/
   no_of_trucks = document.forms[form_id].elements["no_of_trucks"].value;
   no_of_trailers = document.forms[form_id].elements["no_of_trailers"].value;
   contact_name1 = document.forms[form_id].elements["contact_name1"].value;
   contact_phone1 = document.forms[form_id].elements["contact_phone1"].value;
   contact_cell1 = document.forms[form_id].elements["contact_cell1"].value;
   /*contact_name2 = document.forms[form_id].elements["contact_name2"].value;
   contact_phone2 = document.forms[form_id].elements["contact_phone2"].value;
   contact_cell2 = document.forms[form_id].elements["contact_cell2"].value;*/
   hear_from = document.forms[form_id].elements["hear_from"].value;
   authorization_first_name = document.forms[form_id].elements["authorization_first_name"].value;
   authorization_last_name = document.forms[form_id].elements["authorization_last_name"].value;
	
	if (company == 0)
	{
		// something is wrong
		alert('Please fill the Company field');
		document.forms[form_id].elements["company"].focus();
		document.forms[form_id].elements["company"].style.borderColor = "#FF0000";
		return false;
	}
        
        
        if (customer_name == 0)
	{
		// something is wrong
		alert('Please fill the Contact Name field');
		document.forms[form_id].elements["name"].focus();
		document.forms[form_id].elements["name"].style.borderColor = "#FF0000";
		return false;
	}
        if (address == 0)
	{
		// something is wrong
		alert('Please fill the address field');
		document.forms[form_id].elements["address"].focus();
		document.forms[form_id].elements["address"].style.borderColor = "#FF0000";
		return false;
	}
        if (city == 0)
	{
		// something is wrong
		alert('Please fill the City field');
		document.forms[form_id].elements["city"].focus();
		document.forms[form_id].elements["city"].style.borderColor = "#FF0000";
		return false;
	}
        if (province == 0)
	{
		// something is wrong
		alert('Please fill the Province/State field');
		document.forms[form_id].elements["province"].focus();
		document.forms[form_id].elements["province"].style.borderColor = "#FF0000";
		return false;
	}
        if (postal_code == 0)
	{
		// something is wrong
		alert('Please fill the Postal/Zip Code field');
		document.forms[form_id].elements["postal_code"].focus();
		document.forms[form_id].elements["postal_code"].style.borderColor = "#FF0000";
		return false;
	}
        
        if (country == 0)
	{
		// something is wrong
		alert('Please fill the Country field');
		document.forms[form_id].elements["country"].focus();
		document.forms[form_id].elements["country"].style.borderColor = "#FF0000";
		return false;
	}
        if (phone == 0)
	{
		// something is wrong
		alert('Please fill the Phone field');
		document.forms[form_id].elements["phone"].focus();
		document.forms[form_id].elements["phone"].style.borderColor = "#FF0000";
		return false;
	}
        if (fax == 0)
	{
		// something is wrong
		alert('Please fill the Fax field');
		document.forms[form_id].elements["fax"].focus();
		document.forms[form_id].elements["fax"].style.borderColor = "#FF0000";
		return false;
	}
        if (contact1 == 0)
	{
		// something is wrong
		alert('Please fill the Contact #1 field');
		document.forms[form_id].elements["contact1"].focus();
		document.forms[form_id].elements["contact1"].style.borderColor = "#FF0000";
		return false;
	}
        /*if (contact2 == 0)
	{
		// something is wrong
		alert('Please fill the Contact #2 field');
		document.forms[form_id].elements["contact2"].focus();
		document.forms[form_id].elements["contact2"].style.borderColor = "#FF0000";
		return false;
	} */
        if (no_of_trucks == 0)
	{
		// something is wrong
		alert('Please fill the No. of Trucks field');
		document.forms[form_id].elements["no_of_trucks"].focus();
		document.forms[form_id].elements["no_of_trucks"].style.borderColor = "#FF0000";
		return false;
	}
        if (no_of_trailers == 0)
	{
		// something is wrong
		alert('Please fill the No. of Trailers field');
		document.forms[form_id].elements["no_of_trailers"].focus();
		document.forms[form_id].elements["no_of_trailers"].style.borderColor = "#FF0000";
		return false;
	}
        if (contact_name1 == 0)
	{
		// something is wrong
		alert('Please fill the Name field');
		document.forms[form_id].elements["contact_name1"].focus();
		document.forms[form_id].elements["contact_name1"].style.borderColor = "#FF0000";
		return false;
	}
        if (contact_phone1 == 0)
	{
		// something is wrong
		alert('Please fill the Phone field');
		document.forms[form_id].elements["contact_phone1"].focus();
		document.forms[form_id].elements["contact_phone1"].style.borderColor = "#FF0000";
		return false;
	}
        if (contact_cell1 == 0)
	{
		// something is wrong
		alert('Please fill the Cell field');
		document.forms[form_id].elements["contact_cell1"].focus();
		document.forms[form_id].elements["contact_cell1"].style.borderColor = "#FF0000";
		return false;
	}
       /* if (contact_name2 == 0)
	{
		// something is wrong
		alert('Please fill the Name field');
		document.forms[form_id].elements["contact_name2"].focus();
		document.forms[form_id].elements["contact_name2"].style.borderColor = "#FF0000";
		return false;
	}
        if (contact_phone2 == 0)
	{
		// something is wrong
		alert('Please fill the Phone field');
		document.forms[form_id].elements["contact_phone2"].focus();
		document.forms[form_id].elements["contact_phone2"].style.borderColor = "#FF0000";
		return false;
	}
        if (contact_cell2 == 0)
	{
		// something is wrong
		alert('Please fill the Cell field');
		document.forms[form_id].elements["contact_cell2"].focus();
		document.forms[form_id].elements["contact_cell2"].style.borderColor = "#FF0000";
		return false;
	}*/
        if (hear_from == 0)
	{
		// something is wrong
		alert('Please fill the Hear From field');
		document.forms[form_id].elements["hear_from"].focus();
		document.forms[form_id].elements["hear_from"].style.borderColor = "#FF0000";
		return false;
	}
        if (authorization_first_name == 0)
	{
		// something is wrong
		alert('Please fill the First Name field');
		document.forms[form_id].elements["authorization_first_name"].focus();
		document.forms[form_id].elements["authorization_first_name"].style.borderColor = "#FF0000";
		return false;
	}
        if (authorization_last_name == 0)
	{
		// something is wrong
		alert('Please fill the Last Name field');
		document.forms[form_id].elements["authorization_last_name"].focus();
		document.forms[form_id].elements["authorization_last_name"].style.borderColor = "#FF0000";
		return false;
	}
	
        
	// If the script gets this far through all of your fields
	// without problems, it's ok and you can submit the form

	return true;
}


function check_link_form(form_id)
{
   //alert("hello");
   title = document.forms[form_id].elements["title"].value;
   description = document.forms[form_id].elements["description"].value;
   url = document.forms[form_id].elements["url"].value;
   category = document.forms[form_id].elements["category"].value;
   first_name = document.forms[form_id].elements["first_name"].value;
   last_name = document.forms[form_id].elements["last_name"].value;
   email = document.forms[form_id].elements["email"].value;
   reciprocal = document.forms[form_id].elements["reciprocal"].value;
   captcha = document.forms[form_id].elements["captcha"].value;
   
	
	if (title == 0)
	{
		// something is wrong
		alert('Please fill the Title field');
		document.forms[form_id].elements["title"].focus();
		document.forms[form_id].elements["title"].style.borderColor = "#FF0000";
		return false;
	}
        
        if (description == 0)
	{
		// something is wrong
		alert('Please fill the Description field');
		document.forms[form_id].elements["description"].focus();
		document.forms[form_id].elements["description"].style.borderColor = "#FF0000";
		return false;
	}
        
        if (url == 0)
	{
		// something is wrong
		alert('Please fill the URL field');
		document.forms[form_id].elements["url"].focus();
		document.forms[form_id].elements["url"].style.borderColor = "#FF0000";
		return false;
	}
        
        if (category == "Select")
	{
		// something is wrong
		alert('Please Choose the Category field');
		document.forms[form_id].elements["category"].focus();
		document.forms[form_id].elements["category"].style.borderColor = "#FF0000";
		return false;
	}
       
        
        if (first_name == 0)
	{
		// something is wrong
		alert('Please fill the First Name field');
		document.forms[form_id].elements["first_name"].focus();
		document.forms[form_id].elements["first_name"].style.borderColor = "#FF0000";
		return false;
	}
        
        if (last_name == 0)
	{
		// something is wrong
		alert('Please fill the Last Name field');
		document.forms[form_id].elements["last_name"].focus();
		document.forms[form_id].elements["last_name"].style.borderColor = "#FF0000";
		return false;
	}
        
        if (email == 0)
	{
		// something is wrong
		alert('Please fill the Email field');
		document.forms[form_id].elements["email"].focus();
		document.forms[form_id].elements["email"].style.borderColor = "#FF0000";
		return false;
	}
        
        else 
		{
			if ( !isValidEmail(email) )
			{
				alert('Please enter a valid email');
				document.forms[form_id].elements["email"].focus();
				document.forms[form_id].elements["email"].style.borderColor = "#FF0000";
				return false;
			}
					
		}
        
        if (reciprocal == 0)
	{
		// something is wrong
		alert('Please fill the Reciprocal Link URL field');
		document.forms[form_id].elements["reciprocal"].focus();
		document.forms[form_id].elements["reciprocal"].style.borderColor = "#FF0000";
		return false;
	}
        
        if (captcha == 0)
	{
		// something is wrong
		alert('Please fill the Verification Code field');
		document.forms[form_id].elements["captcha"].focus();
		document.forms[form_id].elements["captcha"].style.borderColor = "#FF0000";
		return false;
	}
        
        
        
	
        
	// If the script gets this far through all of your fields
	// without problems, it's ok and you can submit the form

	return true;
}
