$(function(){
if($.browser.msie&&$.browser.version<=7){$("body").css("overflow-y","hidden");$('<div id="overlay"></div>').css("top",$(document).scrollTop()).css("height",$(document).height()).css("opacity","0").animate({opacity:"0.9"},"slow").appendTo("body");$('<div id="lightbox"></div>').hide().appendTo("body");

$("<div id='msgie'><p>Lo sentimos...Te encuentras en una versi&oacuten antigua de tu navegador, <strong>Operadora de Banquetes</strong> no da soporte a esta versi&oacuten.</p><p>Puedes actualizar tu explorador u obtener otro de manera gratuita desde las siguientes p&aacuteginas oficiales.</p><div class='conmsg'><ul><li><a href='http://www.microsoft.com/spain/windows/internet-explorer/worldwide-sites.aspx'><img src='img/ie.gif' border='0' width='30px' height='30px' alt='Internet Explorer'/>Internet Explorer</a></li><li><a href='http://www.mozilla-europe.org/es/firefox/'><img src='img/ff.gif' border='0' width='30px' height='30px' alt='Fire Fox'/>Firefox</a></li><li><img src='img/gc.gif' border='0' width='30px' height='30px' alt='Google Chromes'/><a href='http://www.google.com/chrome?hl=es'>Google Chrome</a></li></ul></div></div>").appendTo("#overlay");
}

	selectMenu(0);
	$("#bigcont .pages").data('min',false);
	$('#contenido').css({'overflow': 'hidden','height':$('#contenido .pages:eq(0)').height()});
	reduce(0);
	$('#menu a').bind('click', function(){
		var size = $('#'+$(this).html()).height();
		var pos = $('#menu a').index(this);
		selectMenu(pos);
		moveSlide(pos,size);
		return false;
	});
	$('a.galefull').bind('click', function(){
		window.open($(this).attr('href'), '', 'fullscreen=yes, scrollbars=yes');
		return false;
	});
        
        iniBoxGalerias();
});
// Mueve slide a posicion num
function moveSlide(num,size){
		var d = 0;
		$('#slideInner .pages:lt('+num+')').each(function() {
			d += $(this).height();
		});
		$('#contenido').animate( {  height : size }, { queue:false, duration:500 } );
		reduce(num);
		$('#slideInner').animate({
				  marginTop : d*-1
		},700);
}
// Selecciona menu
function selectMenu(num){
	$('#menu a:eq('+num+')').addClass('aselect');
	$('#menu a:not(:eq('+num+'))').removeClass('aselect');
}
// funcion reduccion
function reduce(num){
	var overscroll = $(document).height() - $(window).height();
			if(overscroll > 0){
				if(overscroll > 4 && $.browser.msie && $.browser.version >= 8 && !$("#bigcont .pages:eq("+num+")").data('min')){
					$("#bigcont").animate( {width : $("#bigcont").width()-scrollbarWidth()}, { queue:false, duration:400 } );
					$("#bigcont .pages:eq("+num+")").data('min',true);
				}
				if(!$.browser.msie && !$("#bigcont .pages:eq("+num+")").data('min')){
					$("#bigcont").animate( {width : $("#bigcont").width()-scrollbarWidth()}, { queue:false, duration:400 } );
					$("#bigcont .pages:eq("+num+")").data('min',true);
				}
			}
			else{ }
}
// Ancho scrollbar
function scrollbarWidth() {
    var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
    $('body').append(div);
    var w1 = $('div', div).innerWidth();
    div.css('overflow-y', 'scroll');
    var w2 = $('div', div).innerWidth();
    $(div).remove();
    return (w1 - w2);
}

function iniBoxGalerias(){
    $('<span id="btn_siguiente"></span>').bind("click",function(){
        $(".galeria_th_box").animate({
            "marginLeft": "-=100"
            }, { duration: 400,  "easing": "linear", queue: false });
    }).addClass("siguiente_boton").appendTo("#galeria_box");
    $('<span id="btn_atras"></span>').bind("click",function(){
        var margin = parseFloat($(".galeria_th_box").css("marginLeft"));
        var add = 100;
        ((margin-add) < 0)? add = 0:add = "+="+add;
        $(".galeria_th_box").animate({
            "marginLeft": add
            }, { duration: 400,  "easing": "linear", queue: false });
    }).addClass("atras_boton").appendTo("#galeria_box");
}

function l(mensaje){
    console.log(mensaje);
}
