function cambiarBgColor (tr, estado, anterior) {
	
  if (tr.style.background != "#d5d5d5") {
	  if (estado == 1) {
	    tr.style.background = "#ebebeb";
	  }
	  else {
    	tr.style.background = anterior;
	  }
	}
}

function cambiarBgColorAM (tr, estado, anterior, id_nuevo, hiddenId) {
	
  if (tr.style.background != "#d5d5d5") {
	  if (estado == 1) {
	    tr.style.background = "#ebebeb";
	  }
	  else {
	  	if (estado == 2) {
	  		var valores = document.all(hiddenId).value;
	  		if (valores.indexOf("|" + id_nuevo + "|") >= 0) {
	  			tr.style.background = anterior;
	  		}
	  		else {
	  			tr.style.background = "#ffffff";
	  		}
	  	}
	  	else {
	    	tr.style.background = anterior;
	    }
	  }
	}
}

function cambiarBgColorClick (tr, id_nuevo, hiddenId) {
  if (tr.style.background != "#d5d5d5") {
    if (! blnCtrl) {
    	limpiarTodos();
    	document.all(hiddenId).value = "|" + id_nuevo + "|";
    }
  	else {
	    var valores = document.all(hiddenId).value;
	    if (valores == "0") {
	     document.all(hiddenId).value = "|" + id_nuevo + "|";
	    }
	  	else {
	  		document.all(hiddenId).value = valores + "|" + id_nuevo + "|";
	  	}
	  }
    tr.style.background = "#d5d5d5";
    //cambiarStatus("Status: item seleccionado", 3000);
  }
  else {
    if (! blnCtrl) {
    	limpiarTodos();
    	document.all(hiddenId).value = 0;
    }
  	else {
  		tr.style.background = "#ffffff";
  		document.all(hiddenId).value = replaceSubstring(document.all(hiddenId).value, "|" + id_nuevo + "|", "");
  	}
    //cambiarStatus("Status: item liberado", 3000);
  }
}

function resetTodos (hiddenId) {
	document.all(hiddenId).value = 0;
	limpiarCeldas("c");
}

function limpiarTodos () {
  limpiarCeldas("c");
}

function cambiarStatus (valor, tiempo) {
  //document.all("status").innerHTML = valor;
  limpiarStatus(tiempo);
}

function limpiarStatus (tiempo) {
  //setTimeout("cambiarStatus('&nbsp;')", tiempo);
}

function limpiarCeldas (tipo) {
  var loop = true;
  for (i = 1; loop; i++) {
    tr = document.all("tr" + tipo + i);
    if (tr) {
      //busco el color original
      color = "#ffffff";
      tr.style.background = color;
    }
    else {
      loop = false;
    }
  }
}
