
	  function validarCampos(){
		
		document.fhog.ValorContinente.value = document.fhog.ValorContinente.value.replace (/^\s*|\s*$/g,"")
		if (document.fhog.ValorContinente.value.length!=0) { 
		  if (!comprobarvalor(document.fhog.ValorContinente.value)) {
		    alert('El valor del "Continente" introducido "'+ document.fhog.ValorContinente.value +'" no es un valor válido y se borrará')
		    document.fhog.ValorContinente.value="" 
			document.fhog.ValorContinente.focus()
			return false;
		  }
		}
		
		document.fhog.ValorContenido.value = document.fhog.ValorContenido.value.replace (/^\s*|\s*$/g,"")
		if (document.fhog.ValorContenido.value.length!=0) { 
		  if (!comprobarvalor(document.fhog.ValorContenido.value)) {
		    alert('El valor del "Contenido" introducido "'+ document.fhog.ValorContenido.value +'" no es un valor válido y se borrará')
		    document.fhog.ValorContenido.value="" 
			document.fhog.ValorContenido.focus()
			return false;
		  }
		}
		
		document.fhog.ValorJoyas.value = document.fhog.ValorJoyas.value.replace (/^\s*|\s*$/g,"")
		if (document.fhog.ValorJoyas.value.length!=0) { 
		  if (!comprobarvalor(document.fhog.ValorJoyas.value)) {
		    alert('El valor de las "Joyas" introducido "'+ document.fhog.ValorJoyas.value +'" no es un valor válido y se borrará')
		    document.fhog.ValorJoyas.value="" 
			document.fhog.ValorJoyas.focus()
			return false;
		  }
		}
		
		if (document.fhog.ValorContinente.value.length==0 && document.fhog.ValorContenido.value.length==0 && document.fhog.ValorJoyas.value.length==0) {
		  alert("Debe indicar el valor de los elementos que desea proteger: Continente, Contenido o Joyas")
       	  document.fhog.ValorContinente.focus() 
          return false; 
		}
		
		document.fhog.ValorOtrosObjetos.value = document.fhog.ValorOtrosObjetos.value.replace (/^\s*|\s*$/g,"")
		if (document.fhog.ValorOtrosObjetos.value.length>250) {
		  alert("El texto introducido para indicar los objetos de valor supera los 250 caracteres") 
		  document.fhog.ValorOtrosObjetos.focus() 
		  return false; 
		}
		
		if (document.fhog.TipoVivienda.value == "ninguna") {
		  alert("Debe seleccionar un tipo de vivienda de la lista desplegable") 
		  document.fhog.TipoVivienda.focus() 
		  return false; 
		}
		
		if (document.fhog.ClaseConstrucción.value == "ninguna") {
		  alert("Debe seleccionar una clase de construcción de la lista desplegable") 
		  document.fhog.ClaseConstrucción.focus() 
		  return false; 
		}
		
		if (document.fhog.UsoVivienda.value == "ninguna") {
		  alert("Debe seleccionar el uso de la vivienda de la lista desplegable") 
		  document.fhog.UsoVivienda.focus() 
		  return false; 
		}
		
        if (document.fhog.AñoConstrucción.value.length==0) { 
       	  alert("Debe indicar el año de construcción") 
       	  document.fhog.AñoConstrucción.focus() 
          return false; 
		}
	    else {
		  if (!comprobarFechas(document.fhog.AñoConstrucción.value)) {
			document.fhog.AñoConstrucción.value=""  
  	        alert("Debe indicar el año de construcción con 4 cifras") 
       	    document.fhog.AñoConstrucción.focus()
			return false;
		  }
		  if (document.fhog.AñoConstrucción.value<1900) {
  	        alert("No aseguramos viviendas construidas antes de 1900") 
       	    document.fhog.AñoConstrucción.focus()
			return false;
		  }
		  fecha = new Date()
		  anio = fecha.getFullYear()
		  if (document.fhog.AñoConstrucción.value>anio) {
  	        alert("La fecha introducida es posterior al año actual, por favor, modifíquela") 
       	    document.fhog.AñoConstrucción.focus()
			return false;
		  }
    	}
		
		document.fhog.MetrosConstruidos.value = document.fhog.MetrosConstruidos.value.replace (/^\s*|\s*$/g,"")
        if (document.fhog.MetrosConstruidos.value.length==0) { 
       	  alert("Debe indicar los metros construidos de vivienda") 
       	  document.fhog.MetrosConstruidos.focus() 
          return false; 
    	}
	    else {
		  if (!comprobarvalor(document.fhog.MetrosConstruidos.value)) {
  	        document.fhog.MetrosConstruidos.value = ""
			alert("Debe indicar los metros construidos de vivienda con números") 
       	    document.fhog.MetrosConstruidos.focus()
			return false;
		  }
    	}
		
		document.fhog.Dormitorios.value = document.fhog.Dormitorios.value.replace (/^\s*|\s*$/g,"")
        if (document.fhog.Dormitorios.value.length==0) { 
       	  alert("Debe indicar el número de dormitorios de la vivienda") 
       	  document.fhog.Dormitorios.focus() 
          return false; 
    	}
	    else {
		  if (!comprobarvalor(document.fhog.Dormitorios.value)) {
  	        document.fhog.Dormitorios.value = ""
			alert("Debe indicar el número de dormitorios de la vivienda con números") 
       	    document.fhog.Dormitorios.focus()
			return false;
		  }
    	}
		
		if (document.fhog.Situación.value == "ninguna") {
		  alert("Debe seleccionar la situación de la vivienda de la lista desplegable") 
		  document.fhog.Situación.focus() 
		  return false; 
		}

		document.fhog.MaterialesConstrucción.value = document.fhog.MaterialesConstrucción.value.replace (/^\s*|\s*$/g,"")
		if (document.fhog.MaterialesConstrucción.value.length==0) { 
		    alert("Debe indicar los materiales de construcción de la vivienda")
			document.fhog.MaterialesConstrucción.focus()
			return false;
		}

		document.fhog.TipoProtección.value = document.fhog.TipoProtección.value.replace (/^\s*|\s*$/g,"")
		  
		document.fhog.NombreContacto.value = document.fhog.NombreContacto.value.replace (/^\s*|\s*$/g,"")
        if (document.fhog.NombreContacto.value.length==0) { 
       	  alert("Debe indicar su nombre") 
       	  document.fhog.NombreContacto.focus() 
          return false; 
    	}
	
		document.fhog.ApellidosContacto.value = document.fhog.ApellidosContacto.value.replace (/^\s*|\s*$/g,"")
	    if (document.fhog.ApellidosContacto.value.length==0) { 
       	  alert("Debe indicar sus apellidos") 
       	  document.fhog.ApellidosContacto.focus() 
       	  return false; 
	    } 

		document.fhog.Correo.value = document.fhog.Correo.value.replace (/^\s*|\s*$/g,"")
	    if (document.fhog.Correo.value.length==0) { 
       	  alert("No ha introducido la dirección de correo electrónico") 
       	  document.fhog.Correo.focus() 
       	  return false; 
	    }
	    else {
		  if (!comprobarCorreo(document.fhog.Correo.value)) {
			return false;
		  }
	    }
		
	
		document.fhog.Teléfono.value = document.fhog.Teléfono.value.replace (/^\s*|\s*$/g,"")
		if (document.fhog.Teléfono.value.length!=0) {
		  if (!comprobarTelefono(document.fhog.Teléfono.value)) {
			alert("Debe indicar el número de teléfono con 9 cifras")
			document.fhog.Teléfono.focus()
			return false;
		  }
		}


		document.fhog.Fax.value = document.fhog.Fax.value.replace (/^\s*|\s*$/g,"")
		if (document.fhog.Fax.value.length!=0) {
		  if (!comprobarTelefono(document.fhog.Fax.value)) {
			alert("Debe indicar el número de fax con 9 cifras")
			document.fhog.Fax.focus()
			return false;
		  }
		}
		
		document.fhog.DirecciónPostal.value = document.fhog.DirecciónPostal.value.replace (/^\s*|\s*$/g,"")

	
		  return true;
	  } 

	  function comprobarCorreo(cadena) {
	    var formato = /[^\w^@^\.^-]+/gi
		if (formato.test(cadena)) {
     	  alert('La dirección de correo electrónico que ha introducido "'+ cadena + '" contiene caracteres extraños')
       	  document.fhog.Correo.focus()
		}
		else {
     	  formato =/(^\w+)(@{1})([\w\.-]+$)/i
     	  if (formato.test(cadena)){
		    return true; 
		  }
     	  else {
  	        alert("La dirección de correo electrónico que ha introducido no es válida") 
       	    document.fhog.Correo.focus()
            return false;
		  }
     	} 
	  }
	  
	  function comprobarvalor(cadena) {
	    var formatovalor = /[0-9]/
     	  if (formatovalor.test(cadena)){
		    return true; 
		  }
     	  else {
            return false;
		  }
     	}

	  function comprobarFechas(cadena) {
	    var formatonum = /[0-9]{4}/
     	  if (formatonum.test(cadena)){
		    return true; 
		  }
     	  else {
            return false;
		  }
     	} 


	  function comprobarTelefono(cadena) {
	    var formatofono = /[0-9]{9}/
     	  if (formatofono.test(cadena)){
		    return true; 
		  }
     	  else {
            return false;
		  }
     	} 


	  function limpiaralentrar() {
			document.fhog.reset();
		}

/*-----------Contador de caracteres que faltan por escribir en un cuadro de texto-----------*/
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Written by Steve - http://jsmadeeasy.com/ -->
<!-- Ampliado por Pepe Munilla -->

<!--
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    }
	else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    }
	else {
      return obj.style;
    }
  }
  return null;
}

//Contador de caracteres.
function Contar(entrada,salida,texto,caracteres,textofinal) {
  var entradaObj=getObject(entrada);
  var salidaObj=getObject(salida);
  var longitud=caracteres - entradaObj.value.length;
  if(longitud <= 0) {
    longitud=0;
    texto='<span class="fincaracteres"> '+textofinal+' </span>';
    entradaObj.value=entradaObj.value.substr(0,caracteres);
  }
  salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
}