//Add trimming functions to the String object.
String.prototype.trim = function(){ return this.replace(/^\s*|\s*$/g,''); }
String.prototype.ltrim = function(){ return this.replace(/^\s*/g,''); }
String.prototype.rtrim = function(){ return this.replace(/\s*$/g,''); }

function isAlpha(p_strValue) {
    //Define Matching expression
    var l_regExp = /^[a-zA-Z\ \'\-\.\,]*$/;
    var l_strValue = p_strValue.trim()
    if (l_strValue.match(l_regExp)) 
        return true; 
    else 
        return false;
}

function isNumeric(p_strNum) {   
    if (p_strNum.match(/^\d+$/)) 
        return true; 
    else 
        return false;
}

function isPassword(p_strPass)
{
    //Alpha numeric password 6-15 characters long.
    var l_regExp = /(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,15})$/;
    if (p_strPass.match(l_regExp)) 
        return true; 
    else 
        return false;
}

function isValidPhoneNumber(p_strPhone) {
    //Define Matching expression
    var l_regPhone = /^(1-)*\(*\d{3}(\)|\-) *\d{3}-\d{4}( |$)/;
    
    if (p_strPhone.match(l_regPhone)) 
        return true; 
    else 
        return false;
}

function isValidZipCode(p_strZip) {
    //Define Matching expression
    var l_regExp = /(^\d{5}$)|(^\d{5}-\d{4}$)/
    
    if (p_strZip.match(l_regExp)) 
        return true; 
    else 
        return false;
}

function isValidImage(p_strImage) {
    //Define Matching expression
    var l_regExp = /^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*.*))+\.(jpg|gif|png|jpeg)$/i;   
    if (p_strImage.match(l_regExp)) 
        return true; 
    else 
        return false;
}


function displayError(p_strError) {
    document.getElementById(p_strError+"Error").style.display = "inline";
}

function clearError(p_strError) {
    document.getElementById(p_strError+"Error").style.display = "none";
}

