
	window.addEvent("domready", function() {
		
		menu();
		slideMenu();
		innerFadeSubseccion();
		innerFadeOfertas();
		reservas();
		
	});
	
	function reservas()
	{
		$$("#boton").addEvent("click", function(event) {
			if(event) event.preventDefault();
			
			form = this.getParent("form");
			
			form.valida = function() {
				var nombreLleno = this.nombre.value.replace(/^\s*|\s*$/g,"") != "";
				var apellidosLleno = this.apellidos.value.replace(/^\s*|\s*$/g,"") != "";
				var phoneLleno = this.phone.value != "";
				var mailBueno = validateEmail(this.mail.value);
				return nombreLleno && apellidosLleno && phoneLleno && mailBueno;
			};
			
			if(form.valida())
				$('formulario').fireEvent("submit");
			else 
				alert("Nombre, apellidos y teléfono obligatorios.")
			
		});
	}
	
	function validateEmail(elementValue){  
		var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
		return emailPattern.test(elementValue);  
	}  
	
	function menu()
	{
		$$("#nav li:last-child a").setStyle("border-right", "none");
		$$("#navFooter li:last-child").setStyle("border-right", "none");
		$$("#nav li.liReservas a").addClass("mainLink");
		$$("#nav li.liReservas .submenu li a").removeClass("mainLink");

		$$("#nav li.mainLi").addEvent("mouseover", function() {
			//this.getElements("a.mainLink").setStyle("font-weight", "bold");
			this.setStyle("background", "white");
		});
		
		$$("#nav li.mainLi2, .submenu li").addEvent("mouseover", function() {
			//this.getElements("a").setStyle("font-weight", "bold");
			this.setStyle("background", "white");
		});
		
		$$("#nav li.mainLi").addEvent("mouseleave", function() {
			this.getElements("a.mainLink").setStyle("font-weight", "normal");
			this.setStyle("background", "transparent");
		});
		
		$$("#nav li.mainLi2, .submenu li").addEvent("mouseleave", function() {
			this.getElements("a").setStyle("font-weight", "normal");
			this.setStyle("background", "transparent");
		});
		
		$$("#nav li.mainLi2 a").addClass("mainLink");
		
	}
	
	function slideMenu()
	{
		$$(".slide").slide("hide");
		$$(".subBox").setStyle("height", "0px");
		
		$$("#nav li.mainLi").addEvent("click", function(event) {
			//if(event) event.preventDefault();
			$$("#nav li.mainLi .slide").slide("out");
			$$("#nav li.mainLi .subBox").setStyle("height", "0px");
			this.getElements(".slide").slide("in");
			this.getElements(".subBox").setStyle("height", "21px");
		});
	}
	
	function innerFadeSubseccion()
	{
		if($("imagenesFade"))
		{
			$$("#imagenesFade li").each(function(li) {
				if(!li.getElements("img").length) li.dispose();
			});
	
			jQuery('#imagenesFade').innerfade({
				animationtype: 'fade',
				speed: 3000,
				timeout: 6000,
				height: 230,
				containerheight: 230,
				containerHeight: 230
			});
		}
	}
	
	function innerFadeOfertas()
	{
		$$("#imagenesOfertas li img").setStyle("opacity", ".5");
		
		if($("ofertas"))
		{
			$$("#ofertas li").each(function(li) {
				if(!li.getElements("img").length) li.dispose();
			});
	
			jQuery('#ofertas').innerfade({
				animationtype: 'fade',
				speed: 2000,
				timeout: 10000,
				height: 165,
				containerheight: 165,
				containerHeight: 165
			});
		}
	}
	

