jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function
    /* MAIN NAVIGATION HACK FIX (Remove when actual fix is found)  */
    $('#menu-item-1135').html('<a href="http://www.portdhiver.com/melbourne-fl-nature-tours.html"><span>Nature Tours</span></a>');    
    /* END NAV HACK */
    
    $('#tabs').tabs();
    
    if($("#tabs") && document.location.hash){
	  $.scrollTo("#pageContent");
	} 
	
	$("#tabs ul").localScroll({ 
	  target:"#pageContent",
	  duration:0,
	  hash:true
	});
	
	
	
	
	function changeTab(){
		var $tabs = $('#tabs').tabs();
		var currentHash = document.location.hash;
		
		switch(currentHash){
			case '#Property_Layout':
				$tabs.tabs('select', 1);
				break;
			case '#Rate_Chart': 
				$tabs.tabs('select', 2);
				break;
			case '#Room_Overview': 
				$tabs.tabs('select', 0);
		}
	}
	if(window.addEventListener){
		window.addEventListener("hashchange", changeTab, false);
	}else if(window.attachEvent){
		window.attachEvent("hashchange", changeTab, false);
	}else{}
	
	 /* slideshows */
	 var slideHeight = $('.wsImageHolder img').attr('height');
	 var slideWidth = $('.wsImageHolder img').attr('width');
        $('.wsImageHolder').cycle({
    		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    		timeout: 6000,
    		speed: 2000,
    		height: slideHeight,
    		width: slideWidth
    	});
    	
     /* Home page slideshow with text reveal */
     var homeSlideHeight = $('.wsImageContainer img').attr('height');
     var homeSlideWidth = $('.wsImageContainer img').attr('width');
        function beforeSlide(){
        	var textElement = $(this).children()[1];
        	$(textElement).hide();
        }
        
        function onAfter(){
        	var textElement = $(this).children()[1];
        	$(textElement).delay(1500).fadeIn(1500, function(){});
        }
        
        $('.homeSlides').cycle({
            fx:     'fade',
            speed:   1700,
            timeout: 8000,
            before: beforeSlide,
            after: 	onAfter,
    		height: homeSlideHeight,
    		width: homeSlideWidth
        });
   	
   	/* Press Slider */
   	var slideNum = $('.awardWrapper').length;
   	var slideWidth = slideNum * 715;
   	$('.awardFullWidth').cycle({ 
	    fx:     'scrollHorz',  
	    next:   '#next1', 
	    timeout: 0 
	});
	
	$('.addOnContent').hide();
	$('.addOnContent').first().show();
	/* Packages add on slider */
	$('.addOnTitle').click(function(){
		var titleClicked = this;
		$(titleClicked).next('.addOnContent').slideToggle();
	});
   	
   	$('.social_a').hover(function(){$('.weatherWidget').fadeToggle(500);}, function(){$('.weatherWidget').fadeToggle(500);});
   	
	var vidHTML = $('#vimeoInclude').html();

	
   	$('#videoButton').click(function(){
		$('#vimeoInclude').html(vidHTML);
   		$('#slideshowContainer').fadeOut(1000).css('display', 'none');
   		//$('#vimeoInclude').fadeIn().css('display', 'block');
   		$('#logoContainer').animate({top: -190}, {duration:1000, easing: "easeInExpo"});
   		$('#main_nav').animate({top: -190}, {duration:1000, easing: "easeInExpo"});
   		$('#closeVideo').fadeIn().css('display', 'block');
   	});
   	
   	$('#closeVideo').click(function(){
   		$('#slideshowContainer').fadeIn().css('display', 'block');
   		//$('#vimeoInclude').fadeOut().css('display', 'none');
   		$('#logoContainer').animate({top: 0}, {duration:1000, easing: "easeInExpo"});
   		$('#main_nav').animate({top: 0}, {duration:1000, easing: "easeInExpo"});
   		$('#closeVideo').fadeOut().css('display', 'none');
		$('#vimeoInclude').html('');
   	});
	
	  
});
