var gap=0;

function hide(espaco, tempo, id){
	var militempo = Math.abs(Math.round(tempo/espaco));
	var incre = militempo;
	if(gap==1){
		gap=0;
		if(id=='corpo') {
			document.getElementById('corpoimg').src='imgs/more_down.gif';
			document.getElementById('movie').style.visibility='hidden';
		}
		if(id=='head') document.getElementById('menuimg').src='imgs/menu.gif';
		for(x=0;x>=espaco;x--){
			setTimeout("document.getElementById('"+id+"').style.marginTop="+x,militempo);
			militempo+=incre;
		}
		setTimeout("document.getElementById('"+id+"').style.visibility='hidden'",militempo);
		setTimeout("gap=1",militempo);
	}
}

function down(espaco, tempo, id){
	var militempo = Math.abs(Math.round(tempo/espaco));
	var incre = militempo;
	var freio;
	var diferencial=28;
	var elemento=document.getElementById(id);
	if(gap==1){
		gap=0;
		elemento.style.visibility="visible";
		if(id=='head') document.getElementById('menuimg').src='imgs/menu1.gif';
		for(x=espaco;x<=0;x++){
			setTimeout("document.getElementById('"+id+"').style.marginTop="+x,militempo);
			militempo+=incre;
			freio=incre+(diferencial/Math.abs(espaco));
			a=Math.abs(Math.round((100*x)/espaco));
		 	if(a<50){
			 	incre=freio;
			}
		}
		if(id=='corpo'){
			document.getElementById('corpoimg').src='imgs/more_up.gif';
			setTimeout("document.getElementById('movie').style.visibility='visible'",militempo);
		}
		setTimeout("gap=1",militempo);
	}
}

function drop(espaco, tempo, id){
	var elemento=document.getElementById(id);
	if (elemento.style.visibility=="" || elemento.style.visibility=="hidden") down(espaco, tempo, id);
	else hide(espaco, tempo, id);
}
