$("#main_map").live('mousedown', function(e){	var posX = e.pageX;	var posY = e.pageY;		var map_initX = parseInt($("#main_map").css("marginLeft"));	var map_initY = parseInt($("#main_map").css("marginTop"));		var img_width = $("#main_map img").get(0).width;	var img_height = $("#main_map img").get(0).height;		var map_width = parseInt($("#map_content").css("width"));	var map_height = parseInt($("#map_content").css("height"));		$(document).mousemove(function(e){			new_left = map_initX - (posX - e.pageX);		new_top = map_initY - (posY - e.pageY);				if(new_left>0)			new_left=0;		else if(new_left+img_width<map_width)			new_left = map_width - img_width;				if(new_top>0)			new_top=0;		else if(new_top+img_height<map_height)			new_top = map_height - img_height;				//console.log(top);		//console.log($("#main_map img").get(0).height - parseInt($("#main_map").css("height")));				$("#main_map").css({			marginLeft : new_left+"px",			marginTop : new_top+"px"		});				return false;	});			$(document).mouseup(function(e){		if(posX==e.pageX && posY==e.pageY)			click(e);				$(document).unbind("mousemove");		$(document).unbind("mouseup");		return false;	});		return false;});	$("#main_map area").live('mousemove', function(e){	var id = $(this).attr("id");	var pos = findPos($(".corps").get(0));	var left = e.pageX - pos.x +5 ;	var top = e.pageY - pos.y +5 ;	$("#description_"+id).css({		marginLeft : left+"px",		marginTop : top+"px",		display : "block"	});		$("#main_map area").bind('mouseout', function(e){		var id = $(this).attr("id");		$("#description_"+id).css({			display : "none"		});				$("#main_map area").unbind('mouseout');	});		});/** DEPLACEMENT **/var perso = new Array;perso.x = 228;perso.y = 144;function click(e){	var pos = findPos($("#main_map").get(0));	var left = e.pageX - pos.x ;	var top = e.pageY - pos.y ;	cherche_chemin(perso.x, perso.y, left, top);}function cherche_chemin(dx, dy, ax, ay){	//drawLine(dx, dy, ax, ay, 2, "#1D375F", 100, "main_map");}var move = false;var posX = 0;var posY = 0;var left = 0;var top = 0;var new_left = 0;var new_top = 0;function findPos(obj) {    var curleft = obj.offsetLeft || 0;    var curtop = obj.offsetTop || 0;    while (obj = obj.offsetParent) {            curleft += obj.offsetLeft            curtop += obj.offsetTop    }    return {x:curleft,y:curtop};}
