var resolu
	resolu = screen.width;

function irUrl(url)
 {
  parent.location.href = url;
 }
 
function mostrarLayer(Obj)
 {
  var lay = document.getElementById(Obj);
  lay.style.visibility = 'visible';
 }

function esconderLayer(Obj)
 {
  var lay = document.getElementById(Obj);
  lay.style.visibility = 'hidden';
 }

function fondoCelda(src, col)
 {
  src.bgColor = col;
 }

function abrirPopUp(w, h, Pagina, Parametros, scrollb, resi)
 {
  var w, h
  var iz=((screen.width) / 2) - (w / 2)  ; 
  var de=((screen.height) / 2) - (h / 2) ; 
  ventana = window.open(Pagina + '?' + Parametros, '_blank', 'width=' + w + ', height=' + h + ', scrollbars=' + scrollb + ', resizable=' + resi );
  ventana.moveTo(iz,de); 
return true;
 }

function cambiaStyle(idObj, estilo)
 {
  var obj = document.getElementById(idObj);
  obj.className=estilo;
 }

function cambiaImagenFondoCelda(idObj, img)
 {
  var obj = document.getElementById(idObj);
  if (img == "" || img == "none")
   obj.style.backgroundImage = 'none';
  else
   obj.style.backgroundImage = 'url(' + img + ')';
 }
 
function enviaForm(IdForm, target)
 {
  var frm = document.getElementById(IdForm);
  if (target == null || target == "")
   frm.target = "_self";
  else
   frm.target = target;
  frm.submit();
 }

function desaparecerLayer(Obj)
 {
  var lay = document.getElementById(Obj);
  lay.style.display = 'none';
 }

function aparecerLayer(Obj)
 {
  var lay = document.getElementById(Obj);
  lay.style.display = '';
 }

function agregaCod(Idpapa, Cod, Sep)
{
 var Codf;
 Cod = Cod.split(Sep);
 Codf = "";
 for(i = 0;i < Cod.length;i++) 
 	Codf = Codf + '"' + Cod[i];
 Codf = Codf.substr(1, Codf.length);
 codigoFinal = codigoFinal + Codf;
 var Papa = document.getElementById(Idpapa);
 Papa.innerHTML = codigoFinal;
}

function imprimir(marco)
{
 marco.focus();
 marco.print();
}

function cambiaImg(idImg, img)
 {
  var Img = document.getElementById(idImg);
  Img.src = img;
 }

function enviaCampo(IdCampo, Valor, IdForm)
 {
  var campo = document.getElementById(IdCampo);
  campo.value = Valor;
  enviaForm(IdForm);
 }
 
function cambiaCampo(IdCampo, Valor)
 {
  var campo = document.getElementById(IdCampo);
  campo.value = Valor;
 }
 
function enviaCampoPagina(IdCampo, Valor, IdForm, Pagina)
 {
  var campo = document.getElementById(IdCampo);
  var form  = document.getElementById(IdForm);
  campo.value = Valor;
  form.action = Pagina;
  enviaForm(IdForm);
 }

function validaFrm(FRM, cabeza, bajada)
 {
  var form = document.getElementById(FRM);
  var camposNo = "";
  for (t = 0; t < form.elements.length; t++)
   {
    Largo = form.elements[t].value.length;
    if (Largo == 0 && form.elements[t].nulo == 'false')
     camposNo = camposNo + "\n" + form.elements[t].desc;
   }
  if (camposNo.length > 0)
   alert(cabeza + camposNo + '\n' + bajada);
  else
   form.submit();
 }

function muestraEsconde(id, img)
 {
  var cel = document.getElementById(id);
  if (img != "")
   var ima = document.getElementById(img);
  if (cel.style.display == 'none')
   {
    cel.style.display = '';
    if (img != "")
     {
      ima.alt = "Esconder";
      ima.src = "imgs/menos.jpg";
     }
   }
  else
   {
    cel.style.display = 'none';
    if (img != "")
     {
      ima.alt = "Mostrar";
      ima.src = "imgs/mas.jpg";
	 }
   }
 }
