//This script verifys the hosting signup form on hosting_signup.shtml

//Check for selection of Hosting Package radio buttons
// Begin
function checkRadios() 
{
 var el = document.forms[0].elements;
 for(var i = 0 ; i < el.length ; ++i) {
  if(el[i].type == "radio")
  {
   var radiogroup = el[el[i].name]; // get the whole set of radio buttons.
   var itemchecked = false;
   for(var j = 0 ; j < radiogroup.length ; ++j) {
    if(radiogroup[j].checked) {
	 itemchecked = true;
	 break;
	}
   }
   if(!itemchecked) { 
    alert("Please Select a Maintenance Plan, Thank You!");
    if(el[i].focus)
     el[i].focus();
	return false;
   }
  }
 }
 return true;
} 
//End checkRadios
	
// Validate e-mail address 
function validateEmail(emailstr)
{
// Characters that don't belong in email
invalidChars = " /:,; ";

// Check for email string
 if (emailstr == "" )
 {
  window.alert("Please enter your E-mail Address");
  return false;
 } 
 //Check for something before the @ sign
 if (emailstr.indexOf("@", 0) == 0)
 {
  window.alert ("No username in E-mail Address!");
  return false;
 }
 //Check for the @ sign
 if (emailstr.indexOf("@", 1) == -1)
 {
  window.alert("No @ sign in Email Address!");
  return false;
 } 
 //Check for period in email
 if (emailstr.indexOf(".", 0) == -1)
 {
  window.alert ("No period in E-mail Address!");
  return false;
 }
 //Check for invalid charecters
 for (i=0; i<invalidChars.length; i++)
 {
  if (emailstr.indexOf(invalidChars.charAt(i), 0) > -1)
  {
   window.alert ("Bad character(s) in Email Address!", invalidChars.charAt(i), i);
   return false;
  }
 }
//Email looks good!
 return true;
//End of Function
}
	
//This function verify's the various inputs of the form
function verifyMaintenance(myform)
{
 //Check for Hosting Package choice
 if (!checkRadios())
 {
  return false;
 } 
//Check for first name
 if (myform.first_name.value == "")
 {
  window.alert("Please enter your First Name!");
  myform.first_name.focus();
  myform.first_name.select();
  return false;
 }
 //check for last name
 if (myform.last_name.value == "")
 {
  window.alert("Please enter your Last Name!");
  myform.last_name.focus();
  myform.last_name.select();
  return false;
 }
 //Check for address
 if (myform.address1.value == "")
 {
  window.alert("Please enter your Address!");
  myform.address1.focus();
  myform.address1.select();
  return false;
 }
 //Check city
 if (myform.city.value == "")
 {
  window.alert("Please enter your City!");
  myform.city.focus();
  myform.city.select();
  return false;
 }
 //Check state
 if (myform.state.value == "")
 {
  window.alert("Please enter your State!");
  myform.state.focus();
  myform.state.select();
  return false;
 }
 //Check zip code
 if (myform.zip.value == "")
 {
  window.alert("Please enter your Zip Code!");
  myform.zip.focus();
  myform.zip.select();
  return false;
 }
 //Check area code
 if (myform.day_phone_a.value == "")
 {
  window.alert("Please enter your Area Code, Thank you!");
  myform.day_phone_a.focus();
  myform.day_phone_a.select();
  return false;
 }
 //Check telephone number prefix
 if (myform.day_phone_b.value == "")
 {
  window.alert("Please enter your telephone number Prefix, Thank you!");
  myform.day_phone_b.focus();
  myform.day_phone_b.select();
  return false;
 }
 //Check telephone number suffix
 if (myform.day_phone_c.value == "")
 {
  window.alert("Please enter your telephone number Suffix, Thank you!");
  myform.day_phone_c.focus();
  myform.day_phone_c.select();
  return false;
 }
 //Check for email
 if (!validateEmail(myform.email.value))
 {
  myform.email.focus();
  myform.email.select();
  return false;
 }
 //Check for web address
 if (myform.url.value == "")
 {
  window.alert("Please enter your Web Site Address! Ex:(http://www....)");
  myform.url.focus();
  myform.url.select();
  return false;
 }
 //Check for Hosting Company
 if (myform.hosting.value == "")
 {
  window.alert("Please enter the name of your Hosting Company!");
  myform.hosting.focus();
  myform.hosting.select();
  return false;
 }
  //Check for User ID
 if (myform.user_id.value == "")
 {
  window.alert("Please enter your User ID!");
  myform.user_id.focus();
  myform.user_id.select();
  return false;
 }
  //Check for Password
 if (myform.password.value == "")
 {
  window.alert("Please enter your Password!");
  myform.password.focus();
  myform.password.select();
  return false;
 }
 //All data OK!  
 else
 return true;
} 
/* End of Function */


