// *** 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;
}

// --- cookies
function saveCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000))
		var expires = "; expires="+date.toGMTString()
	}
	else expires = ""
	document.cookie = name+"="+value+expires+"; path=/"
}
function readCookie(name) {
	var nameEQ = name + "="
	var ca = document.cookie.split(';')
	for(var i=0;i<ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length)
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length)
	}
	return null
}
function deleteCookie(name) {
	saveCookie(name,"",-1)
}


// --- main init
function initMain() {
	if (window.updateKoszykDivs)
		updateKoszykDivs();
}

//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: #FFF7E1;} --></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" class="pro"></a><br><div class="load-info" id="loadInfo">ładowanie zdjęcia..</div></td></tr></body></html>');
	JSFSplashWin.document.close();
	JSFSplashWin.focus();
	
	singleImage.src = url;
}

var singleImageText = "";
function displaySingleOnload() {

	displayWidth = singleImage.width + 50; displayHeight = singleImage.height + 120;
	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();
}
