﻿

var f = {
    // INIT
    init: function () {
        Cufon.replace('#nav  > li >  a , #nav  > li >  a strong, #nav .shadow', { fontFamily: 'Gill Sans' });
        Cufon.replace('h2 , h1', { fontFamily: 'Gill Sans Light' });
        $('.slider').flexslider({ animation: "slide", directionNav: false, controlNav: true });
        f.formField()
    },
    // MARCA MENU DA SEÇÃO
    marcaNav: function (i, si) {
        setTimeout(function () {
            var l = $('#nav > li:eq(' + i + ')'), _l, _w;
            _l = l.position();
            _w = l.outerWidth(true);
            $('#nav .back').css('width', _w).css('left', _l.left);
            f.navLavaLamp('#nav');
        }, 150);
        //nav bottom
        $('.lsFooter > li:eq(' + i + ') > a').addClass('atv');
        $('.lsFooter > li:eq(' + i + ')  ul  li:eq(' + si + ') > a').addClass('atv');



    },
    // ANIMAÇÃO DO MENU LAVALAMP 
    navLavaLamp: function (o, e) {
        var _t, _pt, _ipt, _pl, _ipl, _w, _iw, _b = $(o + ' .back'), _bi, _d, _tl;
        _d = 700; //tempo de execução
        _iw = _b.outerWidth(true);
        _bi = _b.position();
        $(o + ' > li').hover(
            function () {
                _t = $(this);
                _pl = _t.position();
                _w = _t.outerWidth(true);
                _b.clearQueue();
                _b.stop(true, false).animate({ width: _w, left: '+' + _pl.left }, _d, 'backout', /* subnav */function () { _t.find('ul').animate({ width: 'show' }, 300, 'easein'); })

            },
            function () {
                $(this).find('ul').animate({ width: 'hide' }, 300, 'easeout'); //subnav
                _b.stop(true, false).animate({ width: _w, left: '+' + _bl.left }, _d, 'backout')
                _b.clearQueue();
            }
        );
        // volta a posição inicial
        $(o).hover(function () { },
             function () {
                 $(this).find('ul').animate({ width: 'hide' }, 300, 'easeout'); //subnav
                 _b.stop(true, false).animate({ width: _iw, left: '+' + _bi.left }, _d, 'backout')
                 _b.clearQueue();
             }
        )
    },
    // MASCARAS DE INPUT
    formField: function () {
        $('input[type="text"] , textarea').addClass("idleField");
        $('input[type="text"] , textarea').focus(function () {
            $(this).removeClass("idleField").addClass("focusField");
            if (this.value == this.defaultValue) {
                this.value = '';
            }
            if (this.value != this.defaultValue) {
                this.select();
            }
        });
        $('input[type="text"] , textarea').blur(function () {
            $(this).removeClass("focusField").addClass("idleField");
            if ($.trim(this.value) == '') {
                this.value = (this.defaultValue ? this.defaultValue : '');
            }
        });
    },
    // EXPANSIVEIS
    exp: function () {
        $('.lsExp > li > a').click(function (e) {
            $(this).toggleClass('atv').next().animate({ height: 'toggle' }, 1000, 'backout')
            e.preventDefault();
        })
    }

}

$(document).ready(function () {

    $(".divConteudo ul").addClass("lsBullet");
    
    $(".googleMaps").fancybox({
        'width': '50%',
        'height': '50%',
        'autoScale': false,
        'transitionIn': 'none',
        'transitionOut': 'none',
        'type': 'iframe'
    });

    f.init();
}); 
    
// FIM DO LOADING
