/*function actualizaDiv()
   {
	var incremento = 61;
	
	var div01 = document.getElementById("div_01");
	var divEl = document.getElementById("seccion_elastica2");		
	var altura  = div01.offsetHeight;
	var sobrante = altura%incremento;
	var alturaNueva = altura  + (incremento-sobrante);
	//divEl.style.height = alturaNueva;
	//alert ("Altura = "+altura + "\n  sobrante  ="+ sobrante + "\n alturaNueva = "+alturaNueva);
	
	}

function actualiza(divname)
   {
	parent.document.getElementById(divname) = document.body.scrollHeight+20; 
	scrollTo(0,0);
	   
	   }*/
function  tabPrincipal (id, destino, activa, estiloActivo, estiloInactivo)
   {
	   this.menuSel = null;
	   this.id = id;
       this.destino = destino;	   
	   this.activa = activa;
	   	   this.cssActivo = estiloActivo;
	   this.cssInactivo = estiloInactivo;
	   this.tabs = new Array();
   };
tabPrincipal.prototype.crear = function ()
   {
	   for (var t = 0; t<= this.tabs.length-1; t++)
	      {
			  var tabTemp = document.getElementById(this.tabs[t].id);
			  tabTemp._parent = this;
			  tabTemp._recurso = this.tabs[t].recurso;
			  tabTemp._funcion = this.tabs[t]._funcion;
			  tabTemp._funcion2 = this.tabs[t]._funcion2;
			  tabTemp.onclick = function ()
			     {					 
					this._parent.peticionMenu(this, this._recurso, this._funcion, this._funcion2); 
					return false;
				 }
		  }
	  if (this.activa >= 0)
	     {
			 this.peticionMenu(document.getElementById(this.tabs[this.activa].id),this.tabs[this.activa].recurso); 
		 }
	 

   };
tabPrincipal.prototype.agregaTab = function (id,recurso, funcion, funcion2)
   {
	   var tabTemp= new Object();
	   tabTemp.id = id;
	   tabTemp.recurso = recurso;
	  tabTemp._funcion = funcion;
	  tabTemp._funcion2 = funcion2;
	   this.tabs.push(tabTemp);
   }
tabPrincipal.prototype.peticionMenu = function (celda, recurso, funcion, funcion2)	
   {	          
      
	   oThis = this;
	   if (celda != false)
			 {
				this.menuOut(celda);
			 }  
	   this.despliegaInfo("</br><img src='images/cargando.gif' width='20' height='20' />Cargando información</br>");	
	   var oXMLHttp = zXmlHttp.createRequest();
	   oXMLHttp.open("get", recurso, true);	
	   oXMLHttp.onreadystatechange = function ()
		   {
			   if (oXMLHttp.readyState == 4)
				 {
					 if (oXMLHttp.status == 200)
						{
							oThis.despliegaInfo(oXMLHttp.responseText, funcion, funcion2);
						}else
						{
							oThis.despliegaInfo("Ocurre un error de comunicación: "+ oXMLHttp.statusText)
						}
				 }
		   }	
	document.documentElement.scrollTop = 0;	
		oXMLHttp.send(null);			   	   
		 
   }
tabPrincipal.prototype.menuPress = function (celda)   
   {
	   celda.className = this.cssInactivo;
	   
	   
	   
   }
tabPrincipal.prototype.menuOut = function (celda)   
   {
       if (this.menuSel != null)
   	   this.menuPress (this.menuSel);
	   celda.className =  this.cssActivo;
	   this.menuSel = celda;
	   
	   
	   
   }

tabPrincipal.prototype.despliegaInfo = function (contenido, funcion, funcion2)	   
   {
      var divR = document.getElementById(this.destino);
	  divR.innerHTML = contenido;
	  if (funcion != null || funcion != undefined)
		{							  
		   funcion();
		}
		if (funcion2 != null || funcion2 != undefined)
		{							  
		   funcion2();
		}
		actualizaDiv();	

   }
/************************************************************/



