// File: galeria.js
//

// global galeria state
var pictureWindow;	// Opened window with a picture
var openPicture;	// Name of opened image

function thumbnailPicture(path, imageFilename, width, height) {
	var small = path + 'm_' + imageFilename;
	var big = path + 'd_' + imageFilename;
	
	// <a target="_blank" href="#" onclick="return galeriaPicture('galeria/d_bc_010.jpg')">
	// 	<img border="0" src="galeria/m_bc_010.jpg">
	// </a>
	document.write('<a target="_blank" href="#" ');
	document.write('onclick="return galeriaPicture(\'' + big + '\',' + width + ',' + height + ')">');
	document.write('<img border="0" src="' + small + '">');
	document.write('</a>');
}

function galeriaPicture(imagePathname, width, height) {
	if ((pictureWindow != null) && !pictureWindow.closed) {
		if (openPicture != imagePathname) {
			// pictureWindow.resizeTo(width, height);
			pictureWindow.close();
			openPicture = "";
		}
	}
	
	if ((pictureWindow == null) || pictureWindow.closed) {
		var winFeatures = "menubar=0,toolbar=no,scrollbars=no,resizable=no,left=20,top=20,height=" + (height) + ",width=" + width;
		pictureWindow = window.open(imagePathname, "Galeria", winFeatures);
		// setTimeout("galeriaWriteWindow(imagePathname, width, height)", 50);
	}
	
	galeriaWriteWindow(imagePathname, width, height)
	// Store the open picture name
	openPicture = imagePathname;
	
	// Already open, bring it to the front
	pictureWindow.focus();
	
	return false;
}

function galeriaWriteWindow(imagePathname, width, height) {
	// pictureWindow.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">');
	// pictureWindow.document.write('<title>Galeria</title></head><body>');
	// pictureWindow.document.write('<img align="absmiddle" border="0" src="' + imagePathname + '">');
	// pictureWindow.document.write('</body></html>');
	pictureWindow.document.open();
	pictureWindow.document.write('<html><head>');
	pictureWindow.document.write('<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">');
	pictureWindow.document.write('<title>Galeria</title>');
	pictureWindow.document.write('<link rel="stylesheet" href="style_par.css" type="text/css" />');
	pictureWindow.document.write('</head>');
	pictureWindow.document.write('<body marginheight="0" marginwidth="0" leftmargin="0" rightmargin="0" topmargin="0" bgcolor="#ffffff">');
	pictureWindow.document.write('<img border="0" src="' + imagePathname + '" alt=" ">');
	pictureWindow.document.write('<div id="imageClose">');
	pictureWindow.document.write('<a href="#" class="polecenie" onclick="return window.close()"><img border="0" src="images/zamknij.gif" width="72" height="20" alt=" "></a>');
	pictureWindow.document.write('</div>');
	pictureWindow.document.write('</body></html>');
	pictureWindow.document.close();
}



// End of galeria.js
