$(window).load(function () {					

/*-----------------------------------------------------------------------------------*/
/*	Booking Mask and Date Picker
/*-----------------------------------------------------------------------------------*/

	$(function() {
		$( "#datepicker" ).datepicker();
	});

		function getDateStr() {
		var today = new Date();
		var todayStr = (today.getMonth()+1) + "/" + today.getDate() + "/" + today.getFullYear();;
		document.resform.DateIn.value = todayStr;
		}
		getDateStr();
	
/*-----------------------------------------------------------------------------------*/
/*	FlexSlider - http://flex.madebymufffin.com/
/*-----------------------------------------------------------------------------------*/

		$('#main-slider').flexslider({
			animation: "fade",              //Select your animation type (fade/slide)
			slideshow: true,                //Should the slider animate automatically by default? (true/false)
			slideshowSpeed: 7000,           //Set the speed of the slideshow cycling, in milliseconds
			animationDuration: 500,         //Set the speed of animations, in milliseconds
			directionNav: true,             //Create navigation for previous/next navigation? (true/false)
			controlNav: true,               //Create navigation for paging control of each clide? (true/false)
			keyboardNav: false,              //Allow for keyboard navigation using left/right keys (true/false)
			touchSwipe: false,               //Touch swipe gestures for left/right slide navigation (true/false)
			prevText: "Previous",           //Set the text for the "previous" directionNav item
			nextText: "Next",               //Set the text for the "next" directionNav item
			randomize: false,                //Randomize slide order on page load? (true/false)
			slideToStart: 0,                //The slide that the slider should start on. Array notation (0 = first slide)
			pauseOnAction: true,            //Pause the slideshow when interacting with control elements, highly recommended. (true/false)
			pauseOnHover: false,            //Pause the slideshow when hovering over slider, then resume when no longer hovering (true/false)
			controlsContainer: ".flexslider-container"           //Advanced property: Can declare which container the navigation elements should be appended too. Default container is the flexSlider element. Example use would be ".flexslider-container", "#container", etc. If the given element is not found, the default action will be taken.
		});

/*-----------------------------------------------------------------------------------*/
/*	Testimonial Slider 
/*-----------------------------------------------------------------------------------*/

		$('#testimonial-slider').flexslider({
			animation: "fade",              //Select your animation type (fade/slide)
			slideshow: true,                //Should the slider animate automatically by default? (true/false)
			slideshowSpeed: 9000,           //Set the speed of the slideshow cycling, in milliseconds
			animationDuration: 500,         //Set the speed of animations, in milliseconds
			directionNav: false,             //Create navigation for previous/next navigation? (true/false)
			controlNav: false,               //Create navigation for paging control of each clide? (true/false)
			keyboardNav: false,              //Allow for keyboard navigation using left/right keys (true/false)
			touchSwipe: false,               //Touch swipe gestures for left/right slide navigation (true/false)
			prevText: " ",           //Set the text for the "previous" directionNav item
			nextText: " ",               //Set the text for the "next" directionNav item
			randomize: true,                //Randomize slide order on page load? (true/false)
			slideToStart: 0,                //The slide that the slider should start on. Array notation (0 = first slide)
			pauseOnAction: true,            //Pause the slideshow when interacting with control elements, highly recommended. (true/false)
			pauseOnHover: true
			
		});
		 
/*-----------------------------------------------------------------------------------*/
/*	DropDown Menu - http://users.tpg.com.au/j_birch/plugins/superfish/
/*-----------------------------------------------------------------------------------*/	
		 
		 $("#responsive-nav select").change(function() {
  			window.location = $(this).find("option:selected").val();
		 });
		 		
/*-----------------------------------------------------------------------------------*/
/*	Widget Overlay Area - custom, no URL
/*-----------------------------------------------------------------------------------*/	

		var topBar = jQuery('#topbar');
		var logo = jQuery('#logotype');
		
		var topBarHeight = logo.height();
		
		topBar.css({
			height : topBarHeight
		});
		
	
		var widgetOverlay = jQuery('#overlay-master-container');
		var widgetTrigger = jQuery('#overlay-open a');
		
		var widgetOverlayHeight = widgetOverlay.height();
		
		widgetOverlay.css({
			marginBottom : -widgetOverlayHeight,
			display : 'block'
		});
		
		widgetTrigger.addClass('close');
		
		widgetTrigger.toggle( function() {
			 
			widgetOverlay.animate({
				marginBottom : 0
			}, 600, 'easeInOutCirc');
			
			widgetTrigger.removeClass('close');
		
		}, function() {
			
			widgetOverlay.animate({
				marginBottom : -widgetOverlayHeight
			}, 600, 'easeInOutCirc');
			
			widgetTrigger.addClass('close');		
			
		});
	
/*-----------------------------------------------------------------------------------*/
/*	PERSISTENT HEADER - http://css-tricks.com
/*-----------------------------------------------------------------------------------*/
	
	function UpdateTableHeaders() {
	   $(".persist-area").each(function() {
	
	       var el             = $(this),
	           offset         = el.offset(),
	           scrollTop      = $(window).scrollTop(),
	           floatingHeader = $(".floatingHeader", this)
	
	       if ((scrollTop > offset.top) && (scrollTop < offset.top + el.height())) {
	           floatingHeader.css({
	            "visibility": "visible"
	           });
	       } else {
	           floatingHeader.css({
	            "visibility": "hidden"
	           });
	       };
	   });
	}
	
	// DOM Ready
	$(function() {
	
	   var clonedHeaderRow;
	
	   $(".persist-area").each(function() {
	       clonedHeaderRow = $(".persist-header", this);
	       clonedHeaderRow
	         .before(clonedHeaderRow.clone())
	         .css("width", clonedHeaderRow.width())
	         .addClass("floatingHeader");
	
	   });
	
	   $(window)
	    .scroll(UpdateTableHeaders)
	    .trigger("scroll");
	
	});


/*-----------------------------------------------------------------------------------*/
/*	Chosen Select Menu - http://harvesthq.github.com/chosen/
/*-----------------------------------------------------------------------------------*/

	$(".chzn-select").chosen();
 

/*-----------------------------------------------------------------------------------*/
/*	Jump to the Top - custom, no URL
/*-----------------------------------------------------------------------------------*/

	var topLink = jQuery('#back-to-top');
	function jumpToTop(topLink) {		
		if(jQuery(window).scrollTop() > 0) {topLink.fadeIn(150);} 
		else {topLink.fadeOut(150);}
	}
	
	jQuery(window).scroll( function() {jumpToTop(topLink);});
	
	topLink.find('a').click( function() {
		jQuery('html, body').stop().animate({scrollTop:0}, 450);
		return false;
	});


});


      

