// $Id: misc.js,v 1.2 2007/09/07 12:39:17 tkepski Exp $

function PopupWindow(url,width,height,name){
    if (name==null){
      name = new String(Math.round(Math.random()*10000000));
    }

    var left = (screen.width - width)/2;
    var top = (screen.height - height)/2 - 18;

    var win = window.open(url,name,"toolbar=no,location=no,directories=no,"+
      "status=no,menubar=no,scrollbars=no,resizable=no,"+
      "copyhistory=no, width="+width+",height="+height+",left="+left+",top="+top);
}

function PopupImage(url,width,height,title,name)
{
    if (name==null){
      name = new String(Math.round(Math.random()*10000000));
    }
    var windowheight = height+40;
    var windowwidth = width+20;

    var left = (screen.width - windowwidth)/2;
    var top = (screen.height - windowheight)/2 - 18;
    
    var scrollbars = "no";
    
    if (left<0) { scrollbars = "yes"; left = 32; windowwidth = screen.width - 2*left; }
    if (top<0) { scrollbars = "yes"; top = 32; windowheight =  screen.height - 2*top - 18; top = top - 18; }

    var win = window.open("",name,"toolbar=no,location=no,directories=no,"+
        "status=no,menubar=no,scrollbars=" + scrollbars + ",resizable=no,"+
        "copyhistory=no, width="+windowwidth+",height="+windowheight+",left=" + left + ",top=" + top);
    win.document.write("\<HEAD\>\<link rel=\"stylesheet\" type=\"text\/css\" href=\"\/style.css\"\/\>\<meta http-equiv=\"pragma\" content=\"no-cache\"\>\<TITLE\>"+title+"\<\/TITLE\>");
    win.document.write("\<\/HEAD\>");
    win.document.write("\<BODY class=\"popup\" style=\"margin:0\"\>\<img src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" border=0 vspace=\"10\" hspace=\"10\"\>\<BR\>\<a href=\"javascript:window.close();\" class=\"popup\"\>Close\<\/a\>\<\/BODY\><\/HTML\>");
}

function jmShowHelp(url)
{
    var width  = 750;
    var height = 580;
    var left   = (screen.width - width)/2;
    var top    = (screen.height - height)/2

    var win = window.open(url,null,"toolbar=no,location=no,directories=no,"+
      "status=no,menubar=no,scrollbars=yes,resizable=yes,"+
      "copyhistory=no, width="+width+",height="+height+",left=" + left + ",top=" + top);
   
    return false;
}
/**
 * 	Shows popup help window.
 */ 
function popup(title,width,height)
{
	if (!width) width = 350;
	if (!height) height = 450;

    var left = (screen.width - width)/2;
    var top = (screen.height - height)/2 - 18;

    var win = window.open('/misc/popup.xml?' + title,'popup',"toolbar=no,location=no,directories=no,"+
      "status=no,menubar=no,scrollbars=yes,resizable=yes,"+
      "copyhistory=no, width="+width+",height="+height+",left="+left+",top="+top);
     if (win) win.focus();
}
