	
	window.onload = function () 
	{
		oApp.initialize();
		MM_preloadImages('img/m_01_down.gif','img/m_02_down.gif','img/m_03_down.gif','img/m_04_down.gif');
		
		dhtmlHistory.initialize();
		dhtmlHistory.addListener(oApp.handleHistoryChange);
   
		var sHash = dhtmlHistory.getCurrentLocation();
		sHash = oApp.initializeLocation(sHash);
		oApp.displayLocation(sHash, null);
		oArt.alert('zaladowane: '+ sHash);
		
	} // window.onload
	
	
	
	
function openPopUpWithStatus(x, y, w, h, name, page) {

	winPopUp = window.open(page,name, 'location=no,menubar=no,scrollbars=no,status=yes,resizable=no,dependent=yes,width='+ w +',height='+ h +',screenX='+ x+',screenY='+ y +',left='+ x+',top='+ y +'');
	if(!winPopUp) 
		alert('Okienko pomocnicze nie zosta?o otwarte z powodu blokady pop-up.')
	else 
		winPopUp.focus();
	return winPopUp;
}
	

function showImage(width, height, url, time) {
	
	var nMaxHeight, nMaxWidth, nHFactor, nWFactor, nFactor, sSrc;
	
	nMaxHeight = (screen.availHeight? screen.availHeight:700) - 120;
	nMaxWidth = (screen.availWidtht? screen.availWidth:1000) - 67;
	
	if(height > nMaxHeight) nHFactor = nMaxHeight / height; else nHFactor = 1;
	if(width > nMaxWidth) nWFactor = nMaxWidth / width; else nWFactor = 1;
	nFactor = nHFactor <= nWFactor? nHFactor : nWFactor;

	if(nFactor < 1) {
		height = Math.floor(height * nFactor);
		width = Math.floor(width * nFactor);
		sSrc = '/Includes/showImage.php?time='+ time +'&h=' + height  +'&w=' + width +'&link=' + url;
	} else {
		sSrc = '/Includes/showImage.php?time='+ time +'&link=' + url;
	}
	
	//alert('h: '+ nHFactor +', w: '+ nWFactor +', = '+ nFactor);
	
	width += 7;
	height += 60;
	
	winShowImage = openPopUpWithStatus(50, 50, width, height, 'showImageWindow', sSrc);
	winShowImage.resizeTo(width, height);
}