// JavaScript Document

	$(function()
		{
		
			$('.input_search_date').datePicker();
		
		});

	move = Array(0,0);

	UTF8 = {
	encode: function(s){
		for(var c, i = -1, l = (s = s.split("")).length, o = String.fromCharCode; ++i < l;
			s[i] = (c = s[i].charCodeAt(0)) >= 127 ? o(0xc0 | (c >>> 6)) + o(0x80 | (c & 0x3f)) : s[i]
		);
		return s.join("");
	},
	decode: function(s){
		for(var a, b, i = -1, l = (s = s.split("")).length, o = String.fromCharCode, c = "charCodeAt"; ++i < l;
			((a = s[i][c](0)) & 0x80) &&
			(s[i] = (a & 0xfc) == 0xc0 && ((b = s[i + 1][c](0)) & 0xc0) == 0x80 ?
			o(((a & 0x03) << 6) + (b & 0x3f)) : o(128), s[++i] = "")
		);
		return s.join("");
	}
	};
	
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.fadeInOut = true;
	hs.allowSizeReduction = true;
	hs.dimmingOpacity = 0.8;
	hs.outlineType = 'rounded-white';
	hs.captionEval = 'this.thumb.alt';
	hs.marginBottom = 105 // make room for the thumbstrip and the controls
	hs.numberPosition = 'caption';
	hs.slideshows = [];
 
	// Add the slideshow providing the controlbar and the thumbstrip
	hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		overlayOptions: {
			className: 'text-controls',
			position: 'bottom center',
			relativeTo: 'viewport',
			offsetY: -60
 
		},
		thumbstrip: {
			position: 'bottom center',
			mode: 'horizontal',
			relativeTo: 'viewport'
		}
	});
			
	function visible(id) {
		document.getElementById(id).style.visibility='visible';	
	}
				
	function hidden(id){
		document.getElementById(id).style.visibility='hidden';			
	}
	
	
	function show(id)
		{
		document.getElementById(id).style.display='block';	
		}
		
	function hide(id)
		{
		document.getElementById(id).style.display='none';			
		}
		
	function show_hide(id)
		{			
		if (document.getElementById(id).style.display == 'block')
			{
			document.getElementById(id).style.display='none';	
			}
		else
			{
			document.getElementById(id).style.display ='block';	
			}
		}
		
	function form_submit(id)
		{
		document.forms[id].submit();
		}
			
	function move_down(page,id)
 		{
		move_max = document.getElementById(page + '_scrool').offsetHeight - document.getElementById(page).offsetHeight + 20;	
		
		if ((stopbit == 0) && (Math.abs(move[id]) < move_max))
			{		
			move[id] -= 1;	
		
			document.getElementById(page + '_scrool').style.marginTop = move[id] + 'px';
						
			window.setTimeout("move_down('"+ page +"',"+ id +");",1);
			}
		}
		
	function move_up(page,id)
 		{		
		if ((stopbit == 0) && (Math.abs(move[id]) > 0))
			{
			move[id] += 1;	
		
			document.getElementById(page + '_scrool').style.marginTop = move[id] + 'px';
			
			window.setTimeout("move_up('"+ page +"',"+ id +");",1);
			}
		}
		
	function calendar_reset(id)
		{
		document.getElementById('date_from_span').style.textDecoration = 'none';
		document.getElementById('date_to_span').style.textDecoration = 'none';
		document.getElementById('date_db_from').value = '';
		document.getElementById('date_db_to').value = '';
		document.getElementById('calendar_point').value = 'from';
		document.getElementById('date_from').value = '';
		document.getElementById('date_to').value = '';
		hide('calendar_dates');
		
		var xmlhttp=false;
				
		if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
		
		else if (window.ActiveXObject)
			{ // if IE
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
				} 
			catch (e)
				{
				try
					{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
					}
				catch (e)
					  {
					  }
				}
			}
			
		values =  'date_from=' + document.getElementById('date_db_from').value +
				  '&date_to=' + document.getElementById('date_db_to').value +				  
				  '&id=' + id;
				 
			
		xmlhttp.open('POST',"/include_pages/calendar.php",false);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=Windows-1250');	
				 
		xmlhttp.setRequestHeader("Content-length", values.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(values);		
		xmlhttp.close;
		
		document.getElementById('calendar').innerHTML = xmlhttp.responseText;
		}	
			
	function calendar_book_point(id)
		{
		document.getElementById('date_from_span').style.textDecoration = 'none';
		document.getElementById('date_to_span').style.textDecoration = 'none';		
		document.getElementById('date_' + id + '_span').style.textDecoration = 'underline';
		document.getElementById('calendar_point').value = id;
		}
	
	function calendar_book(date,id)
		{
		if (document.getElementById('calendar_point').value == 'to')
			{
			if (date > document.getElementById('date_db_from').value)
				{
				document.getElementById('date_db_' + document.getElementById('calendar_point').value).value = date;
				document.getElementById('date_' + document.getElementById('calendar_point').value).value = date.substr(8,2) + '.' + date.substr(5,2) + '.' + date.substr(0,4);
				}
			}
		else
			{
			if (date < document.getElementById('date_db_to').value || document.getElementById('date_db_to').value == '')
				{
				document.getElementById('date_db_' + document.getElementById('calendar_point').value).value = date;	
				document.getElementById('date_' + document.getElementById('calendar_point').value).value = date.substr(8,2) + '.' + date.substr(5,2) + '.' + date.substr(0,4);
				}
			}
			
		if (document.getElementById('date_db_to').value == '')
			{
			document.getElementById('date_from_span').style.textDecoration = 'none';	
			document.getElementById('date_to_span').style.textDecoration = 'underline';	
			document.getElementById('calendar_point').value = 'to';
			}
			
		var xmlhttp=false;
				
		if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
		
		else if (window.ActiveXObject)
			{ // if IE
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
				} 
			catch (e)
				{
				try
					{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
					}
				catch (e)
					  {
					  }
				}
			}
			
		values =  'date_from=' + document.getElementById('date_db_from').value +
				  '&date_to=' + document.getElementById('date_db_to').value +				  
				  '&id=' + id;
				 
			
		xmlhttp.open('POST',"/include_pages/calculate-price.php",false);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=Windows-1250');	
				 
		xmlhttp.setRequestHeader("Content-length", values.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(values);		
		xmlhttp.close;
		
		document.getElementById('date_price').innerHTML = xmlhttp.responseText;	
		
		var xmlhttp=false;
				
		if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
		
		else if (window.ActiveXObject)
			{ // if IE
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
				} 
			catch (e)
				{
				try
					{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
					}
				catch (e)
					  {
					  }
				}
			}
			
		values =  'date_from=' + document.getElementById('date_db_from').value +
				  '&date_to=' + document.getElementById('date_db_to').value +				  
				  '&id=' + id;
				 
			
		xmlhttp.open('POST',"/include_pages/calendar.php",false);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=Windows-1250');	
				 
		xmlhttp.setRequestHeader("Content-length", values.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(values);		
		xmlhttp.close;
		
		document.getElementById('calendar').innerHTML = xmlhttp.responseText;
		
		show('calendar_dates');
		
		//document.getElementById('test').namespaceURI = document.getElementById('date_db_' + document.getElementById('calendar_point').value).value;
		}
		
	function booking_list(lang,id)
		{			
		var xmlhttp=false;
				
		if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
		
		else if (window.ActiveXObject)
			{ // if IE
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
				} 
			catch (e)
				{
				try
					{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
					}
				catch (e)
					  {
					  }
				}
			}
			
		values =  'arrival_date=' + document.getElementById('arrival_date').value +
				  '&departure_date=' + document.getElementById('departure_date').value +
				  '&persons=' + document.getElementById('persons').value +
				  '&persons_extra=' + document.getElementById('persons_extra').value +
				  '&id=' + id;
				 
			
		xmlhttp.open('POST',"/include_pages/booking-list.php",false);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=Windows-1250');	
				 
		xmlhttp.setRequestHeader("Content-length", values.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(values);		
		xmlhttp.close;
		
		document.getElementById('booking_list_prices').innerHTML = xmlhttp.responseText;
		
		if (document.getElementById('error').value == 1)
			{
			hide("booking_step_2");
			}
		else
			{
			show("booking_step_2");
			}
		}	
		
	function send_to_friend(lang,id)
		{			
		var xmlhttp=false;
				
		if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
		
		else if (window.ActiveXObject)
			{ // if IE
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
				} 
			catch (e)
				{
				try
					{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
					}
				catch (e)
					  {
					  }
				}
			}
			
		values =  'from_name=' + document.getElementById('from_name').value +
				  '&from_email=' + document.getElementById('from_email').value +
				  '&to_name=' + document.getElementById('to_name').value +
				  '&to_email=' + document.getElementById('to_email').value +
				  '&lang=' + lang +
				  '&id=' + id;
				 
			
		xmlhttp.open('POST',"/include_pages/send_to_friend.php",false);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=Windows-1250');	
				 
		xmlhttp.setRequestHeader("Content-length", values.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(values);		
		xmlhttp.close;
		
		document.getElementById('send_to_friend').innerHTML = xmlhttp.responseText;			
		}
		
	function call(lang)
		{
		var error = new Array;	
		
		if (document.getElementById('call_name').value == '')
			{
			error.push(' \n\t - enter your name');
			}
						
		if (document.getElementById('call_phone').value == '')
			{
			error.push(' \n\t - enter your phone');
			}
			
		if (document.getElementById('call_country').value == '')
			{
			error.push(' \n\t - enter your country');
			}
			
		if (document.getElementById('call_time').value == '')
			{
			error.push(' \n\t - enter your local time');
			}	

		if (error.length != 0)
			{
			alert('Please correct these errors: \n' + error);				
			}
		else
			{
			var xmlhttp=false;
					
			if (window.XMLHttpRequest) // if Mozilla, Safari etc
			xmlhttp = new XMLHttpRequest()
			
			else if (window.ActiveXObject)
				{ // if IE
				try {
					xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
					} 
				catch (e)
					{
					try
						{
						xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
						}
					catch (e)
						  {
						  }
					}
				}
				
			values =  'name=' + document.getElementById('call_name').value +
					  '&phone=' + document.getElementById('call_phone').value +
					  '&country=' + document.getElementById('call_country').value +
					  '&time=' + document.getElementById('call_time').value +
					  '&lang=' + lang;
					 
				
			xmlhttp.open('POST',"/include_pages/call.php",false);
			xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=Windows-1250');	
					 
			xmlhttp.setRequestHeader("Content-length", values.length);
			xmlhttp.setRequestHeader("Connection", "close");
			xmlhttp.send(values);		
			xmlhttp.close;
			
			document.getElementById('call').innerHTML = xmlhttp.responseText;
			}
		}	
	
	function gallery_detail(lang,order,id,id_detail)
		{
		var xmlhttp=false;
		
		if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
		
		else if (window.ActiveXObject)
			{ // if IE
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
				} 
			catch (e)
				{
				try
					{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
					}
				catch (e)
					  {
					  }
				}
			}
			
		values =  '?order=' + order + 
				  '&lang=' + lang +
				  '&id=' + id +
				  '&id_detail=' + id_detail +	
				  '&set=1';	
			
		xmlhttp.open('GET',"/include_pages/gallery-detail.php" + values,false);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=Windows-1250');	
				 
		xmlhttp.setRequestHeader("Content-length", values.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(values);		
		xmlhttp.close;
		
		document.getElementById('main_middle').innerHTML = xmlhttp.responseText;
		}
		
	function check_form_contact()
	 	{
		var error = new Array;	
		
		if (document.getElementById('name').value == '')
			{
			error.push(' \n\t - enter your name');
			}
			
		if (document.getElementById('email').value == '')
			{
			error.push(' \n\t - enter your e-mail');
			}	
			
		if (document.getElementById('prefixphone').value == '')
			{
			error.push(' \n\t - enter your phone prefix');
			}
			
		if (document.getElementById('phone').value == '')
			{
			error.push(' \n\t - enter your phone');
			}
			
		if (document.getElementById('subject').value == '')
			{
			error.push(' \n\t - enter your subject');
			}
			
		if (document.getElementById('text').value == '')
			{
			error.push(' \n\t - enter your text');
			}	
			
		if (document.getElementById('spam').value == '')
			{
			error.push(' \n\t - enter spam check');
			}			

		if (error.length != 0)
			{
			alert('Please correct these errors: \n' + error);	
			return false;
			}
		else
			{
			return true;
			}
			
		}
		
	function check_form_realestate()
	 	{
		var error = new Array;	
		
		if (document.getElementById('name').value == '')
			{
			error.push(' \n\t - enter your name');
			}
			
		if (document.getElementById('email').value == '')
			{
			error.push(' \n\t - enter your e-mail');
			}	
			
		if (document.getElementById('prefixphone').value == '')
			{
			error.push(' \n\t - enter your phone prefix');
			}
			
		if (document.getElementById('phone').value == '')
			{
			error.push(' \n\t - enter your phone');
			}
			
		if (document.getElementById('text').value == '')
			{
			error.push(' \n\t - enter your text');
			}	
			
		if (document.getElementById('spam').value == '')
			{
			error.push(' \n\t - enter spam check');
			}			

		if (error.length != 0)
			{
			alert('Please correct these errors: \n' + error);	
			return false;
			}
		else
			{
			return true;
			}
			
		}	
		
	function check_form_booking(lang)
	 	{
		var error = new Array;	
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
		
		if (document.getElementById('first_name').value == '')
			{
			error.push(' \n\t - enter your first name');
			}
			
		if (document.getElementById('last_name').value == '')
			{
			error.push(' \n\t - enter your last name');
			}	
			
		if(reg.test(document.getElementById('email').value) == false)	
			{
			error.push(' \n\t - enter your e-mail');
			}	
			
		if (isNaN(parseInt(document.getElementById('phone').value)))
			{
			error.push(' \n\t - enter your phone');
			}
			
		if (document.getElementById('street').value == '')
			{
			error.push(' \n\t - enter your street');
			}
			
		if (document.getElementById('no').value == '')
			{
			error.push(' \n\t - enter your street no');
			}	
			
		if (document.getElementById('city').value == '')
			{
			error.push(' \n\t - enter your city');
			}
			
		if (document.getElementById('zip_code').value == '')
			{
			error.push(' \n\t - enter your ZIP code');
			}
			
		if (document.getElementById('state').value == '')
			{
			error.push(' \n\t - enter your state/provence');
			}
			
		if (document.getElementById('country').value == '')
			{
			error.push(' \n\t - enter your country');
			}				

		if (error.length != 0)
			{
			alert('Please correct these errors: \n' + error);	
			return false;
			}
		else
			{
			return true;
			}
			
		}
		
	function departure_date_f()
		{
		var xmlhttp=false;
		
		if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
		
		else if (window.ActiveXObject)
			{ // if IE
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
				} 
			catch (e)
				{
				try
					{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
					}
				catch (e)
					  {
					  }
				}
			}
			
		values =  '?arrival_date=' + document.getElementById('arrival_datel').value;
			
		xmlhttp.open('GET',"/include_pages/departure_date.php" + values,false);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=Windows-1250');	
				 
		xmlhttp.setRequestHeader("Content-length", values.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(values);		
		xmlhttp.close;
		
		document.getElementById('departure_datel').value = xmlhttp.responseText.substring(3,15);
		}
		
	function departure_date_f2()
		{
		var xmlhttp=false;
		
		if (window.XMLHttpRequest) // if Mozilla, Safari etc
		xmlhttp = new XMLHttpRequest()
		
		else if (window.ActiveXObject)
			{ // if IE
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
				} 
			catch (e)
				{
				try
					{
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
					}
				catch (e)
					  {
					  }
				}
			}
			
		values =  '?arrival_date=' + document.getElementById('arrival_date2').value;
			
		xmlhttp.open('GET',"/include_pages/departure_date.php" + values,false);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=Windows-1250');	
				 
		xmlhttp.setRequestHeader("Content-length", values.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(values);		
		xmlhttp.close;
		
		document.getElementById('departure_date2').value = xmlhttp.responseText.substring(3,15);
		}	
		
	function empty()
		{
		
		}