function muestraHora() {
    var hoy = new Date();

    var dia = hoy.getDate();
    var mes = hoy.getMonth() + 1;
    var anyo = hoy.getFullYear();
    var hora = hoy.getHours();
    var minutos = hoy.getMinutes();
    var segundos = hoy.getSeconds();

    if (dia < 10) dia = "0" + dia;
    if (mes < 10) mes = "0" + mes;
    if (hora < 10) hora = "0" + hora;
    if (minutos < 10) minutos = "0" + minutos;
    if (segundos < 10) segundos = "0" + segundos;

    document.getElementById("hora").innerHTML = (dia + "/" + mes + "/" + anyo + " " + hora + ":" + minutos + ":" + segundos);

    setTimeout("muestraHora()", 1000);
}

function AbreVentana(URL_Ventana, OpcionesVentana, Ancho, Alto,
  Centrada, PosX, PosY) {

  if (Centrada) {
    PosX = (screen.availWidth - Ancho)/2;
    PosY = (screen.availHeight - Alto)/2;
    }

  if (OpcionesVentana == '')
    OpcionesVentana = 'width=' + Ancho;
  else
    OpcionesVentana += ',width=' + Ancho;

  OpcionesVentana += ',height=' + Alto + ',left=' + PosX
    + ',top=' + PosY;

  window.open(URL_Ventana, "", OpcionesVentana);
}

function AbreVentanaCSB(URL_Ventana, Ancho, Alto) {
  AbreVentana(URL_Ventana, "scrollbars=1", Ancho, Alto, true);
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}

function textoAyuda(texto) {
    document.getElementById('divAyuda').innerHTML = texto;
}

function detalleImagen(texto) {
    document.getElementById('divDetalleImagen').innerHTML = texto;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function compruebaMail(texto){
  //Copyright İ McAnam.com
  var mailres = true;
  var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-";

  var arroba = texto.indexOf("@",0);
  if ((texto.lastIndexOf("@")) != arroba) arroba = -1;

  var punto = texto.lastIndexOf(".");

   for (var contador = 0 ; contador < texto.length ; contador++){
      if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
          mailres = false;
          break;
   }
  }

  if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1))
   mailres = true;
  else
   mailres = false;

  return mailres;
}

function compruebaFormularioAlta(form) {
    correcto = true;
    camposObligatorios = new Array('email', 'password', 'password2', 'nombre', 'apellidos');
    errores = new Array();
    errores.push("<span style='color: #E02230'>The form contains the following errors:<br><br>");
    if(!compruebaCampos(form, camposObligatorios)) {
        errores.push("- The obligatory fields have not been filled in.<br><br>");
        correcto = false;
    }
    if(!compruebaMail(form['email'].value)) {
        errores.push("- The address of mail introduced is not valid.<br><br>");
        correcto = false;
    }
    if(!compruebaPassword(form['password'].value, form['password2'].value)) {
        errores.push("- The same password has to be introduced twice.<br><br>");
        correcto = false;
    }
    if(!correcto) {
        errores.push("</span>");
        textoError = "";
        for(i = 0; i < errores.length; i++) {
            textoError = textoError + errores[i];
        }
        textoAyuda(textoError);
    }
    return correcto;
}

function compruebaFormularioContacto(form) {
    correcto = true;
    camposObligatorios = new Array('email', 'nombre', 'apellidos');
    errores = new Array();
    errores.push("<span style='color: #E02230'>The form contains the following errors:<br><br>");
    if(!compruebaCampos(form, camposObligatorios)) {
        errores.push("- The obligatory fields have not been filled in.<br><br>");
        correcto = false;
    }
    if(!compruebaMail(form['email'].value)) {
        errores.push("- The address of mail introduced is not valid.<br><br>");
        correcto = false;
    }
    if(!correcto) {
        errores.push("</span>");
        textoError = "";
        for(i = 0; i < errores.length; i++) {
            textoError = textoError + errores[i];
        }
        textoAyuda(textoError);
    }
    return correcto;
}

function compruebaFormularioCaballo(form) {
    correcto = true;
    camposObligatorios = new Array('nombre', 'edad');
    errores = new Array();
    errores.push("<span style='color: #E02230'>The form contains the following errors:<br><br>");
    if(!compruebaCampos(form, camposObligatorios)) {
        errores.push("- .<br><br>");
        correcto = false;
    }
    if(!correcto) {
        errores.push("</span>");
        textoError = "";
        for(i = 0; i < errores.length; i++) {
            textoError = textoError + errores[i];
        }
        textoAyuda(textoError);
    }
    return correcto;
}

function compruebaCampos(form, campos) {
    rellenos = true;
    for(i = 0; i < campos.length; i++) {
        if(form[campos[i]].value == "") {
            rellenos = false;
        }
    }
    return rellenos;
}

function compruebaPassword(password1, password2) {
    return (password1 == password2);
}

function compruebaFormularioRecuperacion(form) {
    correcto = true;

    if(!compruebaMail(form['email'].value)) {
        alert("The address of mail introduced is not valid.");
        correcto = false;
    }
    return correcto;
}

function confirmaBorrado(texto) {
    var ok = confirm(texto);
    if (ok) {
        return true;
    } else {
        return false;
    }
}

window.onload = muestraHora;