// Copyright (c) 2006-2007, Powermand Inc. All Rights Reserved.

// Position Related Functions
// Requires js.toolbox.js

function leftCoord(Obj){ return (document.layers)? $TB(Obj).x : $TB(Obj).offsetLeft; }
function topCoord(Obj){ return (document.layers)? $TB(Obj).y : $TB(Obj).offsetTop; }
function bottomCoord(Obj){ return height(Obj) + topCoord(Obj) }
function rightCoord(Obj){ return width(Obj) + leftCoord(Obj) }
function width(Obj){ return parseInt((document.layers)? $TB(Obj).style.width : $TB(Obj).offsetWidth )}
function height(Obj){ return parseInt((document.layers)? $TB(Obj).style.height : $TB(Obj).offsetHeight )}
function inBounds(x,y,bounds){
			if(y<topCoord(bounds) || y>bottomCoord(bounds) ||
			   x<leftCoord(bounds) || x>rightCoord(bounds)) return false
			else return true;	
		}

var mouseX = 0;
var mouseY = 0;	
//var DragEvents = new EventCache();
var DragEvents= new Observer();
var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
if (!IE) document.captureEvents(Event.MOUSEUP)
document.onmousemove = getMouseXY;
		
function getMouseXY(e) {
	if (IE) { // IE
		mouseX = event.clientX + document.body.scrollLeft
		mouseY = event.clientY + document.body.scrollTop
	} else {  // NS
		mouseX = e.pageX;
		mouseY = e.pageY;
	}  
	//DragEvents.execute();
	DragEvents.fire();
  }
  
 function reposition(ObjToMove,leftPos,topPos){
		$TB(ObjToMove).style.left = leftPos+'px';
		if(topPos!=null) $TB(ObjToMove).style.top = topPos+'px';
	}  