window.onerror = function ()
{
alert(Message_boxMessages.WindowError)
}

//-----------------------------------------------------------------------------

// Variable initialization
var Message;
Message = new MessageBox();


var Pressed = false;    // Determines mouse button pressed
var X = 0;              // Initial mouse
var Y = 0;              // click coordinates
var Left = 0;           // Initial message box
var Top = 0;            // location


// Message box prototype

function MessageBox()
{
    // set colors
    this.frameColor = "#000000";
    this.lineColor = "#000000";
    this.buttonCellBkColor = "#737373";
    this.sender = "";
    this.senderHF = "";
    this.ArrayHF = new Array();
    this.showed = false;
    this.ReadyToProcessFunction = true;
}

//-----------------------------------------------------------------------------

// Set function name, wich process button YES/NO/Cancel onClick event

MessageBox.prototype.setButtonClickFunction = function(funcName) {
    this.btnClick = funcName;
    this.ReadyToProcessFunction = true;
}

//-----------------------------------------------------------------------------

MessageBox.prototype.createLayer = function()
{
    // Creating over layer
    var OverLayer = document.createElement("div");
    OverLayer.id = "overLayer";
    OverLayer.style.position = "absolute";
    OverLayer.style.opacity = 0.1;
    OverLayer.style.filter="alpha(opacity=10)";
    OverLayer.style.zIndex = 100000;
    OverLayer.style.left = "0px";
    OverLayer.style.top = "0px";
    OverLayer.style.width = String( document.body.clientWidth ) + "px";
    OverLayer.style.height = String( document.body.clientHeight ) + "px";
    document.body.style.overflow = "hidden";
    OverLayer.style.backgroundColor = "#000000";

    document.body.insertBefore(OverLayer,document.body.firstChild);

    // Creating message box layer
    var MainLayer = document.createElement("div");
    MainLayer.id = "MessageBoxLayer";
    MainLayer.style.position = "absolute";

    document.body.appendChild(MainLayer);

    this.overLayer = OverLayer;
    this.parent = MainLayer;
}

//-----------------------------------------------------------------------------

MessageBox.prototype.deleteLayer = function()
{
    // deleting over layer and message box layer

    var Layer = document.getElementById("MessageBoxLayer");
    if (Layer != null)
    {
        var LayerParent = Layer.parentNode;
        LayerParent.removeChild(Layer);
    }

    var overLayer = document.getElementById("overLayer");
    if (overLayer != null)
    {
        var overLayerParent = overLayer.parentNode;
        overLayerParent.removeChild(overLayer);
    }

}

//-----------------------------------------------------------------------------

MessageBox.prototype.createButtons = function()
{
    var Result = "";

    switch (this.buttonType)
    {
        case "TRIALBUTTONS":
            {
                var Arr = this.ArrayHF;
                var LoginUrl = '"' + Arr[0] + '"';
                var UpgradeUrl = '"' + Arr[1] + '"';
                Result += "<table cellspacing='2' cellpadding='0' style='width:" + this.tableWidth + "px'>" +
                             "<tr align='center'>" +
                                "<td style='width:33%'><input id='LOGIN' type='button' value='Continue' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='location.href=" + LoginUrl + "; Message.Hide();' /></td>" +
                                "<td style='width:33%'><input id='UPGRADE' type='button' value='Upgrade' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='location.href=" + UpgradeUrl + "; Message.Hide();' /></td>" +
                                "<td style='width:33%'><input id='CANCEL' type='button' value='Cancel' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick=Message.Hide(); /></td>" +
                             "</tr>" +
                          "</table>";
                break;
                
            }
        case "OK" :
            {
                Result += "<table cellspacing='1' cellpadding='0' style='width:" + this.tableWidth + "px'>" +
                             "<tr align='center'>";
                if (this.btnClick == null)
                    Result += "<td style='width:100%'><input id='OK' type='button' value='OK' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();' /></td>";
                else
                    Result += "<td style='width:100%'><input id='OK' type='button' value='OK' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();" + this.btnClick + "(1)" + "' /></td>";
                Result += "</tr></table>";
                break;
            }
        case "OKCANCEL" :
            {
                Result += "<table cellspacing='2' cellpadding='0' style='width:" + this.tableWidth + "px'>" +
                             "<tr align='center'>" +
                                "<td style='width:50%'><input id='OK' type='button' value='OK' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();" + this.btnClick + "(1)" + "' /></td>" +
                                "<td style='width:50%'><input id='CANCEL' type='button' value='" + Message_boxMessages.Cancel + "' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();" + this.btnClick + "(3)" + "'/></td>" +
                             "</tr>" +
                          "</table>";
                break;
            }
        case "OKCANCEL_DIS" :
            {
                Result += "<table cellspacing='2' cellpadding='0' style='width:" + this.tableWidth + "px'>" +
                             "<tr align='center'>" +
                                "<td style='width:50%'><input id='OK' disabled = true type='button' value='OK' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();" + this.btnClick + "(1)" + "' /></td>" +
                                "<td style='width:50%'><input id='CANCEL' type='button' value='" + Message_boxMessages.Cancel + "' style='width:" + Math.round( ( parseFloat(this.multiplier) * 120 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();" + this.btnClick + "(3)" + "'/></td>" +
                             "</tr>" +
                          "</table>";
                break;
            }
        case "YESNOCANCEL" :
            {
                Result += "<table cellspacing='3' cellpadding='0' style='width:" + this.tableWidth + "px'>" +
                             "<tr align='center'>" +
                                "<td style='width:33.3%'><input id='YES' type='button' value='" + Message_boxMessages.YES + "' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();" + this.btnClick + "(1)" + "' /></td>" +
                                "<td style='width:33.3%'><input id='NO' type='button' value='" + Message_boxMessages.NO + "' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();" + this.btnClick + "(2)" + "'/></td>" +
                                "<td style='width:33.3%'><input id='CANCEL' type='button' value='" + Message_boxMessages.Cancel + "' style='width:" + Math.round( ( parseFloat(this.multiplier) * 120 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();" + this.btnClick + "(3)" + "'/></td>" +
                             "</tr>" +
                          "</table>";
                break;
            }
        case "RADIO":
            {
                Result +=   "<table cellspacing='2' cellpadding='0' style='width:" + this.tableWidth + "px'>" +
                                "<tr align='center'>" +
                                    "<td style='width:50%'><input id='OK' type='button' value='OK' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='" + this.btnClick + "(1,Message.checkIt())" + ";Message.Hide();' /></td>" +
                                    "<td style='width:50%'><input id='CANCEL' type='button' value='" + Message_boxMessages.Cancel + "' style='width:" + Math.round( ( parseFloat(this.multiplier) * 120 ) ) + "px;" + this.fontSize + "' onclick='" + this.btnClick + "(3,Message.checkIt())" + ";Message.Hide();'/></td>" +
                                "</tr>" +
                            "</table>";
                break;        
            }
        case "RADIOCHK":
            {
                Result +=   "<table cellspacing='2' cellpadding='0' style='width:" + this.tableWidth + "px'>" +
                                "<tr align='center'>" +
                                    "<td style='width:50%'><input id='OK' type='button' value='OK' style='width:" + Math.round( ( parseFloat(this.multiplier) * 100 ) ) + "px;" + this.fontSize + "' onclick='" + this.btnClick + "(1,Message.checkIt(),document.getElementById(\"chkAll\").checked)" + ";Message.Hide();' /></td>" +
                                    "<td style='width:50%'><input id='CANCEL' type='button' value='" + Message_boxMessages.Cancel + "' style='width:" + Math.round( ( parseFloat(this.multiplier) * 120 ) ) + "px;" + this.fontSize + "' onclick='" + this.btnClick + "(3,Message.checkIt(),document.getElementById(\"chkAll\").checked)" + ";Message.Hide();'/></td>" +
                                "</tr>" +
                            "</table>";
                break;
            }
        default:
            {
                Result += "<table cellspacing='2' cellpadding='0' style='width:" + this.tableWidth + "px'>" +
                             "<tr align='center'>" +
                                "<td style='width:30%'><input id='OK' type='button' value='" + Message_boxMessages.Cancel + "' style='width:" + Math.round( ( parseFloat(this.multiplier) * 120 ) ) + "px;" + this.fontSize + "' onclick='Message.Hide();" + this.btnClick + "(1)" + "' /></td>" +
                                "<td style='width:70%'>" + Message_boxMessages.WrongButtonType + "</td>" +
                             "</tr>" +
                          "</table>";
                break;
            }
    }

    return Result;
}

//-----------------------------------------------------------------------------

// Creates inner HTML for parent region

MessageBox.prototype.createTable = function(text)
{
    var fontSize = Math.round( ( parseFloat(this.multiplier) * 18 ) );

    var textCellHeight = "height=" + Math.round( ( parseFloat(this.multiplier) * 120 ) ) + "px";
    var buttonCellHeight = "height=" + Math.round( ( parseFloat(this.multiplier) * 30 ) ) + "px";
    
    //Set width of table
    if (this.buttonType == "RADIO" || this.buttonType == "RADIOCHK")
        this.tableWidth = Math.round( ( parseFloat(this.multiplier) * 500 ) );
    else
        this.tableWidth = Math.round( ( parseFloat(this.multiplier) * 500 ) );

    this.fontSize = "font-size:" + fontSize + "px";

    var buttons = this.createButtons();

    var tableHTML = "<table id='MessageBoxTable' color='#FF0000' width='" + this.tableWidth + "' style='" + this.fontSize + ";text-decoration: none;font-family: Arial, Sans-Serif, Verdana;' cellpadding=0 cellspacing=0>";

    tableHTML +=
        "<tr height='1'>" +
            "<td width='1'></td>" +
            "<td width='1'></td>" +
            "<td width='1'></td>" +
            "<td width='1'></td>" +
            "<td width='" + String(this.tableWidth - 8) + "'></td>" +
            "<td width='1'></td>" +
            "<td width='1'></td>" +
            "<td width='1'></td>" +
            "<td width='1'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td colspan='3'></td>" +
            "<td colspan='3' bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='3'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td colspan='2'></td>" +
            "<td colspan='2' bgcolor='" + this.frameColor + "'></td>" +
            "<td bgcolor='#737373'></td>" +
            "<td colspan='2' bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='2'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='5' bgcolor='#737373'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td colspan='2' bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='5' bgcolor='#737373'></td>" +
            "<td colspan='2' bgcolor='" + this.frameColor + "'></td>" +
        "</tr>";

    tableHTML +=
        "<tr " + textCellHeight + ">" +
            "<td width='4px' bgcolor='" + this.frameColor + "'></td>" +
            "<td style='border-left:2px solid #000000; border-right:2px solid #000000;' colspan='7' bgcolor='#737373'>" +
                "<div id='PopupText' align='center' style='color:#FFFFFF; width:" + this.tableWidth + "px; overflow:hidden;position:static'>" + text + "</div>" +
            "</td>" +
            "<td width='4px' bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='" + this.frameColor + "'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='#000000'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='" + this.frameColor + "'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>";
        
    if (this.buttonType == "RADIO" || this.buttonType == "RADIOCHK")
    {
       tableHTML +=
        "<tr height='15'>" +
            "<td colspan='9' bgcolor='#ffffff'></td>" +
        "</tr>" +         
        "<tr align='left'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='#ffffff'><input id='radio0' name='radioButtons' type='radio' value='0' checked='checked'>" + Message_boxMessages.OverwriteLesson + "</input></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr align='left'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='#ffffff'><input id='radio1' name='radioButtons' type='radio' value='1'>" + Message_boxMessages.DoNotAssignNewLesson + "</input></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr align='left'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='#ffffff'><input id='radio2' name='radioButtons' type='radio' value='2'>" + Message_boxMessages.KeepLessonAssignLesson + "</input></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='15'>" +
            "<td colspan='9' bgcolor='#ffffff'></td>" +
        "</tr>" +    
        "<tr height='1'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='" + this.frameColor + "'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='#ffffff'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='" + this.frameColor + "'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>";
    }
    
    if (this.buttonType == "RADIOCHK")
    {
        tableHTML +=
        "<tr height='5'>" +
            "<td colspan='9' bgcolor='#ffffff'></td>" +
        "</tr>" +
        "<tr align='left'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='#ffffff'><input id='chkAll' type='checkbox' name='chkALL'>" + Message_boxMessages.ForAllStudents + "</input></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='5'>" +
            "<td colspan='9' bgcolor='#ffffff'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='" + this.lineColor + "'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='#ffffff'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='7' bgcolor='" + this.lineColor + "'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>";   
    }
    tableHTML +=
        "<tr " + buttonCellHeight + ">" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td style='border-left:2px solid #000000; border-right:2px solid #000000;' colspan='7' bgcolor='" + this.buttonCellBkColor + "'>" +
                "<div align='justify'>" +
                    buttons +
                  "</div>" +
            "</td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
        "</tr>";

    tableHTML +=
        "<tr height='1'>" +
            "<td colspan='2' bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='5' bgcolor='" + this.buttonCellBkColor + "'></td>" +
            "<td colspan='2' bgcolor='" + this.frameColor + "'></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='5' bgcolor='" + this.buttonCellBkColor + "'></td>" +
            "<td bgcolor='" + this.frameColor + "'></td>" +
            "<td></td>" +
        "</tr>" +
        "<tr height='1'>" +
            "<td colspan='2'></td>" +
            "<td colspan='2' bgcolor='" + this.frameColor + "'></td>" +
            "<td bgcolor='" + this.buttonCellBkColor + "'></td>" +
            "<td colspan='2' bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='2'></td>" +
        "</tr>" +

        "<tr height='1'>" +
            "<td colspan='3'></td>" +
            "<td colspan='3' bgcolor='" + this.frameColor + "'></td>" +
            "<td colspan='3'></td>" +
        "</tr>";


        tableHTML += "</table>";

    return tableHTML;

}

//-----------------------------------------------------------------------------
MessageBox.prototype.showMessage = function(MessageText, ButtonType, arrayHF) {
    this.ArrayHF = arrayHF;
    this.multiplier = "1";
    this.oldKeyPress = document.onkeypress;
    document.onkeypress = this.keyPress;
    // Create parent region
    this.createLayer();

    if (ButtonType == null)
        ButtonType = "OK";
    this.buttonType = ButtonType;

    // this events needs to move message box with cursor
    this.oldOnMouseMoveEvent = document.onmousemove;
    document.onmousemove = this.mouseMove;
    this.parent.onmousedown = this.mouseDown;
    this.parent.onmouseup = this.mouseUp;

    var InnerHTML = this.createTable(MessageText);
    this.parent.innerHTML = InnerHTML;

    var DialogBox = this.parent;

    var Table = document.getElementById("MessageBoxTable");
    var TableWidth = Table.offsetWidth;
    var TableHeight = Table.offsetHeight;

    // Setting message box location and size parameters

    DialogBox.style.visibility = "visible";
    DialogBox.style.overflow = "hidden";
    DialogBox.style.zIndex = 1000000;

    DialogBox.style.width = Math.round(parseFloat(this.multiplier) * TableWidth) + "px";
    DialogBox.style.height = Math.round(parseFloat(this.multiplier) * TableHeight) + "px";
    DialogBox.style.clip = "rect(0px," + Math.round(parseFloat(this.multiplier) * TableWidth) + "px," +
                                 Math.round(parseFloat(this.multiplier) * TableHeight) + "px,0px)";
    
    winY = document.documentElement.scrollTop + 200;     
    DialogBox.style.left = "200px";
    DialogBox.style.top  = winY + "px";

    switch (this.buttonType) {
        case "OK":
            {                
                var button = document.getElementById("OK");
                button.focus();
                break;
            }
        case "OKCANCEL":
            {
                document.getElementById('CANCEL').focus();
                break;
            }
        case "OKCANCEL_DIS":
            {
                document.getElementById('CANCEL').focus();
                break;
            }
        case "YESNOCANCEL":
            {
                document.getElementById('CANCEL').focus();
                break;
            }
        case "RADIO":
            {
                document.getElementById('CANCEL').focus();
                break;
            }
        case "RADIOCHK":
            {
                document.getElementById('CANCEL').focus();
                break;
            }
        default:
            {
                document.getElementById('OK').focus();
                break;
            }
    }

    this.showed = true;
}

//-----------------------------------------------------------------------------

MessageBox.prototype.Confirm = function(MessageText, sender, senderHF, arrayHF)
{
    this.sender = sender;
    this.senderHF = senderHF;
    this.ArrayHF = arrayHF;
    this.setButtonClickFunction("MessageBoxConfirm");
    this.showMessage(MessageText, "OKCANCEL");
}

//-----------------------------------------------------------------------------

// Hides message box after click on button

MessageBox.prototype.Hide = function() {
    // restore old onMouseMove event
    document.onmousemove = this.oldOnMouseMoveEvent;
    document.onkeypress = this.oldKeyPress;

    this.parent.onmousedown = null;
    this.parent.onmouseup = null;
    this.btnClick = null;

    // deleting over layer and messagebox layer
    this.deleteLayer();

    // enabling scroll bars
    document.body.style.overflow = "";
    this.showed = false;
        
}

//-----------------------------------------------------------------------------

MessageBox.prototype.mouseMove = function(e)
{
    if ( e == null )
        e = window.event;

    var DialogBox = document.getElementById("MessageBoxTable").parentNode;
    if ( Pressed )
    {
        DialogBox.style.left = Left + e.clientX - X;
        DialogBox.style.top = Top + e.clientY - Y;
    }

}

//-----------------------------------------------------------------------------

MessageBox.prototype.mouseDown = function(e)
{
    if ( e == null )
        e = window.event;
    Pressed = true;
    X = e.clientX;
    Y = e.clientY;
    
    var DialogBox = document.getElementById("MessageBoxTable").parentNode;
    Left = parseFloat( DialogBox.style.left );
    Top =  parseFloat( DialogBox.style.top );
}

//-----------------------------------------------------------------------------

MessageBox.prototype.mouseUp = function(e)
{
    if ( e == null )
        e = window.event;
    Pressed = false;
}

//-----------------------------------------------------------------------------

MessageBox.prototype.keyPress = function(e) {
    if (e == null)
        e = window.event;
    
    if (navigator.appName != "Netscape") {
        if ((e.srcElement.id == "edIntegerPart") ||
            (e.srcElement.id == "edNumerator") ||
            (e.srcElement.id == "edDenominator")) {
            e.returnValue = false;
            return false;
        }
    }

    var Key;

    Key = e.keyCode;

    if (e.charCode == 0 || e.charCode == undefined)
        Key = e.keyCode;
    else if (e.keyCode == 0 || e.keyCode == undefined)
        Key = e.charCode;

    if (Message.buttonType == "OK") {
        if (Key == 13)                      // Enter key
        {
            try {
                if (navigator.appName == "Netscape") {
                    e.cancelBubble = true;
                    e.returnValue = false;
                    if (this.ReadyToProcessFunction == true) {
                        this.ReadyToProcessFunction = false;
                        document.getElementById("OK").onclick();
                    }
                }
                else {
                    e.returnValue = false;
                    document.getElementById("OK").onclick();
                }
            }
            catch (err) {

            }



            return;
        }
        else {
            return;
        }
    }


    if (Message.buttonType != "OKCANCEL_DIS") {
        if (Key == 13)                      // Enter key
        {
            document.getElementById("CANCEL").onclick();
            return;
        }

        else if (((Key == 121) || (Key == 89)) &&    // y or Y key
                ((document.getElementById("YES")) ||
                  (document.getElementById("OK")))) {
            if (document.getElementById("YES"))
                document.getElementById("YES").onclick();
            else if (document.getElementById("OK"))
                document.getElementById("OK").onclick();
        }

        else if (((Key == 110) || (Key == 78)) &&    // n or N key
                (document.getElementById("NO")))
            document.getElementById("NO").onclick();

        return;
    }
    else {
        if ((Key == 114) || (Key == 82)) {                 // r or R key        
            if (navigator.appName != "Netscape") {
                window.event.cancelBubble = true;
            }
            e.returnValue = false;
            document.getElementById("OK").onclick();
        }
        if ((Key != 114) && (Key != 82)) {                 // r or R key         {
            document.getElementById("CANCEL").onclick();
        }
    }
}

//-----------------------------------------------------------------------------

function getHiddenField(hfName)
{
  var hf = document.getElementsByName( hfName )[0];

  if( hf == null )
      throw Message_boxMessages.InvalidHiddenFieldName;

  return hf.value;
}

//-----------------------------------------------------------------------------

function MessageBoxConfirm(ID)
{
    if ( ID == 1 )
    {
        document.getElementById(Message.senderHF).value = "true";
        document.getElementById(Message.sender).click();
    }
    else
    {
        document.getElementById(Message.senderHF).value = "false";
        if (Message.ArrayHF != null)
            for(i = 0; i < Message.ArrayHF.length; ++i)
                document.getElementById(Message.ArrayHF[i]).value = "false";
    }
}

//-----------------------------------------------------------------------------

MessageBox.prototype.checkIt = function() 
{
 var chk;
 if (document.getElementById("radio0").checked)
    chk = "radio0";
 if (document.getElementById("radio1").checked)
    chk = "radio1";
 if (document.getElementById("radio2").checked)
    chk = "radio2";
 if (chk != null)
    return document.getElementById(chk).value;
 return null;
}

//-----------------------------------------------------------------------------
