// JavaScript Document
// Load jQuery
google.load("jquery", "1.4");
google.load("jqueryui", "1.7.2");

  
// use callback to make sure jquery has loaded when it runs
google.setOnLoadCallback(function() {

	// when page loads
	$(document).ready(function() {
      
	  	  /**************************************** HOME: Featured Destinations ****************************************/
		  //register top ten mouseover
		  $('#destinations li').mouseover(function(event){
		  var info = $(this).find('.topten-info');	// get info box related to this item
		  if(info.size() == 0) return;
		  
		  //copy the contents from the hidden div of the top10 elements
		  var topten_data = $('#topten-highlight')
					  .hide()
					  .empty()
					  .append(info.children().clone());
					  
		  $('#feature').hide();
		  $('#topten-highlight').show();
		  
		}
		  );
		  
		  var transition_speed = 150;
		  
		  /**************************************** Custom Booking: Thumbnails ****************************************/
		  //register top ten mouseover
		  $('#custom_thumbs li a').mouseover(function(event){
		  var info = $(this).attr('href');	// get large image
		  
		  $('#lgimg').attr('src',info);
					  
		 	});
		  
		  
		  /**************************************** Header: Newsletter ****************************************/
		  //register events for newsletter box
		  var newsletter_steps = $('#newsletter-signup ol li');
		  
		  newsletter_steps.find('.next-button').click(function(e) {
		var cur_item = $(this).parents("li");
		var next_item = cur_item.next();
		
		cur_item.hide('slide', {direction: 'left'}, transition_speed, function() {
		  next_item.show('slide', {direction: 'right'}, transition_speed);
		});
		
		return false;
		  });
		  
		  newsletter_steps.find('.prev-button').click(function(e) {
		var cur_item = $(this).parents("li");
		var prev_item = cur_item.prev();
		
		cur_item.hide('slide', {direction: 'right'}, transition_speed, function() {
		  prev_item.show('slide', {direction: 'left'}, transition_speed);
		});
		
		return false;
		});
		  
		$("#newsletter-submit").click(function(){ $("#JqAjaxForm").submit() });  
		  
    	$("#JqAjaxForm").submit(function(){
	        dataString = $("#JqAjaxForm").serialize();
	        $.ajax({
		        type: "POST",
		        url: "http://www.famtripper.com/newsletter-signup.php",
		        data: dataString,
		        dataType: "json",
		        success: function(data) {
		
		            if(data.email_check == "invalid"){
		                $("#response").html("NOT a valid e-mail address. Try again.");
		            } else {
		                $("#response").html( "Thank you, " + data.name + ".");
		            }
		
		        } 
       		});
    	    return false;            
	    });
	    
		  
		  /**************************************** HOME: Insider Tips ****************************************/
		  $("#more-tip").click(function(){
			$("#insider-more").slideToggle("slow");
			$("#less-tip").show();
			$(this).hide(); return false;
		  });
		   $("#less-tip").click(function(){
			$("#insider-more").slideToggle("slow");
			$("#more-tip").show();
			$(this).hide(); return false;
		  });


		  /**************************************** Header: Trip On callout ****************************************/
		  $("#trip_on a").hover(function(e) {
		   $(this).next("div").animate({opacity: "show", bottom:"-65"}, "slow");
		  }, function() {
		   $(this).next("div").animate({opacity: "hide", bottom:"-85"}, "fast");
		  });
		
		/**************************************** LIGHTBOX ****************************************/
		if ($("a[rel=gallery]").length > 0)
		{
			$("a[rel=gallery]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		 if ($("a[rel=gallery0]").length > 0)
		{
			$("a[rel=gallery0]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		 if ($("a[rel=gallery1]").length > 0)
		{
			$("a[rel=gallery1]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		
		if ($("a[rel=gallery2]").length > 0)
		{
			$("a[rel=gallery2]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery3]").length > 0)
		{
			$("a[rel=gallery3]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery4]").length > 0)
		{
			$("a[rel=gallery4]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery5]").length > 0)
		{
			$("a[rel=gallery5]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery6]").length > 0)
		{
			$("a[rel=gallery6]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery7]").length > 0)
		{
			$("a[rel=gallery7]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery8]").length > 0)
		{
			$("a[rel=gallery8]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery9]").length > 0)
		{
			$("a[rel=gallery9]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery10]").length > 0)
		{
			$("a[rel=gallery10]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery11]").length > 0)
		{
			$("a[rel=gallery11]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery12]").length > 0)
		{
			$("a[rel=gallery12]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery13]").length > 0)
		{
			$("a[rel=gallery13]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery14]").length > 0)
		{
			$("a[rel=gallery14]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery15]").length > 0)
		{
			$("a[rel=gallery15]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery16]").length > 0)
		{
			$("a[rel=gallery16]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery17]").length > 0)
		{
			$("a[rel=gallery17]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		if ($("a[rel=gallery18]").length > 0)
		{
			$("a[rel=gallery18]").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
			    return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
				}
			});
		}
		
		
	});
	
	});
	
