

function getDOMElement(name)
{
    return (document.all ? document.all[name] : document.getElementById(name));
}

function createDOMElement(eleName,name)
{
    var rc=document.createElement(eleName);
    rc.id=name;
    rc.name=name;
    return rc;
}

function getEventAndStopBubble(e)
{
    var rc=e;
    if (!e) 
        rc = window.event;
    rc.cancelBubble = true;
    if (rc.stopPropagation) 
        rc.stopPropagation();
    return rc;
}

function getEventOffsetX(e)
{
    if (e.offsetX!=undefined) return e.offsetX;
    return e.layerX;
}

function getEventOffsetY(e)
{
    if (e.offsetY!=undefined) return e.offsetY;
    return e.layerY;
}

function openNewWindow(url,width,height)
{
    return window.open(url,
                new String(Math.round(Math.random() * 100000)),
                "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,"
                +"resizable=1,width="+width+",height="+height);
}

function getXMLHttpRequest()
{
    var request = null;
    if (window.XMLHttpRequest) {
        request = new XMLHttpRequest();
    }
    else if (window.ActiveXObject) {
        try {
            request = new ActiveXObject("Msxml2.XMLHTTP"); 
        } 
        catch (e) { 
            try { 
                request = new ActiveXObject("Microsoft.XMLHTTP"); 
            } 
            catch (e) {} 
        } 
    }
    else {
        alert("No XMLHttpRequest support in this browser.");
    }
    return request;
}

var selectionPopupWindow=null;
var selectionPopupElement=null;
var selectionPopupImage=null;

function updateEntrySelectionWithImage(value,imageSrc)
{
    selectionPopupElement.value=value;
    selectionPopupImage.src=imageSrc;
    selectionPopupElement=null;
    selectionPopupImage=null;
    selectionPopupWindow=null;
    
}

function popupEntrySelection(url,element,image)
{
    if (selectionPopupWindow==null || selectionPopupWindow.closed) {
        selectionPopupElement=element;
        selectionPopupImage=image;
        selectionPopupWindow=openNewWindow(url,600,400);
    }
    else
        selectionPopupWindow.focus();

}

function cancelEntrySelection()
{
    selectionPopupElement=null;
    selectionPopupImage=null;
    selectionPopupWindow=null;
}
