// JavaScript Document
function frmValidation(){

   if(document.frmOrder.txtBusinessTpye.value == "Homeowner") {
 
    var Field= Array();
	var FieldName= Array();

	Field[0]=document.frmOrder.txtFName.value;
	Field[1]=document.frmOrder.txtLName.value;
	Field[2]=document.frmOrder.txtAddress.value;
	Field[3]=document.frmOrder.txtCity.value;
	Field[4]=document.frmOrder.txtState.value;
	Field[5]=document.frmOrder.txtZip.value;
	Field[6]=document.frmOrder.txtCountry.value;
	Field[7]=document.frmOrder.txtPh.value;
	Field[8]=document.frmOrder.txtEmail.value;
	Field[9]=document.frmOrder.txtBusinessTpye.value;
	Field[10]=document.frmOrder.hear.value;
	
	FieldName[0]="First Name";
	FieldName[1]="Last Name";
	FieldName[2]="Address";
	FieldName[3]="City";
	FieldName[4]="State";
	FieldName[5]="Zip";
	FieldName[6]="Country";
	FieldName[7]="Business Phone";
	FieldName[8]="Email Address";
	FieldName[9]="Type of Business";
	FieldName[10]="How did you hear about LUMA?";
	
	var msg="";
	var bval = true;
	
	for(i=0; i<18; i++)
	{
		if(Field[i]=="" || Field[i]==0)
		{
			//alert("Please fill " + FieldName[i] + " field.");
			msg = msg + "Please Fill:"
			msg = msg + "\n" + ">> " + FieldName[i];
			alert(msg);
			bval = false;
			break;

		}
	}

    if(bval)
	{
	  bval=emailCheck();
	}
	
	return bval;

  	}
   else
	{
		
	var Field= Array();
	var FieldName= Array();

	Field[0]=document.frmOrder.txtFName.value;
	Field[1]=document.frmOrder.txtLName.value;
	Field[2]=document.frmOrder.txtAddress.value;
	Field[3]=document.frmOrder.txtCity.value;
	Field[4]=document.frmOrder.txtState.value;
	Field[5]=document.frmOrder.txtZip.value;
	Field[6]=document.frmOrder.txtCountry.value;
	Field[7]=document.frmOrder.txtPh.value;
	Field[8]=document.frmOrder.txtEmail.value;
	Field[9]=document.frmOrder.txtBusinessTpye.value;
	Field[10]=document.frmOrder.hear.value;
	Field[11]=document.frmOrder.txtBusComp.value;
	Field[12]=document.frmOrder.txtBusAddress.value;
	Field[13]=document.frmOrder.txtBusCity.value;
	Field[14]=document.frmOrder.txtBusState.value;
	Field[15]=document.frmOrder.txtBusZip.value;
	Field[16]=document.frmOrder.txtBusCountry.value;
	Field[17]=document.frmOrder.txtTerritory.value;
	
	FieldName[0]="First Name";
	FieldName[1]="Last Name";
	FieldName[2]="Address";
	FieldName[3]="City";
	FieldName[4]="State";
	FieldName[5]="Zip";
	FieldName[6]="Country";
	FieldName[7]="Business Phone";
	FieldName[8]="Email Address";
	FieldName[9]="Type of Business";
	FieldName[10]="How did you hear about LUMA?";
	FieldName[11]="Company Name";
	FieldName[12]="Company Address";
	FieldName[13]="Company City";
	FieldName[14]="Company State";
	FieldName[15]="Company Zip";
	FieldName[16]="Company Country";
	FieldName[17]="Geographic Territory";
	
	var msg="";
	var bval = true;
	
	for(i=0; i<18; i++)
	{
		if(Field[i]=="" || Field[i]==0)
		{
			//alert("Please fill " + FieldName[i] + " field.");
			msg = msg + "Please Fill:"
			msg = msg + "\n" + ">> " + FieldName[i];
			alert(msg);
			bval = false;
			break;

		}
	}

    if(bval)
	{
	  bval=emailCheck();
	}
	
	return bval;

}
}

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