    // Validator Object
    var valid = new Object();

    // REGEX Elements

        // matches zip codes
        valid.zipCode = /\d{5}(-\d{4})?/;

        // matches $17.23 or $14,281,545.45 or ...
        valid.Currency = /\$\d{1,3}(,\d{3})*\.\d{2}/;

        // matches 5:04 or 12:34 but not 75:83
        valid.Time = /^([1-9]|1[0-2]):[0-5]\d$/;

        //matches email
        valid.emailAddress = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;

        // matches phone ###-###-####
        valid.phoneNumber = /^\(?\d{3}\)?\s|-\d{3}-\d{4}$/;

        // International Phone Number
        valid.phoneNumberInternational = /^\d(\d|-){7,20}/;

        // IP Address
        valid.ipAddress = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;

        // Date xx/xx/xxxx
        valid.Date = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/;

        // State Abbreviation
        valid.State = /^(AK|AL|AR|AZ|CA|CO|CT|DC|DE|FL|GA|HI|IA|ID|IL|IN|KS|KY|LA|MA|MD|ME|MI|MN|MO|MS|MT|NB|NC|ND|NH|NJ|NM|NV|NY|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VA|VT|WA|WI|WV|WY)$/i;

        // Social Security Number
        valid.SSN = /^\d{3}\-\d{2}\-\d{4}$/;

    
    function validateForm(theForm) {

        var elArr = theForm.elements; 

        for(var i = 0; i < elArr.length; i++) {

           with(elArr[i]) { 

              var v = elArr[i].validator; 

              if(!v) continue; 

              var thePat = valid[v]; 

              var gotIt = thePat.exec(value); 

              if(! gotIt){
                 alert(name + ": Invalid Type or Format. Please enter a valid email address.");                  
                 elArr[i].select();
                 elArr[i].focus(); 
                 return false;
              }
           }
		if (frmRegister.email.value != frmRegister.reemail.value)
		{
		alert("Your email address in both fields must match");
		frmRegister.email.focus();
		return(false);
		}
        }	
			
return true;
}

// THESE TWO FUNCTIONS ARE FOR ERROR CHECKING ON REGISTRATIONS PAGESS
function IsNumeric(Str) {
//str = document.form1.test.value;
	re = /^\d\d\d-\d\d\d-\d\d\d\d$/;
	if (str.replace(/ /g, "").length > 0 && !str.match(re)) 
	{
	alert("The phone number is of the wrong format.\nPlease use the format 999-999-9999");
	return false;
	}
}

function verifydata() {
	// THESE IF STATEMENTS ARE FOR Mem_Reg_Step1.asp	
	if(frmFirstLogin.Temp_Pass.value=="")
		{
		alert('Please enter the temporary password that is emailed to you in the beginning of the registration process');
		frmFirstLogin.Temp_Pass.focus();
		return (false);
		}	
	///////////////////// END //////////////////////////////////
	// THESE IF STATEMENTS ARE FOR Mem_Reg_Step3.asp	
	if (document.frmBusProfile.BusinessName.value=="")
    {
     alert("Business Name is a required field for Advertising your business with Khoj.ca");
	 document.frmBusProfile.BusinessName.focus();
     return false;
	}
	
		if (document.frmBusProfile.TollNumber.value!="")
    {
		if (IsNumeric(document.frmBusProfile.TollNumber.value)==false)
		{
			document.frmBusProfile.TollNumber.value="";
			document.frmBusProfile.TollNumber.focus();
			return false;
		}
	}
	if (document.frmBusProfile.FaxNumber.value!="")
    {
		if (IsNumeric(document.frmBusProfile.FaxNumber.value)==false)
		{
			document.frmBusProfile.FaxNumber.value="";
			document.frmBusProfile.FaxNumber.focus();
			return false;
		}
	}
	///////////////////// END //////////////////////////////////
	
	// THESE IF STATEMENTS ARE FOR Mem_Reg_Step4.asp	
	//if (document.frmShowCats.CatDesc.value=="")
    //{
     //alert("Khoj requires you to selected a business category that fits your business");
	 //document.frmShowCats.CatDesc.focus();
     //return false;
	//}
	//if (document.frmShowCats.SubCatDesc.value=="")
    //{
     //alert("Khoj requires you to selected a business sub-category that fits your business");
	 //document.frmShowCats.SubCatDesc.focus();
     //return false;
	//}
	///////////////////// END //////////////////////////////////
		
	// THESE IF STATEMENTS ARE FOR Mem_Reg_PassChg.asp
	if (document.frmAccountAuthentication.Password.value=="")
    {
     alert("Empty Password is not acceptable. Please enter your password that consists of at least 6 length letters, digits and symbols.");
	 document.frmAccountAuthentication.Password.focus();
     return false;
	}
	if (document.frmAccountAuthentication.RePassword.value=="")
    {
     alert("Empty Password is not acceptable. Please enter your password that consists of at least 6 length letters, digits and symbols.");
	 document.frmAccountAuthentication.RePassword.focus();
     return false;
	}
	
	if (frmAccountAuthentication.Password.value != frmAccountAuthentication.RePassword.value)
	{
     alert("Your passwords do not match. Please enter same password twice");
	document.frmAccountAuthentication.Password.value="";
	document.frmAccountAuthentication.RePassword.value="";
	document.frmAccountAuthentication.Password.focus();
	return(false);
	}
	  

	/////////////////// END //////////////////////////////
   return true;
}

// AUTO TAB
function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}

function placeFocus() {
if (document.forms.length > 0) {
var field = document.forms[0];
for (i = 0; i < field.length; i++) {
if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
document.forms[0].elements[i].focus();
break;
         }
      }
   }
}

//////////////////////////////////////////////////////////////////////////////////////////////////