// JavaScript Document

function muestragrande (idencen, ptiempo) {
	if (idencen!=idlast) {
		opacity(idencen, 0, 100, ptiempo, 0);
		if (idlast!="textoini") {
			opacity(idlast, 100, 0, ptiempo, 0);
		} else {
			opacity(idlast, 100, 0, 2, 0);
		}
		idlast=idencen;
	}
}

function muestraimage (idndiv, idnima, indi) {
	document.getElementById(idnima).style.borderColor = "#222222";
	document.getElementById(idndiv).style.zIndex = indi+20;
}

function escondeimage (idndiv, idnima, indi) {
	document.getElementById(idnima).style.borderColor = "#222222";
	document.getElementById(idndiv).style.zIndex = indi;
}

function irlinkt (iddd, bannn, linkir, nro) {
	apabaj();
	document.location.href = linkir + ".php?id=" + iddd + "&bannerdde=" + bannn + "&dato=" + nro;
}

function actufoth(stepi, id) {
	mencent=-(Math.floor(stepi/580)*580);
	var object = document.getElementById(id).style; 
	object.left = String(mencent)+"px";
}
//	mencent=-(Math.floor(stepi/12)*12);

function actufot(stepi, id) {
	mender=-stepi;
	var object = document.getElementById(id).style; 
	object.top = String(mender)+"px";
}

function scrolihor(id, cantscro, millisec, dirscro, largorollo, largovent, idsli, larsli, altsli) {
	if (menceest==0&&((dirscro==1&&mencent<0)||(dirscro==-1&&mencent>-(largorollo-largovent)))) {
		if (dirscro==1&&mencent>=-cantscro) {
			cantscro=-mencent;
		}
		if (dirscro==-1&&mencent<=-(largorollo-largovent)+cantscro) {
			cantscro=(largorollo-largovent)-(-mencent);
		}
		menceest=1;
		var speed = Math.round(millisec / 100);
		var timer = 0;
		for(i = 0; i <= (cantscro-4); i=i+4) {
			mencent = mencent+(dirscro*4);
			pasli = (-mencent)*(larsli-altsli)/(largorollo-largovent);
			setTimeout("changeScroh(" + pasli + "," + mencent + ",'" + id + "','" + idsli + "')",(timer * speed));
			timer=timer+4;
		}
		setTimeout("changemenh()",(timer * speed));
	}
}

function changemenh() {
		menceest=0;
}

function changeScroh(ponli, sum, iden, idemsli) {
	var object = document.getElementById(iden).style; 
	object.left = String(sum)+"px";
	var object = document.getElementById(idemsli).style; 
	object.left = String(ponli)+"px";
}

function scroliup(id, cantscro, millisec, dirscro, largorollo, largovent, idsli, larsli, altsli) {
	if (menest==0&&((dirscro==1&&mender<0)||(dirscro==-1&&mender>-(largorollo-largovent)))) {
		if (dirscro==1&&mender>=-cantscro) {
			cantscro=-mender;
		}
		if (dirscro==-1&&mender<=-(largorollo-largovent)+cantscro) {
			cantscro=(largorollo-largovent)-(-mender);
		}
		menest=1;
		var speed = Math.round(millisec / 100);
		var timer = 0;
		for(i = 0; i <= cantscro; i=i+1) {
			mender = mender+dirscro;
			pasli = (-mender)*(larsli-altsli)/(largorollo-largovent);
			setTimeout("changeScro(" + pasli + "," + mender + ",'" + id + "','" + idsli + "')",(timer * speed));
			timer=timer+1;
		}
		setTimeout("changemen()",(timer * speed));
	}
}

function changemen() {
		menest=0;
}

function changeScro(ponli, sum, iden, idemsli) {
	var object = document.getElementById(iden).style; 
	object.top = String(sum)+"px";
	var object = document.getElementById(idemsli).style; 
	object.top = String(ponli)+"px";
}

function showbotonbis(altini, idnum, pantid, pdde, phta, ptpo, ppath, ppathreverse) {
	if (arranque==1) {
		mouseafuera[idnum]=0;
		if (encendiendo[idnum]==0 && apagando[idnum]==0 && encendido[idnum]==0) {
			enciendebotonbis (altini, idnum, pantid, pdde, phta, ptpo, ppath, ppathreverse);
		} else {
			debeencender[idnum]=1;
		}
	}
}

function hidebotonbis(altini, idnum, pantid, pdde, phta, ptpo, ppath, ppathreverse) {
	if (arranque==1) {
		mouseafuera[idnum]=1;
		if (encendiendo[idnum]==0 && apagando[idnum]==0 && encendido[idnum]==1) {
				apagabotonbis (altini, idnum, pantid, pdde, phta, ptpo, ppath, ppathreverse);
		} else {
				debeapagar[idnum]=1;
		}
	}
}

function enciendebotonbis (altini, idnum, pantid, pdde, phta, ptpo, ppath, ppathreverse) {
	encendiendo[idnum]=1;
	mencity(altini, pantid, pdde, phta, ptpo, 0);
	setTimeout("ponerencendidobis(" + idnum + ")", ptpo);
	setTimeout("finencendiendobis(" + altini + "," + idnum + ",\"" + pantid + "\"," + pdde + "," + phta + "," + ptpo + ",\"" + ppath + "\",\"" + ppathreverse + "\")", ptpo);
}

function apagabotonbis (altini, idnum, pantid, pdde, phta, ptpo, ppath, ppathreverse) {
	apagando[idnum]=1;
	mencity(altini, pantid, pdde, phta, ptpo, 0);
	setTimeout("ponerapagadobis(" + idnum + ")", ptpo);
	setTimeout("finapagandobis(" + altini + "," + idnum + ",\"" + pantid + "\"," + pdde + "," + phta + "," + ptpo + ",\"" + ppath + "\",\"" + ppathreverse + "\")", ptpo);
}

function finencendiendobis(altini, idnumero, pantid, pdde, phta, ptpo, ppath, ppathreverse) {
	encendiendo[idnumero]=0;
	if (debeapagar[idnumero]==1 || mouseafuera[idnumero]==1) {
		apagabotonbis (altini, idnumero, pantid, phta, pdde, ptpo, ppath, ppathreverse);
		debeapagar[idnumero]=0;
	}
}

function finapagandobis(altini, idnumero, pantid, pdde, phta, ptpo, ppath, ppathreverse) {
	apagando[idnumero]=0;
	if (debeencender[idnumero]==1 || mouseafuera[idnumero]==0) {
		enciendebotonbis (altini, idnumero, pantid, phta, pdde, ptpo, ppath, ppathreverse);
		debeencender[idnumero]=0;
	}
}

function ponerencendidobis(idnumero) {
	encendido[idnumero]=1;
}

function ponerapagadobis(idnumero) {
	encendido[idnumero]=0;
}

function mencity(altini, id, opacStart, opacEnd, millisec, retrazo) {
	var speed = Math.round(millisec / 100);
	var timer = 0;
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i=i-4) {
			setTimeout("changeMen(" + altini + "," + i + ",'" + id + "')",(timer * speed + retrazo));
			timer=timer+4;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i=i+4)
			{
			setTimeout("changeMen(" + altini + "," + i + ",'" + id + "')",(timer * speed + retrazo));
			timer=timer+4;
		}
	}
}

function changeMen(altini, opacity, id) {
	var object = document.getElementById(id).style; 
	object.height = String(altini+((opacity-50)/5))+"px";
	object.fontSize = String(11+((opacity-50)/20))+"px";
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function ponercinc(id) {
	var object = document.getElementById(id).style; 
	object.opacity = (50 / 100);
	object.MozOpacity = (50 / 100);
	object.KhtmlOpacity = (50 / 100);
	object.filter = "alpha(opacity=" + 50 + ")";
}
