var IE = (navigator.userAgent.indexOf("MSIE") > -1);

if (!IE) window.captureEvents(Event.MOUSEMOVE);
var calcular = true;
function retornaNada(){return false}

//função para anular o onmousmove e o onmousedown das imagens
function arrumaImg(idDiv){	
	imagens = document.getElementById(idDiv).getElementsByTagName('img');
	if(imagens.length > 0 && imagens[0].onmousedown == null){
		for(i = 0; i < imagens.length; i++){
			imagens[i].onmousemove = retornaNada;
			imagens[i].onmousedown = retornaNada;
		}
	}
}

//Função para arrastar a div
function arrasta(idDiv){
	if (calcular) arrumaImg(idDiv);
	document.onmousemove = function(e){			
		pX = (IE)?event.clientX + document.body.scrollLeft : e.pageX;
		pY = (IE)?event.clientY + document.body.scrollTop : e.pageY;
		if(calcular){
			if (IE) document.getElementById(idDiv).style.filter = "alpha(opacity=60)"
			else document.getElementById(idDiv).style.opacity = "0.6"
			difX = pX - document.getElementById(idDiv).offsetLeft;
			difY = pY - document.getElementById(idDiv).offsetTop;
			calcular = false;				
		}
		document.getElementById(idDiv).style.left = pX - difX + 'px';
		document.getElementById(idDiv).style.top = pY - difY + 'px';
	}	
	
	document.onselectstart = retornaNada;

	document.onmouseup = function(){
		calcular =  true;
		if (IE) document.getElementById(idDiv).style.filter = "alpha(opacity=100)"
		else document.getElementById(idDiv).style.opacity = "1.0"
		document.onmousemove = document.onselectstart = document.onmouseup = null;		
	}	
}

