$(document).ready(
	function () {
		
	//	function CufonEaves() {
	//		Cufon.set('fontFamily', 'MrsEaves').replace('#header h3')('.headSearch-block label');
	//	}
		Cufon.replace('#header h3, .headSearch-block label',
			{
				fontFamily: 'MrsEavesRoman'
			});
		function menuReplace() {
			Cufon.replace(' .mainMenu a.menuLink',
				{
					fontFamily: 'MrsEavesRoman',
					hover: {
						color:'#ffffff'
						}
				});
		}
		Cufon.replace('.inside-cell h3, #showMap h3, #content h2, #content h3.title, .title-section h3, li.tab-item .border, #footer h3, #footer label, #content .widget-box h1, #content .widget-box h2',
			{
				fontFamily: 'Interstate'
			});
		Cufon.replace('.lPost h3, #topMenu .title, .main-tabs li.main-tabs-item .r-b, #content h1,',
			{
				fontFamily: 'MrsEaves',
				fontStyle: 'italic',
				hover: true
			});
		Cufon.replace('#content .widget-box h1, #content .widget-box h2, #content .widget-box h3, #content .lodge-cat h3',
			{
				fontFamily: 'Interstate'
			});
		Cufon.replace(' #content .lodge-cat h2',
			{
				fontFamily: 'MrsEaves',
				fontStyle: 'italic',
				hover: true
			});
		$("a.inline-popup").fancybox({
			padding: 20,
			margin: 0,
			autoScale: false,
			scrolling: 'no',
			titleShow: false,
			showNavArrows: false,
			autoDimensions: false,
			overlayOpacity: 0.7,
			overlayColor: '#000',
			width: 676,
			height: 672,
			onComplete: function() {
					$("#fancybox-wrap").addClass('maps');
				},
			onClosed: function() {
					$("#fancybox-wrap").removeClass('maps');
				}
				
		});
		$("a.form-popup").fancybox({
			padding: 5,
			margin: 0,
			autoScale: false,
			scrolling: 'no',
			titleShow: false,
			showNavArrows: false,
			autoDimensions: false,
			overlayOpacity: 0.7,
			overlayColor: '#000',
			width: 800,
			height: 'auto',
			onComplete: function() {
					$("#fancybox-wrap").addClass('form-popup');
					Cufon.replace('h1',
						{
							fontFamily: 'MrsEaves',
							fontStyle: 'italic'							
						});
				},
			onClosed: function() {
					$("#fancybox-wrap").removeClass('form-popup');
				}	
		});
		$("a.gallery-popup").fancybox({
			ajax : 
				{
		    		type	: "GET",
					cache	: false,
					dataType: 'html'
			},
			padding: 5,
			margin: 0,
			autoScale: false,
			scrolling: 'no',
			titleShow: false,
			showNavArrows: false,
			autoDimensions: false,
			overlayOpacity: 0.7,
			overlayColor: '#000',
			width: 990,
			height: 726,
			onComplete: 
				 function(el) {
				 $("#fancybox-wrap").addClass('gallery-popup');
				 Cufon.replace('h1',
				  {
				   fontFamily: 'MrsEaves',
				   fontStyle: 'italic'       
				  });
				 $('#include-gallery').galleryView({
					  panel_width: 915,
					  panel_height: 487,
					  frame_width: 126,
					  frame_height: 126,
					  background_color: '#000000',
					  border: 'none',
					  overlay_color: 'none',
					  overlay_height: 40,
					  overlay_text_color: '#ffffff',
					  caption_text_color: '#ffffff'
				 });
				 $("#include-gallery .filmstrip li:eq(" + $(el).attr('rel') + ")").click();
				 function showGallery() {
					 	
						 $('.gallery-wrap').css({ zIndex: '100' });
						 $('.loading').css({ zIndex: '-100' });
					 }
				 setTimeout( showGallery, 2000);
			},
			onClosed: function() {
					$("#fancybox-wrap").removeClass('gallery-popup');
					$("#include-gallery .filmstrip").unwrap();
				}	
		});
	// Tabs
		$('.tabs-wrap').tabs({selected: 0});

	// Gallery
		$('.ad-gallery').adGallery({
			width: 295, 
		  	height: 219,
			slideshow: {enable: false},
			callbacks: {
				beforeImageVisible: function(){
					Cufon.replace('#content h3',
						{
							fontFamily: 'Interstate'
						});
					}
				}
		});
//-------------------------------------------------------
		
	function showHidden(thisBlock) { $('.' + thisBlock + ' .drop-block').show()};
	function hideHidden(thisBlock) { $('.' + thisBlock + ' .drop-block').hide()};
    
    var reservationsClass = 'reservations-block';
    var reservationsTimer = null;
    var isFocused = false;
    var isHovered = false;
    
	$('.' + reservationsClass).hover( 
		function(){
			isHovered = true;
			clearTimeout(reservationsTimer);
			reservationsTimer = setTimeout( "$('." + reservationsClass + " .drop-block').show()", 3000 );
		},
		function(){
        	isHovered = false;
	        clearTimeout(reservationsTimer);
    	    if(!isFocused) {
			hideHidden(reservationsClass);
		}
	});
    
	$('input, select', '.' + reservationsClass).focusin(
		function() {
			isFocused = true;
			clearTimeout(reservationsTimer);
			showHidden(reservationsClass);
		});
    
	$('input, select', '.' + reservationsClass).focusout(
		function() {
			isFocused = false;
			clearTimeout(reservationsTimer);
			if(!isHovered) {
				hideHidden(reservationsClass);
			}
	});
	
	var hover_on_menu = false;
	var lastLI;
	var timeShow;
	var timeHide;

	function hideMenu()
	{	
		if(lastLI != undefined) {
			$('.drop-block', lastLI).hide();
			lastLI.removeClass('hover');
			menuReplace();
		}
	}

	function makeTall(){  $('.drop-block', this).show(); $(this).addClass('hover');}

	function makeShort(){ $('.drop-block', this).hide(); $(this).removeClass('hover'); menuReplace()}
	
	var configMenu = {    
	     sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
    	 interval: 150, // number = milliseconds for onMouseOver polling interval    
	     over: makeTall, // function = onMouseOver callback (REQUIRED)    
	     timeout: 400, // number = milliseconds delay before onMouseOut    
    	 out: makeShort // function = onMouseOut callback (REQUIRED)    
	};
	$("ul.mainMenu > li.menuItem").hoverIntent( configMenu );
	menuReplace();
	});
