$(document).ready(function() {
	
	//click function for home logo
	$('.intro h1.logo, #header h1.logo').click(function() {
		window.location.href = "home.html";
		return false;
	});
	
	//fancybox
	$('a.fancybox').fancybox({
		'overlayOpacity': 0.9
	});
	
	$('a.video').fancybox({
		'overlayOpacity': 0.9,
		'frameWidth': 640,
		'frameHeight': 385
	});
	
	//hover fade  function for images
	$('.photos a img').hover(function() {
		$(this).stop().fadeTo('slow',1);
	},function() {
		$(this).stop().fadeTo('slow',0.6);
	}).fadeTo('fast',0.6);
	
	$('a.video.first img').hover(function() {
		$(this).stop().fadeTo('slow',1);
	},function() {
		$(this).stop().fadeTo('slow',0.6);
	}).fadeTo('fast',0.6);
	
	//cocktail lists remove last border of the li
	$('.cocktailGroup').each(function() {
		$(this).find('li:last').css({'border':'none'});
	});
	
	$('.photos').each(function(){
		var $this = $(this);
		var $imgs = $this.find('img');
		var $imgsAmmount = $imgs.length+1;
		var $imgWidth = 179;
		var $slider = $this.find('.slider');
 		$this.css({
			'width':'585px',
			'overflow':'hidden',
			'position':'relative'
		});
		
		$slider.css({
			'width': $imgWidth*$imgsAmmount,
			'position':'relative'
		});
			
		//Scroll the menu on mouse move above the #sidebar layer
		$this.mousemove(function(e) {
	
			//Sidebar Offset, Top value
			var s_left = parseInt($(this).offset().left);	
			
			//Sidebar Offset, Bottom value
			var s_right = parseInt($(this).width() + s_left);
		
			//Roughly calculate the height of the menu by multiply height of a single LI with the total of LIs
			var mWidth = parseInt($imgWidth*$imgsAmmount);	
				
			//Calculate the top value
			//This equation is not the perfect, but it 's very close	
			//var left_value = Math.round(((s_left - e.pageX	) /100) * mWidth/10);
			var left_value = Math.round((((s_left - e.pageX))/100)*100);

			//Animate the #menu by chaging the top value
			$slider.animate({left: left_value}, { queue:false, duration:100});
		});
		
		$this.hover(function() {
			//nothing
		}, function() {
			$slider.animate({left: 0}, { queue:false, duration:100});	
		});
		
	});
	
});	