
function forgotEmail() {

    var str1 = document.theForm.email.value;

    if(str1.length==0){
        alert("Please Enter Your Email Address Before Submitting the Form");
        document.theForm.email.focus();
        return false;
    } else if( (str1.length > 0) && ( (str1.indexOf(">") > -1) || (str1.indexOf("<") > -1) || (str1.indexOf("%") > -1) || (str1.indexOf(" ") > -1) ) ){
        alert("Percent Symbols, Spaces and Brackets are not Allowed");
        document.theForm.email.focus();
        return false;
    } else if( (str1.length > 0) && (str1.indexOf("@") < 1) ){
        alert("Please Double-Check Your Email Address");
        document.theForm.email.focus();
        return false;
    }

    return true;
}



function checkFullLogin() {

    var usr = document.theForm.user.value;
    var pwd = document.theForm.pass.value;

    if(usr.length==0){
        alert("Please Enter Your UserName in the Field Provided");
        document.theForm.user.focus();
        return false;
    } else if (pwd.length==0){
        alert("Please Enter Your Password in the Field Provided");
        document.theForm.pass.focus();
        return false;
    } else if( (usr.length > 0) && ( (usr.indexOf(">") > -1) || (usr.indexOf("<") > -1) || (usr.indexOf("%") > -1) ) ){
        alert("Percent Symbols and Brackets are not Allowed - User Field");
        document.theForm.user.focus();
        return false;
    } else if( (pwd.length > 0) && ( (pwd.indexOf(">") > -1) || (pwd.indexOf("<") > -1) || (pwd.indexOf("%") > -1) ) ){
        alert("Percent Symbols and Brackets are not Allowed - Password Field");
        document.theForm.pass.focus();
        return false;
    }

    return true;
}

function checkHeaderLogin() {

    var usr = document.hForm.user.value;
    var pwd = document.hForm.pass.value;

    if(usr.length==0){
        alert("Please Enter Your UserName in the Field Provided");
        document.hForm.user.focus();
        return false;
    } else if (pwd.length==0){
        alert("Please Enter Your Password in the Field Provided");
        document.hForm.pass.focus();
        return false;
    } else if( (usr.length > 0) && ( (usr.indexOf(">") > -1) || (usr.indexOf("<") > -1) || (usr.indexOf("%") > -1) ) ){
        alert("Percent Symbols and Brackets are not Allowed - User Field");
        document.hForm.user.focus();
        return false;
    } else if( (pwd.length > 0) && ( (pwd.indexOf(">") > -1) || (pwd.indexOf("<") > -1) || (pwd.indexOf("%") > -1) ) ){
        alert("Percent Symbols and Brackets are not Allowed - Password Field");
        document.hForm.pass.focus();
        return false;
    }

    return true;
}



function checkRegForm() {

    var myRegex = new RegExp("^[A-Za-z0-9\.\-_]+@[A-Za-z0-9\.\-_]+\.[A-Za-z]+$")

    rName = document.rForm.name.value;
    title = document.rForm.title.value;
    comp = document.rForm.company.value;
    phone = document.rForm.phone.value;
    email = document.rForm.email.value;
    user = document.rForm.user.value;

    if(rName.length==0){
        alert("Please Enter Your Name in the Field Provided");
        document.rForm.name.focus();
        return false;
    } else if(title.length==0){
        alert("Please Enter Your Title in the Field Provided");
        document.rForm.title.focus();
        return false;
    } else if(comp.length==0){
        alert("Please Enter Your Company in the Field Provided");
        document.rForm.company.focus();
        return false;
    } else if(phone.length==0){
        alert("Please Enter Your Phone Number in the Field Provided");
        document.rForm.phone.focus();
        return false;
    } else if(email.length==0){
        alert("Please Enter Your Email Address in the Field Provided");
        document.rForm.email.focus();
        return false;
    } else if(! email.match(myRegex)){
        alert("Invalid Email Address, Please Double-Check");
        document.rForm.email.focus();
        return false;
    } else if(user.length==0){
        alert("Please Enter a UserName in the Field Provided");
        document.rForm.user.focus();
        return false;
    } else if( (rName.length > 0) && (rName.indexOf(" ") < 1) ){
        alert("Please enter your first and last name into the field provided.");
        document.rForm.name.focus();
        return false;
    }

    if(user.length<6){
        alert("Username Must be at least 6 Characters in Length");
        document.rForm.user.focus();
        return false;
    }

    if (phone) {
        var openParen = phone.substring(0,1);
        var areaCode = phone.substring(1,4);
        var closeParen = phone.substring(4,5);
        var exchange = phone.substring(5,8);
        var dash = phone.substring(8,9);
        var line = phone.substring(9,13);


        if ((openParen != "(")
          || (!isANumber(areaCode, "phone number - area code"))
          || (closeParen != ")")
          || (!isANumber(exchange, "phone number - exchange"))
          || (dash != "-")
          || (!isANumber(line, "phone number - line"))) {
            alert("Please enter phone number in the following format: (123)456-7890");
            document.rForm.phone.focus();
            return false;
      	}
      }


    return true;
}


function isANumber(number) {
  answer = 1;
  if (!parseFloat(number)) {
    //the first digit wasn't numeric
    answer = 0;
  } else {
    //the first digit was numeric, so check the rest
    for (var i=0; i<number.length; i++) {
      if ((number.charAt(i) != "0")
        && (!parseFloat(number.charAt(i)))) {
          answer = 0;
          break;
      }
    }
  }
  return answer;
}


/*
var digits = "0123456789";
var phoneNumberDelimiters = "()- ";
var validWorldPhoneChars = phoneNumberDelimiters + "+";
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidateForm(){
	var Phone=document.frmSample.txtPhone

	if ((Phone.value==null)||(Phone.value=="")){
		alert("Please Enter your Phone Number")
		Phone.focus()
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please Enter a Valid Phone Number")
		Phone.value=""
		Phone.focus()
		return false
	}
	return true
 }
*/