﻿function CharsRemaining(textbox,max,updateView)
{
    // Check for GSM 2 long chars - we treat all data as Gsm type data
    var Gsm2Long = /[[\]^{|}\\~\n\f\r]/g;
    
    var Gsm2Occurs = CharOccurances(textbox.value,Gsm2Long);
    var CharCount = max - (textbox.value.length+Gsm2Occurs);
        
        if (CharCount < 0) {
            textbox.value = textbox.value.substring(0,max-Gsm2Occurs);
            CharCount = 0;
        }

    if (updateView != null) {
        document.getElementById(updateView).innerHTML=CharCount;
    }
}

function IsDigit(textbox)
{
    var d = /[^0-9]/;
    if (d.test(textbox.value))
    {
        textbox.value = "";
    }
}

function CharOccurances(s,patt)
{
    var m = s.match(patt);
    return m ? m.length : 0;
}

function ShowInfo(info)
{
    $("#"+info).fadeToggle("fast");
}

function GetSelectValue(select) {
    return select.options[select.selectedIndex].value;
}

jQuery.fn.fadeToggle = function(speed, easing, callback) {
   return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
};