﻿function auto_tab(obj, nxt)
{
    var strValidChars = "0123456789";
    var strChar;
    var blnResult = true;

    if (obj.value.length > 0) 
    {
        if (obj.value.length == 1) 
        {
            if (strValidChars.indexOf(obj.value) == -1) obj.value = '';
        }
        if (obj.value.length == 2) 
        {
            var dltFirstChar = false;
            var dltSecondChar = false;
            if (strValidChars.indexOf(obj.value.charAt(0)) == -1) dltFirstChar = true;
            if (strValidChars.indexOf(obj.value.charAt(1)) == -1) dltSecondChar = true;

            if (dltFirstChar && dltSecondChar) obj.value = '';
            if (dltFirstChar && !dltSecondChar) obj.value = obj.value.charAt(1);
            if (!dltFirstChar && dltSecondChar) obj.value = obj.value.charAt(0);
        }
        
        if (obj.value.length == 2) nxt.focus();
    }

}    
    
function remove_invalid_char(obj)
{
    var strValidChars = "0123456789";
    var strLen = obj.value.length;
    var newStr = '';
    if (strLen > 0)
    {
        for (i = 0; i < strLen; i++)
        {
            var strChar = obj.value.charAt(i);
            if (strValidChars.indexOf(strChar) != -1) newStr += strChar;
        }
        obj.value = newStr;
    }
}

function showPopup(url, width, height)
{
//    if(navigator.appName != "Netscape")
//    {
//        window.showModelessDialog(url, "", "dialogWidth="+width+"px;dialogHeight="+height+"px;scroll=no;border=thin;status=no;help=no;center:yes;resizable:no");
//    }
//    else
//    {
        window.open(url, "", "width="+width+",height="+height+",location=no,menubar=no,resizable=no,scrollbars=yes,status=no");
//    }
}   