$(document).ready(

	function(){
		
		$("#lnkSendContacto img").click(
			
			function(event){
			
				$(".msj-error").remove();
			
				var vError = false;
				
				if( jQuery.trim($("#txt-nombre").val()) == ""){
					$("#txt-nombre").after("&nbsp;<span class='msj-error'>Campo requerido</span>")
					vError = true;
				}
				
				if( jQuery.trim($("#txt-correo").val()) == ""){
					$("#txt-correo").after("&nbsp;<span class='msj-error'>Campo requerido</span>")
					vError = true;
				}else{
					
					if(!validarEmail($("#txt-correo").val())){
						$("#txt-correo").after("&nbsp;<span class='msj-error'>Correo invalido</span>")
						vError = true;
					}
					
				}
				
				if( jQuery.trim($("#txt-comentario").val()) == ""){
					$("#txt-comentario").after("&nbsp;<span class='msj-error'>Campo requerido</span>")
					vError = true;
				}
				
				if(!vError){
					$("#frmContacto").submit();
				}else{
					//mandar error
				}
			
				event.preventDefault();
			
			}
			
		);
		
	}

);

function validarEmail(valor) {

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