// JavaScript Document
var seccActual;
var seccAnterior;

function traerElemento(_id){
	var elemento = document.getElementById(_id);	
	return elemento;
}

function traerSubElemento(_elemento,_etiqueta,_atributo){
	var subelemento = _elemento.getElementsByTagName(_etiqueta)[0][_atributo];
	return subelemento;
}

function cambiaSeccion( _seccion, _contenedor ){
	
	seccAnterior = seccActual;
	seccActual = _seccion;

	document.getElementById(seccActual).style.display = "block";
	document.getElementById(seccActual+"Btn").style.color = "#FFFFFF";
	document.getElementById(seccActual+"Btn").style.backgroundColor = "#666";
	
	scrollDivTop(""+_contenedor+"");
	
	if(seccAnterior!=seccActual & seccAnterior!=""){	
		
		document.getElementById(seccAnterior).style.display = "none";
		document.getElementById(seccAnterior+"Btn").style.color = "";
	    document.getElementById(seccAnterior+"Btn").style.backgroundColor = "";
	
	}
		
}

function scrollDivTop(divid){
	var t;
	var div = document.getElementById(divid);

	if (div.scrollTop>0){
		div.scrollTop-=3;
		t = setTimeout("scrollDivTop('"+divid+"')", 1);
	}else{
		clearTimeout(t);
	}
}

function MM_preloadImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function btnOver (){
	this.style.backgroundImage = "url(images/"+this.id+"On.gif)";
}

function btnOut (){
	this.style.backgroundImage = "url(images/"+this.id+"Off.gif)";
}

function btnClick(){
	var seccion = traerSubElemento(this,"span","innerHTML");
	window.location = seccion+".php";
}

function habilitaBtn(_boton){
	var miBoton = traerElemento(_boton);
	miBoton.onmouseover = btnOver;
	miBoton.onmouseout = btnOut;
	miBoton.onclick = btnClick;
}

function deshabilitaBtn(_boton){
	var miBoton = traerElemento(_boton);
	miBoton.style.backgroundImage = "url(images/"+_boton+"On.gif)";
	miBoton.style.cursor = "default";
}


