/***********************************************
***  BUTTON ROLLOVER & PRELOAD  ****************
************************************************/

$(document).ready(function() {
	// button rollover
	if ($('.imgBtn') != null) {
		$('.imgBtn').hover(function(){
				if(!$(this).is('.disabled'))
					$(this).attr("src", $(this).attr("src").replace(/^(.*?)(?:-hover)?(\..*?)$/i,'$1-hover$2'));
			},
			function(){
					if(!$(this).is('.disabled'))
						$(this).attr("src", $(this).attr("src").replace(/^(.*)-hover(\..*?)$/i, '$1$2'));
				});
	}
	// preload image rollovers
	if ($("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']") != null) {
	    $("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']").each(function(){
			    $("<img>").attr("src", $(this).attr("src").replace(/(btn-.*)(\..*?)/i, '$1-hover$2'));
		    });
	}

/***********************************************
***  EXTERNAL LINKS  ***************************
************************************************/

	$("a[rel=external]").each(function() {
		$(this).addClass('external');
		$(this).attr({
			title: "Open this page in a new window",
			target: "_blank"
		});
	})

/***********************************************
***  GEE SLIDE SHOW  ***************************
************************************************/

	$(function() {
		$('#homeMainSlides').geeFader(($.browser.msie && parseInt($.browser.version) < 9) ? {
				effect: 'snap',
				delay: 3000,
				bookmarks: '.bannerControls a'
			} : {
					effect: 'fade',
					delay: 3000,
					duration: 500,
					easing: 'swing',
					bookmarks: '.bannerControls a'
				});
	});

/***********************************************
***  COMPACT FORM (LABEL OVER INPUT)  **********
************************************************/

	$('form.compact input, form.compact select, form.compact textarea').focus(function(){
			$('label[for=' + $(this).attr('id') + ']').hide();
		});
	$('form.compact input, form.compact select, form.compact textarea').each(function(ele){
			if($(this).val().length > 0)
				$('label[for=' + $(this).attr('id') + ']').css({ display: "none" });
		});
	$('form.compact input, form.compact select, form.compact textarea').blur(function(){
			if($(this).val().length == 0)
				$('label[for=' + $(this).attr('id') + ']').show();
		});
	$('form.compact').removeClass('compact');


/***********************************************
***  CONTACT PAGE BUTTONS  *********************
************************************************/

	$('#footer .footerSubscribe, #homeCols .homeNewsletterContainer a, #homeMainContainer .btnBuyTicketsHome, #homeCols .homeTicketContainer a').hover(function(){
			$(this).stop().animate({
					paddingRight: '23px'
				}, 150);
		}, function(){
				$(this).stop().animate({
						paddingRight: '18px'
					}, 150);
			});

/***********************************************
***  ANIMATED SCROLLING   **********************
************************************************/

	$('.msgBox ol a[href^="#"]').click(function(){
			
			var id = $(this).attr('href');
			if(id.length === 1) return;
			var ele = $(id);
			$(this).addClass('clicked');
			if(ele.length) {
				var destination = ele.offset().top;
				$('html:not(:animated), body:not(:animated)').animate({
						scrollTop: destination -20
					}, 700, 'swing');
			};
			return false;
		});

/***********************************************
***  TOOLTIPS  *********************************
************************************************/

	$(".tooltipTrigger").hover(function(){
		if($(this).parent().find(".tooltipContent").is(':animated'))
			return;
		$(this).parent().find(".tooltipContent").stop().addClass('open').css({ bottom: '22px' }).animate({
						bottom: 32,
						opacity: 1
					}, 300);
	},
	function(){
			
			$(this).parent().find(".tooltipContent").stop().css({ bottom: '32px' }).animate({
						bottom: 42,
						opacity: 0
					}, 150, function(){
							$(this).removeClass('open');
					});
		});
		
/***********************************************
***  DATEPICKER  *******************************
************************************************/

	$(function() {
		$(".dateField").datepicker();
	});
	
/***********************************************
***  EQUAL HEIGHTS  ****************************
************************************************/

	function equalHeight(group) {
		tallest = 0;
		group.each(function() {
			thisHeight = $(this).height();
			if(thisHeight > tallest) {
			    tallest = thisHeight;
			}
		});
		if ($.browser.msie && $.browser.version.substring(0,1) === '6'){
			group.css('height',tallest);
		}
		else {
			group.css('min-height',tallest);
		}
	}
	$(document).ready(function() {
	    equalHeight($("fieldset.leftCol, fieldset.rightCol"));
	});
	
/***********************************************
***  FANCYBOX  *********************************
************************************************/

	$("a.grouped_elements").fancybox( {
			'padding'			: 0,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'type'				: 'image',
			'speedIn'			: 600, 
			'speedOut'			: 200, 
			'overlayColor'		: '#000'
		});
});


/***********************************************
************ PRETTY PHOTO PLUGIN ***************
************************************************/ 

$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({
			theme: 'pp_default',
			ie6_fallback: true,
			social_tools: false,
			deeplinking: false,
			default_width: 750,
			default_height: 350
	});
	
	$('#bookingSunStars').click(function(){
		$('#ArrivalTimeSunStars').show();
	});
	$('#bookingStandard').click(function(){
		$('#ArrivalTimeSunStars').hide();
	});
});

/***********************************************
**************** SPAM CAPTURE ******************
************************************************/ 

$(function() {
	$('.pageForm').prepend('<input type="hidden" name="formAuth" value="001" />');
});
