// Arrastrar y soltar menu

var object = null;
var cX =  0;
var cY = 0;

function initPage () {	
	document.onmousedown = seleccionar;
	document.onmousemove = arrastrar;
	document.onmouseup = soltar;	
}

function seleccionar(evt) {
	evt = (evt) ? evt : ((window.event) ? event : null);
	var objectID = (evt.target) ? evt.target.id : ((evt.srcElement) ? evt.srcElement.id : null);
	
	if (objectID.indexOf('movFotos')!=-1)  object = document.getElementById(objectID);
	
	
	if (object) { 
		object.style.cursor = 'move';
		object.style.zIndex = 100;
		cX = evt.clientX - object.offsetLeft;
		cY = evt.clientY - object.offsetTop;
		return;
	}
	else {
		object = null;
		return;
	}
}
function arrastrar(evt) {
	
	evt = (evt) ? evt : ((window.event) ? event : null);
	
	if (object) {		
		object.style.cursor = 'move';
		object.style.left = evt.clientX - cX + 'px';
		object.style.top = evt.clientY - cY + 'px';
		return false;
	}
}

function soltar() {
	if (object) {	
		object.style.cursor = 'default';
		object.style.zIndex = 11;
		/*alert("top: "+object.style.top+"\nleft: "+object.style.left);*/
		object = null;
		return false;
	}
}

initPage();

// -->
