var aWin = 0;
var win = "";

function winOpen(url, width, height, title) {
	var toBig = 0;

	if (win && win.open && !win.closed) win.close();

	var option = "";

	if (window.screen) {
		if (screen.availWidth > width) {
			var left = (screen.availWidth - width) / 2;
			option += "width=" + width + ",innerWidth=" + width;
			option += ",left=" + left + ",screenX=" + left;
		} else {
			option += "width=" + screen.availWidth + ",innerWidth=" + screen.availWidth;
			option += ",left=0,screenX=0";			
			toBig = 1;
		}
		
		if (screen.availHeight > height) {
			var top = (screen.availHeight - height) / 2;
			option += ",height=" + height + ",innerHeight=" + height;
			option += ",top=" + top + ",screenY=" + top;
			
		} else {
			option += ",height=" + screen.availHeight + ",innerHeight=" + screen.availHeight;
			option += ",top=0,screenY=0";
			toBig = 1;
		}
	}
	
	option += ",toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no";
	if (toBig) option += ",scrollbars=yes"
	else option += ",scrollbars=no";

	win = window.open('', 'foto', option);
//	win.resizeTo(width, height);
//	win.focus();

	var winDoc = win.document;
	winDoc.close();
	winDoc.open();
	astr = '<html><head><title>' + title + '</title>';
	astr += '</head>';
//	astr += '<script language="JavaScript" src="../scripts/closeonclick.jsp" type="text/javascript">';
//	astr += '<\/script>';
	astr += '\<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"\>';
	astr += '<a href="#" onClick="parent.close()">';
	astr += '<img src=\"' + url + '\" alt=\"Zavřít\" border=\"0\">';
	astr += '</a>';
	astr += '</body></html>';
	winDoc.write(astr);
	winDoc.close();
	self.aWin = win;
}

//------------------------------------------------------------------------------------------//
//*** funkce pro galerii obrazku  **********************************************************//
//------------------------------------------------------------------------------------------//

function getObject(id) {
   var obj = (document.getElementById ? document.getElementById(id) : document.all
               ? document.all[id] : eval('document.' + id));
   return obj;
}

function showGalery(id, show) {
   objectImg = getObject('img'+id);
   if (show) {
       objectImg.style.opacity = ".5";
       objectImg.style.filter = "alpha(opacity=50)";
   } else {
       objectImg.style.opacity = "1";
       objectImg.style.filter = "alpha(opacity=100)";
   }
}
