$(document).ready(function() {
	$("li").hover(
	  function () {
		
		$(this).addClass("over");
		
	    child_list = $(this).children("ul");
		if(child_list.position()){
			l = child_list.position().left;
			w = child_list.width();
			overhead = -($(window).width() - (l+w))+35;

			if(overhead > 0){
				overhead = overhead+45;
				child_list.animate({marginLeft : "-"+overhead+"px"}, 0);
			}
		}
	  },
	  function(){
		
		$(this).removeClass("over");
		
	    child_list = $(this).children("ul");
		child_list.animate({marginLeft : ""}, 0);
	  }
	);
});
