function powiekszObraz(imgName, imgUri) {
	//checks if a temporary image holder exists and removes it if it does
	var oldImgWindow = document.getElementById("tmpPowiekszenie");
	if (oldImgWindow)
		oldImgWindow.parentNode.removeChild(oldImgWindow);
	
	
	//creates a temporary image holder
	var newTmpHld = document.createElement("div");
		newTmpHld.setAttribute("id","tmpPowiekszenie");		
		
		if (navigator.appName != "Microsoft Internet Explorer") {
			newTmpHld.style.top = (window.pageYOffset + 119) + 'px';
		}
		
		else {
			newTmpHld.style.top = ((document.documentElement.scrollTop || document.body.scrollTop) - (document.documentElement.clientTop || 0) + 119) + 'px';
		}
		document.body.appendChild(newTmpHld);	


		//creates a window inside the image holder
		var newTmpWindow = document.createElement("div");
			newTmpWindow.setAttribute("id","tmpPowiekszenieOkno");
			newTmpHld.appendChild(newTmpWindow);
	
	
			// creates a holder for the link that closes the temporary image holder
			var hldLnk = document.createElement("div");
				hldLnk.setAttribute("id","powiekszenieZamkniecie");
					newTmpWindow.appendChild(hldLnk);
					
				var closeLnk = document.createElement("a");
					closeLnk.setAttribute("href","javascript:zamknijPowiekszenie();");
					closeLnk.innerHTML = 'zamknij';
						hldLnk.appendChild(closeLnk);
						
	
			// creates a holder for the image
			var hldImg = document.createElement("div");
				hldImg.setAttribute("id","powiekszenieObraz");
					newTmpWindow.appendChild(hldImg);
				
	
			// creates a loading screen
			var loadingScreen = document.createElement("div");
				loadingScreen.setAttribute("id","powiekszenieLadowanie");
				
				var loadingScreenImg = document.createElement("img");
					loadingScreenImg.setAttribute("src","gui/grafika/ajax-loader.gif");
					loadingScreenImg.setAttribute("alt","Ładowanie");
						loadingScreen.appendChild(loadingScreenImg);
						newTmpWindow.appendChild(loadingScreen);
	
				
			//gets the image from the server
			advAJAX.get({
				url: imgUri + '.php?imgNazwa=' + imgName,
				onSuccess : function(obj) {
					hldImg.innerHTML = obj.responseText;
				},
				onError : function(obj) {
					hldImg.innerHTML = "Wystąpił błąd podczas ładowania obrazu.";
				},
				onFinalization : function(obj) {
					var bigImg = document.getElementById("powiekszonyObraz");
						bigImg.onload = pokazObraz;
						bigImg.onclick = zamknijPowiekszenie;
				}
			});		
}
	
	//shows a new image after it's finished loading
	function pokazObraz () {
		var bigImg = document.getElementById("powiekszonyObraz");
			var imgW = bigImg.width;
			var imgH = bigImg.height;
			
		var loadingScreen = document.getElementById("powiekszenieLadowanie");
			loadingScreen.parentNode.removeChild(loadingScreen);
			
		var tmpWindow = document.getElementById("tmpPowiekszenieOkno");
			tmpWindow.style.width = (imgW + 14) + 'px';
			tmpWindow.style.height = (imgH + 40) + 'px';
			
		var hldImg = document.getElementById("powiekszenieObraz");
			hldImg.style.width = (imgW) + 'px';
			hldImg.style.height = (imgH) + 'px';
	}
	
	//removes opened full size image window
	function zamknijPowiekszenie () {
		var oldImgWindow = document.getElementById("tmpPowiekszenie");
		if (oldImgWindow)
			oldImgWindow.parentNode.removeChild(oldImgWindow);
	}


function otworzPopUp(url) {
	var oknoPopUp;
	
	oknoPopUp=window.open(url,'oknoPopUp','height=657,width=593,left=100,top=100,scrollbars=yes,resizable=yes,toolbar=yes,status=yes');
	if (window.focus) {oknoPopUp.focus()}
}


function runFlashHeader() {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="796" height="246">\n');
		document.write('<param name="movie" value="gui/naglowek.swf" />\n');
		document.write('<param name="quality" value="high" />\n');
		document.write('<param name="wmode" value="transparent">\n');
		document.write('<embed src="gui/naglowek.swf" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="796" height="246"></embed>\n');
		document.write('</object>\n');
}