function popup(page, width, height, winname)
{
    sWidth  = screen.width;
    sHeight = screen.height;

    xPos  = (sWidth  - width)  / 2;
    yPos  = (sHeight - height) / 2;
    yPos  = 30;

    prob  = "left="+xPos+",";
    prob += "top="+yPos+",";
    prob += "screenX="+xPos+",";
    prob += "screenY="+yPos+",";
    prob += "width="+width+",";
    prob += "height="+height+",";
    prob += "menubar=0,";
    prob += "toolbar=0,";
    prob += "statusbar=0,";
    prob += "scrollbars=1,";
    prob += "resizable=0,";
    prob += "locationbar=0,";
    prob += "directories=0";

    win = window.open(page, winname, prob);
    win.focus();
    
    return false;
}

function new_imgwin(location, width, height)
{
    sWidth = screen.width;   xPos = (sWidth  - width)  / 2;
    sHeight = screen.height; yPos = (sHeight - height) / 2; yPos -= 150; if(yPos < 30) { yPos = 30; }

    prob  = "left="+xPos+",";
    prob += "top="+yPos+",";
    prob += "screenX="+xPos+",";
    prob += "screenY="+yPos+",";
    prob += "width="+width+",";
    prob += "height="+height+",";
    prob += "menubar=0,";
    prob += "toolbar=0,";
    prob += "statusbar=0,";
    prob += "scrollbars=1,";
    prob += "resizable=1,";
    prob += "locationbar=0,";
    prob += "directories=0";

    win = window.open(location, "IMGVIEW", prob);
    win.focus();
    
    return false;
}

function lowLight(item)
{
    if(item.className == 'hvr') { item.className = 'nrml'; }
}

function highLight(item)
{   
    if(item.className == 'nrml') { item.className = 'hvr'; }
}

function mkFocus(item)
{
    item.className = 'fcs';
}

function mkBlur(item)
{
    item.className = 'nrml';
}

function setCN(item, cn)
{
    item.className = cn;
}

function mkrl(item)
{
    if(item.className == 'tbln') { item.className = 'tblh'; }
}

function mkrh(item)
{   
    if(item.className == 'tblh') { item.className = 'tbln'; }
}

function set_selected_item(itemid, itemtitle, formitem, doSubmit)
{
    if(document.contentform.elements[formitem])
    {
        selectbox = document.contentform.elements[formitem];

        if(selectbox.length)
        {
            selectbox.selectedIndex = add_item_if_not_exists(selectbox, itemid, itemtitle);
            
            if(doSubmit)
            {
                document.contentform.submit();
            }
        }
    }

    return(true);
}

function set_selected_color(colorvalue, formitem)
{
    if(document.contentform.elements[formitem])
    {
        formelm = document.contentform.elements[formitem];

        formelm.value = colorvalue; document.contentform.submit();
    }

    return(true);
}

function add_item_if_not_exists(selectbox, itemid, itemtitle)
{
    selectbox.style.color           = '#FFFFFF';
    selectbox.style.backgroundColor = '#880000';
    
    for(i=0; i<selectbox.length; i++)
    {
        if(selectbox.options[i].value == itemid)
        {
            selectbox.options[i].text = itemtitle; return(i);
        }
    }
    
    sel = selectbox.length; selectbox.options[sel] = new Option(itemtitle, itemid, false, false);
    
    return(sel);
}

function showSubElem(parentID, subID, diffx, diffy)
{
    // POSITION ERMITTELN UND SUBELEMENT ANZEIGEN
    var pos = getElemPos(parentID);
    var itm = document.getElementById(subID);

    if(pos[0] && pos[1])
    {
        itm.style.left    = (pos[0]+diffx)+"px";
        itm.style.top     = (pos[1]+diffy)+"px";
        itm.style.display = "block";
    }

}

function hideElem(elemID)
{
    document.getElementById(elemID).style.display = "none";
}

function getElemPos(el)
{
    var lx=0, ly=0;
    
    if(el)
    {
        while(el!=null)
        {
            lx+=el.offsetLeft;
            ly+=el.offsetTop;
            el=el.offsetParent;
        }
        
        return new Array(lx, ly);
    }
    return false;
}

function highlight_text(formitem)
{
	formitem.focus();
	formitem.select();
}

function outline(elem)
{
    if(elem.style.display == "none")
    {
        elem.style.display = "";
        return false;
    }
    else
    {
        elem.style.display = "none";
        return false;
    }
    return true;
}
