$(document).ready(function() {
		 $("#logo").hover(function(){
     		 $(this).animate({ opacity: 0.5 }, 500 );
   		 }, 
		 function(){
		 	 $(this).animate({opacity:1}, 500);
		});
		
		function getY( oElement )
				{
					var y = 0;
					while( oElement != null ) {
					y += oElement.offsetTop;
					oElement = oElement.offsetParent;
				}
					return y;
				}
				var navH = $("#nav").height();
				var navChildren = $("#nav").children().size();
				var pOffset = navH / navChildren;
				var p = document.getElementById('nav');
				var startPos = 108; //getY(p);
				
				
				
				$("#nav li a").each(function(i){
				$(this).attr('offset', i)
				
				});
				
 				var visId = $("#visible").val();
				$(visId).css({'display' : 'block'});
				$('#nav li a').each(function(){
				$(this).click(function(e){
				var p = document.getElementById('nav');
				var y = getY(p);
					var s = '#' + $(this).attr('id') + 'Details';
					var curr = $("#visible").val();
				$(curr).fadeOut("fast", function(){
				$(s).fadeIn("fast");
				});
				$("#visible").val(s);
				var move = $(this).attr('offset') * pOffset;
				var newPos = startPos - move;
				var dis = y - newPos;
				var goTo = $(this).attr("href");
				$("#nav").animate({ top: "-=" + dis }, 500, 0, function(){
				if(goTo != ''){
					window.location.href = goTo;
					}
					});
				return false;
			});
		});
	});