  var modificando=0;
  var idmodif=0;
  var codigomodif=null;
  var modificando_prov=0;
  var idmodif_prov=0;
  var codigomodif_prov=null;

  function modifica(id) {
    if (modificando) {
      if (id!=idmodif) {
        var Ocodigo=eval("document.formModifAg.codigo"+idmodif);
        Ocodigo.value=codigomodif;
        modificando=0;
        Ocodigo.style.display="none";
        document.getElementById('codigo_txt'+idmodif).style.display="block";
        modifica(id);
      }
    } else {
      var Ocodigo=eval("document.formModifAg.codigo"+id);
      Ocodigo.style.display="block";
      document.getElementById('codigo_txt'+id).style.display="none";
      Ocodigo.focus();
      modificando=1;
      idmodif=id;
      codigomodif=Ocodigo.value;
      if (document.getElementById('msjERROR')) document.getElementById('msjERROR').style.display="none";
    }
  }
  function modifica_prov(id) {
    if (modificando_prov) {
      if (id!=idmodif_prov) {
        var Ocodigo=eval("document.formModifProv.codigo"+idmodif_prov);
        Ocodigo.value=codigomodif_prov;
        modificando_prov=0;
        Ocodigo.style.display="none";
        document.getElementById(idmodif_prov).style.display="block";
        modifica_prov(id);
      }
    } else {
      var Ocodigo=eval("document.formModifProv.codigo"+id);
      Ocodigo.style.display="block";
      document.getElementById(id).style.display="none";
      Ocodigo.focus();
      modificando_prov=1;
      idmodif_prov=id;
      codigomodif_prov=Ocodigo.value;
      if (document.getElementById('msjERROR')) document.getElementById('msjERROR').style.display="none";
    }
  }
  function guarda(id) {
    document.formModifAg.seleccionado.value=id;
    document.formModifAg.submit();
  }
  function guarda_old(id) {
    if (modificando) {
      if (id==idmodif) {
        document.formModifAg.seleccionado.value=id;
        document.formModifAg.submit();
      } 
    }
  }

  function guarda_prov(id) {
    arr_datos=id.split("^");
    if (modificando_prov) {
      if (arr_datos[0]==idmodif_prov) {
        document.formModifProv.idproveedor.value=arr_datos[1];
        document.formModifProv.submit();
      }
    }
  }
  function leetecla(id) {
    if(event.keyCode == 13 ) {
      if(id==null)
        if(modificando_prov)
          id=idmodif_prov;
        else return false;
      document.formModifProv.idproveedor.value=id;
      document.formModifProv.submit();
    }
  }

  var prevClass="";

  function sobre (obj) {
    prevClass=obj.className;
    obj.className="microsite_pestana-act";
  }

  function fuera (obj) {
    obj.className=prevClass;
  }

  function go_to (destino) {
    window.location = destino;
  }  
  
  function MM_findObj(n, d) {
    var p,i,x;
    if(!d)
      d=document;
    if((p=n.indexOf("?"))>0&&parent.frames.length) {
      d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all)
      x=d.all[n];
    for (i=0;!x&&i<d.forms.length;i++)
      x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++)
      x=MM_findObj(n,d.layers[i].document);
    return x;
  }

  function OnClick_changeprov(cod_pro)
  {
    document.datos.autonomia.value = cod_pro;
  }
  function selecciona(valor) {
	if (valor == "PORTUGAL")
	{
		document.datos.provincia.value="";
		document.datos.pais[1].selected = "1";
	}
	else
	{
		document.datos.pais[0].selected = "1";
		document.datos.provincia.value=valor;
	}
  }

  function setProvincia(provincia) {
    var obj = document.getElementById('div_provincia');
    if (obj) {
      obj.innerHTML = unescape('%3Cspan class=%22azul%22%3E%3Cb%3E' + provincia +'%3C/b%3E%3C/span%3E');
    }
    /*var newText = '%3Cspan class=%22azul%22%3E%3Cb%3E' + provincia +'%3C/b%3E%3C/span%3E';
    if ((obj=MM_findObj('div_provincia'))!=null) with (obj) {
      if (navigator.appName=='Netscape') {
        document.write(unescape(newText));
        document.close();
      } else innerHTML = unescape(newText);
    }*/
  }

 function muestra(grupo) {
  if (grupo == "")  {
    document.getElementById("ver_url").style.display="none";
  } else {
    document.getElementById("ver_url").style.display="inline";
    document.getElementById("ver_url").value=array_urls[grupo];
  }
 }

function habilitar(proveedor) {
 if (proveedor == "") {
    document.f.grupo.disabled = true;
 } else {
    window.location.href="/?opc=prov&accion=modurl&IDPROV="+proveedor;
 }

}
