// JavaScript Document
//Checking if Email Address is valid
function validEmail(email) {
    var emailRE = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/);
    return emailRE.test(email);
  }
   //  check for valid numeric strings	  
function IsNumeric(strString)
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }
function ValidIPAddress(ipaddr) {
   var re = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
   if (re.test(ipaddr)) {
      var parts = ipaddr.split(".");
      if (parseInt(parseFloat(parts[0])) == 0) { return false; }
      for (var i=0; i<parts.length; i++) {
         if (parseInt(parseFloat(parts[i])) > 255) { return false; }
      }
      return true;
   } else {
      return false;
   }
}


//  End -->

//Validation Starts Here
function validForm(Form) {
//Validating Name Field

if (Form.fn.value =="")
{
alert("Please enter your full name.")
Form.fn.focus()
Form.fn.select()
return false
}
/*if (Form.lname.value =="")
{
alert("Please enter your last name.")
Form.lname.focus()
Form.lname.select()
return false
}*/
// end validating name
//Country Selection Validation
countryChoice = Form.country.selectedIndex
if (Form.country.options[countryChoice].value == "")
{
alert("Please select your country")
Form.country.focus()
return false
}

//end validating Country 
//Email Validation

if (Form.email.value =="")
	{
	alert("Please enter your e-mail address")
	Form.email.focus()
	return false
	}
if (validEmail(Form.email.value) == false)
     // return focusElement(formElement.email,
	 {
    alert("Invalid e-mail address.");
	Form.email.focus()
	return false
	}
/*if (Form.cmail.value =="")
	{
	alert("Please confirm your e-mail address")
	Form.cmail.focus()
	return false
	}
if (Form.email.value !=Form.cmail.value)
	{
	alert("Entered e-mail addresses did not match")
	Form.cmail.focus()
	Form.cmail.select()
	return false
	}*/
//end validating email

//Validating Phone including to check if the field is numerical.
 if (Form.phone.value.length == 0) 
      {
      alert("Please enter your phone number. No space or symbols allowed. eg:9471234567");
	  Form.phone.focus()
	  Form.phone.select()
	  return false
      } 
   if (IsNumeric(Form.phone.value) == false) 
      {
      alert("Only numbers are alowed! No space or symbols allowed. eg:9471234567");
	    Form.phone.focus()
	  Form.phone.select()
	  return false
      }
//end validating phone
//validating chat fields
/*if (Form.msn.value =="")
	{
	alert("Please enter your MSN chat ID")
	Form.msn.focus()
	return false
	}
if (validEmail(Form.msn.value) == false)
     // return focusElement(formElement.email,
	 {
    alert("Invalid MSN ID!");
	Form.msn.focus()
	return false
	}
if (Form.yahoo.value =="")
	{
	alert("Please enter your Yahoo email address")
	Form.yahoo.focus()
	return false
	}
if (validEmail(Form.yahoo.value) == false)
     // return focusElement(formElement.email,
	 {
    alert("Invalid Yahoo ID");
	Form.yahoo.focus()
	return false
	}*/
//end validating chat fields
//Validating Method
swtChoice = Form.swt.selectedIndex
if (Form.swt.options[swtChoice].value == "")
{
alert("Please select softswitch type.")
Form.swt.focus()
return false
}

if (Form.ipaddr.value =="")
	{
	alert("Please enter your IP Address")
	Form.ipaddr.focus()
	return false
	}
if (ValidIPAddress(Form.ipaddr.value) == false)
     // return focusElement(formElement.email,
	 {
    alert("Invalid IP address.");
	Form.ipaddr.focus()
	return false
	}


salesChoice = Form.sales.selectedIndex
if (Form.sales.options[salesChoice].value == "")
{
alert("Please select your monthly sales.")
Form.sales.focus()
return false
}

hearChoice = Form.abtus.selectedIndex
if (Form.abtus.options[hearChoice].value == "")
{
alert("Please select how you heard about us.")
Form.abtus.focus()
return false
}


//end validating Method
//Validating Captcha Field
if (Form.captcha_input.value =="")
{
alert("Please enter the verification number displayed.")
Form.captcha_input.focus()
Form.captcha_input.select()
return false
}
return true
}
//end validating captcha field
