﻿
$.fn.extend({

    check: function() {
        return this.each(function() { this.checked = true; });
    },
    tocheck: function(blnVal) {
    return this.each(function() { this.checked = blnVal; });
    },
    uncheck: function() {
        return this.each(function() { this.checked = false; });
    },

    toggle: function() {
        return this.each(function() { this.checked = !this.checked; });
    },

    enabled: function(enableIt) {
        if (enableIt == null || enableIt == undefined) { return !($(this).attr("disabled") == "disabled"); } else { $(this).each(function() { if (enableIt) { $(this).removeAttr("disabled"); } else { $(this).attr("disabled", "disabled"); } }); return this; } 
    },

    cbchecked: function(checkIt) {
        if (checkIt == null || checkIt == undefined) { return ($(this).attr("checked")); } else { $(this).each(function() { if (checkIt) { $(this).removeAttr("checked"); } else { $(this).attr("checked", "checked"); } }); return this; } 
    },

    addItems: function(data) {
        return this.each(function() {
            var list = this;
            $.each(data, function(index, itemData) {
                var option = new Option(itemData.text, itemData.value);
                list.add(option);
            });
        });
    }

});

/*    
function $(sName){return document.getElementById(sName);}
*/

function checkEMail(strEmail) { var RegExpr = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-])+(\.[a-zA-Z0-9-]+)+$/; return RegExpr.test(strEmail); }
function checkPassword(strIn) { var RegExpr = /^([a-zA-Z0-9]){6,30}$/; return RegExpr.test(strIn); }
function checkCustomerNumber(strIn) { var RegExpr = /^([0-9]){6}$/; return RegExpr.test(strIn); }

function showError(id) {
    try { $('#' + id).attr('className', 'errField'); if ($('#' + id + '_error').length) { $('#' + id + '_error').show(); } if ($('#' + id + '_error_msg').length) { $('#' + id + '_error_msg').show(); } } catch (e) { }
}
function hideError(id) {
    try { $('#' + id).attr('className', ''); if ($('#' + id + '_error').length) { $('#' + id + '_error').hide(); } if ($('#' + id + '_error_msg').length) { $('#' + id + '_error_msg').hide(); } } catch (e) { }
}








