function menu(){

	$("#nav li ul").addClass("jqhide");
    
	   $("#nav li").hover(
		function(){
		  $(this).children("ul").show();
		},
		function(){
		  $(this).children("ul").hide();
		});
}


function clickableBoxes(){

		// Clickable Boxes 
		$('#container #blocks .block1').click(function(event) {
			window.location.href = $('a', this).attr('href');
			return false;
		});
		
		$('#container #blocks .block2').click(function(event) {
			window.location.href = $('a', this).attr('href');
			return false;
		});
		
		$('#container #blocks .block3').click(function(event) {
			window.location.href = $('a', this).attr('href');
			return false;
		});
		
		$('#container #content #right .block').click(function(event) {
			window.location.href = $('a', this).attr('href');
			return false;
		});

}


		///////////////////////////////////////
		// Frontpage Slideshow
		///////////////////////////////////////
		function slideSwitch() {
			var $active = $('#slideshow img.active');
		
			if ( $active.length == 0 ) $active = $('#slideshow img:last');
		
			// use this to pull the images in the order they appear in the markup
			var $next =  $active.next().length ? $active.next()
				: $('#slideshow img:first');
		
			// uncomment the 3 lines below to pull the images in random order
			
			// var $sibs  = $active.siblings();
			// var rndNum = Math.floor(Math.random() * $sibs.length );
			// var $next  = $( $sibs[ rndNum ] );
		
		
			$active.addClass('last-active');
		
			$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1000, function() {
					$active.removeClass('active last-active');
				});
		}
		
		$(function() {
			setInterval( "slideSwitch()", 5500 );
		});
		///////////////////////////////////////
		// End Frontpage Slideshow
		///////////////////////////////////////
		
		///////////////////////////////////////
		// Frontpage Slideshow
		///////////////////////////////////////
		function slideSwitch2() {
			var $active = $('#slideshow2 img.active');
		
			if ( $active.length == 0 ) $active = $('#slideshow2 img:last');
		
			// use this to pull the images in the order they appear in the markup
			var $next =  $active.next().length ? $active.next()
				: $('#slideshow2 img:first');
		
			// uncomment the 3 lines below to pull the images in random order
			
			// var $sibs  = $active.siblings();
			// var rndNum = Math.floor(Math.random() * $sibs.length );
			// var $next  = $( $sibs[ rndNum ] );
		
		
			$active.addClass('last-active');
		
			$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1000, function() {
					$active.removeClass('active last-active');
				});
		}
		
		$(function() {
			setInterval( "slideSwitch2()", 5500 );
		});
		///////////////////////////////////////
		// End Frontpage Slideshow
		///////////////////////////////////////
		
		
		
		///////////////////////////////////////
		// Booking page
		///////////////////////////////////////
	function gobooking()
	{
	 
	 	// Show n Hide
		$('#step-two').hide();
		$('#step-three').hide();
		$('#step-four').hide();
		$('#step-five').hide();
		
		
		$('input#button').click(function() {
			updateInfo();							 
			$('#step-two').slideDown();
			$('#step-one').hide();
			$('#step-three').hide();
			$('#step-four').hide();
			$('#step-five').hide();
			$('#steps #1').removeClass('stepactive');
			$('#steps #2').addClass('stepactive');
			$('#steps #3').removeClass('stepactive');
			$('#steps #4').removeClass('stepactive');
			$('#steps #5').removeClass('stepactive');
		});
		
		$('a.step1').click(function() {
			updateInfo();						
			$('#step-one').slideDown();
			$('#step-two').hide();
			$('#step-three').hide();
			$('#step-four').hide();
			$('#step-five').hide();
			$('#steps #1').addClass('stepactive');
			$('#steps #2').removeClass('stepactive');
			$('#steps #3').removeClass('stepactive');
			$('#steps #4').removeClass('stepactive');
			$('#steps #5').removeClass('stepactive');
			return false;
		});
		
		$('a.step2').click(function() {
			updateInfo();						
			$('#step-two').slideDown();
			$('#step-one').hide();
			$('#step-three').hide();
			$('#step-four').hide();
			$('#step-five').hide();
			$('#steps #1').removeClass('stepactive');
			$('#steps #2').addClass('stepactive');
			$('#steps #3').removeClass('stepactive');
			$('#steps #4').removeClass('stepactive');
			$('#steps #5').removeClass('stepactive');
			return false;
		});
		
		$('a.step3').click(function() {
			updateInfo();
			$('#step-three').slideDown();
			$('#step-two').hide();
			$('#step-one').hide();
			$('#step-four').hide();
			$('#step-five').hide();
			$('#steps #1').removeClass('stepactive');
			$('#steps #2').removeClass('stepactive');
			$('#steps #3').addClass('stepactive');
			$('#steps #4').removeClass('stepactive');
			$('#steps #5').removeClass('stepactive');
			return false;
		});
		
		$('a.step4').click(function() {
			updateInfo();
			$('#step-four').slideDown();
			$('#step-two').hide();
			$('#step-three').hide();
			$('#step-one').hide();
			$('#step-five').hide();
			$('#steps #1').removeClass('stepactive');
			$('#steps #2').removeClass('stepactive');
			$('#steps #3').removeClass('stepactive');
			$('#steps #4').addClass('stepactive');
			$('#steps #5').removeClass('stepactive');
			return false;
		});
		
		// Agree with the Terms and Agreements
		function updatebutton(){
			if ($('#iagree:checked').val() === 'yes') {
				$('#button').removeAttr("disabled");
				$('#button').attr("value", "Confirm my reservation");
				//alert($('#iagree:checked').val());
			}
			else
			{
				$('#button').attr("disabled", "disabled");
				$('#button').attr("value", "Please agree with the Terms and Agreements first");
				//alert('bla2');
			}
		}
		updatebutton();
		$('#iagree').click(function(){
			updatebutton();
		});
		
		// ajax update
		function updateInfo()
		{
			$.post("/templates/ajax/booking.php", { 
				   
				doa: $('#doa').val(), 
				period: $('#period').val(), 
				adults: $('#adults').val(), 
				children: $('#children').val(), 
				airportpickup: $('#airportpickup').val(), 
				salutation: $('#salutation').val(), 
				initials: $('#initials').val(), 
				name: $('#name').val(), 
				address: $('#address').val(), 
				postalcode: $('#postalcode').val(), 
				city: $('#city').val(), 
				state: $('#state').val(), 
				country: $('#country').val(), 
				email: $('#email').val(), 
				phone: $('#phone').val(), 
				phonehome: $('#phonehome').val()
			
				},
				
				function(data)
				{
					$('#doa').val(data.doa);				
					$('#period').val(data.period);
					$('#adults').val(data.adults);
					$('#children').val(data.children);
					$('#airportpickup').val(data.airportpickup);
					$('#salutation').val(data.salutation);
					$('#initials').val(data.initials);
					$('#name').val(data.name);
					$('#address').val(data.address);
					$('#postalcode').val(data.postalcode);
					$('#city').val(data.city);
					$('#state').val(data.state);
					$('#country').val(data.country);
					$('#email').val(data.email);
					$('#phone').val(data.phone);
					$('#phonehome').val(data.phonehome);
					
					$('#amount').html(data.amount);
					$('#charge').html(data.charge);
					$('#tax').html(data.tax);
					$('#total').html(data.total);
					
					$('#salutation2').html(data.salutationnice);
					$('#initials2').html(data.initials);
					$('#name2').html(data.name);
					
					$('#adults2').html(data.adults);
					$('#children2').html(data.children);
					$('#period2').html(data.periodnice);
					$('#doa3').html(data.doanice);
					
					//alert(data.doanice);
					
					$('#amount2').html(data.amount);
					$('#charge2').html(data.charge);
					$('#tax2').html(data.tax);
					$('#total2').html(data.total);
					
					$('#airportpickup2').html(data.airportpickupnice);
					
				}, "json");
			}
	
		$("#doa, #period, #adults, #children, #airportpickup, #airportpickup2").change(function () {
			updateInfo();						 
		});
		
		updateInfo();
	}
		
function updatePeriod(){
	
	$('#period').change(function () {
								 
		var m = $('#formm').val();
		var y = $('#formy').val();
		var c = $('#formc').val();
		var n = $('#period').val();
		
		updateCal(m, y, c, n);				 
	});
}

function updateCal(m, y, c, n)
{
	
	$('.loading').fadeIn();
	
	updateCal2(m, y, c, n);
	
}
		
function updateCal2(m, y, c, n)
{
	
	$.post("/templates/ajax/cal.php", {
		  
		m: m, 
		y: y, 
		c: c, 
		n: n 
	
		},
		
		function(data)
		{
			$('#cal').html(data.cal);
			$('#error').html(data.error);
			$('#period').html(data.drop);
			$('#hiddenFields').html(data.hiddenFields);
			$('#doa').val(data.doa);
			$('#doa2').val(data.doa2);
			
			if(data.doa != 0)
			{
				$('.hidden').show('fast');
			}
			
			$('.loading').fadeOut();
			if($('#page').val() == 'booking'){
				gobooking();
			}
			
		}, "json");
}