$(function(){
	//Get our elements for faster access and set overlay width
	var div = $('div.sc_menu'),
		ul = $('ul.sc_menu'),
		ulPadding = 0;
	
	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars	
	div.css({overflow: 'hidden'});
	
	//Find last image container
	var lastLi = ul.find('li:last-child');
	
	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding ;	
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
});

function makeFotoClickable(){
$('.sc_menu a').click(function(){
var img = $(this).attr('href');
$('#bigfoto img').fadeOut(500, function(){
$('#bigfoto').html('<img src="'+img+'">');
});
return false;
});
}

$(function (){
makeFotoClickable();
});

$(function($) {
	$.fn.jfade = function(settings) {
   
	var defaults = {
		start_opacity: "1",
		high_opacity: "1",
		low_opacity: ".2",
		timing: 200
	};
	var settings = $.extend(defaults, settings);
	settings.element = $(this);
			
	//set opacity to start
	$(settings.element).css("opacity",settings.start_opacity);
	//mouse over
	$(settings.element).hover(
	
		
		function () {												  
			$(this).stop().animate({opacity: settings.high_opacity, top:"0px"}, settings.timing); //100% opacity for hovered object
			$(this).siblings().stop().animate({opacity: settings.low_opacity, top:"0px"}, settings.timing); //dimmed opacity for other objects
		},
		
		//mouse out
		function () {
			$(this).stop().animate({opacity: settings.start_opacity, top:"0px"}, settings.timing); //return hovered object to start opacity
			$(this).siblings().stop().animate({opacity: settings.start_opacity, top:"0px"}, settings.timing); // return other objects to start opacity
		}
	);
	return this;
	}
	
})(jQuery);

