//random image
var imgTotal=5;
var rndNum = Math.round(Math.random()*(imgTotal-1))+1;

$(document).ready(function(){	

$("div.imgtop").css("background","url(/img/picbg_" + rndNum  + ".jpg) center");

slidebook();
$().blockSlider('#slidebook .title','#slidebook .arrowdown','#slidebook .close','#slidebook .container');
hoverDestinos();
bookingWidth();
resizeWindow();
seqChange();
eCalendar();
//tabsFix();

//$('body').animate({width:700},{duration: 2500}).css('margin','0 auto');
//bookingBanner('#bookingbanner .container','','','.slider');

});

function slidebook(){
	if ($("#bookwrap").length > 0) {
		return true;			
	} else {
		$('#slidebook').show('slow');			
	}
}

(function($) { jQuery.fn.blockSlider = function(sOpen,sOpenico,sClose,sBlock) {
	$(sOpen).mouseover(function(event) {
		$(sBlock)
			.animate(
				{opacity: 0.95}, {duration: 'fast'}
			)
			.animate(
				{ top: 170 }, {
					duration: 'slow',
					easing: 'easeOutBounce'
				});

			$(sOpenico).fadeOut();
			$(sClose).fadeIn();
			
	});
		
	$(sClose).click(function(event) {
		$(sBlock)
			.animate(
				{ top: 0 }, {
					duration: 'slow',
					easing: 'easeOutBounce'
				})
			.animate(
				{opacity: 1}, {duration: 'fast'}
			);
			
		$(this).fadeOut();
		$(sOpenico).fadeIn();

	});
	
}})(jQuery);

function hoverDestinos(){
	$( ".info div.bb" ).each(
	function( intIndex ){
 
 		$( this ).bind (
			"mouseover",
			function(){
				$('a', this).addClass('ok-active');
				$(this).addClass('flash');			
			}
			);
 
 		$( this ).bind (
			"mouseout",
			function(){
				$('a', this).removeClass('ok-active');
				$(this).removeClass('flash');
			}
			);

	});
};

function bookingWidth(){
	
	if ($("#xform-two").length > 0) {
		$('body').css({
			'min-width': '850px'
			});
	};
	
}

function resizeWindow(){
	
	var wsizeLoaded = null;
	var wsize = null;
	  
	wsizeLoaded = $(window).width();		
	
	if(wsizeLoaded < 999){
	  	
		$('.imglft').css({
			'margin-left': '0%',
			'margin':'0 auto'			
		});
		$('.imgrgt').css({
			'margin-right': '0%',
			'margin':'0 auto'			
		});
			  	
		$('.imglft').addClass('img_clean');
		$('.imgrgt').addClass('img_clean');
		
		$('#bookwrap .pdf').hide('slow');
	  	
	  } else {	  
		
		
		$('#bookwrap .pdf').show('slow');
					
	  	$('.imglft').removeClass('img_clean');
		$('.imgrgt').removeClass('img_clean');
	
		//Target IE6 and below
		if ($.browser.msie && $.browser.version <= 6 ){
		
	  	$('.imglft').css({			
			'margin-left': '5%',
			'margin-bottom':'10px'			
		});
		$('.imgrgt').css({
			'margin-right': '5%'
		});

			
		} else {
		
	  	$('.imglft').css({			
			'margin-left': '10%',
			'margin-bottom':'10px'			
		});
		$('.imgrgt').css({
			'margin-right': '10%'
		});
			
		}	
		
		
	  } 

	
	$(window).resize(function(){
	  	  	
	  wsize = $(window).width();
				
	  if(wsize < 999){
		
		$('.imglft').css({
			'margin-left': '0%',
			'margin':'0 auto'			
		});
		$('.imgrgt').css({
			'margin-right': '0%',
			'margin':'0 auto'			
		});
			  	
	  	$('.imglft').addClass('img_clean');
		$('.imgrgt').addClass('img_clean');
		
		$('#bookwrap .pdf').hide('slow');
	  	
	  } else {
		
		$('#bookwrap .pdf').show('slow');

	  	$('.imglft').removeClass('img_clean');
		$('.imgrgt').removeClass('img_clean');
		
		
		//Target IE6 and below
		if ($.browser.msie && $.browser.version <= 6 ){
		
	  	$('.imglft').css({			
			'margin-left': '5%',
			'margin-bottom':'10px'			
		});
		$('.imgrgt').css({
			'margin-right': '5%'
		});

			
		} else {
		
	  	$('.imglft').css({			
			'margin-left': '10%',
			'margin-bottom':'10px'			
		});
		$('.imgrgt').css({
			'margin-right': '10%'
		});
			
		}
		
	  }
	  
	  return true
	  		  
	});

	
}

function seqChange(){
	
	$("#bookwrap ul li").each(function (i) {
    i = i+1;
    //$(this).addClass('step'+i);	
	$(this).prepend('<span class="step">'+i+'</span> ');
	
	});
	
}


function eCalendar(){

	$(".eventCalendar tr td").hover(function(){
	
		var tdWidth = $(this).width();
		var tdHeight = $(this).height();
		bgcol = $(this).css('background');
		
		if ($(this).html() != '' && $(this).attr('class') != 'eMainTitle') {
		
			$(this).css({
				background: '#eee'
			});
			
		}
		
	}, function(){
	
		$(this).css({
			'background': bgcol
		})
		
	});
	
	$('.eventCalendar tr td').each(function(){
		if ($(this).html() == '') {
			$(this).css({
				'background': 'none',
				'cursor': 'default'
			})
		}
	});
	
	$('div.eWhen').prepend('<strong>When:</strong> ');
	$('div.eWhere').prepend('<strong>Where:</strong> ');
	
	/*var eQuick = $('table.eQuick').html();	
	$('table.eventCalendar').each(function(){
		$(this).before('<table width="100%" class="eventCalendar eQuick eSmall">' + eQuick + '</table>');
	})*/
	$('table.eventCalendar').each(function(){
		$(this).append('<tr><td colspan="3" class="eTop"><a href="#eQuick">Back to Top</a></td></tr>');
	})
	
	
}