﻿// JScript File
var opopWaitWindow = window.createPopup();

function waitWindow(msgstr)
{
    if (msgstr.length == 0)
    {
	    opopWaitWindow.hide();
	    document.onmousedown = enableMouseClick;
	    document.body.style.cursor="default";
	    return
    }
	
    var msgHTML = "<table cellspacing='4'><tr>";
    msgHTML += "<td><img alt='' src='/_common/_image/progress.gif' /></td>";
    msgHTML += "<td style='font-size:8pt;font-family:Verdana;'><B>"+msgstr+"</B></td>";
    msgHTML += "</tr></table>"
	
    var w = 200 + (msgstr.length * 5) ;
    var h = 100;
    var winTOP = (screen.height/2)-h;
    var winLEFT = (screen.width - w)/2;

    opopWaitWindow.document.body.style.backgroundColor = "lightyellow";
    opopWaitWindow.document.body.style.border = "solid black 2px";
    opopWaitWindow.document.body.style.font = "normal bolder 11pt Verdana";
    opopWaitWindow.document.body.style.textAlign='center';
    opopWaitWindow.document.body.style.padding=(msgstr.length > 34 ? "5%" : "9%");
    opopWaitWindow.document.body.innerHTML = msgHTML;
    opopWaitWindow.show(winLEFT,winTOP,w,h);

    document.onmousedown = disableMouseClick;
}

function enableMouseClick()
{
 return true;
}

function disableMouseClick(value)
{
 return false;
}

function SelectGridRow(tableClientID, selectedRowIndex, checked)
{
    var oTable = document.getElementById(tableClientID);
    var oRows = oTable.rows;
    oRows[selectedRowIndex].className = (checked ? 'gridrowselected' : 'gridrowunselected');
}

function FormatNCMCode(txtObj)
{
    var reOneOrMoreDigits = /[\d+]/;    
    var keyCode = event.keyCode;
    var keyCharacter = cleanNumericKeyCode(keyCode);
    
    if(reOneOrMoreDigits.test(keyCharacter))
    {
        if (txtObj.value.length == 4 || txtObj.value.length == 7)
            txtObj.value += ".";
    }
}
        
function cleanNumericKeyCode(key)
{
    switch(key)
    {
        case 48: return "0"; break;
        case 49: return "1"; break;
        case 50: return "2"; break;
        case 51: return "3"; break;
        case 52: return "4"; break;
        case 53: return "5"; break;
        case 54: return "6"; break;
        case 55: return "7"; break;
        case 56: return "8"; break;
        case 57: return "9"; break;
        default: return String.fromCharCode(key); break;
    }
}

function IsNumeric(input) 
{ 
    input = String(input);       
    return (input - 0) == input && input.length > 0; 
} 

