// Funciones para tablas
function showHideTable(theRow,theImg) {
  if (document.getElementById(theRow+ "_" + 1).style.display == 'none') {
    document.getElementById(theImg).src='Temas/comun/img/table/collapse.gif';
           showTableRecursive(theRow);
  }
  else {
    document.getElementById(theImg).src='Temas/comun/img/table/expand.gif';
    hideTableRecursive(theRow);
  }
}

function hideTableRecursive(theRow) {
  var row, i = 1;
  while (row = document.getElementById(theRow + "_" + i)) {
    row.style.display = 'none';
    if (document.getElementById("img"+theRow + "_" + i))
      document.getElementById("img"+theRow + "_" + i).src='Temas/comun/img/table/expand.gif';

    idrow = theRow + "_" + i;
    i++;
    hideTableRecursive(idrow);
  }
}

function showTableRecursive(theRow) {
  var row, i = 1;
  while (row = document.getElementById(theRow + "_" + i)) {
    row.style.display ="";
    var theImg = "img" + theRow + "_" + i;
    if (document.getElementById(theImg)){
        document.getElementById(theImg).src='Temas/comun/img/table/collapse.gif';
    }
    idrow = theRow + "_" + i;
    i++;
    showTableRecursive(idrow);
  }
}

function OcultarTabla() {

  //if (document.all)
    var row, i = 1;
    while (row = document.getElementById("tr_" + i)) {
      var theRow = "tr_" + i;
      var theImg = "img" + theRow;
      if (document.getElementById(theImg)){
        document.getElementById(theImg).src='Temas/comun/img/table/expand.gif';
        
      }
      hideTableRecursive(theRow);
      i++;
    }
}
function MostrarTabla() {

  //if (document.all)
    var row, i = 1;
    while (row = document.getElementById("tr_" + i)) {
      var theRow = "tr_" + i;
      var theImg = "img" + theRow;
      if (document.getElementById(theImg)){
        document.getElementById(theImg).src='Temas/comun/img/table/collapse.gif';
        
      }
      showTableRecursive(theRow);
      i++;
    }
}

function showHideTableRecursive() {
	if(document.getElementById("imgID").src.indexOf('collapse.gif')>-1){
		OcultarTabla();
		if(document.getElementById("imgID")){
			document.getElementById("imgID").src='Temas/comun/img/table/expand.gif';
		}
	} else {
		MostrarTabla();	
		if(document.getElementById("imgID")){
			document.getElementById("imgID").src='Temas/comun/img/table/collapse.gif';
		}
		
	}
}
