﻿///<reference name="MicrosoftAjax.js" />

String.prototype.trim = function() {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

function cleanStr(item) {
    var txt, re, r;
    txt = item.value;
    re = /[^A-Za-z0-9_\s\.\-\&\,]/g;
    r = txt.replace(re, '');
    r = r.trim();
    item.value = r.toUpperCase();
}

function chk_Select(src, args) {
    var s = document.getElementById(src.controltovalidate);
    args.IsValid = (s.selectedIndex > 0);
}

function justNumbers(item) {
    var txt, re, r;
    txt = item.value;
    re = /[^0-9]/g;
    r = txt.replace(re, '');
    item.value = r.trim();
}

function justAlphaNum(item) {
    var txt, re, r;
    txt = item.value;
    re = /[^A-Za-z0-9]/g;
    r = txt.replace(re, '');
    item.value = r.trim();
}

function justAlpha(item) {
    var txt, re, r;
    txt = item.value;
    re = /[^A-Za-z\s]/g;
    r = txt.replace(re, '');
    r = r.trim();
    item.value = r.toUpperCase();
}

function justDates(item) {
    var txt, re, r;
    txt = item.value;
    re = /[^0-9\-\/]/g;
    r = txt.replace(re, '');
    r = r.trim();
    item.value = r.toUpperCase();
}

function trimEmail(item) {
    //var r = new String(item.value);
    //item.value = r.trim();
    var txt, re, r;
    txt = item.value;
    re = /[^A-Za-z0-9_\@\.\-]/g;
    r = txt.replace(re, '');
    item.value = r.trim();
}

function CharCount_onchange(srcEntry, dispID) {
    var i = srcEntry.value;
    var x = 149 - i.length;
    $get(dispID).value = x;
}

function clearEntries() {
    for (var i = 0; i < clearEntries.arguments.length; i++) {
        $get(clearEntries.arguments[i]).value = '';
    }
}
