var wk=false;
var to=0;
var inte;
var st=1;
var qu=0;
function abrir(q) {
	if(wk) return;
	
	var d=document.getElementById("sub"+q);
	var t=document.getElementById("subt"+q);
	if(!d||!q) return;
	
	st=1;
	to=t.offsetHeight;
	wk=true;
	qu=q;
	var h=parseInt(d.style.height);
	if(isNaN(h)) h=0;
	if(h>0) inte=setInterval(cerrar_step,10); else inte=setInterval(abrir_step,10);
}
function abrir_step() {
	var d=document.getElementById("sub"+qu);
	var h=parseInt(d.style.height);
	if(isNaN(h)) h=0;
	if(h>=to) { clearInterval(inte);wk=false;return; }
	if((h+st)<=to) {
		d.style.height=(h+st)+"px";
	} else {
		d.style.height=to+"px";
	}
	if(st<7) st++;
}
function cerrar_step() {
	var d=document.getElementById("sub"+qu);
	var h=parseInt(d.style.height);
	if(isNaN(h)) h=0;
	if(h<=0) { clearInterval(inte);wk=false;return; }
	if((h-st)>=0) {
		d.style.height=(h-st)+"px";
	} else {
		d.style.height="0px";
	}
	if(st<7) st++;
}
