/*
* Fichero JavaScript para la iluminación de filas en tabla. Cross-browser
*/

    /*Detectamos el navegador y lo asignamos a una variable global   */
    nc = (document.layers)? true:false
    ie =  (document.all)? true:false
    n6 = (document.getElementById)? true:false
	
	
    /*para iluminar la fila dada, con numero de columnas dadas*/
    function ilumina(fila, columnas, col_oscuro, col_claro, col_ilum) /*, filas*/
    {
	/*colores que se va a usar para desiluminar VER SI DECIDIR DE ACUERDO A NUM COLUMNAS*/
	 colores = new Array(col_oscuro,col_claro,col_oscuro,col_claro,col_oscuro,col_claro,col_oscuro)	
//alert("OK");
		/*Para Internet Explorer*/
        if(ie)
        {        
            for(i=1;i<=columnas;i++)
             {   
			   id=('td'+fila+i)
               eval("document.all['"+id+"'].style.background='"+col_ilum+"'");
             }
        }
        /*Lo mismo para Netscape 4x*/
        else if(nc)
        { 
		   /*for(j=1;j<=filas;j++)
             {*/		
                for(i=1;i<=columnas;i++)
                  { 
                     id=('div'+fila+i) /*j*/
     			     /*if ( j == fila )
	     		      color = col_ilum
		     		 else
			     	  color = colores[i-1]*/
  				     color = col_ilum					 
                     eval('document.layers['+id+'].bgColor="'+color+'"');
                  }
			 /*}*/
        } 
        /*Lo mismo para Netscape 6x*/
        else if(n6)
        {   
		   /*for(j=1;j<=filas;j++)
             {*/		
     		   for(i=1;i<=columnas;i++)
                  {   
			        id=('td'+fila+i) /*j*/
     			    /*if ( j == fila )
	     		     color = col_ilum
		     		else
			     	 color = colores[i-1]*/
					color = col_ilum 
     			    eval("document.getElementById('"+id+"').style.background='"+color+"'");
                  }
			 /*}*/				 
        }
    }//ilumina

	
    /*para desiluminar la fila dada, con numero de columnas dadas y colores dados*/
    function desilumina(fila, columnas, col_oscuro, col_claro, col_ilum) /*, filas*/
    {		
        /*colores que se va a usar para desiluminar VER SI DECIDIR DE ACUERDO A NUM COLUMNAS*/
	colores = new Array(col_oscuro,col_claro,col_oscuro,col_claro,col_oscuro,col_claro,col_oscuro)	

        /*Para Internet Explorer*/
        if(ie)
        {        
		   for(i=1;i<=columnas;i++)
             {   
			   id=('td'+fila+i)
			   color= colores[i-1]
               eval("document.all['"+id+"'].style.background='"+color+"'");
             }
        }
        /*Lo mismo para Netscape 4x*/
        else if(nc)
        { 
		   /*for(j=1;j<=filas;j++)
             {*/		
                for(i=1;i<=columnas;i++)
                  {   
	     		    id=('div'+fila+i) /*j*/
		     	    color= colores[i-1]
                    eval('document.layers['+id+'].bgColor="'+color+'"');
                  }
			 /*}*/
        } 
        /*Lo mismo para Netscape 6x*/
        else if(n6)
        {   
		   /*for(j=1;j<=filas;j++)
             {*/
		        for(i=1;i<=columnas;i++)
                  {   
	     		    id=('td'+fila+i) /*j*/
		     	    color= colores[i-1]
			        eval("document.getElementById('"+id+"').style.background='"+color+"'");
                  }
			 /*}*/		   
        }
    }	//desilumina


// Para tratamiento de cambio de imagen con el Onclic
    function activar(nombreImagen, nuevaImg) {
//    alert(nuevaImg);
	  if (document.images) {
        document[nombreImagen].src=nuevaImg; }
    }


    function desactivar(nombreImagen, nuevaImg) {
//    alert(nuevaImg);		
      if (document.images) {
        document[nombreImagen].src=nuevaImg; }
    }


menu_status = new Array(); 

function showHide(theid){
    if (document.getElementById) {
    var switch_id = document.getElementById(theid);

        if(menu_status[theid] != 'show') {
           switch_id.className = 'show';
           menu_status[theid] = 'show';
        }else{
           switch_id.className = 'hide';
           menu_status[theid] = 'hide';
        }
    }
}

function hide(theid){
  if (document.getElementById) {
      var switch_id = document.getElementById(theid);
	  if (switch_id != null)
        switch_id.className = 'hide';
	}
}



function show(theid, imgname, pathimg){
    if (document.getElementById) {
      var switch_id = document.getElementById(theid);
      switch_id.className = 'show';
      menu_status[theid] = 'show';
	  activar(imgname, pathimg);
	}
}

array_family = new Array(); 

function showFamyly(theid, cant, index){
	 if (document.getElementById) {
	 for (i=1; i<= cant; i++){
        var id = 'Family'+i; 
	    var switch_id = document.getElementById(id);
        if (switch_id != null){
		  switch_id.className = 'hide';		
		}
     }
	 var switch_id = document.getElementById(theid);
      if (switch_id != null){
        switch_id.className = 'show';
		array_family[theid] = 'show';
     	hide('idtext_nodata');			  		
     	hide('idtext_explain');		
	  }
	  else{
     	hide('idtext_explain');		
        show('idtext_nodata');			  
	  }
	}
}


function vacio(control)
{
  if (control.value == "" || control.value <= 0)
    control.value = 1;
}


function Imprimir()
{
  window.print();
}


// set these variables equal to the original top and left of layers

var orig_x=600;  // layers' left
var orig_y=100;	 // layers' top

// onresize for ns4
var origWidth, origHeight;

if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  hideLayer("idtext_explain");
//  shiftLayerTo( id, orig_x, orig_y + getScrollY() );
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function shiftLayerTo(id,x,y) {
  var px = document.layers? 0: "px";
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) {
    lyr.css.top = y + px;
    lyr.css.left = x + px;
  }
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

// credit to http://www.13thparallel.org for the following function
// returns amount of vertical scroll
function getScrollY() {
	var sy = 0;
	if (document.documentElement && document.documentElement.scrollTop)
		sy = document.documentElement.scrollTop;
	else if (document.body && document.body.scrollTop) 
		sy = document.body.scrollTop; 
	else if (window.pageYOffset)
		sy = window.pageYOffset;
	else if (window.scrollY)
		sy = window.scrollY;
	return sy;
}

 