/* ws-site.js */
jQuery(document).ready(function($) {
    // $() will work as an alias for jQuery() inside of this function
    /* Fancybox Calls */
    /* pop-ups via fancybox */
       
    	var siteWidth = 920;
    	
    	$('.pageFancy').fancybox({
    	 	'type'		:'iframe',
    		'width' 	:siteWidth,
    		'height' 	:810,
    		'padding' 	:0,
    		'scrolling'	: 'auto'			
    	});
    	$('.navPop > a').fancybox({
    	 	'type'		:'iframe',
    		'width' 	:siteWidth,
    		'height' 	:810,
    		'padding' 	:0,
    		'scrolling'	: 'auto'			
    	});
    /* Slideshow home */
     /* Home page slideshow with text reveal */
     
    $('.slideLoading').ready().fadeOut().css('display', 'none');
    $('.homeSlides').ready().fadeIn().css('visibility', 'visible');
     
     
    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: 426,
		width: 938
    });        
    
    /* Slideshow default */
    $('.mainSlideshow').ready().fadeIn().css('visibility', 'visible');
    $('.mainSlideshow').cycle({
    		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    		timeout: 4000,
    		height: 426,
    		width: 938
    	});
    
   $('.wsFancyList li:nth-child(even)').addClass('wsListEven');  
   
   $('.room-name').hover(function(){
         	ws_this = this;
         
         	
         	if($(ws_this).hasClass('activeRoom')){
         		
         	}else{
         		$('.room-name').removeClass('activeRoom');
         		$('.wsRoomSumContainer').removeClass('wsActive');
         		$(ws_this).addClass('activeRoom');
         		
         		$(ws_this).siblings('.wsRoomSumContainer').addClass('wsActive');
         	}
         });
         
    $('.wsRoomPrevNext a').addClass('wsGreenButton');
    $('.wsRoomPrevNext a:first-child').addClass('wsButtonLeft');
    $('.wsRoomPrevNext a:last-child').addClass('wsButtonRight'); 
    
    /* fancy navigation */
    $('.pageHeader .menu > ul > li > ul.sub-menu').hide();
    
    $('.pageHeader .menu > ul > li').hover(
    	function(){    
   		 	$($(this).children()[1]).stop(true, true).css('display', 'block').animate({opacity: 1}, 500, function(){});
    	},
    	function() {
    		$($(this).children()[1]).stop(true, true).css('display', 'none').animate({opacity: .0}, 300, function(){});
    	});
    	
    		
    /* Directions tabs */
    
    $('#wsPopTabs').tabs();
    // JavaScript Document
    
    $('.attContainer').hide();
    
    $('.attractionList li').click(function(){
    	
    	$(this).next().slideToggle();
    });
    
   $('<div class="pagetopdiv"></div><div class="pagebottomdiv"></div><div class="pagerightdiv"></div><div class="pageleftdiv"></div>').appendTo('#fancybox-wrap');
   
   /* Randomly possition leaves */
   
   var leafNum = Math.floor(Math.random()*7);
   var leaf1 = 'bodyLeaf1';
   var leaf2 = 'bodyLeaf2';
   var leaf3 = 'bodyLeaf3';
   var leaf4 = 'bodyLeaf4';
   var leaf5 = 'bodyLeaf5';
   var leafArray = new Array(leaf1, leaf2, leaf3, leaf4, leaf5);
   var leafHeight = $('.layout2Cols').innerHeight();
   
   for(var i = 0; i <= leafNum; i++){
   		var leafLeft = Math.floor(Math.random()*937);
 		var leafTop = Math.floor(Math.random()*(leafHeight + 1));
   		var leafSelect = Math.floor(Math.random()*5);
   		$('<div class="wsLeafSprite wsLeaf'+i+'"></div>').appendTo('.layout2Cols');
   		$('.wsLeaf'+i).addClass(leafArray[leafSelect]).css({'top' : leafTop, 'left' : leafLeft});
   		
   		//console.log(i);
   		
   }
   
   
   
   
   
   
   
   
   
   
   
});
