var isNN=!document.all&&document.getElementById;
var isHot=false;
var currLayerName="";
var selLayer;


function ddInit(e){
  if (currLayerName!=''){
	topDog=iens6 ? "BODY" : "HTML";
	selLayer=getObject(currLayerName);  
	hotDog=(iens6&&!isNN) ? event.srcElement : e.target;
	


	while (hotDog.id!=currLayerName&&hotDog.tagName!=topDog){
		hotDog=(iens6&&!isNN) ? hotDog.parentElement : hotDog.parentNode;
	}  
	
	if (hotDog.id==currLayerName){
		offsetx=(iens6&&!isNN) ? event.clientX : e.clientX;
		offsety=(iens6&&!isNN) ? event.clientY : e.clientY;
		

			
		nowX=parseInt(selLayer.style.left);
		nowY=parseInt(selLayer.style.top);
		ddEnabled=true;
		document.onmousemove=dd;
	}
  }
}

function dd(e){
  if (!ddEnabled) return;
  selLayer.style.left=(iens6&&!isNN) ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  selLayer.style.top=(iens6&&!isNN) ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!ns4) return;
  N4=getObject(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function mveLyr(lyr){
	currLayerName=lyr;isHot=true;if(ns4){ddN4(lyr);}
}
function stpMveLyr(){
	currLayerName='';isHot=false;
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");

