function active (element)
{
	element.className='active';
}
function noactive (element)
{
	element.className='';
}



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 NextPrev(index,maximum)
{	
	
		index = parseInt(index);
		maximum = parseInt(maximum);
		
	
		document.getElementById("source").innerHTML=dynamicImages[index][0]+dynamicImages[index][1];
	
	if(maximum!=0)
	{
		if(index == maximum)
		{
			document.getElementById("rightButton").innerHTML='<a id="gRight" onclick="NextPrev(0,'+maximum+'); return false;" href="#">Następne</a>';
		}
		else
		{
			ix = parseInt(index)+1;
			document.getElementById("rightButton").innerHTML='<a id="gRight" onclick="NextPrev('+ix+','+maximum+'); return false;" href="#">Następne</a>';
		}
	
		if(index == 0)
		{
			document.getElementById("leftButton").innerHTML='<a id="gLeft" onclick="NextPrev('+maximum+','+maximum+'); return false;" href="#">Poprzednie</a>';
		}
		else
		{
			ix= parseInt(index)-1;
			document.getElementById("leftButton").innerHTML='<a id="gLeft" onclick="NextPrev('+ix+','+maximum+'); return false;" href="#">Poprzednie</a>';
		}
	
	}
}

function popup(url, nr, width, height) 
{
        var Win = window.open(url, nr,'width=' + width + ',height=' + height + ',resizable=0,scrollbars=no,menubar=no,left=50,top=100' );
}




function sendRezervation(elm){
getPageSize();


 advAJAX.submit
 (
	document.getElementById(elm), 
	{
		
		onInitialization : function(obj)
		{
			document.getElementById("preloader").style.display="block";
			document.getElementById("preloader").style.width=arrayPageSize[0]+'px'
			document.getElementById("preloader").style.height=arrayPageSize[1]+'px';
			document.getElementById("preloader").innerHTML='<img style="top:50%; left:50%; position:absolute;background-color:#000000;"  src="/images/ajax-loader.gif" />';
		},
		onComplete : function()
		{

		},

		onSuccess : function(obj) 
		{ 
			document.getElementById("preloader").style.display = "none";
			// jesli ni bedzie zadnego alertu czyli wszystk Ědz?okej
			//alert(obj.responseText);
			document.getElementById("captchaImgRezerv").src='/captchaDisplay.php?data='+Math.round(1000*Math.random());
			//obj.disableForm=false;
			var word=obj.responseText.split("|")
			if(word[1]==1)
			{
				alert(word[0]);
				obj.disableForm=false;
			}
			else
			{
				alert(obj.responseText)
			}

		}
		
	}
 );
}

