$(function(){
	
	$("body #images img:first").show();		
	
		$(".navigation > li").each(function() {
		var active = false;
		$(this).find("a").each(function() {
			if (document.location.href.match($(this).attr("href")) && $(this).attr("href") != "index.html"  ) { active = true; }								
		});
		
		if (active) { $(this).addClass("active"); }
	});
	
	$("ul.navigation li").css({"visibility":"visible"});
  Cufon.replace(".navigation > li > a", {fontFamily:"Myriad Pro Bold"});
   Cufon.now();
		   
  $(".navigation li").hover(function(){
    $(this).addClass("hover");
    var width = $(this).children("ul").width();
    $(this).find("li").each(function(){
      $(this).width(width);
    })
  },function(){$(this).removeClass("hover")});
  

  $("#content *:last-child").addClass("last")


  
  $("#content select").change(function(){
		if ($(this).val()) { document.location = $(this).val();}									 
  });

  //Cufon.replace("h1", {fontFamily:"Myriad Pro Light"})
  $('.scroll-pane').jScrollPane({"scrollbarMargin":"10", "scrollbarWidth":"4", animateTo:true});
  $(".location #text a").each(function(){
		var link = $(this);
		if (link.attr("href") == "#cafe") {
			link.click(function(){
			$('#text')[0].scrollTo("#cafe");
			return false;
		});
		}
	});
  
  	$('body.gallery .gallery img').each(function(){
		var img = $(this);
		// Add to thumbnails
		$("#" + img.parent(".gallery").attr("id") + "_thumbnails").append('<li><a href="#"><img src="' + img.attr('src') + '" /></a></li>');		
	});
});

$(window).load(function() {
	$("body #images .loading").hide();		
	$("body #images img").show();		
	

  	$('body.gallery #images').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		slideExpr: 'img',
		pager: '#content',
		timeout: 4000,
		speed: 1000,
		pause:  true,  
    	pauseOnPagerHover: true,
		pagerAnchorBuilder: function(idx, slide) { 
        	return '#content a:eq(' + idx + ')'; 
   		} ,
		before:  function(current, next) { $("#description").fadeOut(function() { $("#description").html("<h3>"+next.title+"</h3><p>"+next.alt+"</p>").fadeIn();}); }
	});

/*	$('#lunch').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		pager: '#lunch_thumbnails',
		timeout: ($("#thumbnails").length > 0 ? 0 : 4000), 
		pause:  true,  
    	pauseOnPagerHover: true,
		pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#"><img src="' + slide.src + '" /></a></li>';  },
		before:  function(current, next) { $("#description").fadeOut(function() { $("#description").html("<h3>"+next.title+"</h3><p>"+next.alt+"</p>").fadeIn();}); },
		nowrap: true,
		pagerClick:function(idx, slide) {
			$('#dinner').cycle('stop');
			$('#dinner').fadeOut(function() { $('#lunch').fadeIn(); });
		},
		end: function() { $('#lunch').fadeOut(); $('#dinner').cycle(0); }
	});
	
	$('#dinner').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		pager: '#dinner_thumbnails',
		timeout: ($("#thumbnails").length > 0 ? 0 : 4000), 
		pause:  true,  
    	pauseOnPagerHover: true,
		pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#"><img src="' + slide.src + '" /></a></li>';  },
		before:  function(current, next) { $("#description").fadeOut(function() { $("#description").html("<h3>"+next.title+"</h3><p>"+next.alt+"</p>").fadeIn();}); },
		nowrap: true,
		pagerClick:function(idx, slide) {
			$('#lunch').cycle('stop');
			$('#lunch').fadeOut(function() { $('#dinner').fadeIn(); });
		},
		end: function() { $('#dinner img').hide(); $('#lunch').cycle(0); }
	});*/


  $('body:not(".gallery") #images').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		pager: '#thumbnails',
		timeout: ($("#thumbnails").length > 0 ? 0 : 4000), 
		pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#"><img src="' + slide.src + '" /></a></li>';  }
	});
});
