
function cssInputs(){
    $("input[type=text], input[type=password], select, textarea").css({
        "border":"1px solid #DFDFDF",
        "background-color":"#EFEFEF"
    });
}

/*
 * requer jquery min 1.3.2
 */
$(document).ready(function(){

    //----- BEGIN efeito menu lateral -----
    $(".index-left .menu li").hover(function(){
        $(this).addClass("hover");
    }, function(){
        if($(this).hasClass("hover")) $(this).removeClass("hover");
    });
    //----- END efeito menu lateral -----

    //----- BEGIN efeito menu topo -----
    //monta botao
    $("a.btn-topo").each(function(){
        $(this).html('<span class="left">&nbsp;</span><span class="center">'+$(this).html()+'</span><span class="right">&nbsp;</span>');
    });
    //efeitos
    $("a.btn-topo").hover(function(){
        $(".left", this).addClass("left-hover");
        $(".center", this).addClass("center-hover");
        $(".right", this).addClass("right-hover");
    }, function(){
        if($(".left", this).hasClass("left-hover")) $(".left", this).removeClass("left-hover");
        if($(".center", this).hasClass("center-hover")) $(".center", this).removeClass("center-hover");
        if($(".right", this).hasClass("right-hover")) $(".right", this).removeClass("right-hover");
    });
    //----- END efeito menu topo -----

    cssInputs();

    //----- BEGIN efeito botao -----
    $("a.btn").each(function(){
        $(this).html('<span class="left">&nbsp;</span><span class="center">'+$(this).html()+'</span><span class="right">&nbsp;</span>');
    });
    //----- END efeito botao -----

    //----- BEGIN efeitos dos inputs do lado direito -----
    $(".index-right input[type=text], .index-right input[type=password]").css({
        "border":"none",
        "background":" url(img/input-back.gif) no-repeat",
        "height":"26px",
        "width":"180px",
        "padding-top":"4px",
        "padding-left":"8px",
        "padding-right":"8px"
    });
    //----- END efeitos dos inputs do lado direito -----

    //----- BEGIN efeitos pareceiros -----
    $("#slideshow-parceiros").cycle({
        fx: "fade"
    });
    $("#slideshow-top").cycle({
        fx: "fade"
    });

    $("#slideshow-parceiros").corner();
    $("#slideshow-parceiros div").css("z-index","11");
    //----- END efeitos parceiros -----

    // ----- BEGIN thumb carrinho-----
    $("a.thumb-car").hover(function(){
        $(this).addClass("thumb-car-hover");
    }, function(){
        if($(this).hasClass("thumb-car-hover")) $(this).removeClass("thumb-car-hover");
    });
    // ----- END thumb carrinho -----

    $("#saudacao").html(get_saudacao());
    
    $("#formLogin").validar();

    $("#formNewsletter").validar({
        "end":function(){
            $.post('ajax/ajax.gravarNewsletter.php', $("#formNewsletter").serialize(), function(data){
                if(data.result){
                    alert('Email cadastrado com sucesso!');
                }else{
                    alert('Não foi possivel cadastrar o email, por favor tente mais tarde!');
                }
            }, 'json' );
            return false;
        }
    });

    $('#formIndique').validar({
        "end":function(){
            $("#loadingIndique").css("display","block");
            $.post('ajax/ajax.sendIndique.php', $("#formIndique").serialize(), function(data){
                $("#loadingIndique").css("display","none");
                if(data.result){
                    alert('Indique enviado com sucesso!');
                    document.formIndique.reset();
                }else{
                    alert('Não foi possivel enviar o indique, por favor tente mais tarde!');
                }
            }, 'json' );
            return false;
        }
        });

    $("div.hr").each(function(){
        $(this).html("<p>"+$(this).html()+"</p>");
    });

});


function atualizaCar(param){
    $("#loading").css("display","block");
    $.getScript("ajax/ajax.carrinho.php?atualizar=TRUE&"+param, function(){
        $("#loading").css("display","none");
    });
}

// ----- BEGIN noticia -----
function carregaNoticia(id){
    $("#contentNoticia").load('ajax/ajax.carregaNoticia.php?id='+id+'&carregar=true');
}
// ----- END noticia ----
