// File: galeria.js
//

// global galeria state
var pictureWindow;	// Opened window with a picture
var openPicture;	// Name of opened image
var intX;
var img = new Image();
var imPN;

function loadPicture(imagePathName){
	imgl = new Image();
	imgl.src=imagePathName;
	img.src = imgl.src;
	imPN= imagePathName;
	intX=0;
	setTimeout("checkImg()",1000);
	setTimeout("checkImg()",2000);
	setTimeout("checkImg()",3000);
	setTimeout("checkImg()",4000);
	galeriaPicture();
}

function galeriaPicture() {
	if ((pictureWindow != null) && !pictureWindow.closed) {
		if (openPicture != imPN) {
			pictureWindow.close();
			openPicture = "";
		}
	}
	
	if ((pictureWindow == null) || pictureWindow.closed) {


		var winFeatures = "menubar=0,toolbar=no,scrollbars=no,resizable=no,left=20,top=20,height=" + img.height + ",width=" + img.width;
		pictureWindow = window.open(imPN, "Galeria", winFeatures);
		// setTimeout("galeriaWriteWindow(imagePathname, width, height)", 50);
	}
	
	galeriaWriteWindow(imPN, img.width, img.height)
	// Store the open picture name
	openPicture = imPN;
	
	// Already open, bring it to the front
	pictureWindow.focus();
}

function checkImg(){
	pictureWindow.resizeTo(img.width,img.height+80);
}

function galeriaWriteWindow(imPN, intW, intH) {
	// 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_klub.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="' + imPN + 
// '" width="' + width + '" height="' + height +
	'" alt=" ">');
	pictureWindow.document.write('<div id="imageClose">');
	pictureWindow.document.write('<a href="#" class="polecenie" onclick="return window.close()"><img border="0" src="../zamknij.gif" width="72" height="20" alt=" "></a>');
	pictureWindow.document.write('</div>');
//	pictureWindow.document.write('<br/> height=' + intH + ' width=' + intW );
	pictureWindow.document.write('</body></html>');
	pictureWindow.document.close();
	pictureWindow.resizeTo(intW,intH+80);
}



// End of galeria.js

