
function formCheck(formName){

  ValidOk = true;
  var count = 0;
  while(count < formName.elements.length){
    var fieldType = formName.elements[count].type;
    var theFieldName = formName.elements[count].name;
    var fieldName = formName.elements[formName.elements[count].name];
    
	switch(fieldType){
	  case 'text':
	    if(theFieldName == 'txtFirstName')
		  strCheck(fieldName,1,'First Name');
		if(theFieldName == 'txtLastName')
		  strCheck(fieldName,1,'Last Name');
		if(theFieldName == 'txtCompanyName')
		  strCheck(fieldName,1,'Company Name');
		if(theFieldName == 'txtAddress')
		  strCheck(fieldName,1,'Address');
		if(theFieldName == 'txtSuburb')
		  strCheck(fieldName,1,'Suburb');
		if(theFieldName == 'txtState')
		  strCheck(fieldName,1,'State');
		if(theFieldName == 'txtCountry')
		  strCheck(fieldName,1,'Country');
		if(theFieldName == 'txtPostcode')
		   strCheckEmpty(fieldName,1,'postcode');
		if(theFieldName == 'txtPhoneNumber')
		   strCheckEmpty(fieldName,1,'phone number');
		if(theFieldName == 'txtEmail')
		  emailCheck(fieldName,'valid Email address');
	break;
	case 'select-one' :		
		if(theFieldName == 'ddlWhereHeard')
		{			
			if(fieldName.options[0].selected == true)
			{
				alert('Please select a valid option in "Where did you hear about us".');
				ValidOk = false;
			}
		}	
	break;
	}
	if(ValidOk == false){
	  break;
	}
	count++;
  }
  if (ValidOk == true){
    return true;
  }else{
  	return false;
  }
}
