 // PRE LOADER OF IMAGES ---------------------------------------------------------------------------
//http://perishablepress.com/press/2009/12/28/3-ways-preload-images-css-javascript-ajax/

<!--//--><![CDATA[//><!--


			if (document.images) {
		var img1 = new Image();
		var img2 = new Image();
		var img3 = new Image();
		var img4 = new Image();
		var img5 = new Image();
		var img6 = new Image();
		var img7 = new Image();
		var img8 = new Image();
		var img9 = new Image();
		var img10 = new Image();
		var img11 = new Image();
		var img12 = new Image();
		var img13 = new Image();
		var img14 = new Image();
		var img15 = new Image();
		var img16 = new Image();
		var img17 = new Image();

		img1.src = "imgs/full_bkg/misc1_bkg.jpg";
		img2.src = "imgs/full_bkg/misc2_bkg.jpg";
		img3.src = "imgs/full_bkg/misc3_bkg.jpg";
		img4.src = "imgs/content_bkg.png";
		img5.src = "imgs/header_bkg.png";
		img6.src = "imgs/header_curve.png";
		img7.src = "imgs/logo.png";
		img8.src = "imgs/footer_bkg.png";
		img9.src = "imgs/sub_nav_divider.png";
		img10.src = "imgs/subnav_bkg.png";
		img11.src = "imgs/content_base.png";
		img12.src = "imgs/full_bkg/misc4_bkg.jpg";
		img13.src = "imgs/full_bkg/misc5_bkg.jpg";
		img14.src = "imgs/full_bkg/misc6_bkg.jpg";
		img15.src = "imgs/full_bkg/misc7_bkg.jpg";
		img16.src = "imgs/full_bkg/misc8_bkg.jpg";
		img17.src = "imgs/full_bkg/misc9_bkg.jpg";
			}

		//--><!]]>
 
 $(document).ready(function() {
	 var speed = 150; //speed of animations
	 var hover_current = false;
	 
	$(window).resize();
	 
	$('.nav_main ul li').append('<div class="nav_hover"></div>');
	$('.dropdown_nav li').append('<div class="nav_hover"></div>').click(function() {window.location = $('a', this).attr('href');});
	$('.home_vislinks').prepend('<div class="imghover"></div>');
	
	
	$('body').append($('.tasting_notes'));
	
	if ($('html').hasClass('ie7') == false) {
		$('#backstretch_container #backstretch').css({
			opacity :	'0.0',
			filter :	'alpha(opacity=0)',
			display :	'block'
		});
		
		$('#backstretch_container #backstretch:first').css({
			opacity :	'1.0',
			filter :	'alpha(opacity=100)',
			display	: 'block'
		});
	}
	
	
	$(function() {
		$('#tasting_notes a, #wines_list a').leanModal({ top : (($(window).height() - $('.tasting_notes').outerHeight())/2)});
	});
	
   $('.home_vislinks').hover(function() {
		$('.imghover', this).toggleClass('hover_on');
		$('.hover_on', this).animate({opacity: 0.50}, speed, function() {});
	},function() {
		$('.hover_on', this).animate({opacity: 0.00}, speed, function() { $(this).toggleClass('hover_on'); });   
	});
	
	$('.home_vislinks').click(function() {
		window.location = $('a', this).attr('href');
	});
	
	$('.nav_main ul li').hover(function() {
		var button_width = $(this).width(); 
		$('.nav_hover', this).width(button_width);
		$('.nav_hover', this).toggleClass('hover_on');	
		$('.hover_on', this).animate({opacity: 0.70}, speed, function() {});
	}, function() {
		$('.hover_on', this).animate({opacity: 0.00}, speed, function() { $(this).toggleClass('hover_on'); });
	});
	
	 // DROPDOWN CODE --------------------------------------------------------------------------------
	 

	
	
	
	$('.dropdown_nav li[class!="no_hover spacer"]').hover(function() {
		var button_width = $(this).innerWidth() - 2; //- is used so the location of the hover effect does not overlap over the border 
		$('.nav_hover', this).width(button_width);
		$('.nav_hover', this).toggleClass('hover_on');	
		$('.hover_on', this).animate({opacity: 0.50}, speed, function() {});
	}, function() {
		$('.hover_on', this).animate({opacity: 0.00}, speed, function() { $(this).toggleClass('hover_on'); });
	});
	
	
	
	 // DROPDOWN CODE END -------------------------------------------------------------------------------
	

	
 // SLIDE TO PROFILE --------------------------------------------------------------------------------
	
	$('.slide_to').click(function() {
   		var elementClicked = $(this).attr("href");
   		var destination = $(elementClicked).offset().top;
   		$("html:not(:animated),body:not(:animated)").animate(
			{ scrollTop: destination-180}, 
				{
                    duration: 2000,
                    easing: 'easeInOutQuint'
                })
			
   		return false;
	});

 });
 
  // SLIDE SHOW FOR INDEX --------------------------------------------------------------------------------

 
$(window).load(function() {
	
			$(window).resize();
		
		if ($('html').hasClass('ie7') == false) {
			$('#backstretch_container #backstretch').css({
				display :	'block'
			});
		}
		
		
		
		if ($('html').hasClass('ie7') == false) {
		 $('#backstretch_container').cycle({
			fx: 'fade',
			cleartypeNoBg : 'true',
			speed:         800,
			timeout:       8000
			//nowrap:        1     // true to prevent slideshow from wrapping 
			//pager:         '.slideshow'  // element, jQuery object, or jQuery selector string for the element to use as pager container 
	     });
		}
		
		
    });
	
	
$(window).resize(function(){
	 $('#backstretch_container').width($(window).width());
	 $('#backstretch_container').height($(window).height());
	 
	 $('#backstretch_container #backstretch').width($(window).width());
	 $('#backstretch_container #backstretch').height($(window).height());
});
