// JScript source code
var ALERTSOFF = 0
var ALERTSON = 1


 function checkName(name)
{
     if (name.value.length == 0)
          return;

     for (var i=0; i < name.value.length; i++)
     {
          var ch = name.value.substring(i, i+1);
          if ((ch >= "A" && ch <= "Z") || 
               (ch >= "a" && ch <= "z")||
               (ch == "'")||(ch == "-")||
               (ch == " ")||(ch == "."))
          {
               continue;
          }
          else
          {
			
               alert("Invalid name.  Please re-enter");
              
               name.value="";
               name.focus ();
               return;
          }
     }
}

function onFocusNumericOnly(oTextbox) {
	var sReturnValue;
	sReturnValue = '';
	var i;
	for (i=0;i<oTextbox.value.length;i++) {
		if (oTextbox.value.charCodeAt(i) >= 48 && oTextbox.value.charCodeAt(i) <= 57) {
			sReturnValue = sReturnValue + oTextbox.value.charAt(i);
		}
	}
	oTextbox.value = sReturnValue;
	return true;
}

function formatPhone(oTextbox) {
	var sReturnValue;
	
	sReturnValue = '';
	oTextbox.value.replace(" ","");
	if (oTextbox.value.length > 0) {
		while(oTextbox.value.substr(0,1) == "1" || oTextbox.value.substr(0,1) == "0"){
			oTextbox.value = oTextbox.value.substr(1,(oTextbox.value.length-1))
		}
		if (oTextbox.value.length < 10) {
			alert('Please enter your area code and phone number in the following format: 8007821967\nIf your phone number includes an extension,\nadd it to the end like this: 8007821967111\nPlease do not include the "1" prefix.\n\nThis page will automatically reformat the phone number for you.');
			oTextbox.value="";
			oTextbox.focus();
		} else {
			sReturnValue = '(' + oTextbox.value.substr(0,3) + ')' + oTextbox.value.substr(3,3) + '-' + oTextbox.value.substr(6,4);
			if (oTextbox.value.length > 10) {
				sReturnValue = sReturnValue + 'x' + oTextbox.value.substr(10);
			}
			oTextbox.value = sReturnValue;
		}
	}
	return true;
}

function numericOnly(oTextbox,evt) {
	if (evt.keyCode == 13)
	{
		return true;
	}
	if (((evt.keyCode < 48 || evt.keyCode > 57) && (evt.keyCode < 96 || evt.keyCode > 105) && evt.keyCode != 8 && evt.keyCode != 9 && evt.keycode != 13 && evt.keyCode != 37 && evt.keyCode != 39 && evt.keyCode != 46) || evt.shiftKey == 1)
	{
		return false;
	}
	else
	{
		return true;
	}
}


function validate_email(email, usealerts) {

	var str = email.value; // email string
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,10}|[0-9]{1,10})(\]?)$/; // valid
	if (!(!reg1.test(str) && reg2.test(str))) { // if syntax is valid
	    if(usealerts && str.length != 0){
			alert("\"" + str + "\" is an invalid e-mail address."); // this is also optional
			email.focus();
		}
		return false;
	}
	
    
    // define a list of invalid characters
    invalidCharsList = " /:,;~#'%&*$()[]{}<>!\|=?`";
	
	if (email.value=="" && usealerts == 1){
		return true;
	} 		
	predot = email.value.indexOf('.',0);	
   at=email.value.indexOf('@',0);
   dot=email.value.indexOf('.',at);
   afterdot=email.value.length-dot;
    if (at==-1 ||
       at==0 ||
       dot==-1 ||
       dot-at<2 ||
       afterdot<3 ||
       (at-predot<2 && at-predot>0)) {
       if(usealerts == 1){ 
	        alert("The e-mail address appears to be invalid!");      
		    //email.value = "";
			email.focus();
		}
		return false;
   }
    for (i = 0; i < invalidCharsList.length; i++) {
        errorChar = invalidCharsList.charAt(i);
        if (email.value.indexOf(errorChar,0) != -1) {
			if(usealerts == 1){
	            alert("The e-mail address appears to be invalid!");
	            //email.value = "";
	            email.focus();
	        }
            return false;
        }
    }
    return true;
}


function checkValue(oInput){
	if(trimString(oInput.value) == ""){
		return false;
	}else{
		return true;
	}
}


//Form Scripts
function validatevipprogramform(theForm)
    {
        if(theForm.txtname.value=="")
        {
            alert("Please enter your Name.");
            theForm.txtname.focus();
            return false;
        }
        
        if(theForm.txtaddress.value=="")
        {
            alert("Please enter your Address.");
            theForm.txtaddress.focus();
            return false;
        }
        
        if(theForm.txtcity.value=="")
        {
            alert("Please enter your City.");
            theForm.txtcity.focus();
            return false;
        }
        
        if(theForm.txtstate.value=="")
        {
            alert("Please enter your State.");
            theForm.txtstate.focus();
            return false;
        }
        
        if(theForm.txtzip.value=="")
        {
            alert("Please enter your Zip Code.");
            theForm.txtzip.focus();
            return false;
        }
        
        if(theForm.txtphone.value=="")
        {
            alert("Please enter your contact Phone Number.");
            theForm.txtphone.focus();
            return false;
        }
        
        if(theForm.txtemail.value=="")
        {
            alert("Please enter your Email Address.");
            theForm.txtemail.focus();
            return false;
        }
        
                
        if(theForm.txtage.value=="")
        {
            alert("Please enter your Age.");
            theForm.txtage.focus();
            return false;
        }
        
        if(theForm.txthowdidyouhear.value=="")
        {
            alert("How did you hear of this Web Site?");
            theForm.txthowdidyouhear.focus();
            return false;
        }
        
        return true;
        
    }
