﻿function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}
function ShowProgress(title, message, showHideButton) {
    $("#ProgressUI").dialog({ title: title, modal: true });
    $("#ProgressMessage").html(message);
    if (showHideButton) {
        $("#ProgressCloseButtonDiv").show();
        $("#isuProgLoaderGif").hide();
    }
    else {
        $("#ProgressCloseButtonDiv").hide();
        $("#isuProgLoaderGif").show();
    }
}

function HideProgress() {
    try {
        $("#ProgressUI").hide();
    }
    catch (ex) {
        alert("Failed to hide the progress box. Error: " + ex);
    }
}

function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g, "");
}
function ltrim(stringToTrim) {
    return stringToTrim.replace(/^\s+/, "");
}
function rtrim(stringToTrim) {
    return stringToTrim.replace(/\s+$/, "");
}

function isNumeric(val) {
    var validChars = '0123456789.,';

    for (var i = 0; i < val.length; i++) {
        if (validChars.indexOf(val.charAt(i)) == -1)
            return false;
    }

    return true;
}

