window.addEvent('domready', function() {
	if ($('reservas')) {
		   new FormCheck('fReservas', {
			display : {
				errorsLocation : 1,
				indicateErrors : 1,
				showErrors : 1
			}
		});

	}
});

window.addEvent('load', function() {

	var foto = new Asset.images([base_url+'img/'+fondo], { 
		onComplete : function() { 
			$("imagen").set('html', "<img id=\"bgImg\" src=\"" + base_url+'img/'+fondo + "\" />");
			setTimeout("onResize()",100);
		} 
	});
	
	
});

window.addEvent('resize', onResize);

function onResize() {
	var contentHeight = $$('.content')[0].getScrollSize().y;
	var menuboxHeight = $('menu').getScrollSize().y;
	var maxLength = (contentHeight<menuboxHeight)?menuboxHeight:contentHeight;
	var bodyScrollHeight = $$('body')[0].getSize().y;

	if (bodyScrollHeight <= maxLength){
		$("imagen").setStyle('height',maxLength);
		if ($$('body')[0].getScrollSize().x > $("bgImg").getSize().x) {
			$("bgImg").setStyles({"width" : "100%", "height" : "auto"});
		}
		if ($$('body')[0].getScrollSize().y > $("bgImg").getSize().y) {
			$("bgImg").setStyles({"width" : "auto", "height" : "100%"});
		}
	} else {
		$("imagen").setStyle('height','100%').setStyle('width','100%');
		// Resize de foto de fondo y/o cambio de aspect ratio
		if ($$('body')[0].getScrollSize().x > $("bgImg").getSize().x) {
			$("bgImg").setStyles({"width" : "100%", "height" : "auto"});
		}
		if ($$('body')[0].getScrollSize().y > $("bgImg").getSize().y) {
			$("bgImg").setStyles({"width" : "auto", "height" : "100%"});
		}
	}
	
	

}