// JavaScript Document
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function validar() {
	alerta="";
	i=0;
	txt=window.document.getElementById('nombre').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - Nombre.\n';
    }
	
	txt=window.document.getElementById('apellidos').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - Apellidos.\n';
    }
	
	var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
	txt=trim(window.document.getElementById('email').value);
	if (txt != "" ) {
		if( !b.test(txt)) {
			i=1;
			alerta += '      - E-mail válido.\n';
		}
	} else {
		i=1;
		alerta += '      - E-mail.\n';
	}
	
	txt=window.document.getElementById('pais').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - País.\n';
    }
	
	txt=window.document.getElementById('ciudad').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - Ciudad.\n';
    }
	
	txt=window.document.getElementById('mensaje').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - Lo más importante, su Mensaje.\n';
    }
	
	if(i==0){
		window.document.getElementById('EnViArEmAil').submit();
	}  else {
		alert("Por favor ingrese lo siguiente:\n" + alerta);
	}
}

function validarSubmit() {
	alerta="";
	i=0;
	txt=window.document.getElementById('nombre').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - Nombre.\n';
    }
	
	txt=window.document.getElementById('apellidos').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - Apellidos.\n';
    }
	
	var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/;
	txt=trim(window.document.getElementById('email').value);
	if (txt != "" ) {
		if( !b.test(txt)) {
			i=1;
			alerta += '      - E-mail válido.\n';
		}
	} else {
		i=1;
		alerta += '      - E-mail.\n';
	}
	
	txt=window.document.getElementById('pais').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - País.\n';
    }
	
	txt=window.document.getElementById('ciudad').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - Ciudad.\n';
    }
	
	txt=window.document.getElementById('mensaje').value;
	txt=trim(txt);
	if ( txt.length <  1 ) {
		i=1;
		alerta += '      - Lo más importante, su Mensaje.\n';
    }
	
	if(i==0){
		return true;
	}  else {
		alert("Por favor ingrese lo siguiente:\n" + alerta);
		return false;
	}
}