//---------------------------------------------------------------------------------------------------------------
/*----------------------- Data Validation Functions -----------------------*/
//---------------------------------------------------------------------------------------------------------------
/* Returns True if the provided phone number consists of 10 characters and is numeric*/
function isValidPhone(strPhoneNumber){
    //currently only matches consecutive numbers, no dashes, parenthesis or otherwise.
    return (typeof (strPhoneNumber) == "string" && /\s*1?[0-9]{10}\s*/.test(strPhoneNumber));
}

/* Returns True if the provided zip code is numeric and consists of either 5 or 9 characters*/
function isValidZip(strZIPCode){
    return (typeof (strZIPCode) == "string" && /\s*([0-9]{5}|[0-9]{9})\s*/.test(strZIPCode));
}

/*Returns True if strNumbers contains all numeric characters*/	
function isNumeric(strNumbers){
    return (typeof(strNumbers) == "string" && /\s*[0-9]+\s*/.test(strNumbers));
}	


function isValidEmail(strEmail) {
    /*strEmail = (!strEmail || !typeof (strEmail) == "string" ? "" : strEmail);
    //here is the break down of the components of this regex.
    //1.  ^\s*   starting with zero or more whitespace characters
    //2.  [\!\#\$\%\&\*\+\-\~a-zA-Z0-9_]+   matching one or more of the valid characters inside the brackets []
    //3.  @   matching a single @ symbol
    //4.  [\!\#\$\%\&\*\+\-\~a-zA-Z0-9_]+   matching one or more of the valid characters inside the brackets []
    //5.  (\.[\!\#\$\%\&\*\+\-\~a-zA-Z0-9_]+)+   matching one or more of the patterns inside the parenthesis ()
    //                                      where the pattern inside the parenthesis is a . followed by the pattern from 4.
    //6.  \s*$   ending with zero or more whitespace characters
    return /^\s*[\!\#\$\%\&\*\+\-\~a-zA-Z0-9_]+@[\!\#\$\%\&\*\+\-\~a-zA-Z0-9_]+(\.[\!\#\$\%\&\*\+\-\~a-zA-Z0-9_]+)+\s*$/.test(strEmail);*/
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(strEmail) == false) {
      return false;
   }
	return true;
}

function isValidTaxID(strTaxID) {
    return typeof(strTaxID) == "string" && isNumeric(strTaxID) && strTaxID.length > 9;
}

function GetByName($ctx, name) {
    return $ctx.find("[name=" + name + "]");
}
