<script language="JavaScript">
function beginDrag(elementToDrag,event)
{
	var deltaX=event.clientX-parseInt(elementToDrag.style.left);
	var deltaY=event.clientY-parseInt(elementToDrag.style.top);
 
	if(document.addEventListener)
	{
		document.addEventListener("mousemove",moveHandler,true);
		document.addEventListener("mouseup",upHandler,true);
	}
	else if(document.attachEvent)
	{
		document.attachEvent("onmousemove",moveHandler);
		document.attachEvent("onmouseup",upHandler);
	}
 
	if(event.stopPropagation)   
		event.stopPropagation();
	else 
		event.cancelBubble=true;
	
	if(event.preventDefault)  
		event.preventDefault();
	else 
		event.returnValue=false;

 function moveHandler(e) 
 {
　　if (!e) e=window.event; //如果是IE的事件对象，那么就用window.event
　　//全局属性，否则就用DOM二级标准的Event对象。
    elementToDrag.style.left=(event.clientX-deltaX)+"px";
    elementToDrag.style.top=(event.clientY-deltaY)+"px";
   
    if(event.stopPropagation)   
		event.stopPropagation();
    else 
		event.cancelBubble=true;
  }
 
function upHandler(e)
{
	
	if(document.removeEventListener)
    {
		document.removeEventListener("mouseup",upHandler,true);
		document.removeEventListener("mousemove",moveHandler,true);
	}
	else
    {
      document.detachEvent("onmouseup",upHandler);
      document.detachEvent("onmousemove",moveHandler);
	}
	window.location.href='./mapStatus.php?command=save&drag_x='+elementToDrag.style.left+"&drag_y="+elementToDrag.style.top+"&drag_key_led_num="+elementToDrag.id+"&needDragElement="+needDragElement+"&showingPageType="+showingPageType+"&typeOffset="+typeOffset+"&maxPageNum="+maxPageNum+"&maxLedNum="+maxLedNum+"&bg_img="+bg_img;

 }
	
    if(event.stopPropagation)   
		event.stopPropagation();
    else 
		event.cancelBubble=true;
  } 
</script>

