// *** JSF Main Routines
// *** (c) feel by fish, http://www.imagen.pl

// --- some core stuff
function PageID(lvl, sublvl, sublvl1) {
	this.lvl = lvl;
	this.sublvl = sublvl;
	this.sublvl1 = sublvl1;
}

function confirmAction(action, message) {
	if (message == null)
		message = "Jesteś pewien?";

	if ( confirm(message) )
		document.location.href = action;
}

function parseQuery() {
	query = document.location.search.substring(1,256);
	query = query.replace(/^.*\?(.+)$/,'$1');

	var queryObject = new Object();

	while ((pair = query.match(/([^=]+)=\'?([^\&\']*)\'?\&?/)) && pair[0].length) {
		query = query.substring( pair[0].length );
		if (/^\-?\d+$/.test(pair[2])) pair[2] = parseInt(pair[2]);
		queryObject[pair[1]] = pair[2];
	}

	return queryObject;
}

// --- main init
function initMain() {
}



//display window
var JSFSplashWin = null;

var singleImage = new Image();
singleImage.onload = displaySingleOnload;

function displaySingle(url, text) {

	displayWidth = 300; displayHeight = 100;
	if (window.screen) {screenWidth = window.screen.width; screenHeight = window.screen.height}
	displayPosX = Math.round((screenWidth - displayWidth)/2);
	displayPosY = Math.round((screenHeight - displayHeight)/2);

	singleImage = new Image();
	singleImageText = text;
	singleImage.onload = displaySingleOnload;

	JSFSplashWin = window.open("", "splash", "menubar=no,toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=" + displayWidth + ",height=" + displayHeight + ",left=" + displayPosX + ",top=" + displayPosY);
	
	JSFSplashWin.moveTo(displayPosX, displayPosY);
	JSFSplashWin.resizeTo(displayWidth, displayHeight);
	
	JSFSplashWin.document.open();
	JSFSplashWin.document.clear();
	JSFSplashWin.document.write('<html><head><title>Foto</title><link rel="stylesheet" href="defs.css" type="text/css"><style><!-- body{background: #F1F1F1;} --></style></head><body scroll="no" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><script>function closeMe(e){window.close();} /* document.onclick = closeMe; */</script><table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" class="gallery"><tr><td colspan="2" class="image"><a href="javascript:closeMe();"><img src="gfx/px.gif" name="displayImage" border="0"></a><br><div class="load-info" id="loadInfo">loading..</div></td></tr></body></html>');
	JSFSplashWin.document.close();
	JSFSplashWin.focus();
	
	singleImage.src = url;
}

var singleImageText = "";
function displaySingleOnload() {

	displayWidth = singleImage.width + 30; displayHeight = singleImage.height + 60;
	displayPosX = Math.round((screenWidth - displayWidth)/2);
	displayPosY = Math.round((screenHeight - displayHeight)/2);

	JSFSplashWin.moveTo(displayPosX, displayPosY);
	JSFSplashWin.resizeTo(displayWidth, displayHeight);

	JSFSplashWin.document.displayImage.src = singleImage.src;
	if (document.getElementById)
		JSFSplashWin.document.getElementById("loadInfo").innerHTML = singleImageText;
	else
		JSFSplashWin.document.all["loadInfo"].innerText = singleImageText;

	JSFSplashWin.focus();
}

