// drag action starts here
// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header

isIE=(document.all);
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;
var mouseX = 0;
var mouseY = 0;
var sMsgLayer = null;
var sMsgArea = null;
var activePop = null;

function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  sMsgLayer = isIE ? document.all.sMsgLayer : document.getElementById("sMsgLayer");

  hotDog=isIE ? event.srcElement : e.target;
  while(hotDog.id!="sTitleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
    if(hotDog==null)return;
  }
 
  if(hotDog.id=="sTitleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(sMsgLayer.style.left);
    nowY=parseInt(sMsgLayer.style.top);

    ddEnabled=true;
    document.onmousemove=dd;
  }
}
       
function dd(e){
	if (!ddEnabled) return;
	var activeElement = isIE ? event.srcElement : e.target;

	if(activeElement.id != null && activeElement.id.length>0){
		activePop = activeElement.id;
	}

	if(activePop == "sMsgCaption"){
	  //hede(sMsgLayer.id, isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx, isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety);
	  //sMsgLayer.moveTo(isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx, isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety);
	  try{
		  sMsgLayer.style.left = (isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx) + "px;";
		  sMsgLayer.style.top = (isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety) + "px;";
	  }catch(e){
		try{
		  sMsgLayer.style.left = (isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx);
		  sMsgLayer.style.top = (isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety);
		}catch(f){}
	  }
	}

	return false;
}

function hede(obj, moveX, moveY){
	//dbg(obj+"<br>"+moveX+"<br>"+moveY);
	document.getElementById(obj).style.left = moveX+"px";
	document.getElementById(obj).style.top = moveY+"px";
}

function ddN4(whatDog){
  if (!isN4) return;
  
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    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 init() {
  if ( isNN )
  document.captureEvents(Event.MOUSEMOVE)
  document.onmousemove = handleMouseMove;
}

function handleMouseMove(evt) {
  mouseX = isNN ? evt.pageX : window.event.clientX;
  mouseY = isNN ? evt.pageY : window.event.clientY;

  mouseX = (isIE)?mouseX+document.body.scrollLeft:mouseX;
  mouseY = (isIE)?mouseY+document.body.scrollTop:mouseY;
  //offsetY=isIE ? event.clientY : evt.clientY;    
  //window.status = "Mouse: X="+mouseX+",Y="+mouseY;
  //dbg("Mouse: X="+mouseX+",Y="+mouseY);
  //return false;
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false; init();");
document.onmousemove=init;
/// drag action finishes here
