// simple Window opener
/* <dtml-var "enableHTTPCompression(request=REQUEST, debug=1, js=1)"> (this is for http compression) */
function openWindow(url, width, height, params) {
    var width;
    var height;
    if(!width) width="320";
    if(!height) height="450";
    if(!params) params = "scrollbars, resizable";
    paramstring = "width="+width+",height="+height+","+params;
    
    newWin = window.open(url,"new Window",paramstring);
    newWin.focus();
} 

function SelText(formname, inputid) {
    if (document[formname] != undefined) {
        formobj = document[formname];
        if (formobj[inputid] != undefined) {
            formobj[inputid].focus();
            formobj[inputid].select();
        }
    }
}
   
function evalKey(e, funcname, params) {
    var key ='';
    if(window.event || !e.which) {
        key = e.keyCode; // IE
    } else if(e) {
        key = e.which; // Netscape
    }
    if(key!=9 || e == undefined) {
        fstr = funcname+'(';
        for( i = 0; i<params.length; i++) {
            fstr += 'params['+String(i)+']';
            if(i<(params.length-1))
                fstr += ', ';
        }
        fstr += ')';
        eval(fstr);
    }
}


// Tooltip-like help pop-ups used for glossary items
function glossaryHelp(elem, flag, attrId){ 
    this.ie = document.all ? 1 : 0
    this.ns4 = document.layers ? 1 : 0
    this.dom = document.getElementById ? 1 : 0

    var boxId = "helpBox";
    var boxObj = this.dom ? document.getElementById(boxId) : this.ie ? document.all[boxId] : document.layers[boxId];
    var buttonObj = elem; 
    
    var txt = 'Dummy text '+buttonObj.firstChild.data+'.'
    
    if(!attrId) attrId = "helpText";
    if(buttonObj.getAttribute(attrId)) txt=buttonObj.getAttribute(attrId)
    
    if(boxObj.childNodes.length==0) {
        var newText = document.createTextNode(txt);
        boxObj.appendChild(newText);
    } 
    else {boxObj.firstChild.data = txt}
    
    if(boxObj) {
        var newLeft = buttonObj.offsetLeft;
        var newTop = buttonObj.offsetTop;
    
        boxObj.style ? boxObj.style.left = newLeft+"px" : boxObj.left = newLeft;
        boxObj.style ? boxObj.style.top = newTop+"px" : boxObj.top = newTop;
    }
    
    if (flag) {  
        if (ie) { 
            boxObj.parentNode.parentNode.style.zIndex=1000; 
            boxObj.parentNode.parentNode.style.borderRight='0px solid #000'; 
            // ugly , yes .. but neccesary to avoid a small but very annoying bug in IE6 
        } 
        boxObj.style.visibility='visible'; 
    } 
    else { 
        if (ie) { 
            boxObj.parentNode.parentNode.style.zIndex=1; 
            boxObj.parentNode.parentNode.style.border='none'; 
        } 
        boxObj.style.visibility='hidden' }; 
  }
  
// we need this for wai compabatiblity
function hideJsCalendar() {
    var cal = window.calendar;

    if (window.calendar) 
        cal.hide();
    return false;
}

// The search popup show/hide:

function showBox(id) {
    document.getElementById(id).style.visibility = 'visible';
    return true;
}    
function hideBox(id) {
    document.getElementById(id).style.visibility = 'hidden';
    return true;
}
