function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}

function GoogleLoadMapTeichert() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl()); 
		map.addControl(new GMapTypeControl()); 
		map.setCenter(new GLatLng(53.456473,14.46629), 15);
		var point = new GLatLng(53.456160, 14.465810); 
		map.addOverlay(new GMarker(point, {title:"Teichert \nul. Koralowa 105"}));
	}
} // GoogleLoadMapTeichert();

function preloadimages() {
  var d = document;
  if(document.images) {
  	if(!document.MM_p)
  		document.MM_p = new Array();
  	var i, j = document.MM_p.length, a = preloadimages.arguments;
  	for(i = 0; i < a.length; i++)
  		if(a[i].indexOf("#") != 0) {
  			document.MM_p[j] = new Image;
  			document.MM_p[j++].src=a[i];
  		}
  }
} // preloadimages()

function pwSetDivHeight() {
	var i = 0;
	var a = arguments;
	var l = a.length / 2;
	var aDivObjs = new Array();
	var aDivAdd = new Array();
	var maxDH = 0;
	for(i = 0; i < l; i++) {
		aDivObjs[i] = document.getElementById(a[i * 2]);
		aDivAdd[i] = a[(i * 2) + 1];
	}
	for(i = 0; i < l; i++) {
		if((aDivObjs[i].offsetHeight + aDivAdd[i]) > maxDH) {
			maxDH = aDivObjs[i].offsetHeight;
		}
	}
	for(i = 0; i < l; i++) {
		aDivObjs[i].style.height = (maxDH + aDivAdd[i]) + "px";
	}
}


function pwAloneMenuSwitch(objId) {
	objC = document.getElementById("C" + objId);
	objsK = document.getElementById("tresc").getElementsByTagName("DIV");
	if(objC.style.display == "block") {
		objC.style.display = "none";
		objC.style.visibility = "hidden";
	} else {
		for (i = 0; i < objsK.length; i++) {
			if(objsK[i].id.substring(0,1) == "C") {
				objsK[i].style.display = "none";
				objsK[i].style.visibility = "hidden";
			}
		}
		objC.style.display = "block";
		objC.style.visibility = "visible";
	}
} // pwAloneMenuSwitch()


var pwSelLast = -1;
var pwSelTyp = 'k';
// Zmienna "pwSelList" musi zostać zainicjowana możliwymi wartościami!
var pwSelList = new Array();

function pwSelectChangeDate(dir) {
	var el = document.getElementById('prawaprogramselectdata');
	var l = pwSelList.length;
	var tresc = new Array(document.getElementById('prawaprogram0616' + pwSelTyp),
												document.getElementById('prawaprogram0617' + pwSelTyp),
												document.getElementById('prawaprogram0618' + pwSelTyp),
												document.getElementById('prawaprogram0619' + pwSelTyp),
												document.getElementById('prawaprogram0620' + pwSelTyp));
	pwSelLast = pwSelLast + dir;
	if(pwSelLast >= l)
		pwSelLast = l - 1;
	if(pwSelLast < 0)
		pwSelLast = 0;
	el.innerHTML = pwSelList[pwSelLast];
	for(i = 0; i < l; i++) {
		tresc[i].style.display = 'none';
		tresc[i].style.visibility = 'hidden';
	}
	tresc[pwSelLast].style.display = 'block';
	tresc[pwSelLast].style.visibility = 'visible';
}


function pwSelectChangeType(dir) {
	var el = document.getElementById('prawaprogramselecttyp');
	var typy = new Array('k', 'a', 's', 'r', 'b');
	var pwSelTypeList = new Array('Kino Kryterium', 'Kino Alternatywa', 'Scena festiwalowa', 'Klub Festiwalowy Rezerwat', 'Bałtycka Galeria Sztuki');
	var l = pwSelTypeList.length;
	var tresc = new Array(document.getElementById('prawaprogram0' + (616 + pwSelLast) + 'k'),
												document.getElementById('prawaprogram0' + (616 + pwSelLast) + 'a'),
												document.getElementById('prawaprogram0' + (616 + pwSelLast) + 's'),
												document.getElementById('prawaprogram0' + (616 + pwSelLast) + 'r'),
												document.getElementById('prawaprogram0' + (616 + pwSelLast) + 'b'));
	if(dir == 1) {
		switch(pwSelTyp) {
			case 'k': pwSelTyp = 'a'; break;
			case 'a': pwSelTyp = 's'; break;
			case 's': pwSelTyp = 'r'; break;
			case 'r': pwSelTyp = 'b'; break;
		}
	}
	if(dir == -1) {
		switch(pwSelTyp) {
			case 'a': pwSelTyp = 'k'; break;
			case 's': pwSelTyp = 'a'; break;
			case 'r': pwSelTyp = 's'; break;
			case 'b': pwSelTyp = 'r'; break;
		}
	}
	var selTyp = (pwSelTyp == 'k' ? 0 : (pwSelTyp == 'a' ? 1 : (pwSelTyp == 's' ? 2 : (pwSelTyp == 'r' ? 3 : 4))));
	el.innerHTML = pwSelTypeList[selTyp];
	for(i = 0; i < l; i++) {
		tresc[i].style.display = 'none';
		tresc[i].style.visibility = 'hidden';
	}
	tresc[selTyp].style.display = 'block';
	tresc[selTyp].style.visibility = 'visible';
}


function pwTopLayerOn(src, w, h) {
	var toplayer = document.getElementById('toplayer');
	var pageSize = getPageSize();
	toplayer.innerHTML = '<a id="zamknij1" class="zamknijtop" href="#" onclick="javascript:tcTopLayerOff();">[X] Zamknij</a>';
	toplayer.innerHTML += ' <img id="topfoto" src="' + src + '" width="760" alt="" /> ';
	toplayer.innerHTML += '<a id="zamknij2" class="zamknijtop" href="#" onclick="javascript:tcTopLayerOff();">[X] Zamknij</a>';
	toplayer.style.width = pageSize[0] + "px";
	toplayer.style.height = (pageSize[1] - 90) + "px";
	toplayer.style.visibility = "visible";
	var zamknij1 = document.getElementById('zamknij1');
	var zamknij2 = document.getElementById('zamknij2');
	zamknij1.style.marginRight = "100px"; //((pageSize[0] - 74) / 2) + "px";
	zamknij2.style.marginRight = "100px"; //((pageSize[0] - 74) / 2) + "px";
}

function pwTopLayerOff() {
	var toplayer = document.getElementById('toplayer');
	toplayer.style.visibility = "hidden";
	toplayer.style.width = "0px";
	toplayer.style.height = "0px";
	toplayer.innerHTML = "";
}



function pwLiveDiv() {
	var i = 2;
	var a = arguments;
	var l = a.length;
	var aLiveDiv = document.getElementById(a[0]);
	var aCurrDiv = a[1];
	var aDivObjs = new Array();
	var polecenie = "";
	for(i = 2; i < l; i++) {
		aDivObjs[i - 2] = document.getElementById(a[i]).innerHTML;
	}
	if(aCurrDiv == (l - 3)) {
		aCurrDiv = 0;
	} else {
		aCurrDiv++;
	}
	aLiveDiv.innerHTML = aDivObjs[aCurrDiv];
	for(i = 3; i < l; i++) {
		polecenie = polecenie + "', '" + a[i];
	}
	var calosc = "pwLiveDiv('" + a[0] + "', " + aCurrDiv + ", '" + a[2] + polecenie + "');";
	setTimeout(calosc, 8000);
} // pwLiveDiv();



function pwSetDiv() {
	var a = arguments;
	var aLiveDiv = document.getElementById(a[0]);
	var aCurrDiv = document.getElementById(a[1]).innerHTML;
	aLiveDiv.innerHTML = aCurrDiv;
} // pwSetDiv();



