// pozor tato verzia vola aj funkciu zapocitaj pre obrazky
function open_picture_window(location,picWidth,picHeight,comment, foto_id, id_skupiny) {

    var closeMsg = comment;

	// Some browsers can't open window with width or height less than 100px.
	if (picWidth < 100) {picWidth = 100}
	if (picHeight < 100) {picHeight = 100}

	/*
	If we want to center the window, we need to know the screen resolution.
	Then, if our picture is smaller than screen, we can place it to the center.
	If it is bigger, then we will place it to the top left corner.
	*/

    availHeight = screen.height;
    availWidth = screen.width;

    if (availHeight < picHeight) {posTop = 0;}
    else {posTop = ((availHeight - picHeight)/2)-20;}

    if (availWidth < picWidth) {posLeft = 0;}
    else {posLeft = (availWidth - picWidth)/2;}

	/*
	Construction of window attributes and then opening the window with these
	attributes.
	*/
    atts = "width=" + picWidth + ",height=" + picHeight + ",directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0,top=" + posTop + ",left=" + posLeft;
    win4Pic = window.open('','win4Pic',atts);

	/*
	Inserting the content to the window. Removing any borders (using BODY
	attributes and borderless table). If picture is too small to fit window
	(width or height less than 100px), placing it to the center. Closing the
	window onClick and onBlur.
	*/
    win4Pic.document.open();
    win4Pic.document.write("<html><head><title>" + comment + "</title></head><body marginwidth='0' marginheight='0' leftmargin='0' topmargin='0' onLoad='self.focus()' onBlur='self.close();'><table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td align='center' valign='middle'><a href='#' onClick='self.close()'><img src='" + location + "' border='0' width='" + picWidth + "' height='" + picHeight + "' alt='" + closeMsg + "'></a></td></tr></table><img src='rs/zapocitaj.php?foto_id=" + foto_id + "&id_skupiny=" + id_skupiny + "' width=0 height=0 border=0/></body></html>");
    win4Pic.document.close();
}
