var Eq = Number(0);
var Valor = "";
var Quant = "";
var Looping = "";
var Cont = Number(0);
var Divs = 0;

$(function() {
    // menu de navegação
    $("#header > ul > li").mouseover(function() {
        $(this).addClass("open")
    }).mouseout(function() {
        $(this).removeClass("open")
    })
    $("#header > ul > li").each(function() {
        if($(this).children("ul").length > 0) {
            $(this).children("a").click(function() {
                return false
            })
        }
    })
    
    // ie-fixes
    Common.ieFixes()
    $("#header > ul > li:last-child").addClass("last")
    
    // flash
    Common.ebisFlash()
    Common.logoFlash()
    
    // overtext
    $("#nav input").overText()
    
    // lightbox
    Common.shadowbox()
    
    // busca
    $("#FormSearch").autocomplete(base + "busca/autocompletar.txt")
})

$(document).ready(function() {
    /* 	BANNER */
    banner(0);
    Divs = $("#banner .images > div").length;
    $("#prev").click(function() {
        clearTimeout(Looping)
        Eq = $(this).attr("alt");
        banner(Eq - 2);
    });
    $("#next").click(function() {
        clearTimeout(Looping)
        Eq = $(this).attr("alt");
        banner(Eq++);
    });
});

function banner(Eq) {
    Eq = Eq + 1;
    if (Eq == -Divs) {
        Eq = 4
    }
    if (Eq == Divs + 1) {
        Eq = 1
    }
    $("#prev").attr("alt", Eq);
    $("#next").attr("alt", Eq);
    Valor = $("#banner .images > div").eq(Eq - 1).attr("alt");
    Quant = $("#banner .images > div").length;
    $("#banner .images > div").fadeOut(1000);
    setTimeout(function() {
        $("#banner .images > div").eq(Eq - 1).fadeIn(1000);
        $("#banner .slidetabs a").removeClass("current");
        $("#banner .slidetabs a").eq(Eq - 1).addClass("current");
        Looping = setTimeout(function() {
            if(Eq == Quant) {
                Eq = 0;
            }
            banner(Eq);
        }, Valor); // TEMPO DE TRANSIÇÃO (8000 OU var "Valor")
    }, 1500);
};

$("#click-proposta").live("click", function() {
    $("#overlay").show();
});
$("#proposta a").live("click", function() {
    $("#overlay").hide();
});
