$(document).ready(function () {
    var btnMain = $('header nav#main div#lista1 .area ul li a');

    btnMain.click(function () {
        var vrfcList = $(this).attr('ativaList');
        mainSelected(this, vrfcList);
    });
    /* animacoes content - start */
    var slctContent = $('article#dstqHome .content');

    slctContent.mouseover(function () {
        $(this).children('h3').stop().animate({ color: '#dc7010' }, 300);
    });
    slctContent.mouseout(function () {
        $(this).children('h3').stop().animate({ color: '#0d5ea0' }, 200);
    });
    /* animacoes content - start */

    /* animacoes de btn de acoes - start */
    var btnAcoes = $('.btnAcoes, .btn-ok');
    btnAcoes.mouseover(function () {
        $(this).stop().animate({ color: '#dc7010', backgroundPosition: '0px -25px' }, 200);
    });
    btnAcoes.mouseout(function () {
        $(this).stop().animate({ color: '#0d5ea0', backgroundPosition: '0px 0px' }, 200);
    });
    /* animacoes de btn de acoes - end */

    /* animacao de listagem home - start */
    var listagem = $('article#chamadaAgenda ul li');

    listagem.mouseover(function () {
        $(this).stop().animate({ borderBottomColor: '#dc7010' }, 250);
        $(this).find('strong').stop().animate({ color: '#dc7010' }, 200);
    });
    listagem.mouseout(function () {
        $(this).stop().animate({ borderBottomColor: '#cbced0' }, 250);
        $(this).find('strong').stop().animate({ color: '#0d5ea0' }, 200);
    });
    /* animacao de listagem home - start */

    /* animacao color inputs - start */
    var formPadrao = $('input[type=text], input[type=password], textarea');

    formPadrao.mouseover(function () {
        $(this).stop().animate({ backgroundColor: '#edded1', color: '#dc7010' }, 250);
    });

    formPadrao.mouseout(function () {
        $(this).stop().animate({ backgroundColor: '#d5d5d5', color: '#555' }, 250);
    });
    /* animacao color inputs - end */

});

function ClearForm() {
    $("form input[type='text']").val("");
    $("form input[type='password']").val("");
    $("form input[type='checkbox']").removeAttr("checked");
    $("form textarea").val("");
    $("form select option").removeAttr("selected");
    $("form input[type='radio']").removeAttr("checked");
}

function mainSelected(btn, vrfcList) {
    var selector = $('header nav#main div#lista2');

    if (vrfcList == "list2") {
        $("#divEmpresa").hide();
        $("#divProduto").show();
    }
    else {
        $("#divEmpresa").show();
        $("#divProduto").hide();
    }

    selector.children().stop().fadeIn(200);
    selector.stop().delay(200).animate({ top: '8px' }, 200);

    if (vrfcList) {
        selector.stop().animate({ top: '30px' }, 300);
        selector.children().stop().delay(300).fadeIn(500);
    }

    var stanciaBtn = $(btn).parent();
    $('header nav#main div#lista1 .area ul li span, header nav#main div#lista1 .area ul li a').css({ backgroundPosition: '0px -40px' })
    var linkBtn = stanciaBtn.children('a');
    var textLink = linkBtn.text();
    var lgrItem = linkBtn.width();
    var altItem = linkBtn.height() - 10;

    linkBtn.html('<span class="bg"></span><span>' + textLink + '</span>');
    linkBtn.children().css({ position: 'relative', width: lgrItem + 2, height: altItem }).first().css({ marginRight: -lgrItem, backgroundColor: '#fff' });

    stanciaBtn.children().css({ backgroundPosition: '0px -10px' });
    stanciaBtn.children('.qt').html('<span class="bg"></span>');
    stanciaBtn.children('.qt, a').children('.bg').stop().delay(100).fadeOut(350);
    stanciaBtn.children().stop().delay(350).animate({ backgroundPosition: '0px 0px' }, 250);
}

/* seta tamanho nas divs de acabamento do banner */
var RESIZE = {

    init: function (Args) {
        this.onRisze();
    },

    onRisze: function () {
        var sizeCurv = 1279;
        var sizeWindow = $(window).width();
        var calcFaixas = parseInt((sizeWindow - sizeCurv) / 2);
        if (sizeWindow >= sizeCurv) {
            $('#curvaAcabamento .faixa1, #curvaAcabamento .faixa2').css({ width: calcFaixas });
        } else {
            $('#curvaAcabamento .faixa1, #curvaAcabamento .faixa2').css({ width: '0px' });
        }
    }
}
$(window).resize(function () { RESIZE.onRisze() });

/* =divideColunas - Seta colunas no menú conforme numero de itens - START */
$.fn.extend({
    divideColunas: function (qtdItems) {
        tagert = $(this);
        selectList = tagert.find('.listProducst');

        selectList.each(function () {
            tagert = $(this).children().children();
            countItems = tagert.length;
            //alert(countItems);
            
            if (countItems >= qtdItems) {
                lrgItem = tagert.innerWidth() + 35;
                result = lrgItem * parseInt(calc = (countItems / qtdItems) + 1);
                //alert(selectList.attr('class') + ' - ' + result);
                $(selectList).css({ width: result });
            }
        });
    }
});
/* =divideColunas - Seta colunas no menú conforme numero de itens - END */
