﻿
/* code uses functions from mootools library */

function ZPage_ProcessKeyDown(keyCode, id, e)
{
    var evt = new Event(e);
    if (evt.code == keyCode)
    {
        var elem = $(id);
        if (elem)
        {
            elem.focus();
            elem.click();
        }

        evt.stopPropagation();
        return false;
    }
}

function addLoadEvent(func) 
{ 
    var oldonload = window.onload; 
    if (typeof window.onload != 'function') 
    { 
        window.onload = func; 
    } 
    else 
    { 
        window.onload = function() 
            { 
                if (oldonload) 
                { 
                    oldonload(); 
                } 
                func(); 
            } 
    } 
}

function getElement(Reference)
{
    try
    {
        if ($(Reference))
        {
            return $(Reference);
        }
        var controls = document.getElementsByName(Reference);
        if (controls)
        {
            if (controls.length == 1)
            {
                return $(controls[0]);
            }
        }
    }
    catch (e){}
    return null;
}