
function IsBlank(value) {
   for (var x = value.length - 1; x >= 0; x--) {
      if ((value.charAt(x) != " ") && (value.charAt(x) != "")) {
         return false;
      } 
   }
   return true;
}
////////////////////////////////////////////////////////////
// Checks to see whether a value contains non-numeric
// data.
////////////////////////////////////////////////////////////
function IsANumber(value){

    // Assume everything is okay
    var result = true

    // Check the all the digits,
    // so step through the inputValue one character at
    // a time and set result = false if any non-numeric
    // digits are encountered.

	for (var i=0; i<value.length; i++) {
         if (value.charAt(i) != " " && value.charAt(i) != "0") {
               if (!parseFloat(value.charAt(i))) {
                   result = false
                   break
	         }
	     }
	}

    // Return true (inputValue is a valid number) or
    // false (it's invalid).
    return result
}
////////////////////////////////////////////////////////////
// Checks to see if an input value contains 10 numbers.
////////////////////////////////////////////////////////////
function IsAValidPhoneNumber(value){
    var digitsFound = 0

    // Step through each input Value to see how
    // many digits it contains
    for (var i=0; i<value.length; i++) {
	   if (IsANumber(value.charAt(i))) {
          digitsFound++
	      }
    }
    // If inputValue contains at least 10
    // digits, assume it is a valid phone number
	  if (digitsFound == 10) {
	      return true
    }
    else {
	     return false
    }
}
////////////////////////////////////////////////////////////
// Checks to see whether an input value contains "@" and
// "."
////////////////////////////////////////////////////////////
function IsAValidEmail(value) {

    var foundAt = false
    var foundDot = false

    // Step through the inputValue looking for
    // "@" and "."

    for (var i=0; i<=value.length; i++) {
      if (value.charAt(i) == "@" ) {
          foundAt = true
      }
      else if (value.charAt(i) == ".") {
          foundDot = true
      }
    }

    // If both "@" and "." were found, assume
    // the e-mail address is valid; otherwise,
    // return false so the calling code knows
    // the e-mail address is invalid.

    if (foundAt && foundDot) {
        return true
    }
    else {
        return false
    }
}

function ValidateForm(Info) {
   
   if ((IsBlank(Info.CompanyName.value))) {
      	alert("Please enter your Company Name.");
		document.Info.CompanyName.focus();
     	return false;
   }
   else if ((IsBlank(Info.Name.value))) {
     	alert("Please enter your Your Name.");
   		document.Info.Name.focus();                           
        return false;
   }
   else if ((IsBlank(Info.Position.value))){ 
   		alert("Please enter your Position.");
   		document.Info.Position.focus();                           
        return false;
   }   
   else if ((IsBlank(Info.Email.value))){ 
   		alert("Please enter your e-Mail Address");
   		document.Info.Email.focus();                           
        return false;
   }   
   else if ((!IsAValidEmail(Info.Email.value))){ 
   		alert("Please enter a your e-Mail Address in a proper format.");
   		document.Info.Email.focus();                           
        return false;
   }         
    else if ((IsBlank(Info.PhoneNumber.value))){ 
   		alert("Please enter your Phone Number.");
   		document.Info.PhoneNumber.focus();                           
        return false;
   }   
   else if ((!IsANumber(Info.PhoneNumber.value))){ 
   		alert("Please enter your Phone Number as a number.");
   		document.Info.PhoneNumber.focus();                           
        return false;
   }   
   else if ((!IsAValidPhoneNumber(Info.PhoneNumber.value))){ 
   		alert("Please enter a proper Phone Number.");
   		document.Info.PhoneNumber.focus();                           
        return false;
   }         
    else if ((IsBlank(Info.FaxNumber.value))){ 
   		alert("Please enter your Fax Number.");
   		document.Info.FaxNumber.focus();                           
        return false;
   }   
   else if ((!IsANumber(Info.FaxNumber.value))){ 
   		alert("Please enter your Fax Number as a number.");
   		document.Info.FaxNumber.focus();                           
        return false;
   }   
   else if ((!IsAValidPhoneNumber(Info.FaxNumber.value))){ 
   		alert("Please enter a proper Fax Number.");
   		document.Info.FaxNumber.focus();                           
        return false;
   }         
   else {                              
            return true;
   }
   }                                 

