function openwindow(url, w, h)
{
    var x = (screen.width - w) / 2
    var y = (screen.height - h) / 2

    newwin = window.open(url, "Sportmed", 'width=' + w + ', height=' + h + ', left=' + x + ', top=' + y + ', resizable=1, scrollbars=yes, menubar=0, status=0, location=0, directories=0', false)


    if (newwin.opener == null)
    {
        newwin.opener = self;
    }
    newwin.focus();
}

function openwindow_order(url, w, h)
{
    var x = (screen.width - w) / 2
    var y = (screen.height - h) / 2

    newwin = window.open(url, "Sportmed", 'width=' + w + ', height=' + h + ', left=' + x + ', top=' + y + ', resizable=0, scrollbars=yes, menubar=0, status=0, location=0, directories=0', false)


    if (newwin.opener == null)
    {
        newwin.opener = self;
    }
    newwin.focus();
}

function openwindow_homepage(url, w, h)
{
    var x = (screen.width - w) / 2
    var y = (screen.height - h) / 2

    newwin = window.open(url, "Sportmed", 'width=' + w + ', height=' + h + ', left=' + x + ', top=' + y + ', resizable=0, scrollbars=no, menubar=0, status=0, location=0, directories=0', false)


    if (newwin.opener == null)
    {
        newwin.opener = self;
    }
    newwin.focus();
}

function win_size(w,h)
{
	window.resizeTo(w,h);
	var x = (screen.availWidth - w) / 2;
	var y = (screen.availHeight - h) / 2;
	window.moveTo(x,y);
}

function closeWindow()
{
    window.opener.location.reload()
    self.close();
}

function resizeDialogToContent()
{
    // resize window so there are no scrollbars visible
    var dw = window.dialogWidth;
    while (isNaN(dw))
    {
      dw = dw.substr(0,dw.length-1);
    }
    difw = dw - this.document.body.clientWidth;
    window.dialogWidth = this.document.body.scrollWidth+difw+'px';

    var dh = window.dialogHeight;
    while (isNaN(dh))
    {
      dh = dh.substr(0,dh.length-1);
    }
    difh = dh - this.document.body.clientHeight;
    window.dialogHeight = this.document.body.scrollHeight+difh+'px';
}

var zindex = 0;
var opr=navigator.userAgent.indexOf("Opera")

function dropmenu(e, menuitem)
{
    menuid = eval(menuitem).id

    if (window.themenu && themenu.id != menuid)
        themenustyle.visibility = "hidden";

    themenu = eval(menuitem)
    themenustyle = themenu.style;

    offsetX = document.body.scrollLeft;//0;
    offsetY = document.body.scrollTop;//0;

    if (opr != -1)
    {
        themenustyle.left = offsetX + event.clientX - event.offsetX;
    }
    else
    {
        themenustyle.left = offsetX + event.clientX - event.offsetX - 2;
    }

    if (opr != -1)
        themenustyle.top  = offsetY + event.clientY - event.offsetY + 13;
    else
        themenustyle.top  = offsetY + event.clientY - event.offsetY + 11;

    if (themenustyle.visibility == "hidden")
    {
        themenustyle.visibility = "visible";
        themenustyle.zIndex = zindex++;
    }
    else
        hidemenu();

    return false;
}

function hidemenu()
{
    if (window.themenu)
        themenustyle.visibility = "hidden";
}

document.onclick = hidemenu;

var pictures = new Array();
for (i = 0; i < 6; i++)
    pictures[i] = new Image();

pictures[0].src = '/images/dot_clear.gif';
pictures[1].src = '/images/types/tyyp_dr.gif';
pictures[2].src = '/images/types/tyyp_dl.gif';
pictures[3].src = '/images/types/tyyp_dkr.gif';
pictures[4].src = '/images/types/tyyp_dkl.gif';
pictures[5].src = '/images/types/tyyp_k.gif';

function type2idx(open)
{
    if (open == "F")
        return 0;
    else if (open == "DR")
        return 1;
    else if (open == "DL")
        return 2;
    else if (open == "DKR")
        return 3;
    else if (open == "DKL")
        return 4;
    else if (open == "K")
        return 5;

    return 0;
}
