var mouseDown = false;
var activeWindowId = null;

var mouseDownX = 0;
var mouseDownY = 0;

function DBKITWindowMouseDown(id) {
//	alert("down");

	activeWindowId = id;
	
	mouseDown = true;
	
	if (window.event) {
		mouseDownX = window.event.clientX;
		mouseDownY = window.event.clientY;
	}
	else {
        mouseDownX = id.pageX;
        mouseDownY = id.pageY;
	}
	
	return true;
}

function DBKITWindowMouseUp() {
//	alert("up");

	activeWindowId = null;
	
	mouseDown = false;

	return true;
}

function DBKITWindowMouseMove(netscape_event) {
//	alert("move");

	if (mouseDown) {
		windowStyle = DBKITGetStyleElementById(activeWindowId);		
		
		var X, Y;
		
		if (window.event) {
			X = window.event.clientX;
			Y = window.event.clientY;
		}
		else {
			X = netscape_event.pageX;
			Y = netscape_event.pageY;
		}
		
		windowStyle.left = parseInt(windowStyle.left) + X - mouseDownX;		
		windowStyle.top = parseInt(windowStyle.top) + Y - mouseDownY;
		
		if (parseInt(windowStyle.left) < 0)
			windowStyle.left = 0;
			
		if (parseInt(windowStyle.top) < 0)
			windowStyle.top = 0;
		
		mouseDownX = X;
		mouseDownY = Y;
		
		if (document.selection)
			document.selection.empty();
						
//		alert (X + " " + Y);

		return true;
	}	
}