

	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("");
	}
	};
	

			
	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('price_small');    
		hide('price_small2');
        hide('price_small3');  
		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_card()
	 	{
		var error = new Array;	
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
		
		if (document.getElementById('typeofcard').value == '')
			{
			error.push(' \n\t - enter your typeofcard');
			}
			
		if (document.getElementById('cardnumber').value == '')
			{
			error.push(' \n\t - enter your cardnumber');
			}	
			
		if(reg.test(document.getElementById('expiry').value) == '')	
			{
			error.push(' \n\t - enter your expiry');
			}	
			
		if (isNaN(parseInt(document.getElementById('cvc').value)))
			{
			error.push(' \n\t - enter your cvc');
			}
			

		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_date').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_date').value = xmlhttp.responseText.substring(3,15);
		}
	
  	function departure_date_f3()
		{
		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 =  '?checkin=' + document.getElementById('checkin').value;
			
		xmlhttp.open('GET',"/include_pages/departure_date3.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('checkout').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()
		{
		
		}
		
		
			
		function one_digit(number)
		{
       if(number>9)
       {
           number=number.toString();
           return (parseInt(number[0])+parseInt(number[1]));
       }
       else
       {
        return number;
       }
    }
		
    
    function check_cardcode(number)
		{
        var sum=0;
        for (i=0;i<number.length;i++)
        {
              if(i%2==0)
              sum=sum+parseInt(one_digit(2*number[i]));
              else
              sum=sum+parseInt(number[i]);
        }
        if(sum%10==0)
        return true;
        else
        return false;
    
    }
		
		
				function check_card(departure_date)
	 	{
	 	var departure_date_array=departure_date.split('.'); 
	 	 var departure_month = departure_date_array[1].toString();
     var departure_year = departure_date_array[2].toString().substring(2,4);
    var date= new Date();
	 	var month=date.getMonth().toString();
	 	var year=date.getFullYear().toString().substring(2,4);
		var error = new Array;	  
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;  
		var reg2 = /^([0-9]){2}\/([0-9]){2}$/; 
		var size;
    if (document.getElementById('typeofcard').value == "AMEX")
    size=15;
    else
    size=16;
			
			
			
		if (document.getElementById('cardnumber').value == '')
			{
			   error.push(' \n\t - Enter your card number');
			}
      else
      {
      
        if(isNaN(parseInt(document.getElementById('cardnumber').value)))
        {
                error.push(' \n\t - Enter your card number');
        }
        else
        {
               if(document.getElementById('cardnumber').value.length<size)
                { 
                 	error.push(' \n\t - Card number is too short');
                }
                else
                {
                    if(document.getElementById('cardnumber').value.length>size)
                    {
                      	error.push(' \n\t - Card number is too long');
                    }
                    else
                    {
                        if(size==16 && !check_cardcode(document.getElementById('cardnumber').value))
                        {
                               error.push(' \n\t - The card number is not valid');
                        
                        }
                    }
                
                }
        }
      }	
			
		if(reg2.test(document.getElementById('expiry').value) == false)	
			{
			   error.push(' \n\t - Enter your expiry (mm/yy)');
			}	
		   else
      {
                            if((document.getElementById('expiry').value.substring(3,5)<departure_year) || (document.getElementById('expiry').value.substring(0,2)>12))
                            {
                                        error.push(' \n\t - Your card must be valid until the day of your departure.');
                            }
                            else
                            {
                                    if(document.getElementById('expiry').value.substring(3,5)==departure_year && document.getElementById('expiry').value.substring(0,2)<(departure_month))
                                    {
                                        error.push(' \n\t - Your card must be valid until the day of your departure.');
                                      }
                            
                            }
                    
                    
                    
      }
			
		if (isNaN(parseInt(document.getElementById('cvc').value)))
			{
			   error.push(' \n\t - Enter your cvc');
			}
			else
			{
			   if(document.getElementById('cvc').value.length>4)
			   {
              error.push(' \n\t - Cvc is too long');
          } 
          else
          {
              if(document.getElementById('cvc').value.length<3)
			       {
              error.push(' \n\t - Cvc is too short');
            }

       
       
          }
       }
			

		if (error.length != 0)
			{
			alert('Please correct these errors: \n' + error);	
			return false;
			}
		else
			{
			return true;
			}
			
		}
