	currentX = currentY = 0;  // initialize global position-tracking variables
	startX = startY = 0;
	whichEl = null;           // initialize global element-being-dragged variable
	//activeEl = document.all.cat1;	// topmost element

	function grabEl() {       // function for onmousedown
		//debugger;
		whichEl = event.srcElement;
		//alert(whichEl.id);
		while (whichEl.id.indexOf("cat") == -1) {
			whichEl = whichEl.parentElement;
			if (whichEl == null) { return }
		}/*
		if (whichEl != activeEl) {
			whichEl.style.zIndex = activeEl.style.zIndex + 1;
			activeEl = whichEl;
		}*/
		whichEl.style.pixelLeft = whichEl.offsetLeft;
		whichEl.style.pixelTop = whichEl.offsetTop;
		currentX = (event.clientX + document.body.scrollLeft);
		currentY = (event.clientY + document.body.scrollTop);
		
		startX = whichEl.style.pixelLeft;
		startY = whichEl.style.pixelTop;
	}

	function moveEl() {       // function for onmousemove
		if (whichEl == null) { return };
		newX = (event.clientX + document.body.scrollLeft);
		newY = (event.clientY + document.body.scrollTop);
		distanceX = (newX - currentX);
		distanceY = (newY - currentY);
		currentX = newX;
		currentY = newY;
		whichEl.style.pixelLeft += distanceX;
		whichEl.style.pixelTop += distanceY;
		event.returnValue = false;
	}

	function dropEl() {       // function for onmouseup
		//alert(whichEl.id);
		if (whichEl == null) { return };
		//var now = new Date();
		//now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
		var inhoud = "left: "+whichEl.style.pixelLeft+"; top:"+whichEl.style.pixelTop+";";
		//var naam = whichEl.id;
//		whichEl = null;
		//alert(inhoud);
		window.status=inhoud;
		//alert(naam+" "+inhoud+" "+now);
		//setCookie(naam, inhoud, now);
		if (terugzetten) {
			whichEl.style.pixelLeft = startX;
			whichEl.style.pixelTop = startY;
		}
		whichEl = null;
	}

	document.onmousedown = grabEl;
	document.onmousemove = moveEl;
	document.onmouseup = dropEl;


