// initialize some global variablesvar ie = (document.all) ? true : false;var nn = (document.layers) ? true : false;// OBJECT DEFINITION:      Dragfunction Drag(lyrid) {	this.css = (nn) ? document.layers[lyrid] : document.all[lyrid];	this.layerid = lyrid;	this.startX =  null;	this.startY = null;	this.width =  null;	this.height =  null;	this.offsetX = null;	this.offsetY = null;	this.upperlimit = -1000;	this.leftlimit = -4000;	this.lastclicked = 0;	this.z = (nn) ? this.css.zIndex : this.css.style.zIndex;}if (ie) {	Drag.prototype.shiftTo = function(newX, newY) {		if (this.leftlimit > newX ) newX = this.leftlimit;		if (this.upperlimit > newY) newY = this.upperlimit;		this.css.style.pixelLeft = newX;		this.css.style.pixelTop =  newY;	}	Drag.prototype.clipTo = function(left, top, right, bottom) {		var rectstring = "rect("+top+","+right+","+bottom+","+left+")";		this.css.style.clip = rectstring;		}	Drag.prototype.show = function() {	this.css.style.visibility = "inherit"; }	Drag.prototype.hide = function() {	this.css.style.visibility = "hidden"; }	Drag.prototype.getX = function(e) {	   return event.x + document.body.scrollLeft; }	Drag.prototype.getY = function(e) {	   return event.y + document.body.scrollTop; }	Drag.prototype.getLeft = function() { 	return this.css.style.pixelLeft; }	// IE 5 on a PC always returns 0 this unless the layer has been moved.	Drag.prototype.getTop = function() {	return  this.css.style.pixelTop; }	Drag.prototype.getWidth = function() {	return  this.css.clientWidth; }	Drag.prototype.getHeight = function() {	return  this.css.clientHeight; }	Drag.prototype.getVisibility = function() {	return this.css.style.visibility; }	Drag.prototype.setZIndex = function(z) {	this.css.style.zIndex = z; }	Drag.prototype.writeIt = function(stuff) {	this.css.innerHTML = stuff; }	Drag.prototype.images = function(item) {			if (item) return document.all[item]; return document.all; }	Drag.prototype.forms = function(item) {			if (item) return document.forms[item]; return document.forms; }	Drag.prototype.setLastClicked = function() {		// will not work in IE.  use the onDblClick event in <a href>	}	Drag.prototype.wasDoubleClicked = function() {		// will not work in IE.  use the onDblClick event in <a href>	}}if (nn) {	Drag.prototype.shiftTo = function(newX, newY) {		if (this.leftlimit > newX ) newX = this.leftlimit;		if (this.upperlimit > newY) newY = this.upperlimit;		this.css.moveTo(newX, newY);	}	Drag.prototype.clipTo = function(left, top, right, bottom) {		this.css.clip.left = left;		this.css.clip.width = right;		this.css.clip.top = top;		this.css.clip.bottom = bottom;	}	Drag.prototype.show = function() {	this.css.visibility = "show"; }	Drag.prototype.hide = function() {	this.css.visibility = "hide"; }	Drag.prototype.getX = function(e) {	   return e.pageX; }	Drag.prototype.getY = function(e) {	   return e.pageY; }	Drag.prototype.getLeft = function() {	return  this.css.left; }	Drag.prototype.getTop = function() {	return  this.css.top; }	Drag.prototype.getWidth = function() {	return  this.css.clip.width; }	Drag.prototype.getHeight = function() {	return  this.css.clip.height; }	Drag.prototype.getVisibility = function() {	return this.css.visibility; }	Drag.prototype.setZIndex = function(z) {	this.css.zIndex = z; }	Drag.prototype.writeIt = function(stuff) {	this.css.document.write(stuff); }	Drag.prototype.images = function(item) {			if (item) return this.css.document.images[item];		return this.css.document.images; }	Drag.prototype.forms = function(item) {			if (item) return this.css.document.forms[item];		return this.css.document.forms; }	Drag.prototype.setLastClicked = function() {		// will not work in IE.  use the onDblClick event in <a href>		this.lastclicked = new Date().getTime();	}	Drag.prototype.wasDoubleClicked = function() {		// will not work in IE.  use the onDblClick event in <a href>		var thisClick = new Date().getTime();		var delta = thisClick - this.lastclicked;		this.setLastClicked();		if (delta > 0 && delta < 500) return true;		return false;	}}Drag.prototype.getRight = function() {	return  this.getLeft() + this.getWidth(); }Drag.prototype.isVisible= function() {   var vState = this.getVisibility();   if (vState == 'hide' || vState == 'hidden') return false;   return true;}Drag.prototype.setEngage = function(e) {	// 1) record where on the object it click was	// 2) set z-index arbitrarily high (i.e., 100) so it floats over everything else	this.startX = this.getX(e);	this.startY = this.getY(e);	this.setOffset(e);	this.setZIndex(300);	if (nn) document.captureEvents( Event.MOUSEMOVE );	if (nn) document.captureEvents( Event.MOUSEUP );}Drag.prototype.setRelease = function(e) {//	this.setZIndex(this.z);	if (nn) document.releaseEvents( Event.MOUSEMOVE );	if (nn) document.releaseEvents( Event.MOUSEUP );}Drag.prototype.dragIt = function(x,y) {	this.shiftTo(x, y);}Drag.prototype.setStartCoord = function() {	this.startX = this.getLeft(); 	this.startY = this.getTop();}Drag.prototype.setOffset = function(e) {		this.offsetX = this.getX(e) - this.getLeft();		this.offsetY = this.getY(e) - this.getTop();}Drag.prototype.wasClicked = function(e) {   var x = this.getX(e);   var y = this.getY(e);   this.isWithin(x, y);}Drag.prototype.isWithin = function(x, y) {	var myLeft = this.getLeft();	var myRight = myLeft + this.getWidth();	var myTop = this.getTop();	var myBottom = myTop + this.getHeight();	if ( x>=myLeft && x<myRight && y>=myTop && y<myBottom ) return true;	else return false;}
