<!--
var _startX = 0;			// mouse starting positions
var _startY = 0;

var _offsetX = 0;			// current element offset
var _offsetY = 0;
var _dragElement;			// needs to be passed from OnMouseDown to OnMouseMove

var dropZoneObject=null;
var inZone=false;
var x1=0;
var y1=0;
var clone = null; 
initDragDrop();

function initDragDrop()
{
	document.onmousedown = OnMouseDown;
	document.onmouseup = OnMouseUp;
}

function OnMouseDown(e)
{
	// IE is retarded and doesn't pass the event object
	if (e == null) e = window.event; 
	var target = e.target != null ? e.target : e.srcElement;

	// for IE, left click == 1
	// for Firefox, left click == 0
	if ((e.button == 1 && window.event != null || e.button == 0) && target.className == 'dragDevice') {
		// grab the mouse position
		_startX = e.clientX;
		_startY = e.clientY;
		
		// grab the clicked element's position
		_offsetX = target.offsetLeft;
		_offsetY = target.offsetTop;
	
		
		var x=target;
		if(x.offsetParent) {
			do {
      			_offsetX += x.offsetLeft;
      			_offsetY += x.offsetTop;
    		} while( x=x.offsetParent)
	    }

		// we need to access the element in OnMouseMove
		_dragElement = target;
    
		clone = target.cloneNode(true);
		clone.style.display='none'
    	window.addEvent('domready',function(){
		document.body.appendChild(clone);
		});
		
    	
		// tell our code to start moving the element with the mouse
		document.onmousemove = OnMouseMove;
		
		// cancel out any text selections - 
		//MM/NA - Commented out to fix first click event firing on IE
		//document.body.focus();
		
		// prevent text selection in IE
		document.onselectstart = function () { return false; };
		// prevent IE from trying to drag an image
		target.ondragstart = function() { return false; };
		
		// prevent text selection (except IE)
		return false;
	}
	
}

function ExtractNumber(value)
{
	var n = parseInt(value);
	return n == null || isNaN(n) ? 0 : n;
}

function OnMouseMove(e)
{
	if (e == null) var e = window.event; 
	var evtTarget = e.target || e.srcElement;   
    clone.style.position = 'absolute'; 
    setOpacity(clone,5)
    clone.style.top = (_offsetY + e.clientY - _startY) + 'px';
    clone.style.left = (_offsetX + e.clientX - _startX) + 'px';
    clone.style.display='block';      
    //clone.id="clone"+evtTarget.id;
    clone.style.cursor="move";
}
 
function OnMouseUp(e)
{
	if (_dragElement != null) { 
		if (e == null) e = window.event; 
		var evtTarget = e.target != null ? e.target : e.srcElement;
		if(isInDropZone(e)) { 
				var imgId = evtTarget.id;
				var checkbox_id = "checkbox_" + imgId.substr(4);
				document.getElementById(checkbox_id).click();
				inZone=true;        
		}  else if(!inZone) { 
			document.body.removeChild(clone); 
		}
		// we're done with these events until the next OnMouseDown
		document.onmousemove = null;
		document.onselectstart = null;
		_dragElement.ondragstart = null;
		// this is how we know we're not dragging
		_dragElement = null;
		inZone=false;
	}
}




function isInDropZone(e)
{
	if (e == null) 
		e = window.event; 
		var target = e.target != null ? e.target : e.srcElement;
		
		
	var curLeft=0
    var curTop=0
    var curRight=0;
    var curBottom=0;
    var targetX;
    var targetY;
    var targetHeight;
		
	var result = false;
	var dZone = document.getElementById("dZone");

	var _oWidth=dZone.offsetWidth;
	var _oHeight=dZone.offsetHeight;
	targetHeight=target.offsetHeight;
 
 	if(dZone.offsetParent) {
	    do {
	      curLeft += dZone.offsetLeft;
	      curTop += dZone.offsetTop;
	    } while(dZone = dZone.offsetParent)
    }
   
	curBottom=curTop +_oHeight
	curRight=curLeft + _oWidth
	targetX = target.offsetLeft;
	targetY = target.offsetTop;
 
	if( targetX > curLeft  && targetX < curRight  && (targetY >curTop || (targetY+targetHeight) >curTop) && targetY < curBottom  ) 
    { 
       result = true; 
    } 

 return result;
}



function setOpacity(obj,value) {
	obj.style.opacity = value/10;
	obj.style.filter = 'alpha(opacity=' + value*10 + ')';
}
