function validarTelefono(valor) {
if( /^[0-9]{2,3}-? ?[0-9]{6,7}$/.test(valor)) {
 return true;
	} else {
		return false;
	}
}

function validarEmail(valor) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(valor)){
		return true;
	} else {
		return false;
	}
}


function validar_contacto(){
	
	if (document.formo.nombre.value.length == 0){
       document.formo.nombre.focus();
	   document.getElementById("confirmacion").style.display = "block";
	   document.getElementById("confirmacion").innerHTML = "Introduzca su Nombre";
       return false;
    } 
	
	if(validarTelefono(document.formo.telefono.value) == false ){
       document.formo.telefono.focus();
	   document.getElementById("confirmacion").style.display = "block";
	   document.getElementById("confirmacion").innerHTML = "Introduzca un tel&eacute;fono de contacto valido (ej.986250250)";
       return false;
    }
	
	if(validarEmail(document.formo.email.value) == false){
		document.formo.email.focus();
		document.getElementById("confirmacion").style.display = "block";
	   document.getElementById("confirmacion").innerHTML = "Introduzca un E-mail v&aacute;lido";
		return false;
	}

	if (document.formo.provincia.value.length == 0){
       document.formo.provincia.focus();
	   document.getElementById("confirmacion").style.display = "block";
	   document.getElementById("confirmacion").innerHTML = "Debe indicarnos su Provincia";
       return false;
    } 
	
	if (document.formo.asunto.value.length == 0){
       document.formo.asunto.focus();
	   document.getElementById("confirmacion").style.display = "block";
	   document.getElementById("confirmacion").innerHTML = "Introduzca su mensaje";
       return false;
    }
	
	
	document.formo.submit();
}

function borrar_contacto(){
	
	document.formo.nombre.value = "";
	document.formo.telefono.value = "";
	document.formo.email.value = "";
	document.formo.provinvia.value = "";
	document.formo.asunto.value = "";

      
	document.getElementById("confirmacion").style.display = "none";
	document.getElementById("confirmacion").innerHTML = "";
}


