// HIDE SHOW FUNCTIONS //////////
/////////////////////////////////

$(document).ready(function() {
	
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#needmorehelp-showhide').hide();

 // toggles the slickbox on clicking the noted link
  $('a#needmorehelp').click(function() {
	$('#needmorehelp-showhide').toggle();
	return false;
  });

});

$(document).ready(function() {
	
 // hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
  $('#betamessageform').hide();

 // toggles the slickbox on clicking the noted link
  $('a.beta').click(function() {
	$('#betamessageform').toggle();
	return false;
  });

});

$(document).ready(function() {
// hides the slickbox as soon as the DOM is ready
 // (a little sooner than page load)
	$('.show').hide();

 // toggles the slickbox on clicking the noted link
	$('a.showhide').click(function() {
		$(this).siblings('.show').toggle();
		return false;
	});
	
	$('a.showhide').click(function() {
		$('a.showhide').toggleClass("linkhide");
	});
	
	$('.submit').click(function() {
		$('.jq-divhide').hide('slow');
	});
	
	
	
	// TOOLTIP FUNCTIONS //////////
	/////////////////////////////////
	$('.question').tooltip(	
		{
			showURL: false		
		}	
	);
	
});




// LIGHTBOX FUNCTIONS 
$(function() {
	$('#attraction-gallery ul li a').lightBox({fixedNavigation:true});
	$('#flickrfeed ul li a').lightBox({fixedNavigation:true});
	$('.lightbox-group').lightBox({fixedNavigation:true});
	$('a.photopoll-lightbox').lightBox({fixedNavigation:true});
	$('.event-gallery a').lightBox({fixedNavigation:true});
	$('a.light').lightBox({fixedNavigation:true});
	
});

// MARQUEE

var mq_headline_count;
var mq_headline_interval;
var mq_old_headline = 0;
var mq_current_headline=0;

$(document).ready(function(){
  mq_headline_count = $("div.mq_headline").size();
  $("div.mq_headline:eq("+mq_current_headline+")").css('top','5px');
  
  mq_headline_interval = setInterval(headline_rotate,7500); //time in milliseconds
  $('#mq_scrollup').hover(function() {
    clearInterval(mq_headline_interval);
  }, function() {
    mq_headline_interval = setInterval(headline_rotate,7500); //time in milliseconds
    headline_rotate();
  });
});

function headline_rotate() {
  mq_current_headline = (mq_old_headline + 1) % mq_headline_count; //remainder will always equal mq_old_headline until it reaches mq_headline_count - at which point it becomes zero. clock arithmetic
  $("div.mq_headline:eq(" + mq_old_headline + ")").animate({top: -205},1500, function() {
    $(this).css('top','210px');
    });
  $("div.mq_headline:eq(" + mq_current_headline + ")").show().animate({top: 5},1500);  
  mq_old_headline = mq_current_headline;
}


// CYCLE & PAGER

$(document).ready(function() {


	$('#promoSlide2').css('background','url("/global/theme/images/loader.gif") no-repeat 50% 50%');

	$('#promoSlide2').after('<div class="clearfix" id="pager"></div>').cycle({
		timeout: false, 
		fx: 'scrollUp',
		speed: 1000,
		pause:   1,
		pager: '#pager'
	});

	function onAfter() {
		$(this).find('.slideCaption2').show().animate({opacity: 0.7}, 500).animate({bottom: "0px"}, { queue:false, duration: 500 }).animate({opacity: 0.7}, 6000).animate({opacity: 0.0, bottom: "-40px"}, 500);
	}


});

		// /*-- JUST ANOTHE SLIDESHOW ----------------------*/
		// //SLIDESHOWS
		// 	$(document).ready(function() {
		// var promoSlide = $('#otherSlide');
		// var promoSlideImg = promoSlide.find('img');
		// // var h = promoSlideImg.height();
		// // var w = promoSlideImg.width();
		// // promoSlide.height(h);
		// 
		// promoSlideCSS =	{
		// 					'overflow': 'hidden',
		// 					'background' : '#000 url(/theme/images/loaders/loader_1_black48.gif) center center no-repeat'
		// 				};
		// 
		// promoSlide.css(promoSlideCSS);	
		// 
		// // $('#otherSlide .slideItem').height(h).width(w);
		// 
		// SlideCaptionCSS =	{
		// 						'bottom': -1*$(this).height(),
		// 						'opacity' : '0.7',
		// 						'width' : '100%',
		// 						'position' : 'absolute'
		// 					};
		// 
		// $('#otherSlide .slideCaption').each(function(){
		// 	$(this).css(SlideCaptionCSS);
		// });
		// 
		// function onBefore() {
		// }
		// 
		// function onAfter() {
		// 	sCaption = $(this).find('.slideCaption');
		// 	sCaptionH = -1*sCaption.height();
		// 	sCaption.show().animate({opacity: 0.7}, 500).animate({bottom: "0px"}, { queue:false, duration: 500 }).animate({opacity: 0.7}, 2000).animate({opacity: 0.0, bottom: sCaptionH}, 500);
		// }
		// 
		// function initSlideshowB(slideShow)
		// {
		// 	slideShow.find('img').fadeIn();
		// 	promoSlide.css({'background' : 'none'});
		// 
		// 	slideShow.cycle({
		// 	    timeout: 5000, 
		// 		fx: 'fade',
		// 		speed: 1000,
		// 		before: onBefore,
		// 		after: onAfter,
		// 		pager: '#pager',
		// 		pause:   1
		// 	});
		// }
		// 
		// function is_image_loaded(image) {
		//     if(!image.complete) {
		//         return false;
		//     }
		//     if(typeof image.naturalWidth != "undefined" && image.naturalWidth == 0) {
		//         return false;
		//     }
		//     return true;
		// };
		// 
		// var first_slide = $('#otherSlide img:first');
		// 
		// if(first_slide.length > 0){
		// 	if(is_image_loaded(first_slide.get(0))){
		// 		initSlideshowB($('#otherSlide'));
		// 	} else {
		// 	    first_slide.load(function(e) {
		// 	        $('#loading').hide();
		// 			initSlideshowB($('#otherSlide'));
		// 	    });
		// 	}
		// }




	// });

//#promoSlide - rather old
$(document).ready(function() {

	$('.slideCaption').hide().animate({opacity: 0.0}, 1);
	$('#promoSlide').css('background','url("/global/theme/images/loader.gif") no-repeat 50% 50%');

    $('#promoSlide').cycle({
	    timeout: 9000, 
		fx: 'fade',
		speed: 1000,
		pause:   1,
		before:  onBefore,
		after:  onAfter
	});

	function onBefore() {
		var imageN = this.id.split('_').slice(-1);
	    var imageBefore = imageN-1;
		var totImages = $(this).siblings().length + 1;
		$('#promoSlide').css('background-image','none');
	
		if (imageBefore==0) {imageBefore = totImages};
	
		$('#am'+imageN).addClass('alt2').removeClass('alt1');
		$('#am'+imageBefore).addClass('alt1').removeClass('alt2');
	}
	
	function onAfter() {
		$(this).find('.slideCaption').show().animate({opacity: 0.7}, 500).animate({bottom: "0px"}, { queue:false, duration: 500 }).animate({opacity: 0.7}, 6000).animate({opacity: 0.0, bottom: "-40px"}, 500);
	}


});
	
	
	
