﻿(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');
            });
        },

        changeAbas: function() {
        var menu = $("ul.menu");
            
            

            $("a", menu).unbind().click(function() {
                var $this = $(this),
                    parent = $this.parent(),
                    cl = parent.attr("class"),
                    contentForm = $("div.contentForm, div.cont_positivacao, div.all_content div.esqueciSenha, div.dificuldades");

                if (parent.is(".active"))
                    return false;

                $("div.active", contentForm).fadeOut(function() {
                    $(this).removeClass("active");
                    $("div." + cl, contentForm).fadeIn().addClass("active");
                });


                $("li.active", menu).removeClass("active");
                parent.addClass("active");

                return false;
            });
        },
        
        showOptionMail: function()
        {
            var overlay = $( "div#overlayModal" ),
				divConfirmationMail = $( "div.modalConfirmationMail" );
				
			divConfirmationMail.add( overlay ).show(function()
			{
				$( "a.bt_close, .bt_cancel", divConfirmationMail ).unbind().click(function()
				{
					divConfirmationMail.add( overlay ).fadeOut();
					
					return false;
				});
			});
        }
    }
})();
