String.prototype.trim = function() { 
	return this.replace(/^\s+|\s+$/g, ''); 
};

function verifMail() {

	var email=document.getElementById('email').value;
	var expressionEMail = /^[0-9a-zA-Z\._-]+@[0-9a-zA-Z\._-]+\.[0-9a-zA-Z]+$/;
	
	if ( !email.match(expressionEMail) ) {			
		alert("El correo electrónico proporcionado no es correcto. \nPor favor corríjalo antes de continuar");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	else {		
		return true;	
	}
}

function verifMailAmigo() {

	var email=document.getElementById('email_amigo').value;
	var expressionEMail = /^[0-9a-zA-Z\._-]+@[0-9a-zA-Z\._-]+\.[0-9a-zA-Z]+$/;
	
	if ( !email.match(expressionEMail) ) {			
		alert("El correo electrónico proporcionado no es correcto. \nPor favor corríjalo antes de continuar");
		document.getElementById('email_amigo').focus();
		document.getElementById('email_amigo').select();
		return false;
	}
	else {		
		return true;	
	}
}

function validBuscar() {
	if ( document.getElementById('w').value == "" ) {
		alert("Por favor llene el campo indicado a continuación.");
		document.getElementById('w').focus();
		document.getElementById('w').select();
	}
	else {
		document.formBuscar.submit();
	}
}

String.prototype.trim = function() { 
	return this.replace(/^\s+|\s+$/g, ''); 
};

function validContact() {	
	fields = new Array( "nombre", "apellido", "calle", "numero", "colonia", "cp", "municipio", "ciudad" );
	
	for ( var i = 0; i < fields.length; i++ ){														
		if ( document.getElementById(fields[i]).value.trim() == "" ){
			alert( 'Por favor llene el campo indicado a continuación.');
			document.getElementById(fields[i]).focus();
			document.getElementById(fields[i]).select();
			return false;
		}
	}
	
	if ( !verifMail() ) {
		return false;
	}
	
	return true;
	
}

function validRecomienda() {		
	
	fields = new Array( "nombre", "comentarios" );
	
	for ( var i = 0; i < fields.length; i++ ){														
		if ( document.getElementById(fields[i]).value.trim() == "" ){
			alert( 'Por favor llene el campo indicado a continuación.');
			document.getElementById(fields[i]).focus();
			document.getElementById(fields[i]).select();
			return false;
		}
	}
	if ( !verifMail() ) {
		return false;
	}
	if ( !verifMailAmigo() ) {
		return false;
	}

	document.formRecomienda.submit();
		

}

function changeCampios() {
	val = document.getElementById('why').value;
	
	document.getElementById('contacto_1').style.display = 'none';
	document.getElementById('contacto_2').style.display = 'none';
	
	document.getElementById('contacto_' + val).style.display = 'block';
}