var inputArray = new Array(4);
var message = "";
var inputFields = new Array(4);
inputFields[0] = "Your Name";
inputFields[1] = "Email";
inputFields[2] = "Telephone number";
inputFields[3] = "Question or comment";


function verifyThis() {
	(document.contact_us_7FA.your_name.value != '')?inputArray[0]='good':inputArray[0]='bad';
	(document.contact_us_7FA.email.value != '')?inputArray[1]='good':inputArray[1]='bad';
	(document.contact_us_7FA.telephone_number.value != '')?inputArray[2]='good':inputArray[2]='bad';
	(document.contact_us_7FA.comment.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){
     //putted post script
	 if (submitIt(document.contact_us_7FA))	{
		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.contact_us_7FA))	{
     	document.contact_us_7FA.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;
}
