﻿function validator(action){
	if(submission.company.value=="")
	{
		alert("Please type Company")
		document.all.company.focus()
		return false
	}
	

	if(submission.first_name.value=="")
	{
		alert("Please type First name")
		document.all.first_name.focus()
		return false
	}

	if(submission.last_name.value=="")
	{
		alert("Please type Last name")
		document.all.last_name.focus()
		return false
	}

	//check the validation of the e-mail address
	var mail
	mail=submission.email.value

	//if we have the default its ok
	if (mail=="")
	{
		alert("Please type Email")
		document.all.email.focus()
		return false
	}

	//check if we have the @ sign
	if (mail.indexOf("@")==-1)
	{
		alert("Please use a leagel email address")
		document.all.email.focus()
		return false
	}	

	//check if we have dot in the second part of the form
	var dot
	dot=mail.split("@")[1]	
	if (dot.indexOf(".")==-1)
	{
		alert("Please use a leagel email address")
		document.all.email.focus()
		return false
	}

	//check if the address ends with 2 or 3 letters
		
	var end
	end=dot.split(".")[1]
	if (end.length<2 || end.length>3)
	{
		alert("Please use a leagel email address")
		document.all.email.focus()
		return false
	}
	
	if(submission.country.value=="")
	{
		alert("Please select Country")
		document.all.country.focus()
		return false
	}
	
	if(submission.state.value=="")
	{
		alert("Please select state / Provice")
		document.all.state.focus()
		return false
	}

	if(submission.city.value=="")
	{
		alert("Please type city")
		document.all.city.focus()
		return false
	}


	//submission.action = action
	submission.submit()
	return true;
}

