var iActiveBlock = null;
var iBlocksCounter = 0;
var oBlock = new Array();
var oCloseLink = new Array();
var oShowLink = new Array();
var sLoadFunc = new Array();


function setActiveBlock(iIndex) {
	iActiveBlock = iIndex;
}

	  	function resetPosition(oEvent) {
			if(iActiveBlock == null)
				return false;
			oBlock[iActiveBlock].style.top = document.documentElement.scrollTop + 270 + "px";

		}
	  
	  	function hideBlock(oEvent) {

			removeEventHandler(oCloseLink[iActiveBlock], "click", hideBlock);
			
			oBlock[iActiveBlock].className = "ukryjBloczek";

			//addEventHandler(oShowLink[iActiveBlock], "click", showBlock);
			iActiveBlock = null;
		}
	  
		function showBlock(oEvent) {
			preventDefaultEvent(oEvent);

			if(iActiveBlock != null)
				return false;
			
			var oEventSrc = getEventSrc(oEvent);
			showSelectedBlock(oEventSrc.iBlockNr)
		}


function showSelectedBlock(iIndex) {
			iActiveBlock = iIndex;
			oBlock[iActiveBlock].className = "pokazBloczek";
			if(window.innerWidth && !bIsIE) {
				var oCurrentStyle = document.defaultView.getComputedStyle(oBlock[iActiveBlock], null)
				var iWidth = parseInt(oCurrentStyle.width);
				var iHeight = parseInt(oCurrentStyle.height);
				oBlock[iActiveBlock].style.position = "fixed";
				oBlock[iActiveBlock].style.left = (window.innerWidth - iWidth)/2 + "px";
				oBlock[iActiveBlock].style.top =  (window.innerHeight - iHeight)/2 + "px"; 
			}
			else if(bIsMinIE7) {
				var iWidth = parseInt(oBlock[iActiveBlock].currentStyle.width);
				var iHeight = parseInt(oBlock[iActiveBlock].currentStyle.height);
				oBlock[iActiveBlock].style.position = "fixed";
				oBlock[iActiveBlock].style.left = (document.body.clientWidth - iWidth)/2 + "px";
				oBlock[iActiveBlock].style.top =  (document.documentElement.clientHeight - iHeight)/2 + "px";			
			}
			else {
				var iWidth = parseInt(oBlock[iActiveBlock].currentStyle.width);
				var iHeight = parseInt(oBlock[iActiveBlock].currentStyle.height);
				oBlock[iActiveBlock].style.position = "absolute";
				oBlock[iActiveBlock].style.left = (document.body.clientWidth - iWidth)/2 + "px";
				oBlock[iActiveBlock].style.top =  document.documentElement.scrollTop + 270 + "px"; 
				addEventHandler(window, "scroll", resetPosition);
			}
			addEventHandler(oCloseLink[iActiveBlock], "click", hideBlock);

			if(sLoadFunc[iActiveBlock]) {
				eval(sLoadFunc[iActiveBlock] + "()");
			}	
}

		function activateHiddenBlock(sShowLink, sBlockId, sCloseLink, sLoadFuncParam) {
			oShowLink[iBlocksCounter] = document.getElementById(sShowLink);
			oBlock[iBlocksCounter] = document.getElementById(sBlockId + "0");
			oCloseLink[iBlocksCounter] = document.getElementById(sCloseLink);
			sLoadFunc[iBlocksCounter] = sLoadFuncParam;

			oShowLink[iBlocksCounter].iBlockNr = iBlocksCounter;
			oCloseLink[iBlocksCounter].iBlockNr = iBlocksCounter;

			removeEventHandler(oShowLink[iBlocksCounter], "click", showBlock);
			addEventHandler(oShowLink[iBlocksCounter], "click", showBlock);
			iBlocksCounter++;

		}


