// JavaScript Document
function frmValidation()
{
    var Field= Array();
	var FieldName= Array();

	
	Field[0]=document.floodquote.name.value;
	Field[1]=document.floodquote.address.value;
	Field[2]=document.floodquote.phone.value;
	Field[3]=document.floodquote.altphone.value;
	Field[4]=document.floodquote.emailaddress.value;
	Field[5]=document.floodquote.mailaddress.value;
	Field[6]=document.floodquote.sqft.value;
	Field[7]=document.floodquote.storie.value;
	Field[8]=document.floodquote.foundation.value;
	Field[9]=document.floodquote.dwellvalue.value;
	Field[10]=document.floodquote.source.value;
		
	FieldName[0]="Name";
	FieldName[1]="Address";
	FieldName[2]="Phone";
	FieldName[3]="Alt# ";
	FieldName[4]="Email Address ";
	FieldName[5]="Mail Address ";
	FieldName[6]="Sqft";
	FieldName[7]="Stories";
	FieldName[8]="Foundation";
	FieldName[9]="Dwelling Value";
	FieldName[10]="Source";
		
	var msg="";
	var bval=true;
	
	for(i=0; i<11; i++)
	{
		if(Field[i]=="" || Field[i]==0)
		{
			
			msg = msg + "\n" + ">> " + FieldName[i] + " Field";
			bval = false;
						
		}
		
	}
	
	if(msg != "")
	{
		al = "Please Fill the following fields" 
		al = al + "\n" + msg;
		alert(al);
		bval=false;
	}
	
	if(bval)
	{
		bval=emailCheck(Field[4]);
	}
	
	//alert("Hi");
	return bval;
}

function emailCheck(emailStr1) 
  	{
  	  		var emailPat=/^[a-zA-Z0-9_\.\-]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/
  	        var matchArray;	
  	  		//var emailStr1 =document.frmorder.EmailAddress.value;	
			
  	  	
  	  		
					matchArray = emailStr1.match(emailPat);
					if (matchArray == null) 
					
					{
						alert("Please Enter Correct Email Address"); 
						document.frmorder.EmailAddress.focus;
						return false;
					}	
					else 
					return true;
	  	
    }