function checkForm(form)
{
	if(form.first_name.value=="")
	{
		alert("please enter first name");
		form.first_name.focus();
		return false;
	}

	if(form.last_name.value=="")
	{
		alert("please enter last name");
		form.last_name.focus();
		return false;
	}

	if(form.phone.value=="")
	{
		alert("please enter phone");
		form.phone.focus();
		return false;
	}

	if(form.email.value=="")
	{
		alert("please enter email");
		form.email.focus();
		return false;
	}

	if (echeck(form.email.value)==false){
		form.email="";
		form.email.focus()
		return false
	}


	if(form.city.value=="")
	{
		alert("please enter city");
		form.city.focus();
		return false;
	}

	if(form.zip.value=="")
	{
		alert("please enter zip");
		form.zip.focus();
		return false;
	}


	if(isZip(form.zip.value)==false)
	{
		form.zip="";
		form.zip.focus()
		return false
	}
	
	
    if(form.approx_value.value=="")
	{
		alert("please enter approximate value");
		form.approx_value.focus();
		return false;
	}
	if(form.sq_feet.value=="")
	{
		alert("please enter square feet");
		form.sq_feet.focus();
		return false;
	}
	
	
	return true;
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function isZip(s) 
	{

     // Check for correct zip code
     reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/);

     if (!reZip.test(s)) {
          alert("Zip Code Is Not Valid");
          return false;
     }

	return true;
	}

function checkLogin(form)
{
	if(form.who.value=="")
	{
		alert("please Select Login As");
		form.who.focus();
		return false;
	}
	if(form.username.value=="")
	{
		alert("please enter Email Id");
		form.username.focus();
		return false;
	}
	
	if (echeck(form.username.value)==false){
		form.username="";
		form.username.focus()
		return false
	}

	if(form.password.value=="")
	{
		alert("please enter password");
		form.password.focus();
		return false;
	}

	return true;
}
