function nueva_ventana (href, titulo, ancho, alto)
{
  window.open(href, titulo,
	  'width=' + ancho + ',height=' + alto + 'scrollbars=yes,status=no');
}

function visible (id, img)
{
	if (document.all)
	{
		oDIV = document.all[id];
		oIMG = document.all[img];
	}
	else
	{
		oDIV = document.getElementById(id);
		oIMG = document.getElementById(img);
	}
	
	if (oDIV.style.display == 'none')
	{
		oDIV.style.display = 'block';
		oIMG.src = "img/info_menos.gif";
		oIMG.alt = "Ocultar bloque";
	}
	else
	{
		oDIV.style.display = 'none';
		oIMG.src = "img/info_mas.gif";
		oIMG.alt = "Mostrar bloque";
	}
}

function ver_comentarios (href)
{
  nueva_ventana (href, 'Comentarios', 400, 500);
}

function visibilidad (id, etiqueta)
{
	if (document.all)
	{
		oOBJ = document.all[id];
		oETIQ = document.all[etiqueta];
	}
	else
	{
    // Define la propiedad innerText en Firefox, ya que su equivalente es textContent
		HTMLElement.prototype.__defineGetter__("innerText",function () { return(this.textContent); });   
    HTMLElement.prototype.__defineSetter__("innerText",function (txt) { this.textContent = txt; });

		oOBJ = document.getElementById(id);
		oETIQ = document.getElementById(etiqueta);
	}
	if (oOBJ.style.display == 'none')
	{
		oOBJ.style.display = 'block';
		oETIQ.innerText = '[-]';
	}
	else
	{
		oOBJ.style.display = 'none';
		oETIQ.innerText = '[+]';
	}
}

function confirmar (url, texto)
{
	if (texto=='') texto='querer eliminar este registro';
	if (confirm ('¿Estás seguro de '+texto+'?'))
	{
		document.location.href = url;
	}
	else
	{
		return false;
	}
}

function confirmar_sel (frm)
{
  if(confirm('¿Estás seguro de querer eliminar los registros seleccionados?'))
  {
    frm.submit();
  }
  else
  {
    return false;
  }
}

function markAllRows (container_id, modo)
{
  var rows = document.getElementById(container_id).getElementsByTagName('td');
  var unique_id;
  var checkbox;

alert (rows.length);
  for (var i = 0; i < rows.length; i++)
	{
    checkbox = rows[i].getElementsByTagName('input')[0];
    if (checkbox && checkbox.type == 'checkbox')
		{
      if (checkbox.disabled == false)
			{
        if (modo == -2)
        {
    	    checkbox.checked = checkbox.checked;
        }
        else
        {
      	  checkbox.checked = modo;
        }
      }
    }
  }
  return true;
}

function marcar_chk (id_chk, valor)
{
alert (id_chk);
	if (document.all)
	{
		o_chk = document.all[id_chk];
	}
	else
	{
		o_chk = document.getElementById (id_chk);
	}
alert (o_chk.length);
	for (var c = 0; c < o_chk.length; c++)
  {
//		checkbox = o_chk[c].getElementsByTagName('input')[0];
alert (o_chk[c].checked);
    if (valor == -2)
    {
	    o_chk[c].checked = !o_chk[c].checked;
    }
    else
    {
  	  o_chk[c].checked = valor;
    }
//    checkbox.checked = true;
  }
}

function set_resolucion ()
{ 
	document.cookie = 'res_x=' + screen.width;
	document.cookie = 'res_y=' + screen.height;
}