 function cambia(param)
{
    document.all[param].src="images/btn_" + param + "_Off.gif";
}

function regresa(param)
{
    document.all[param].src="images/btn_" + param + "_On.gif";
}


function escribeopciones(xarray, xclave)	// Llena el select en base a xarray
   {
   window.document.write('<Option Value="">       </Option>');
   for (var i = 0; i < xarray.length; i++)
      {
      var xvalor = xarray[i].length;
      if ( xvalor.length != 0)		//Checa que la celda contenga un valor
	     {
//         	if ( i == 0 )
			if ( xclave == xarray[i][0] )	//Pone como seleccionado la clave que pasa como parámetro
			{	window.document.write('<Option Value="' + xarray[i][0] + '" selected>' + xarray[i][1] + '</Option>');	}
			else
			{	window.document.write('<Option Value="' + xarray[i][0] + '">' + xarray[i][1] + '</Option>');	}
		 }
      } 
   }

// Actualiza las opciones del segundo Select en función del primero
function cambiaselect2(xarray, xpospadre, xform, xselect2)
{
	// Instanciar el select a cambiar
	cad     = 'document.' + xform + '.' + xselect2;
	select2 = eval(cad);

	if ( xpospadre == 0 )  // Se selecciono la primera opción del padre (vacío)
	{
		select2.length = 1;
		select2.options[0].value   = '';
		select2.options[0].text    = '               ';
	}
	else
	{
		// Actualización de las opciones posibles del segundo select
		var xrengselect = xarray.length + 1;	// renglones del select2 + 1 
		select2.length  = xrengselect;

		select2.options[0].value   = '';
		select2.options[0].text    = ' ';
		for (var i = 1; i < xrengselect; i++)
		{
			select2.options[i].value = xarray[i-1][0];
			select2.options[i].text  = xarray[i-1][1];
		}
		// Se activa la primera opción del segundo select
		select2.selectedIndex = 0;   
	}
}

function cambiaselectedo()
{
	xposDele = document.form1.txtCveDele.selectedIndex;
	i = xposDele;
	if ( xposDele > 0 ) { i--; }  // No se selecciono la primer opción
	cambiaselect2(aDele[i][2], xposDele, 'form1', 'txtCveEdo');
}

function cambiaselectcd()
{
	xposEdo = document.form1.txtCveEdo.selectedIndex;
	j = xposEdo;
	if ( xposEdo > 0 ) { j--; }  // No se selecciono la primer opción
	cambiaselect2(aDele[i][2][j][2], xposEdo, 'form1', 'txtCveCd');
}

