/*
'sV = "2.0"
' 2.0 - Major upgrade. 4-Nov-2003, ABK.
' 1.3 - Bugfix, 9/04/2003, ABK.
' 1.2 - New option, objCallingPointRef = either an object, or 'mouse' = the mouse cursor. 07/04/2003, ABK
' 1.1 - Improved! it actually works consistently/properly now. objCallingPointRef is no required at this stage, but will leave in for now. 25/03/2003, abk.
' 1.0 - original.
'GMVEND
*/

function MoveObjToThis(objToMoveID, objCallingPointRef, iPx_X, iPx_Y){
	//-------------------------------------------------------------------------------------------------------
	// objToMoveID
	//	The name of the object (layer) to move
	//
	// objCallingPoint
	//	Usually the same object (link, button, etc) whose event triggers the function: 'this'
	//
	// iPx_X
	//	Number of pixels to move (horizontally, relative to the mouse click event) ie:
	//			  	10 (left), 0 (don't move) or -10 (right)...
	//
	// iPx_Y
	//	Number of pixels to move (vertically, relative to the mouse click event) ie:
	//			  	10 (down), 0 (don't move) or -10 (up)...
	//
	// example: 	onClick="MoveObjToThis('lyrJSCalendar',this,10,10);"
	//-------------------------------------------------------------------------------------------------------

	if(objCallingPointRef=='mouse'){

		//alert(Math.abs(iPx_X));
		//alert(window.pageXoffset);
		//alert(document.body.scrollTop);

		var iSrclTop = document.body.scrollTop;
		var objToMove;	// The object to move.
		var iMoveBy;	// The amount (in pixels) to move the object by.

		objToMove = window.document.getElementById(objToMoveID);
		if(objToMove){

			// Move object along the X-axis: 
			if(iPx_X==0){
				objToMove.style.left = window.event.clientX;
			}
			if(iPx_X < 0){
				iMoveBy = Math.abs(iPx_X);
				objToMove.style.left = (window.event.clientX - iMoveBy);
			}
			if(iPx_X > 0){
				iMoveBy = Math.abs(iPx_X);
				objToMove.style.left = (window.event.clientX + iMoveBy);
			}

			// Move object along the Y-axis: 
			if(iPx_Y==0){
				objToMove.style.top = window.event.clientY + iSrclTop;
			}
			if(iPx_Y < 0){
				iMoveBy = Math.abs(iPx_Y);
				objToMove.style.top = (window.event.clientY - iMoveBy) + iSrclTop;
			}
			if(iPx_Y > 0){
				iMoveBy = Math.abs(iPx_Y);
				objToMove.style.top = (window.event.clientY + iMoveBy) + iSrclTop;
			}

		}else{
			alert('MoveObjToThis - objToMove not found.');
		}

	}else{
		if(objCallingPointRef){
			var objCallingPoint = objCallingPointRef;
			//var objCallingPoint = window.document.getElementById(objCallingPointRef.id);
			window.document.all(objToMoveID).style.left=objCallingPoint.offsetLeft + iPx_X;
			window.document.all(objToMoveID).style.top=objCallingPoint.offsetTop + iPx_Y;
		}else{
			var objToMove = window.document.getElementById(objToMoveID);
			objToMove.style.left = (window.event.clientX + iPx_X);
			objToMove.style.top = (window.event.clientY + iPx_Y);	
		}
	}
}

