function trocarBg(bg){
    setTimeout("fadeBg("+bg+")", 0.5*1000);
}
function fadeBg(bg){
    $('.Bg1').fadeOut('medium', function(){
        $('.Bg1').attr('src', "img/bg"+bg+".jpg")
        //$('.Bg2').hide();
    });
    $('.Bg1').fadeIn('slow');
}
$(document).ready(function() {    //$('.Bg2').hide();
    var aux = 1;
    $('.Menu li a, .Link').live('click', function(){
        pgExc = 1;
        var bg = $(this).attr('bg');
        if(aux == 1){
            $('.Palco').html("");
            $('.Palco2').html("");
            $('.Palco2').load($(this).attr('href'),{attr1: $(this).attr('attr1'), attr2: $(this).attr('attr2')} , function(){
                $('.Palco').animate({
                    left: '-1010px'
                });
                $('.Palco2').animate({
                    left: '0'
                });
            })
            $('.Palco').html("");
            aux = 2;
        }else{
            $('.Palco').load($(this).attr('href'), {attr1: $(this).attr('attr1'), attr2: $(this).attr('attr2')}, function(){

                $('.Palco').animate({
                    left: '0'
                });
                $('.Palco2').animate({
                    left: '1010px'
                });
                $('.Palco2').html("");
            })
            aux = 1;
        }
        /*  $('.Bg2').attr('src', "img/bg"+bg+".jpg");
            $('.Bg2').fadeIn('slow', function(){
            $('.Bg1').attr('src', "img/bg"+bg+".jpg")
            $('.Bg2').hide();
        }); */
        return false;
    });
    $('.Voltar').live('click', function(){
        if(aux == 1){
            $('.Palco').animate({
                left: '-1010px'
            });
            $('.Palco2').animate({
                left: '0'
            });
            aux = 2;
        }else{
            $('.Palco').animate({
                left: '0'
            });
            $('.Palco2').animate({
                left: '1010px'
            });
            aux = 1;
        }
    })

    pgExc = 1;
    $('.ExcProx').live('click', function(){
        paginas = $('.Exc').attr('qtd');
        itens = $('.Exc').attr('qtdItem');        
        if(pgExc == paginas){$('.ExcProx').hide();}
        if(pgExc > paginas){
            return false;
        }else{           
            $('.ExcWrap').animate({left: '-=480px'}, 500)
            $('.ExcAnt').css("visibility","visible");
            $('.ExcAnt').show();
            pgExc++;            
        }
    })

    $('.ExcAnt').live('click', function(){
        paginas = $('.Exc').attr('qtd');
        itens = $('.Exc').attr('qtdItem');
        if(pgExc <3 ){
            $('.ExcAnt').hide();
        }
        if(pgExc == 1){            
            return false;
        }else{
            $('.ExcWrap').animate({left: '+=480px'}, 500)
            $('.ExcProx').show();
            pgExc--;
        }
    })

    $('.DiaExc').live('click', function(){
        obj = $(this);
        if(obj.attr('atual') == 1){
            return false;
        }else{
            $('.DiaExc').attr('atual', '0');
            $(this).attr('atual', '1');
            $('.ExcWrap').fadeOut(function(){
                $('.ExcWrap').load('load_excursoes.php', {tipo: obj.attr('tipo'), tipo2: obj.attr('tipo2')}, function(){
                    $('.ExcWrap').css('left','0');
                    pgExc = 1;
                    $('.ExcWrap').fadeIn();
                });
            });
        }
    });   
    
});
