$(document).ready(function()
{
	if (typeof $.browser.SafariMobile != 'undefined' && $.browser.SafariMobile != null)
	{
		$('body').addClass('static');
	}

	$('form').validate();
	$('.new-window').click(function(){return !window.open($(this).attr('href'));});
	$('.new-popup-window').click(function(){return !window.open($(this).attr('href'),'popupwindow','status=0,toolbar=0,menubar=0,resizable=1,width=720,height=600');});
	$('a[rel="lightbox"]').lightBox();
	theRotator();
	testimonials();

	$('#booking-form').hide();
	$('a.book-day').click(function()
	{
		$('#booking a.hi').removeClass('hi');
		$(this).addClass('hi');
		$('#how-to').slideUp();
		$('#booking-form').slideDown();

		$('#booking-form h2').html($(this).attr('rel'));
		$('#frm_selected_date').val($(this).attr('rel'));

		return false;
	});


	//$('#mickey').hide().fadeIn(1000);
	//$('#minnie').hide().fadeIn(1000);
	//$('#castle').hide().fadeIn(1000);
	//$('#animate').hide().fadeIn(2000);
	//$('#animate').css({'width':'0','overflow':'hidden'}).animate({'width':'486'},3000,function(){
/*
		$('#animate').fadeOut('slow',function(){
			$('#animate').fadeIn('slow',function(){
				$('#animate').fadeOut('slow',function(){
					$('#animate').fadeIn('slow',function(){
						$('#animate').fadeOut('slow',function(){
							$('#animate').fadeIn('slow');
						});
					});
				});
			});
		});
*/
	//});
});

function theRotator()
{
	if ($('ul#photo-slideshow').length == 0)
		return false;
	$('ul#photo-slideshow li').css({opacity: 0.0});
	$('ul#photo-slideshow li:first').css({opacity: 1.0});
	show_caption($('img', $('ul#photo-slideshow li:first')).attr('alt'));
	setInterval('rotate()',5000);
}

function rotate()
{
	$('#photo-caption').animate({opacity: 0.0}, 1000);
	var current = ((typeof $('ul#photo-slideshow li.show').attr('class') != 'undefined')?  $('ul#photo-slideshow li.show') : $('ul#photo-slideshow li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('ul#photo-slideshow li:first') :current.next()) : $('ul#photo-slideshow li:first'));
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 2500);
	current.animate({opacity: 0.0}, 2500).removeClass('show');
	setTimeout('show_caption("'+$('img', next).attr('alt')+'")',1500);
};

function show_caption(caption)
{
	$('#photo-caption').html(caption).animate({opacity: 0.7}, 1000);
	var t = $('ul#photo-slideshow').offset().top + $('ul#photo-slideshow').outerHeight() - ($('#photo-caption').outerHeight() + 20);
	$('#photo-caption').css({'top':t});

}

function testimonials()
{
	if ($('.testimonials-box').length == 0)
		return false;
	$('.testimonials-box blockquote').hide();
	//$('.testimonials-box blockquote:first').css({opacity: 1.0});
	if (typeof $('.testimonials-box blockquote.show').attr('class') != 'undefined')
		$('.testimonials-box blockquote.show').show();
	else
		$('.testimonials-box blockquote:first').show();

	setInterval('rotate_testimonials()',7000);
}

function rotate_testimonials()
{
	var current = ((typeof $('.testimonials-box blockquote.show').attr('class') != 'undefined')?  $('.testimonials-box blockquote.show') : $('.testimonials-box blockquote:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('.testimonials-box blockquote:first') :current.next()) : $('.testimonials-box blockquote:first'));
	current.fadeOut(function()
	{
		next.fadeIn().addClass('show');
	}).removeClass('show');
	//next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 2500);
	//current.animate({opacity: 0.0}, 2500).removeClass('show');
};

jQuery.extend(jQuery.browser,{SafariMobile:navigator.userAgent.toLowerCase().match(/iP(hone|ad)/i)});

