$(function(){
	// initialize scroller
	$.localScroll();
	

	// crossSlider 
	$('#crossSlide').crossSlide({
	  fade: 1
	}, [
	  {
		src:  '/images/Kitchen 1.JPG',
		href: '#noon',
		from: 'bottom right',
		to:   'top left',
		time: 3
	  }, {
		src:  '/images/Upper Bedroom 1.JPG',
		href: '#noon',
		from: 'bottom left',
		to:   'top right',
		time: 2
	  }, {
		src:  '/images/Chairs and sunset.JPG',
		href: '#noon',
		from: 'top right',
		to:   'bottom left',
		time: 2
	  }, {
		src:  '/images/Beach North.JPG',
		href: '#noon',
		from: 'bottom right',
		to:   'top left',
		time: 2
	  }
	]);
    

	//gallery
	$('#thumbnails a').mouseover(function() {
		var href = $(this).attr('href');
		var title = $(this).attr('title');
		$('#thePic').attr('src',href);
		$('#picDesc').html(title);
		return false;
	});
	$('#thumbnails a').click(function() {
		var href = $(this).attr('href');
		var title = $(this).attr('title');
		$('#thePic').attr('src',href);
		$('#picDesc').html(title);
		return false;
	});



	// info 
	$('#home').toggle();
	
	$('#homeLink').click(function() {	
								   $('#homeLink').removeClass('highLight');
								   $('#stuffLink').removeClass('highLight');
								   $('#ratesLink').removeClass('highLight');
								   $('#localLink').removeClass('highLight');
								   $(this).addClass('highLight');
								   $('#stuff').fadeOut('fast');
								   $('#rates').fadeOut('fast');
								   $('#local').fadeOut('fast');
								   $('#home').fadeIn('fast');
								   return false;
								   });
	
	$('#stuffLink').click(function(){	
								   $('#homeLink').removeClass('highLight');
								   $('#stuffLink').removeClass('highLight');
								   $('#ratesLink').removeClass('highLight');
								   $('#localLink').removeClass('highLight');
								   $(this).addClass('highLight');
								   $('#home').fadeOut('fast');
								   $('#rates').fadeOut('fast');
								   $('#local').fadeOut('fast');
								   $('#stuff').fadeIn('fast');
								   return false;
								   });
	$('#ratesLink').click(function(){
								   $('#homeLink').removeClass('highLight');
								   $('#stuffLink').removeClass('highLight');
								   $('#ratesLink').removeClass('highLight');
								   $('#localLink').removeClass('highLight');
								   $(this).addClass('highLight');
								   $('#home').fadeOut('fast');
								   $('#stuff').fadeOut('fast');
								   $('#local').fadeOut('fast');			
								   $('#rates').fadeIn('fast');
								   return false;					  
								   });
	$('#localLink').click(function(){
								   $('#homeLink').removeClass('highLight');
								   $('#stuffLink').removeClass('highLight');
								   $('#ratesLink').removeClass('highLight');
								   $('#localLink').removeClass('highLight');
								   $(this).addClass('highLight');
								   $('#home').fadeOut('fast');
								   $('#stuff').fadeOut('fast');
								   $('#rates').fadeOut('fast');
								   $('#local').fadeIn('fast');	
								   return false;							  
								   });




	// reserve now form
	
	 
    $("#reserveNowButton").click(function() {
      
	  //validate form
	  if ($('#name').val() == '') {
		alert('Please enter your full name.');
		$('#name').focus();
		return false;
	  	}
	  if ($('#phone').val() == '') {
		alert('Please enter your phone number.');
		$('#phone').focus();
		return false;
	  	}
	  if ($('#email').val() == '') {
		alert('Please enter your email address.');
		$('#email').focus();
		return false;
	  	}
	  if ($('#reserveStart').val() == '') {
		alert('Please enter the start date of your reservation.');
		$('#reserveStart').focus();
		return false;
	  	}
	  if ($('#reserveEnd').val() == '') {
		alert('Please enter the end date of your reservation');
		$('#reserveEnd').focus();
		return false;
	  	}
	  if ($('#num').val() == '') {
		alert('Please enter the number of people in your party.');
		$('#num').focus();
		return false;
	  	}
		
		
		//organize the data properly
		var data = 'name=' + $('#name').val() + '&phone=' + $('#phone').val() + '&email=' + $('#email').val() + '&reserveStart=' + $('#reserveStart').val() + '&reserveEnd=' + $('#reserveEnd').val() + '&num=' + $('#num').val() + '&msg='  + encodeURIComponent($('#msg').val());
		
		//disabled all the text fields
		$('.text').attr('disabled','true');
		
		//show the loading sign
		$('.loading').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "reserve.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
					$('#contactForm').toggle();					
					
					//show the success message
					$('.done').fadeIn('slow');
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Sorry, unexpected error. Please try again later.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	
	  
    });

	


});

