 
$(document).ready(function() {	

	//Background color, mouseover and mouseout
	var colorOver = '#5D94CD';
	var colorOut = '#069';

	//Padding, mouseover
	var padLeft = '20px';
	var padRight = '20px';
	
	// padding out
	var padLeft2 = '10px';
	var padRight2 = '10px';
	
	
	//Animate the LI on mouse over, mouse out
	$('#scrollmenu li').click(function () {	
		//Make LI clickable
		window.location = $(this).find('a').attr('href');
		
	}).mouseover(function (){
		
		//mouse over LI and look for A element for transition
		$(this).find('a')
		.animate( { paddingLeft: padLeft, paddingRight: padRight}, { queue:false, duration:100 } )
		.animate( { backgroundColor: colorOver }, { queue:false, duration:200 });

	}).mouseout(function () {
	
		//mouse oout LI and look for A element and discard the mouse over transition
		$(this).find('a')
		.animate( { paddingLeft: padLeft2, paddingRight: padRight2}, { queue:false, duration:100 } )
		.animate( { backgroundColor: colorOut }, { queue:false, duration:200 });
	});	
	
	//Scroll the scrollmenu on mouse move above the #sidebar layer
	$('#sidebar').mousemove(function(e) {

		//Sidebar Offset, Top value
		var s_top = parseInt($('#sidebar').offset().top);		
		
		//Sidebar Offset, Bottom value
		var s_bottom = parseInt($('#sidebar').height() + s_top);
	
		//Roughly calculate the height of the scrollmenu by multiply height of a single LI with the total of LIs
		var mheight = 220; //parseInt($('#scrollmenu li').height() * $('#scrollmenu li').length);
	
		//I used this coordinate and offset values for debuggin
		$('#debugging_mouse_axis').html("X Axis : " + e.pageX + " | Y Axis " + e.pageY);
		$('#debugging_status').html(Math.round(((s_top - e.pageY)/100) * mheight / 2));
			
		//Calculate the top value
		//This equation is not the perfect, but it 's very close	
		var top_value = Math.round(( (s_top - e.pageY) /100) * mheight / 2);
		
		//Animate the #scrollmenu by chaging the top value
		$('#scrollmenu').animate({top: top_value}, { queue:false, duration:500});
	});

	
});

