var screenW = (screen.width/2);
var screenH = (screen.height/2);
var woSendMail  = 'width=520, height=440, scrollbars=yes, toolbar=no, status=yes';
var woClau = 'width=420, height=250, scrollbars=yes, toolbar=no, status=yes';
var woDist = 'width=950, height=690, scrollbars=yes, toolbar=no, status=yes';
var woMedia = 'scrollbars=yes, toolbar=no, status=yes, resize=yes';


function fOpenWindow(pUrl, pTarget, pAtributos)
{
  finestra = window.open(pUrl, pTarget, pAtributos);
}


function registrar()
{
  var f = document.forms['registreWebForm'];
  var language = f.elements['baseWeb.language'].value;
  var mes = "";
  if (validateRegistreWebForm(f))
  {
    if(language=="ca")
      mes = "Se l'hi enviara per correu les dades d'accés a la web.\nEstà segur de que l'e-mail proporcionat es correcte?"
    else
      mes = "Se le enviara por correo los datos de acceso a la web.\n¿Está seguro de que el e-mail proporcionado es correcto?"

    if(confirm(mes))
      f.submit();
    else
      f.elements['registre.email'].focus();
  }
}

function PublicFK(x, url)
{
  obj = document.getElementById('divFK');
  obj.style.display='block';
  ajax.makeRequest(url, 'ajaxResultatNull(divFK)');
  obj.style.left=x[0]-467;
  obj.style.top=x[1]-309;
}

function clave()
{
//  finestra = window.open(pUrl, pTarget, woSendMail);
  fOpenWindow ("/modificar-clave.do", "Clave", woClau)
}

function nuevaClave()
{
  fOpenWindow ("/solicitar-clave.do", "Clave", woClau)
}

function validarClave()
{
  var f = document.forms[0];
  var clau = f.elements['clau.clau'].value;
  var reclau = f.elements['clau.reClau'].value;
  
  if (clau!=reclau)
  {
    alert("Nueva clave y Confirme la clave, no són iguales.");
    f.elements['clau.clau'].value = "";
    f.elements['clau.reClau'].value = "";
    return false;
  }
  
  return validateClauWebForm(f);

}

function fotoAlbum(url)
{
  obj = document.getElementById('fotoAlbumDiv');
  obj.style.display='block';
  ajax.makeRequest(url, 'ajaxResultatNull(fotoAlbumDiv)');
}

function ultimaHora(url)
{
  obj = document.getElementById('ultimaHoraDiv');
  obj.style.display='block';
  obj.style.left="380px";
  obj.style.top="200px";
  ajax.makeRequest(url, 'ajaxResultatNull(ultimaHoraDiv)');
}


function PassarPoblacioFK(codiPoblacio, poblacio, cp, provincia)
{
  f = document.forms[1];
  f.elements['registre.codiPoblacio'].value = codiPoblacio;
  f.elements['registre.adreca.paisCP.poblacio'].value = poblacio;
  f.elements['registre.adreca.paisCP.codiPostal'].value = cp;
  f.elements['registre.adreca.paisCP.provincia'].value = provincia;
  document.getElementById('divFK').style.display='none';
}

function noSubmit(e) {
  tecla = (document.all) ? e.keyCode : e.which;
  return tecla!=13;
}

function ampliarFoto(foto)
{
  obj = document.getElementById('ampliarFotoDiv');
  obj.style.display='block';
  ajax.makeRequest(context+'/ampliacio.do?baseWeb.ampliacio='+foto, 'ajaxResultatNull(ampliarFotoDiv)');

  obj.style.left="200px";
  obj.style.top="200px";
}
