$(document).ready(function(){

	//preload images	
	jQuery.preloadImages = function()
	{
	  for(var i = 0; i<arguments.length; i++)
	  {
	    jQuery("<img>").attr("src", arguments[i]);
	  }
	}
	
	$.preloadImages(
		"images/outdoors.png", 
		"images/menuImg.png",
		"images/location.png",
		"images/catering.png",
		"images/contactUs.png",
		"images/localFarm.png",
		"images/bBistro.png", 
		"images/outdoors2.png"
	)
	
	
	//slideshow
	$('#slideshow ul').after('<div id="controls" class="nav">').cycle({
		fx:    'fade',
		timeout: 4500,
		pager: '#controls',
		pauseOnPagerHover: 1,
		speed:  350, 
		pause: 1
	 });
	 
	 $('#controls').css('display', 'none');
	 
	 $('#slideshow').hover(
	 	function(){
	 		$('#controls').fadeIn(300);
	 	},
	 	function() {
	 		$('#controls').fadeOut(300);
	 	
	 	}
	 );
	
	
	
	//rollover effects for image buttons
	$("a.bttn").hover(
		function() {
			$(this).stop().animate({"opacity": ".7"}, "fast");
		},
		
		function() {
			$(this).stop().animate({"opacity": "1"}, "fast");
	});
	
	$('.fade-area').children().hover(function() {
		$(this).siblings().stop().fadeTo(300,0.5);
		$(this).css('cursor', 'pointer')
	}, function() {
		$(this).siblings().stop().fadeTo(300,1);
	});
	
	
	//primary Nav	
	var currentPage = 'menu';
	
	$.ajax({
	  url: currentPage + '.html',
	  cache: false,
	  success: function(html){
		$("#subMcol").html(html);
	  }
	});
	
	
	$('#header ul li a').click(function(){

		$(this).parent().addClass('active');
					
		$(this).parent().siblings().removeClass('active');
		
		$('.subCallout').css('background-position', '-102px -432px');
		$('.subCallout').css('background-color', '#100006');
		
		var targetPage = $(this).attr("title") + '.html';
		
		$.ajax({
		  url: targetPage,
		  cache: false,
		  success: function(html){
			$('#subMcol div').fadeOut(200, function(){
				$(this).html(html).fadeIn('200');
				})
				
		   }
		});
		
	});
	
	
	//scrollTo
	$('#header ul li a').click(function(){
		$.scrollTo('#subMcol', 600);
		return false;	
	});
	
	
	//tertiarey nav
	$('.subCallout').click(function(){
		
		$('#header ul li').removeClass('active');
		
		$(this).addClass('active');
		$(this).css('background-color', '#300006');
		$(this).siblings().removeClass('active');
		$(this).siblings().css('background-color', '#100006');
					
		var targetPage = $(this).attr("title") + '.html';
		
		$.ajax({
		  url: targetPage,
		  success: function(html){
			$('#subMcol div').fadeOut(200, function(){
				$(this).html(html).fadeIn('200');
				})
				
		   }
		});
		return false;
		
	})

			
});