function sprawdz_pl(lang)
	{
	var poprawne = true;
	for (i = 1; i <= 7; i++)
	{
		field = document.getElementById("data_urodzenia_"+i);
		if (field.value == "DD/MM/RR")
			{ field.value = ""; }
		else if (field.value != "")
			{
			var reg = /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/;
			if (!reg.test(field.value))
				{ poprawne = false; }
			}
	}
	if (poprawne)
		{ poprawne = sprawdz_daty_campingow_pl(lang);}
	else
		{
		alert("Daty urodzenia muszą być w formacie DD/MM/RR!");
		}
	return poprawne;
	}


function sprawdz_daty_campingow_pl(lang)
	{
	var poprawne = true;
	for (i = 1; i <= 1; i++)
		{
		field = document.getElementById("dzien_przyjazdu_na_camping_"+i);
		if (field.value == "DD/MM/RR")
			{ field.value = ""; }
		else if (field.value != "")
			{
			var reg = /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/;
			if (!reg.test(field.value))
				{ poprawne = false; }
			}
		field = document.getElementById("dzien_wyjazdu_z_campingu_"+i);
		if (field.value == "DD/MM/RR")
			{ field.value = ""; }
		else if (field.value != "")
			{
			var reg = /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/;
			if (!reg.test(field.value))
				{ poprawne = false; }
			}
		}
	if (poprawne)
		{ poprawne = sprawdz_last_pl(lang); }
	else
		{alert("Daty przyjazdu i wyjazdu muszą być w formacie DD/MM/RR!");}
	return poprawne;
}


function sprawdz_last_pl(lang)
	{
	if (document.requestHoliday.request_captcha.value == '' ){

		if (lang=='pl')	alert('Aby zamówić wakacje musisz wpisać tekst z obrazka.');
		if (lang=='sk') alert('Aby bola objednávka prijatá musíte prepísať text z obrázka');
	
		return false; 
	}
		
	if ((document.requestHoliday.akceptacja.checked) && (document.requestHoliday.warunki.checked))
		{	var requestHoliday= document.getElementById('requestHoliday');
			requestHoliday.submit(); }
	else
		if (lang=='pl')	alert('Aby zamówić wakacje na sezon 2008,\nmusisz wyrazić zgodę na przetwarzanie danych osobowych\ni potwierdzić znajomość regulaminu rezerwacji.');
		if (lang=='sk') alert('1Aby si bolo možné rezervovať dovolenku v roku 2008, potrebujeme od Vás povolenie na spracovanie Vašich osobných údajov a potvrdenie, že ste oboznámený s našimi rezervačnými podmienkami.');
		if (lang=='cz')	alert('Jestliže by jste si rádi objednali dovolenou v sezone 2008, musíte souhlasit se zpracováním vašich osobních údajů a musíte potvrdit, že poznáte podmínky rezervace.');
		return false;
	}
	




function sprawdz(lang)
	{
	if (document.requestHoliday.request_captcha.value == '' ){

		if (lang=='pl')	alert('Aby zamówić wakacje musisz wpisać tekst z obrazka.');
		if (lang=='sk') alert('Aby bola objednávka prijatá musíte prepísať text z obrázka');
	
		return false; 
	}
		
	if ((document.requestHoliday.akceptacja.checked) && (document.requestHoliday.warunki.checked))
		{ }
	else {
		if (lang=='pl')	alert('Aby zamówić wakacje na sezon 2008,\nmusisz wyrazić zgodę na przetwarzanie danych osobowych\ni potwierdzić znajomość regulaminu rezerwacji.');
		if (lang=='sk') alert('Aby si bolo možné rezervovať dovolenku v roku 2008, potrebujeme od Vás povolenie na spracovanie Vašich osobných údajov a potvrdenie, že ste oboznámený s našimi rezervačnými podmienkami.');
		if (lang=='cz')	alert('Jestliže by jste si rádi objednali dovolenou v sezone 2008, musíte souhlasit se zpracováním vašich osobních údajů a musíte potvrdit, že poznáte podmínky rezervace.');
		return false;
	}
}

function sprawdz_daty_urodzenia(lang)
	{
	var poprawne = true;
	for (i = 1; i <= 7; i++)
	{
		field = document.getElementById("data_urodzenia_"+i);
		if (field.value == "DD/MM/RR")
			{ field.value = ""; }
		else if (field.value != "")
			{
			var reg = /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/;
			if (!reg.test(field.value))
				{ poprawne = false; }
			}
	}
	if (poprawne)
		{ przelacz(1, 2);}
	else
		{
			if (lang=='pl') alert("Daty urodzenia muszą być w formacie DD/MM/RR!");
			if (lang=='sk') alert("Dátum narodenia musí byť vo formáte DD/MM/RR!");
			if (lang=='cz') alert("Datum narození musí být ve tvaru  DD/MM/RR!");
		}
	}

function sprawdz_daty_campingow(lang)
	{
	var poprawne = true;
	for (i = 1; i <= 5; i++)
		{
		field = document.getElementById("dzien_przyjazdu_na_camping_"+i);
		if (field.value == "DD/MM/RR")
			{ field.value = ""; }
		else if (field.value != "")
			{
			var reg = /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/;
			if (!reg.test(field.value))
				{ poprawne = false; }
			}
		field = document.getElementById("dzien_wyjazdu_z_campingu_"+i);
		if (field.value == "DD/MM/RR")
			{ field.value = ""; }
		else if (field.value != "")
			{
			var reg = /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/;
			if (!reg.test(field.value))
				{ poprawne = false; }
			}
		}
	if (poprawne)
		{ przelacz(2, 3); }
	else
		{
		if (lang=='pl') alert("Daty przyjazdu i wyjazdu muszą być w formacie DD/MM/RR!");
		if (lang=='sk') alert("Dátum príchodu a odchodu musí byť vo formáte DD/MM/RR!");
		if (lang=='cz') alert("Datum příjezdu a datum odjezdu musí být ve tvaru  DD/MM/RR!");
		}
	}

function przelacz(krok1, krok2)
	{
				
	prev = document.getElementById('krok'+krok1);
	prev.className = 'hidden';
	next = document.getElementById('krok'+krok2);
	next.className = 'visible';
	}

function dd1()
	{
	if (document.requestBrochure.skad_wie.value=="inne")
		{
		document.requestBrochure.skad_wie_opis.disabled = false;
		document.requestBrochure.skad_wie_opis.style.bacgroundColor="";
		}
	else
		{
		document.requestBrochure.skad_wie_opis.value    = "";
		document.requestBrochure.skad_wie_opis.disabled = true;
		document.requestBrochure.skad_wie_opis.style.bacgroundColor="silver";
		}
	}

function dd()
	{
	if (document.getElementById("skad_wie").value == "inne")
		{ document.getElementById("inne").style.visibility = "visible"; }
	else
		{ document.getElementById("inne").style.visibility = "hidden"; }
	}

function checkBrochure(lang)
	{
	var formularz = document.getElementById("requestBrochure");
	var fields = formularz.getElementsByTagName("INPUT");
	var ok = true;
	var info = "";
	for (i = 0; i < fields.length; i++)
		{
		var pole = fields[i];
		if ((pole.type == "text") && (pole.name != "skad_wie_opis"))
			{
			if (pole.value == "")
				{
				ok = false;
				if (lang=='pl') info = "Musisz wypełnić wszystkie pola.";
				if (lang=='sk') info = "Musíte vyplniť všetky políčka.";
				if (lang=='cz') info = "Musíte vyplnit všechny  políčka.";
				
				}
			}
		else
			if (pole.type == "checkbox")
				{
				if (ok)
				if (!pole.checked)
					{
					ok = false;
					if (lang=='pl') info = "Aby zamówić bezpłatny katalog ofert wakacyjnych Eurocamp 2008\nmusisz wyrazić zgodę na przetwarzanie danych osobowych.";
					if (lang=='sk') info = "K objednaniu gratis Eurocamp katalógu, musite povoliť spracovanie Vašich osobnych údajov";
					if (lang=='cz') info = "Jestliže by jste si rádi objednali katalog na rok 2008, musíte souhlasit se zpracováním svých osobních údajů.";
					}
				}
		}
	if(jQuery("#wojewodztwo").val() == '' || jQuery("#skad_wie").val() == '')
	{
		ok = false;
		if (lang=='pl') info = "Musisz wypełnić wszystkie pola.";
		if (lang=='sk') info = "Musíte vyplniť všetky políčka.";
		if (lang=='cz') info = "Musíte vyplnit všechny  políčka.";
	}
	if (info) window.alert(info);
	return ok;
	}

//zmiana zdjęć
var currentPhoto = 1;
function photo(action)
	{
	toClose = currentPhoto;
	if(action == 'next')
		{
		if(currentPhoto < 5) { currentPhoto++;}
		else { currentPhoto = 1;}
		}
	else if(action == 'prev')
		{
		if(currentPhoto > 1) { currentPhoto--;}
		else { currentPhoto = 5;}
		}
	//alert('zamknąć ' + toClose + ', otworzyć ' + currentPhoto);
	document.getElementById('camp_photo_' + currentPhoto).className = 'block';
	document.getElementById('camp_photo_' + toClose).className = 'none';
	}


function photo_pl(action)
	{
	toClose = currentPhoto;
	if(action == 'next')
		{
		if(currentPhoto < 5) { currentPhoto++;}
		else { currentPhoto = 1;}
		}
	else if(action == 'prev')
		{
		if(currentPhoto > 1) { currentPhoto--;}
		else { currentPhoto = 5;}
		}
	if (!document.getElementById('camp_photo_' + currentPhoto)) currentPhoto=1;
	//alert('zamknąć ' + toClose + ', otworzyć ' + currentPhoto);
	var check= document.getElementById('camp_photo_' + currentPhoto);
	if (check !=null){ 
	var divz1= jQuery('#camp_photo_' + toClose);
	var divz2= jQuery('#camp_photo_' + currentPhoto);
	divz1.css("display","none");
	divz2.fadeIn("slow");}
	}

function photo_acc_pl(action)
	{
	toClose = currentPhoto;
	if(action == 'next')
		{
		if(currentPhoto < 3) { currentPhoto++;}
		else { currentPhoto = 1;}
		}
	else if(action == 'prev')
		{
		if(currentPhoto > 1) { currentPhoto--;}
		else { currentPhoto = 3;}
		}
	//alert('zamknąć ' + toClose + ', otworzyć ' + currentPhoto);
	var check= document.getElementById('camp_photo_' + currentPhoto);
	if (check !=null){ 
	var divz1= jQuery('#camp_photo_' + toClose);
	var divz2= jQuery('#camp_photo_' + currentPhoto);
	divz1.css("display","none");
	divz2.fadeIn("slow");}
	}
//zmiana zakładek
function showTab(nr)
	{
	if(nr != '1') {document.getElementById('rightMap').style.display = 'none';}
	else {document.getElementById('rightMap').style.display = 'block';}
	for(i=1;i<6;i++) //zmienilem z 7 na z bo wylaczylem ostatnia zakaldke JUC
		{
		document.getElementById('tab_' + i).style.display = 'none';
		document.getElementById('topTab' + i).style.backgroundImage = 'url(/images/tab'+i+'_off.gif)';
		}
	document.getElementById('tab_' + nr).style.display = 'block';
	document.getElementById('topTab' + nr).style.backgroundImage = 'url(/images/tab'+nr+'_on.gif)';
	}
	
// to samo ale w wersji pl
function showTab_pl(nr)	{ 
	if(nr != '1') {document.getElementById('rightMap').style.display = 'none';}
	else {document.getElementById('rightMap').style.display = 'block';}
	for(i=1;i<7;i++)
		{
		var tab= jQuery('#tab_' + i);

		tab.hide("slow");
		//document.getElementById('tab_' + i).style.display = 'none';
		document.getElementById('topTab' + i).className = 'img_tops';
		document.getElementById('topTab' + i + '_img_l').src = 'fileadmin/templates/img/tab_left_active.gif';
		document.getElementById('topTab' + i + '_img_r').src = 'fileadmin/templates/img/tab_right_active.gif';
		document.getElementById('topTab' + i + '_p').style.color = 'white';
		}
	var tab2= jQuery('#tab_' + nr);
	tab2.show(1000);
	//document.getElementById('tab_' + nr).style.display = 'block';
	document.getElementById('topTab' + nr).className = 'img_tops_active';
	document.getElementById('topTab' + nr + '_img_l').src = 'fileadmin/templates/img/tab_left.gif';
	document.getElementById('topTab' + nr + '_img_r').src = 'fileadmin/templates/img/tab_right.gif';
	document.getElementById('topTab' + nr + '_p').style.color = '#F8A109';
	}

//zmiana zakładek sunsites
function showSunTab(nr)	{
	var ar = new Array( 'infoMenu', 'udogodnieniaMenu', 'basenyMenu', 'sportMenu', 'atrakcjeMenu', 'opinieMenu' );
	if(nr != '1') {document.getElementById('rightMap').style.display = 'none';}
	else {document.getElementById('rightMap').style.display = 'block';}
	for( i = 1; i <= 6; i++ )
		{
		document.getElementById('tab_' + i).style.display = 'none';
		document.getElementById('topTab' + i).src = '/images/sunsites_'+ar[i-1]+'_blue.gif';
		}
	document.getElementById('tab_' + nr).style.display = 'block';
	document.getElementById('topTab' + nr).src = '/images/sunsites_'+ar[nr-1]+'_pink.gif';
	}

//visual tour w kwaterach
function showVT()
	{
	document.getElementById('accMain').style.display = 'none';
	document.getElementById('accVisual').style.display = 'block';
	}
function showVT_pl()
	{
	document.getElementById('accMain').style.display = 'none';
	document.getElementById('accom_body').style.display = 'none';
	document.getElementById('acc_bottom').style.display = 'none';
	document.getElementById('acc360_banner').style.display = 'none';	
	document.getElementById('accVisual').style.display = 'block';
	}

function createFlash(id,width,height,url)
	{
	document.write('<object id="'+id+'" style="width:'+width+'px; height:'+height+'px;" data="'+url+'" type="application/x-shockwave-flash">');
	document.write('	<param name="movie" value="'+url+'">');
	document.write('	<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer">');
	document.write('	<param name="wmode" value="transparent">');
	document.write('	<param name="quality" value="high">');
	document.write('	<param name="bgcolor" value="#ffffff">');
	document.write('	<param name="scale" value="noscale">');
	document.write('	<param name="menu" value="false">');
	document.write('</object>');
	}

function createFlashMain(id,width,height,url)
	{
	document.write('<object id="'+id+'" style="width:'+width+'px; height:'+height+'px; margin:10px;" data="'+url+'?clickTag=eurocamp,specjalne.xml" type="application/x-shockwave-flash">');
	document.write('	<param name="movie" value="'+url+'?clickTag=eurocamp,specjalne.xml">');
	document.write('	<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer">');
	/*document.write('	<param name="wmode" value="transparent">');*/
	document.write('	<param name="quality" value="high">');
	document.write('	<param name="bgcolor" value="#ffffff">');
	document.write('	<param name="scale" value="noscale">');
	document.write('	<param name="menu" value="false">');
	document.write('</object>');
	}

function flashObject(show,all)
	{
	all = all+1;
	for(i=1; i<all; i++)
		{
		document.getElementById('flashObject_' +i).style.display = 'none';
		document.getElementById('href_' +i).style.fontWeight = 'normal';
		document.getElementById('href_' +i).style.textDecoration = 'underline';
		}
	document.getElementById('flashObject_' +show).style.display = 'block';
	document.getElementById('href_' +show).style.fontWeight = 'bold';
	document.getElementById('href_' +show).style.textDecoration = 'none';
	}
	
function flashObject_pl(show,all)
	{
	all = all+1;
	for(i=1; i<all; i++)
		{
		document.getElementById('flashObject_' +i).style.display = 'none';
		document.getElementById('flash_mask_' +i).style.display = 'none';
		
		
		document.getElementById('href_' +i).style.backgroundColor = 'white';
		document.getElementById('href_' +i).style.height = '25px';
		document.getElementById('href_' +i).style.margin = '10px 0 0 0';
		document.getElementById('href_img_left_' +i).src = 'images/pl/360_top_left.gif';
		document.getElementById('href_img_right_' +i).src = 'images/pl/360_top_right.gif';
		}
	document.getElementById('flashObject_' +show).style.display = 'block';
	document.getElementById('flash_mask_' +show).style.display = 'block';
	document.getElementById('href_' +show).style.fontWeight = 'bold';
	document.getElementById('href_' +show).style.backgroundColor = '#e6edf3';
	document.getElementById('href_' +show).style.textDecoration = 'none';
	document.getElementById('href_' +show).style.height = '35px';
	document.getElementById('href_' +show).style.margin = '0px';
	document.getElementById('href_img_left_' +show).src = 'images/pl/360_top_left_active.gif';
	document.getElementById('href_img_right_' +show).src = 'images/pl/360_top_right_active.gif';
	}
	


function show_newsletter_alert(){
		if (newsletter_alert !=''){
			alert(newsletter_alert);
		}
	}

function addme()
{
	
	if (validateEmail() ==true ){												
	document.forms[ 'special_ofert_form' ].submit();						
	}												
}
					
function validateEmail(){
	
	validMail=/^[a-zA-Z0-9._-]+\@([a-zA-Z0-9_-]+\.){1,}[\w]{1,5}$/;					
	var blad ='';
	email = document.getElementById('email');
	
	if (email.value == '')
	{						
		blad+='\n '+'Brak adresu email';		
	}
	
	if (email.value != '' && email.value.search(validMail) == -1){
		blad+='\n '+ 'Niepoprawny format adresu email';
	}
	 if (blad !=''){
	 		alert(blad);
	 		return false;
	 }						 
	 return true;
}

function price()
	{
	var when= document.getElementById('when_id');
	var time= when.options[when.selectedIndex].value;
	var what= document.getElementById('what_id');
	var locum= what.options[what.selectedIndex].value;
	var result= document.getElementById('price_result');
	var country_initials= document.getElementById('country_initials');
	var price_n= document.getElementById(time+'_n_'+country_initials.value);
	var price= document.getElementById(time+'_'+country_initials.value);
	var price_add= document.getElementById(time+'_'+locum);
	
	/*alert(time);
	
	alert(country_initials.value);
	
	alert(price.innerHTML);	*/
	document.getElementById('tab_1_body_bot').style.height='270px';
	document.getElementById('price_box').style.display='block';
	
	if (locum=='n'){
	result.innerHTML = price_n.innerHTML+' EURO';
	}
	if (locum=='2sc'){
	result.innerHTML = price.innerHTML+' EURO';
	}
	else{
	result.innerHTML = (parseInt(price.innerHTML)+parseInt(price_add.innerHTML))+' EURO';	
	}
	
	//alert(result.innerHtml);
	
	}
	
function formHolidayMembers(row, btn){
	var lp= document.getElementById(row);
	var add= document.getElementById(btn);
	var names = String(add.id);
	var names_nr = names.substr(names.indexOf('_')+1);
	var names_title = names.substr(0,names.indexOf('_'));
	var nmbr= parseInt(names_nr)+1;
	var add_nxt= document.getElementById(names_title+'_'+nmbr);
	lp.style.display='block';
	add.style.display='none';
	add_nxt.style.display='block';	
}

function effect(){
var schedule = { d1:"2009-1-1/2009-5-22", d2:"2009-5-23/2009-5-29", d3:"2009-5-30/2009-6-5", d4:"2009-6-6/2009-6-12", d5:"2009-6-13/2009-6-19", d6:"2009-6-20/2009-6-26", d7:"2009-6-27/2009-7-3", d8:"2009-7-4/2009-7-10", d9:"2009-7-11/2009-7-17", d10:"2009-7-18/2009-7-24", d11:"2009-7-25/2009-7-31", d12:"2009-8-1/2009-8-7", d13:"2009-8-8/2009-8-14", d14:"2009-8-15/2009-8-21", d15:"2009-8-22/2009-8-28", d16:"2009-8-29/2009-9-4", d17:"2009-9-5/2009-9-11", d18:"2009-9-12/2009-12-31"};
var day= jQuery('#day option:selected');   
var month= jQuery('#month option:selected');  
var year= jQuery('#year option:selected');  
var nights= jQuery('#nights option:selected');  
var locum= jQuery('#what_id option:selected');  
var country_initials= jQuery('#country_initials');
var arr_date = new Date(year.val(), month.val()-1, day.val());
var leave_date = new Date(arr_date.getTime() + nights.val()*24*60*60*1000);
var tab1= jQuery('#tab_1_body_bot');
tab1.css("height","350px");
var price_box=jQuery('#price_box');
price_box.css("display","none");
price_box.slideDown("slow");
 
var counter= 0;
var price_result=0;
	jQuery.each(schedule, function(i, val) {
	//funcja zwraca tablice dwuwymiarowa o konstukcji data przyjazdu (yyyy,mm,dd) i data wyjazdu tak samo
	var cutted_date = cut_date(val);
	var val_1 = new Date(cutted_date[0][0], (cutted_date[0][1])-1,cutted_date[0][2]);
	var val_2 = new Date(cutted_date[1][0], (cutted_date[1][1])-1, cutted_date[1][2]);
	var price_n= jQuery("#"+i+'_n_'+country_initials.val());
	var price= jQuery("#"+i+'_'+country_initials.val());
	var price_add= jQuery("#"+i+'_'+locum.val());
					 
		if ((val_2 >= arr_date)  && (leave_date >= val_1)){ 
			
			if ((arr_date >= val_1)  && (val_2 >= leave_date)){
				// przybycie i odjazd w jednym okresie
				 
				if (locum.val()=='n'){
					jQuery("#price_result").text(parseInt(nights.val())*(parseInt(price_n.html())));
				}
				else if (locum.val()=='2sc'){
					jQuery("#price_result").text(parseInt(nights.val())* (parseInt(price.html())));
				}
				else{
					jQuery("#price_result").text(parseInt(nights.val())* (parseInt(price.html())+parseInt(price_add.html())) );
					//alert(i+'-----'+val+'----'+next(i));
					}
				
				//alert(arr_date+'        '+leave_date+'        '+val_1+'        '+val_2);
				//alert (nights.val()+'       '+i+'       '+price.html());
				return;
			}else if (arr_date >val_1){
				
				
				if (i == 'd18'){  // do konca ostatniego okresu	d18			 
					if (locum.val()=='n'){
						
						price_result=parseInt(nights.val())*(parseInt(price_n.html()));
					}else if (locum.val()=='2sc'){
							
						price_result=parseInt(nights.val())* (parseInt(price.html()));
					}else{
						price_result=parseInt(nights.val())* (parseInt(price.html())+parseInt(price_add.html()));
						//alert(i+'-----'+val+'----'+next(i));
					}
					
					jQuery("#price_result").text(price_result);
					//alert(arr_date+'        '+leave_date+'        '+val_1+'        '+val_2);
					//alert (nights.val()+'       '+i+'       '+price.html());
					return;
				}else{	// pierwszy okres przyjazdu
					
					var days_on_camping = val_2.getTime() - arr_date.getTime();
					days_on_camping = (days_on_camping /24/60/60/1000)+1;
					
					if (locum.val()=='n'){
						
						counter +=days_on_camping*(parseInt(price_n.html()));
					}else if (locum.val()=='2sc'){
							
						counter += days_on_camping * (parseInt(price.html()));
					}else{
					
						counter += days_on_camping * (parseInt(price.html())+parseInt(price_add.html())) ;
					}
					
					//alert(arr_date+'        '+leave_date+'        '+val_1+'        '+val_2);
					//alert (days_on_camping+'       '+counter+'       '+i+'       '+price.html()+'  początkowy okres');					
				}
			}else if ( val_2 > leave_date){
				if (i == 'd1'){  // do konca pierwszego okresu d1
					if (locum.val()=='n'){
					
						price_result = parseInt(nights.val())* parseInt(price_n.html());
						//price_result2 = price_result;
						//alert(price_result2);
					}else if (locum.val()=='2sc'){
					
						price_result= parseInt(nights.val())* (parseInt(price.html()));
					}else{
					
						price_result= parseInt(nights.val())* (parseInt(price.html())+parseInt(price_add.html()));
							//alert(i+'-----'+val+'----'+next(i));
					}
					
					//alert(price_result2);
					jQuery("#price_result").text(price_result);
					//alert(arr_date+'        '+leave_date+'        '+val_1+'        '+val_2);
					//alert (nights.val()+'       '+i+'       '+price.html());
					return;
				}else{// koniec - ostatni okres przyjazdu
					var days_on_camping = leave_date.getTime() - val_1.getTime();
					days_on_camping = days_on_camping /24/60/60/1000;
					 
					if (locum.val()=='n'){
						counter +=days_on_camping*(parseInt(price_n.html()));
					}
					else if (locum.val()=='2sc'){
							//alert(counter);
						counter += (days_on_camping * (parseInt(price.html())));
							//alert(counter);
					}else{
						counter += days_on_camping * (parseInt(price.html())+parseInt(price_add.html())) ;
					}
					
					jQuery("#price_result").text(counter);
					//alert(arr_date+'        '+leave_date+'        '+val_1+'        '+val_2);
					//alert (days_on_camping+'       '+counter+'       '+i+'       '+price.html()+'      last');	
					return;
				}
			}else if ((val_1 > arr_date )  && (leave_date > val_2)){ 			
					// środek okesu - pomiędzy dwoma
					
					var days_on_camping = val_2.getTime() - val_1.getTime();
					days_on_camping = (days_on_camping /24/60/60/1000)+1;
					 //alert(price_n);
					if (locum.val()=='n'){
						counter +=days_on_camping*(parseInt(price_n.html()));
					}else if (locum.val()=='2sc'){
						counter += days_on_camping * (parseInt(price.html()));
					}else{
						counter += days_on_camping * (parseInt(price.html())+parseInt(price_add.html())) ;
					}
					
					//alert(arr_date+'        '+leave_date+'        '+val_1+'        '+val_2);
					//alert (days_on_camping+'       '+counter+'       '+i+'       '+price.html());	
					
			}else if ( val_2 >= leave_date ){// koniec - ostatni okres - gdy leave== val_2
					var days_on_camping = leave_date.getTime() - val_1.getTime();
					days_on_camping = days_on_camping /24/60/60/1000;
					 
					if (locum.val()=='n'){
						counter +=days_on_camping*(parseInt(price_n.html()));
					}else if (locum.val()=='2sc'){
						//alert(counter);
						counter += (days_on_camping * (parseInt(price.html())));
						//alert(counter);
					}else{
						counter += days_on_camping * (parseInt(price.html())+parseInt(price_add.html())) ;
					}
					
					jQuery("#price_result").text(counter);
					alert(arr_date+'        '+leave_date+'        '+val_1+'        '+val_2);
					alert (days_on_camping+'       '+counter+'       '+i+'       '+price.html()+'      last');	
					return;
			}
			/*else{
				alert(arr_date+'        '+leave_date+'        '+val_1+'        '+val_2);
				alert (days_on_camping+'       '+counter+'       '+i+'       '+price.html()+'      last');	
			}*/								
		}
	});
}

function cut_date(date) {
	var dates = new String(date);
	var splitter = dates.indexOf("/");
	var val_1 = dates.substr(0,splitter);
	var val_2 = dates.substr(splitter+1,dates.length);

	var f_val_1_splitter = val_1.indexOf("-");
	var s_val_1_splitter = val_1.lastIndexOf("-");
	var val_1_table = new Array(3);
	val_1_table[0]= val_1.substr(0,f_val_1_splitter);
	val_1_table[1] = val_1.substr(f_val_1_splitter+1,f_val_1_splitter-3);
	val_1_table[2] = val_1.substr(s_val_1_splitter+1,val_1.length);
    
	var f_val_2_splitter = val_2.indexOf("-");
	var s_val_2_splitter = val_2.lastIndexOf("-");
	var val_2_table = new Array(3);
	val_2_table[0]= val_2.substr(0,f_val_2_splitter);
	val_2_table[1] = val_2.substr(f_val_2_splitter+1,f_val_2_splitter-3);
	val_2_table[2] = val_2.substr(s_val_2_splitter+1,val_2.length);
	
	if (val_2_table[1]== 1) { val_2_table[1]= 12;}
	
	var val_dates = new Array(2);
	val_dates[0] = val_1_table;
	val_dates[1] = val_2_table;

	return val_dates;
				      
}

function watch_film(div1, div2) {
	var divz1= jQuery('#'+div1);
	var divz2= jQuery('#'+div2);
	var btn1= jQuery('#'+div1+'_btn');
	var btn2= jQuery('#'+div2+'_btn');
	divz2.css("display","none");
	divz1.fadeIn("slow");
	btn1.fadeIn("slow");
	btn2.fadeOut("slow");	
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var 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 eraseCookie(name) {
	createCookie(name,"",-1);
}
function zamknijPopUp() {
	document.getElementById('popup').style.display='none';
}
