﻿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 lookAfter(element)
{
	element.className="active";
}
function standBy(element)
{
	element.className="";
}

function obsluga_warstw()
 {
  if (document.layers) return true;
  if (document.all) return false;
  if (document.getElementById) return true;
  return true;
 }

function get_elem(co)
 {
  if (!obsluga_warstw()) return document.all[co];
  else return document.getElementById(co);
 }


function set_pic(gdzie, patch, patchbig ,x, y)
 {
  get_elem(gdzie).src = patch;
	get_elem(gdzie).style.cursor="pointer"
	 get_elem("pop").href = "javascript:popup(\"/popup/pop.php?url="+patchbig+"\", 1,"+x+","+y+")"
	//get_elem(gdzie).setAttribute("onclick","popup(\"/popup/pop.php?url="+patchbig+"\", 1,"+x+","+y+")")
 }
 
function set_txt(gdzie, text)
 {
  get_elem(gdzie).innerHTML = text;
 }
 
function chColor(element)
{
	ahref = get_elem('newsLinki').getElementsByTagName("a");
	for (var i = 0; i < ahref.length; i++)
	{ 

     ahref[i].className=""; 
	}
	element.className="active"; 
	
}


function switchContent(element)
{
	if(obsluga_warstw())
	{
		var myElement = element.nextSibling.nextSibling;
		// zwraca true czyli normaslna przegladarka
			if(myElement.style.display=='none')
			{
				element.className='switchContentButton';
				Effect.SlideDown(myElement)
				
			}
			else
			{
				element.className='switchContentButtonZwin';
				Effect.SlideUp(myElement)
			}
	}
	else
	{
		var myElement = element.nextSibling.nextSibling;
		if(myElement.style.display=='none')
		{
			element.className='switchContentButton';
			Effect.SlideDown(myElement);
		}
		else
		{
			element.className='switchContentButtonZwin';
			Effect.SlideUp(myElement);
		}
	}
	

	
}



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 sendContact(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" />';
			document.getElementById(elm).getElementsByTagName("button")[0].innerHTML = "Sprzawdza Dane";
		},
		onComplete : function()
		{
			document.getElementById(elm).getElementsByTagName("button")[0].innerHTML = "Wyślij";
		},

		onSuccess : function(obj) 
		{ 
		document.getElementById("preloader").style.display = "none";
			disableForm : true;
			// jesli ni bedzie zadnego alertu czyli wszystk Ědz?okej
			//alert(obj.responseText);
			if(obj.responseText!='')
			{
				if(obj.responseText == 'errorCaptcha')
				{
					alert('Wpisz poprawnie Kod z obrazka!!')
					document.getElementById(elm).getElementsByTagName("img")[0].src='/captchaDisplay.php?data='+Math.round(1000*Math.random());
					//document.getElementById(elm).getElementsByTagName("img")[0].src='/dupa';
					
				}
				
				if(obj.responseText == 'errorName')
				{
					alert('Wpisz Imię i Nazwisko!!')
					
				}
				
				if(obj.responseText == 'errorEmail')
				{
					alert('Wpisz adres e-mail!!!')
					
				}
				
				if(obj.responseText == 'noError')
				{
					document.getElementById("preloader").style.display="none";
					obj.disableForm=false;
					alert("Dane zostały wysłane!!\nDziękujemy");
				
				}
			}
			

		}
		
	}
 );
}


function showImgText(element)
{
	if(element.className=="zwin")
	{
		element.className="rozwin";
	}
	else
	{
		element.className="zwin";
	}
	var alldivs=document.getElementById('midFoto').getElementsByTagName("div")
	for (var i=0; i<alldivs.length; i++)
	{

				if(alldivs[i].className=='imgText')
				{
					if(alldivs[i].style.display == 'none')
					{
						//Effect.Appear(alldivs[i], {duration:1.0,to:0.7});	
						alldivs[i].style.display = 'block'
					}
					else
					{
					//	Effect.Fade(alldivs[i], {duration:1.0,from:0.7,to:0});
						alldivs[i].style.display = 'none'
					}
				 
				}
				
	}
	
	//Effect.Appear('OpisFoto');
	
}






function zapiszNewsletter(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" />';
			document.getElementById(elm).getElementsByTagName("button")[0].innerHTML = "Sprzawdza Dane";
		},
		onComplete : function()
		{
			document.getElementById(elm).getElementsByTagName("button")[0].innerHTML = "Zapisz";
		},

		onSuccess : function(obj) 
		{ 
		document.getElementById("preloader").style.display = "none";
			disableForm : true;
			// jesli ni bedzie zadnego alertu czyli wszystk Ědz?okej
			alert(obj.responseText);
			if(obj.responseText!='')
			{
				if(obj.responseText == 'errorCaptcha')
				{
					alert('Wpisz poprawnie Kod z obrazka!!')
					document.getElementById(elm).getElementsByTagName("img")[0].src='/captchaDisplay.php?data='+Math.round(1000*Math.random());
					//document.getElementById(elm).getElementsByTagName("img")[0].src='/dupa';
					
				}
				
				if(obj.responseText == 'errorName')
				{
					alert('Wpisz Imię i Nazwisko!!')
					
				}
				
				if(obj.responseText == 'errorEmail')
				{
					alert('Wpisz adres e-mail!!!')
					
				}
				
				if(obj.responseText == 'noError')
				{
					document.getElementById("preloader").style.display="none";
					obj.disableForm=false;
					alert("Dane zostały wysłane!!\nDziękujemy");
				
				}
			}
			

		}
		
	}
 );
}



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);
			
			//obj.disableForm=false;
			var word=obj.responseText.split("|")
			
			
			switch(word[1])
			{
				default:
					alert(obj.responseText);
				break;
				case "1":
					alert(word[0]);
					obj.disableForm=false;
				break;
				case "2":
					document.getElementById("captchaImgRezerv").src='/captchaDisplay.php?data='+Math.round(1000*Math.random());
				alert(word[0]);
				break;
			}
			
			

		}
		
	}
 );
}