// JavaScript Document
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 = "<img src='"+logo+"' align='left' style='margin: 0 10px 50px 0;'>";
				html+=direccion+"<br>";
				html+=cp+" "+localidad+"<br>";
				html+=provincia+"<br>";
				html+="<b>Tel "+telefono+"</b><br>";
				html+="<b>Fax. "+fax+"</b><br>";
				html+="<a href='mailto:"+email+"'>"+email+"</a>";
				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.419914,2.200452), 17);
		
		// Set up eight markers with info windows 		
		var point = new GLatLng(41.419914,2.200452);
		var marker = createMarker(point, 1, 'Escola Verns', 'C/Cantabria 31 bis', '08020', 'Barcelona', 'BARCELONA', '93 313 50 51', '93 313 50 51', 'info@escolaverns.cat', 'http://www.escolaverns.cat/images/logovernmapa.jpg');
		map.addOverlay(marker);
	} 
	else{
		alert("Lo siento, Google Maps no es compatible con su navegador");
	}
}

function validarDatos(nameformulario, texto_alerta_campos){
	var Validar = new clsValidator();
	Validar.setEncabezado(texto_alerta_campos);
	Validar.setErrorColor("#DBDD00");
	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_pet_recambios(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 mostrar_diesel(){
	jQuery('#desp_diesel').slideDown('slow');
	jQuery('#desp_gasolina').slideUp('slow');
	jQuery('#desp_gas').slideUp('slow');
}
function mostrar_gasolina(){
	jQuery('#desp_gasolina').slideDown('slow');
	jQuery('#desp_gas').slideUp('slow');
	jQuery('#desp_diesel').slideUp('slow');
}
function mostrar_gas(){
	jQuery('#desp_gas').slideDown('slow');
	jQuery('#desp_gasolina').slideUp('slow');
	jQuery('#desp_diesel').slideUp('slow');
}
