// JavaScript Document

function checkvalue(nextPage) {
   var str2=document.forms[0].email.value;
   var valid = 1
   var valid2 = 1
   var valid3 = 1
   var goodChars = "0123456789()-+ ext."
   var valid_zip = 1
   var good_zip = "0123456789"
   var valid_date = 1
   var good_date = "0123456789/"
   var i = 0
   
   if (document.first_timer.available_time_slot_list.options[0].value == "No Available Time Slots for today") {
      alert('No Available Time Slots for today, please pick another date! ');
      setTimeout("document.forms[0].available_time_slot_list.focus();",2);
      return;
   }

   // check phone number's validity:
   var thePhoneNumber = document.forms[0].phone.value;
   for (i =0; i <= (thePhoneNumber.length -1); i++) {
      if (goodChars.indexOf(thePhoneNumber.charAt(i)) == -1) {
	     valid = 0
	  } // End if statement
	  if (valid == 0) {
	     alert(thePhoneNumber + "is not a valid phone number");
         setTimeout("document.forms[0].phone.focus();",2);
         return;
      }
   } // End for loop

   // check phone number's validity:
   var thePhoneNumber2 = document.forms[0].mobile_phone.value;
   for (i =0; i <= (thePhoneNumber2.length -1); i++) {
      if (goodChars.indexOf(thePhoneNumber2.charAt(i)) == -1) {
	     valid2 = 0
	  } // End if statement
	  if (valid2 == 0) {
	     alert(thePhoneNumber2 + "is not a valid mobile phone number");
         setTimeout("document.forms[0].mobile_phone.focus();",2);
         return;
      }
   } // End for loop
   // check phone number's validity:
   var thePhoneNumber3 = document.forms[0].work_phone.value;
   for (i =0; i <= (thePhoneNumber3.length -1); i++) {
      if (goodChars.indexOf(thePhoneNumber3.charAt(i)) == -1) {
	     valid3 = 0
	  } // End if statement
	  if (valid3 == 0) {
	     alert(thePhoneNumber3 + "is not a valid work phone number");
         setTimeout("document.forms[0].work_phone.focus();",2);
         return;
      }
   } // End for loop
   // check phone number's validity:
   var thePhoneNumber4 = document.forms[0].fax.value;
   for (i =0; i <= (thePhoneNumber4.length -1); i++) {
      if (goodChars.indexOf(thePhoneNumber4.charAt(i)) == -1) {
	     valid3 = 0
	  } // End if statement
	  if (valid3 == 0) {
	     alert(thePhoneNumber4 + "is not a valid work phone number");
         setTimeout("document.forms[0].fax.focus();",2);
         return;
      }
   } // End for loop

   // check phone number's validity:
   var theDate = document.forms[0].mydate.value;
   for (i =0; i <= (theDate.length -1); i++) {
      if (good_date.indexOf(theDate.charAt(i)) == -1) {
	     valid_date = 0
	  } // End if statement
	  if (valid_date == 0) {
	     alert(theDate + "is not a valid date");
         setTimeout("document.forms[0].mydate.focus();",2);
         return;
      }
   } // End for loop

   // check phone number's validity:
   var theZip = document.forms[0].zip.value;
   for (i =0; i <= (theZip.length -1); i++) {
      if (goodChars.indexOf(theZip.charAt(i)) == -1) {
	     valid_zip = 0
	  } // End if statement
	  if (valid_zip == 0) {
	     alert(theZip + "is not a valid zip");
         setTimeout("document.forms[0].zip.focus();",2);
         return;
      }
   } // End for loop

   if (document.forms[0].first_name.value =="") {
      alert('First name field can not be empty! ');
      setTimeout("document.forms[0].first_name.focus();",2);
      return;
   }
         
   if (document.forms[0].last_name.value =="") {
      alert('Last name field can not be empty! ');
      setTimeout("document.forms[0].last_name.focus();",2);
      return;
   }

   if (document.forms[0].phone.value =="") {
      alert('Phone field can not be empty! ');
      setTimeout("document.forms[0].phone.focus();",2);
      return;
   }

   if (document.forms[0].email.value =="") {
      alert('Eamil field can not be empty! ');
      setTimeout("document.forms[0].email.focus();",2);
      return;
   }
         
   if ((str2.indexOf(".")==-1 )&&(str2.indexOf("@")==-1 )&&(str2.indexOf(" ")==-1 )){
         alert('Please enter a valid email!');
         setTimeout("document.forms[0].email.focus();",2);
         return;
   }

   if (document.forms[0].street.value =="") {
      alert('Street address field can not be empty! ');
      setTimeout("document.forms[0].street.focus();",2);
      return;
   }
   if (document.forms[0].city.value =="") {
      alert('City field can not be empty! ');
      setTimeout("document.forms[0].city.focus();",2);
      return;
   }
   if (document.forms[0].zip.value =="") {
      alert('Zip field can not be empty! ');
      setTimeout("document.forms[0].zip.focus();",2);
      return;
   }

   if (document.forms[0].detail_description.value =="") {
      alert('Service Requests Description field can not be empty! ');
      setTimeout("document.forms[0].detail_description.focus();",2);
      return;
   }

   //document.forms[0].action="registerResult.php";
   document.forms[0].action=nextPage;
   document.forms[0].target="_self";
   document.forms[0].submit();
   
   return;
}

function saveCustItem(nextPage) {

   if (document.forms[0].domain.value =="") {
      alert('Domain can not be empty! ');
      setTimeout("document.forms[0].domain.focus();",2);
      return;
   }


   if (document.forms[0].email.value =="") {
      alert('Customer email can not be empty! ');
      setTimeout("document.forms[0].email.focus();",2);
      return;
   }

   if (document.forms[0].contact.value =="") {
      alert('Contact name field can not be empty! ');
      setTimeout("document.forms[0].contact.focus();",2);
      return;
   }

   if (document.forms[0].old_domain.value != document.forms[0].domain.value) {
      if (!(confirm("The domain name has changed, do you want to update anyway?"))) {
         return;
      }
   }

   document.forms[0].command.value="updateCustAcct";
   document.forms[0].action_.value="strAction";
   document.forms[0].action=nextPage;
   document.forms[0].target="_self";
   document.forms[0].submit();
   
   return;
}
