var inputArray = new Array(4);
var message = "";
var inputFields = new Array(4);
inputFields[0] = "Your Name";
inputFields[1] = "Company";
inputFields[2] = "Telephone Number";
inputFields[3] = "Email Address";

function verifyThis()
{
	(document.other_inspection_quote.name.value!='')?inputArray[0]='good':inputArray[0]='bad';
	(document.other_inspection_quote.comp.value!='')?inputArray[1]='good':inputArray[1]='bad';
	(document.other_inspection_quote.phone.value!='')?inputArray[2]='good':inputArray[2]='bad';
	(document.other_inspection_quote.email.value!='')?inputArray[3]='good':inputArray[3]='bad';
	
	var allGood=true;

	for (counter=0;counter<inputArray.length;counter++)
	{
		if (inputArray[counter]!='good')
		{
			message += "\n" + inputFields[counter];
			allGood=false;
		}//end if
	}//end for counter

	if (allGood)
	{
		changeLocation();
	}
	else
	{
		alert("The following fields have either been left blank or not entered properly:\t\n"+message);
		message="";
	}
		
}//end verifyThis()

function changeLocation()
{
     if (submitIt(document.other_inspection_quote))	
		document.other_inspection_quote.submit();
}

function validEmail(emailvalue)
{
		var invalidChars="/:,;";

         if (emailvalue!=""){
	    
         for (i=0; i<invalidChars.length; i++) {
                         badChar=invalidChars.charAt(i)
                         if (emailvalue.indexOf(badChar,0)!= -1) {
                                        return false;
                         }
         }
         atPos=emailvalue.indexOf("@")
         if (atPos==-1){
                        return false;
         }
         if (emailvalue.indexOf("@",atPos+1) !=-1) {
                        return false;
         }
        periodPos=emailvalue.indexOf(".",atPos)
        if ((periodPos == -1) || (periodPos == (emailvalue.length - 1))) {	   
	   		return false;	 
   	  }	 
	  
	  } // end of if not equal to blank
	     	    				    	   
         return true;
}
	 
function submitIt(form)
{
	 if (!validEmail(form.email.value)){
	    alert('Invalid email address');
			return false
	 }	
     return true;
}
