
/* Cambiamos de block a none y viceversa de un div */
function display_on_off(div){
	
	if(document.getElementById(div).style.display=="none") document.getElementById(div).style.display="block";
	else document.getElementById(div).style.display="none";
}

/* Ponemos block a on */
function display_on(div){ document.getElementById(div).style.display="block"; }

/* Ponemos block a off */
function display_off(div){ document.getElementById(div).style.display="none"; }

//Quitar contenido del input
function updateInput(txtLabel, thisInput, opcion) {
	if (opcion == 1) {
		if (thisInput.value == txtLabel) thisInput.value = '';
	}
	else {
		if (thisInput.value == '') thisInput.value = txtLabel;
	}
}

function check_contacto(){
	
	var campos= new Array('nombre', 'telefono', 'email');
	var error=false;
	
	for(var i=0;i<campos.length;i++){
		
		if(document.getElementById(campos[i]).value==""){
			document.getElementById(campos[i]).style.color='red';
			error=true;
		}else{
			document.getElementById(campos[i]).style.color='#333';
		}
	}
	
	if(document.getElementById('nombre').value=="Nombre:"){
		document.getElementById('nombre').style.color='red';
		error=true;
	}
	
	if(document.getElementById('telefono').value=="Telefono:"){
		document.getElementById('telefono').style.color='red';
		error=true;
	}
	
	if(document.getElementById('poblacion').value=="E-mail:"){
		document.getElementById('poblacion').style.color='red';
		error=true;
	}
	
		
	
	//Validacion email
	var filter = /^(.+\@.+\..+)$/;
	
	if(!filter.test(document.getElementById('email').value)){
		document.getElementById('email').style.color='red';
		error=true;
	}else{
		document.getElementById('email').style.color='#333';
	}
	
	if(error) window.alert('Revise los campos marcados en rojo.');
	else{

		if(document.getElementById('condiciones').checked)
	 		document.getElementById('form_contacto').submit();
	 	else{
	 		window.alert('Debe de aceptar las condiciones de uso.');
	 		error=true;
	 	}
	}
}



