if (document.images) {
	var activado = new Array();
	var desactivado = new Array();	
	for (i=1;i<=7;i++){
		desactivado['menu_0'+i] = new Image();
		desactivado['menu_0'+i].src = 'imagenes/menu/menu_0' + i + '_off.gif';
		activado['menu_0'+i] = new Image();
		activado['menu_0'+i].src = 'imagenes/menu/menu_0' + i + '_on.gif';
	}
}

function act(nombreImagen) {
	if (document.images){
		document[nombreImagen].src=activado[nombreImagen].src;
	}
}

function desact(nombreImagen) {
	if (document.images){
		document[nombreImagen].src=desactivado[nombreImagen].src;
	}
}

function mail(texto){
	var mailres = true;            
	var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑPQRSTUVWXYZ1234567890@._-";
	var arroba = texto.indexOf("@",0);
	var punto = texto.lastIndexOf(".");
	if ((texto.lastIndexOf("@")) != arroba){
		return false;
	}
	var contador=0;
	while (contador<texto.length){
		if (cadena.indexOf(texto.substr(contador, 1),0) == -1){
			return false;
		} else contador++;
	}
	
	if ((arroba > 1) && (arroba + 1 < punto) && (punto + 1 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)){
		mailres = true;
	} else mailres = false;
	
	return mailres;
}

function enviar_formulario(){
	document.getElementById('error').style.display='none';
	document.getElementById('enviado').style.display='none';
	var acepto=document.getElementById('acepto').value;
	if ((acepto=='on')&&(document.getElementById('f_nombre').value!="")&&(document.getElementById('f_email').value!="")&&(document.getElementById('f_email').value==document.getElementById('f_email2').value)&&(document.getElementById('f_consulta').value!="")&&(mail(document.getElementById('f_email').value))){
		document.getElementById('formulario').action='contacto.php';
		document.getElementById('formulario').submit();
		document.getElementById('formulario').action='';
	} else {
		document.getElementById('error').style.display='block';	
	}
}

function enviar_formulario_contactar(){
	document.getElementById('error').style.display='none';
	var m=mail(document.getElementById('email').value);
	var acepto=document.getElementById('acepto').checked;
	if ((m)&&(acepto==true)&&(document.getElementById('nombre').value!="")&&(document.getElementById('email').value!="")&&(document.getElementById('comentarios').value!="")){
		document.getElementById('formulario').action='contactar.php';
		document.getElementById('formulario').submit();
		document.getElementById('formulario').action='';
	} else {
		document.getElementById('error').style.display='block';	
	}
}

function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl()); 
		map.addControl(new GMapTypeControl());
		
		// SALAMANCA       
		map.setCenter(new GLatLng(43.538200,-5.654750), 16);
		var point = new GPoint(-5.654750,43.538200);
		var marker = new GMarker(point);
		map.addOverlay(marker);
				
		map.setMapType(G_HYBRID_TYPE);
	}
}
