﻿(function() {
    var Cadastro = window.Cadastro = {
        setInputType: function() {
            var input = $('input'),
				_this;

            input.each(function() {
                _this = $(this);

                _this.addClass(_this.attr('type'));
            });
        },
        setNextFocus: function() {
            var input = $('input.nextFocus'),
				_this;

            input.keyup(function() {
                _this = $(this);

                if (_this.val().length == parseInt(_this.attr('maxlength'))) {
                    _this.next('input').focus();
                }



            });
        },
        lotacaoChange: function() {
            var form = $('ul.form'),
				cboEmpresa = form.find('select.empresa'),
				cboLotacao = form.find('select.lotacao'),
				liOutraLotacao = form.find('li.outraLotacao');

            cboEmpresa.change(function() {
                $(this).next().toggleClass('invisible');

                //mostra outra lotacao
                if (cboLotacao.val() == 'outra')
                    liOutraLotacao.removeClass('hide');
            });

            cboLotacao.change(function() {
                liOutraLotacao.addClass('hide');

                //mostra outra lotacao
                if (cboLotacao.val() == 'outra')
                    liOutraLotacao.removeClass('hide');
            });
        }
    }
})();