function showMap(){
	if($('#google_maps').is(':hidden')){
		$('#google_maps').fadeIn('slow');
	}else{
		$('#google_maps').fadeOut('slow');
	}

}
function showSala1(){
	$('#sala2').hide();
	$('#sala3').hide();
	if($('#sala1').is(':hidden')){
		$('#sala1').fadeIn('slow');
	}else{
		$('#sala1').fadeOut('slow');
	}

}
function showSala2(){
	$('#sala1').hide();
	$('#sala3').hide();
	if($('#sala2').is(':hidden')){
		$('#sala2').fadeIn('slow');
	}else{
		$('#sala2').fadeOut('slow');
	}

}
function showSala3(){
	$('#sala1').hide();
	$('#sala2').hide();
	if($('#sala3').is(':hidden')){
		$('#sala3').fadeIn('slow');
	}else{
		$('#sala3').fadeOut('slow');
	}
}

function showAct1(){
	$('#act2').hide();
	$('#act3').hide();
	$('#act4').hide();
	if($('#act1').is(':hidden')){
		$('#act1').fadeIn('slow');
	}else{
		$('#act1').fadeOut('slow');
	}
}
function showAct2(){
	$('#act1').hide();
	$('#act3').hide();
	$('#act4').hide();
	if($('#act2').is(':hidden')){
		$('#act2').fadeIn('slow');
	}else{
		$('#act2').fadeOut('slow');
	}
}
function showAct3(){
	$('#act2').hide();
	$('#act1').hide();
	$('#act4').hide();
	if($('#act3').is(':hidden')){
		$('#act3').fadeIn('slow');
	}else{
		$('#act3').fadeOut('slow');
	}
}
function showAct4(){
	$('#act2').hide();
	$('#act3').hide();
	$('#act1').hide();
	if($('#act4').is(':hidden')){
		$('#act4').fadeIn('slow');
	}else{
		$('#act4').fadeOut('slow');
	}
}
function abreMenu(){
	if($('#submenu0').is(':hidden')){
		$('#submenu0').slideDown('slow');
	}else{
		$('#submenu0').slideUp('slow');
	}
}
function abreEventos(){
	if($('#submenu1').is(':hidden')){
		$('#submenu1').slideDown('slow');
	}else{
		$('#submenu1').slideUp('slow');
	}
}
function cerrar(id){
	if(id=="carta_menu"){
		if(!$('#platos').is(':hidden')){
			$('#platos').fadeOut('slow');
		}
	}
	if(id=="espacios"){
		if(!$('#sala1').is(':hidden')){
			$('#sala1').fadeOut('slow');
		}
		if(!$('#sala2').is(':hidden')){
			$('#sala2').fadeOut('slow');
		}
		if(!$('#sala3').is(':hidden')){
			$('#sala3').fadeOut('slow');
		}
	}
	if(id=="localizacion"){
		if(!$('#google_maps').is(':hidden')){
			$('#google_maps').fadeOut('slow');
		}
	}
	$('#'+id).fadeOut('slow');
}
function enviaForm(formreserva){
	document.getElementById("message_enviar").innerHTML = ENVIANDO_DATOS;
	$('#message_enviar').fadeIn("slow");
	nombre = document.getElementById("nombre").value;
	telefono = document.getElementById("telefono").value;
	mail = document.getElementById("mail").value;
	provincia = document.getElementById("provincia").options[document.getElementById("provincia").selectedIndex].value;
	poblacion = document.getElementById("poblacion").value;
	comentarios = document.getElementById("comentarios").value;
	origen = document.getElementById("origen").value;

	var nombre = nombre.htmlEntities();
	var telefono = telefono.htmlEntities();
	var mail =	mail.htmlEntities();
	var poblacion = poblacion.htmlEntities();
	var comentarios = comentarios.htmlEntities();


	if((nombre!="")&&(telefono!="")&&(mail!="")&&(provincia!=0)&&(poblacion!="")&&(comentarios!="")){

		mail_valido_1 = isValidEmail(mail);
		if(mail_valido_1){
			$.ajax({
				type: "POST",
				url: "secciones/comunes/formulario.php",
				data: "ajax=1&OP_1=submit"+
				"&origen="+origen+
				"&nombre="+nombre+
				"&telefono="+telefono+
				"&mail="+mail+
				"&provincia="+provincia+
				"&poblacion="+poblacion+
				"&comentarios="+comentarios,


				success: function(msg){
					//alert(msg);
					tmp = msg.split("__");

					switch(tmp[0]){
						case "error1":
						document.getElementById("message_enviar").innerHTML = tmp[1];
						$('#message_enviar').fadeIn("slow");
						break;
						default:
						document.getElementById("message_enviar").innerHTML = tmp[0];
						document.getElementById(formreserva).reset();
						$('#message_enviar').fadeIn("slow");
						break;
					}
					$('#message_enviar').fadeIn("slow");
					return false;
					//cargaDadesCapa(msg,'container_general');
				}
			});
		}else{
			document.getElementById("message_enviar").innerHTML = FORMATO_MAIL_KO;
			$('#message_enviar').fadeIn("slow");
		}
	}else{
		document.getElementById("message_enviar").innerHTML = CAMPOS_OBLIGATORIOS;
		$('#message_enviar').fadeIn("slow");
	}
}

function isValidEmail(str) {
	return (str.indexOf(".") >= 1) && (str.indexOf("@") > 0);
}

//	prototipo htmlentity en javascript
String.prototype.htmlEntities = function (){
	return this.replace(/&/g,'_AMP_').replace('>','_GRAN_').replace('<','_PETIT_').replace(/[+]/g,'_PLUS_').replace(/#/g,'_ALMO_');
};

function abrirModal(){
	//var El_html = "<p>HOLA</p>"
	//document.getElementById('ventana_modal').innerHTML = El_html;
	$('#trama').fadeIn('fast');
	$('#ventana_modal').fadeIn('slow');
}
// cerrar ventana swf
function cerrarModal(){
	$('#trama').fadeOut('slow');
	$('#ventana_modal').fadeOut('fast');
}
