jQuery(document).ready(function(){
	var reset, $activeLi, parentOffset;

	/* Get Parent Offet */
	var parentOffset = $('#Nav_Main_Services').position().left + parseInt($('#Nav_Main_Services').css('margin-left'));

	/* Get the active LI if there is one */
	var $activeLi = $('#Nav_Main_Services').find('a.Active').first().closest('li');

	/* Set a handy reference to the pointer */
	$pointer = $('#Nav_Main_Pointer');

	/* Event Handlers */
	$('#Nav_Main_Services li a').hover(
		function(){
			clearTimeout(reset);

			var newLeft = $(this).closest('li').position().left + parentOffset;
			var newWidth = $(this).outerWidth();
			
			$pointer.stop(true);
//			$pointer.fadeIn();
			$pointer.animate({
				left: newLeft,
				width: newWidth,
				opacity: 1
			},{
				duration : 250,
	            queue : false,
	            easing: 'swing',
	       	});

		},
		function(){
			reset = setTimeout(function() {
//				$pointer.animate({top: yPosFade},500);
				/* Go to currently active li */
				if($activeLi.length > 0){
					var newLeft = $activeLi.position().left + parentOffset;
					var newWidth = $activeLi.outerWidth();
			
					$pointer.stop();
			
					$pointer.animate({
						left: newLeft,
						width: newWidth
					},{
						duration : 250,
		        	    queue : false,
		            	easing: 'swing',
			       	});
				}else{
					$pointer.fadeOut();	
				}
			}, 300);
		}
	);
	
	$activeLi.find('a').first().mouseenter();	
	
});


