function validarDatos(nameformulario, texto_alerta_campos){
	var Validar = new clsValidator();
	Validar.setEncabezado(texto_alerta_campos);
	Validar.setErrorColor("#A04528");
	Validar.setFormatoHora('24');
	Validar.setFormatoFecha('EURO');
	//Primero busco todos los campos a evaluar
	elementos = document.forms[nameformulario].elements;
	var array_validaciones=new Array();
	var inc=0;
	for (i=0; i<elementos.length; i++){
		className = elementos[i].className;
		validadonull = false;
		if(className.substring(className.length-4)=="NULL"){
			if(trim(elementos[i].value)=="") validadonull=true;
			className = className.substring(0, className.length-4);
		}
		if((className=="frmvalEmail")&&(validadonull==false)){
			label = elementos[i].name+"_lb";
			descripcion = document.forms[nameformulario].elements[label].value;
			Validar.Email(elementos[i].name, descripcion);
		}
		if((className=="frmvalNoVacio")&&(validadonull==false)){
			label = elementos[i].name+"_lb";
			descripcion = document.forms[nameformulario].elements[label].value;
			Validar.Vacio(elementos[i].name, descripcion);
		}
		if((className=="frmvalFecha")&&(validadonull==false)){ 
			label = elementos[i].name+"_lb";
			descripcion = document.forms[nameformulario].elements[label].value;
			Validar.Fecha(elementos[i].name, descripcion);
		}
		if((className=="frmvalEntero")&&(validadonull==false)){
			label = elementos[i].name+"_lb";
			descripcion = document.forms[nameformulario].elements[label].value;
			Validar.Entero(elementos[i].name, descripcion);
		}
		if((className=="frmvalDecimal")&&(validadonull==false)){
			label = elementos[i].name+"_lb";
			descripcion = document.forms[nameformulario].elements[label].value;
			Validar.Decimal(elementos[i].name, descripcion);
		}
		if((className=="frmvalCP")&&(validadonull==false)){
			label = elementos[i].name+"_lb";
			descripcion = document.forms[nameformulario].elements[label].value;
			Validar.CP(elementos[i].name, descripcion);
		}
	}
	
	if (Validar.Validar()){
		return true;
	}
	else{
		Validar.getErrors();
		return false;
	}
}

function enviar_form_contacto(nameformulario, texto_alerta_ley, texto_alerta_campos){
	if(document.forms[nameformulario].elements["acepto"].checked==false){
		alert(texto_alerta_ley); 
	}
	else{
		if(validarDatos(nameformulario, texto_alerta_campos)){
			document.forms[nameformulario].submit();
		}
	}
}
function enviar_form_adhesion(nameformulario, texto_alerta_ley, texto_alerta_campos){
	if(document.forms[nameformulario].elements["acepto"].checked==false){
		alert(texto_alerta_ley); 
	}
	else{
		if(validarDatos(nameformulario, texto_alerta_campos)){
			document.forms[nameformulario].submit();
		}
	}
}
function postear_comentario(nameformulario, texto_alerta_campos){
	if(validarDatos(nameformulario, texto_alerta_campos)){
		document.forms[nameformulario].submit();
	}
}

function showMap(){
	if (GBrowserIsCompatible()) { 
		function createMarker(point, i, empresa, direccion, cp, localidad, provincia, telefono, fax, email, logo) {
			var marker = new GMarker(point);
			GEvent.addListener(marker, "click", function() {
				html = "<div id='googlemap_globo'><h2>"+empresa+"</h2>";
				html+=direccion+"<br>";
				html+=cp+" "+localidad+"<br>";
				html+="Telf. "+telefono+"<br>";
				html+="Fax "+fax+"<br>";
				html+="<a href='mailto:"+email+"'>"+email+"</a></div>";
				marker.openInfoWindowHtml(html);
			});
		  return marker;
		}
		// Display the map, with some controls and set the initial location 
		var map = new GMap2(document.getElementById("googlemap"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(41.389785,2.139941), 15);
		
		// Set up eight markers with info windows 		
		var point = new GLatLng(41.389785,2.139941);
		var marker = createMarker(point, 1, 'Gremi de Fusters de Barcelona', 'Travessera de les Corts 361, Entl. 1ª', '08029 ', 'Barcelona', 'BARCELONA', '93 323 32 00', '93 451 24 40', 'gremi@gremifusters.com', 'http://www.gremifusters.com');
		map.addOverlay(marker);
	} 
	else{
		alert("Lo siento, Google Maps no es compatible con su navegador");
	}
}
