
//alert("Hello World")


function validate(f) {


  //alert(f.nameTextBox.value)

/*************
f.fields are:
nameTextBox
emailTextBox
telTextBox
faxTextBox
addressTextBox
contactDropDownList
subjectTextBox 
messageTextBox
submitButton
**************/

   isOK = true;
   message = "";

   //alert(f.telTextBox.value.length)

//   if ((f.contactDropDownList[f.contactDropDownList.selectedIndex].value == "Phone") && (f.telTextBox.value.length < 4)){
//	message = "You said to phone, but the phone number looks wrong";
 //	isOK = false
   //}

   switch (f.contactDropDownList[f.contactDropDownList.selectedIndex].value){
     case "Phone" :  if (f.telTextBox.value.length < 4) {
			  message = "You said to phone, but the phone number looks wrong";
		 	  isOK = false;
			  f.telTextBox.focus()
			}
			break;
     case "Email" :  if (f.emailTextBox.value.length < 8) {
			  message = "You said to email, but the email address looks wrong";
		 	  isOK = false;
			  f.emailTextBox.focus()
			}
			break;
     case "Write" :  if (f.addressTextBox.value.length < 20) {
			  message = "You said to write, but the address looks wrong";
		 	  isOK = false;
			  f.addressTextBox.focus()
			}
			break;
     case "Fax" :  if (f.faxTextBox.value.length < 8) {
			  message = "You said to Fax, but the Fax number looks wrong";
		 	  isOK = false;
			  f.faxTextBox.focus()
			}
			break;
   }

  if (f.messageTextBox.value.length < 3){
	 message = "You have not typed a message";
 	 isOK = false;
	 f.messageTextBox.focus()
  }


  if (isOK)
  {
     return true
  }
  else
  {
     alert(message);
     return false;
  }
}
