function BorrachasVipal(){
    if( $('div.conteudo').hasClass('home') ){
        $('.banner-cycle .banner-images').before('<div class="banner-nav"></div>').cycle({
            fx:     'scrollVert', 
            speed:  400,
            timeout: 7000,
            pager:  '.banner-nav'
        });
        $('.banner-cycle .banner-nav a').each(function(x){
            $(this).addClass('replace2 lk-banner-'+(x+1));
        });
    }
    if( $('.imagem').hasClass('cycle') ){
        $('.imagem.cycle .cycle-img').cycle({
            fx: 'scrollHorz',
            speed: 400,
            timeout: 5000,
            next: '.lk-next-cycle',
            prev: '.lk-prev-cycle',
            after: function(){
            	$(".legenda").html($("div.cycle-img img:visible").attr("alt"));
            }
        });
        $('.lk-play-cycle').click(function(){
            $('.imagem.cycle .cycle-img').cycle('resume');
            $(this).hide().next().show();
        });
        $('.lk-pause-cycle').click(function(){
            $('.imagem.cycle .cycle-img').cycle('pause');
            $(this).hide().prev().show();
        });
    }
    if( $('div.conteudo').hasClass('historia') ){
        $('.historia .content li').each(function(){
            var alturaLI = 217/2;
            var altura = $(this).children('div').height()/2;
            var top = alturaLI-altura;
            $(this).children('div').css('top',top+'px');
        });
        setTimeout(function(){
            $('.historia .content').cycle({
                fx:     'scrollHorz', 
                speed:  400,
                timeout: 0,
                pager:  '.links',
                prev: '.bt-prev',
                next: '.bt-next'
            });
            $('.bt-prev, .bt-next').click(function(){
                var indice = $('.links a.activeSlide').index();
                $('.menu-historia li.ativo').removeClass('ativo');
                $('.menu-historia li:eq('+indice+')').addClass('ativo');
            });
            $('.menu-historia a').click(function(){
                $('.menu-historia li.ativo').removeClass('ativo');
                var indice = $(this).parent().addClass('ativo').index();
                $('.links a:eq('+indice+')').click();
                Cufon.now();
            });
        },1000);
		
    }
    selectFakePrincipal();
    radioFake();
    checkboxFake();
	
    $('.form-login a').click(function(){
        $(this).parent().children('.esqueci-senha').toggle();
    });
	
    $('.listas').each(function(){
        $(this).children('ul').children('li').each(function(x){
            var indice = x+1;
            if( indice%3 == 0 )
                $(this).addClass('third');
        });
    });
    $('.paginacao').each(function(){
        var width = $(this).width();
        var widthUL = $(this).children('ul').width();
        $(this).children('ul').css('margin-left',(width-widthUL)/2+'px');
    });
	
    $('input:reset').click(function(){
        $(this).closest('form').addClass('reset');
        setTimeout(function(){
            $('form.reset input:checkbox.checkbox-padrao').each(function(){
                if( $(this).attr('checked') )
                    $(this).prev().removeClass().addClass('checkbox-fake checkbox-ativo replace');
                else
                    $(this).prev().removeClass().addClass('checkbox-fake replace');
            });
            $('form.reset input:radio.radio-padrao').each(function(){
                if( $(this).attr('checked') )
                    $(this).prev().removeClass().addClass('radio-fake radio-ativo replace');
                else
                    $(this).prev().removeClass().addClass('radio-fake replace');
            });
            $('form.reset select.select-padrao').each(function(){
                $(this).parent('.select-content-principal').children('.select-fake').html( $(this).find('option:first-child').text() );
            });
        },500);
    });
	
    /*$('.menu-produtos .level-3').each(function(){
        $(this).parent().parent().addClass('children');
    });
    $('.menu-produtos .level-2').each(function(){
        $(this).parent().parent().addClass('children');
    });
    $('.menu-produtos .level-1').each(function(){
        $(this).parent().parent().addClass('children');
    });
    $('.menu-produtos a').click(function(){
        if( $(this).parent().hasClass('children') ){
            $(this).parent().toggleClass('ativo');
            $(this).next().toggle();
            //return false;
        }
    });*/
	
    $('.table tr:odd').addClass('par');
    $('.table tr').each(function(){
        $(this).children('*:last').addClass('last-td');
    });
    var amountTD = $('.table tbody tr:first td').size();
    var widthTable = $('.table').width() - (amountTD-1);
    var minWidthTD = parseInt(widthTable/amountTD);
    $('.table.especificacoes tbody tr td').attr('width',minWidthTD);
    $('.table.especificacoes thead tr:last th').attr('width',minWidthTD);
	
    if( $('.box-imagem') ){
        $('.box-imagem .cycle-img').cycle({
            fx: 'scrollHorz',
            speed: 400,
            timeout: 0,
            next: '.lk-next-cycle',
            prev: '.lk-prev-cycle',
            onPrevNextEvent: function(isNext, zeroBasedSlideIndex, slideElement){
                var href = $(slideElement).attr('lang');
                $('.box-imagem .lk-zoom').attr('href',href);
            }
        });
    }
    var href = $('.box-imagem a:first').attr('lang');
    $('.box-imagem .lk-zoom').attr('href',href);
    $('.lk-zoom').lightBox();
}

function mapaSuspenso()
{
	if($(".encontre-reformador #map").size() > 0)
	{

		$(window).scroll(function(){
			
			var rolagem = document.documentElement.scrollTop; 
		
			if(rolagem > 566)
			{
				$("#map").stop().animate({top: (rolagem-121)+'px'},"fast",null,"easein");
			}
			else
			{
				$("#map").stop().animate({top: 455},"fast",null,"easein");
			}
			
		});
    }

}

$(document).ready(function(){
	mapaSuspenso();
    BorrachasVipal();
    get_cidades();
    ativar_menu_topo();
    retira_margem_galeria();
    retira_margem_financeira();
    selectFake();
    controla_abas_contato();
    menu_slide_noticias();
    tira_bg_last_td();
    abrir_lembrar_senha();
    selecionar_area_interesse();
    remove_linha();
    adicionar_experiencia();
    edita_experiencia();
    adicionar_formacao();
    edita_formacao();
    limpa_campos_formacao();
    fileFake();
    abrir_detalhes_vaga();
    abrir_envie_vaga();
    trocar_decada();
    trocar_premiacao();
    abrir_submenu();
    validar_contato();
    cadastrar();
    validar_fispq();
    validar_cadastro_curriculos();
    validar_envio_vaga();
    controla_abas_estrutura();
	
    $("a[rel=external]").attr('target','_blank');
	
	
    jQuery("input:text").setMask();
	
    $('.linguagem li:last, .lista_empresas li:last, .itens_sobre_grupo li:last').css({
        'background':'none',
        'margin-right':'0',
        'padding-right':'0'
    });
	
    $('.itens_home > li:last').css({
        'padding-right':'0'
    });
	
    $('.col_right a:last').css({
        'margin-bottom':'0'
    });
	
    $('.result_premios > div > ul > li ul:last').css({
        'margin-bottom':'14px'
    });
	
    $("#slider_1").easySlider({
        nextId: "slider1next",
        prevId: "slider1prev"
    });
    $("#slider_2").easySlider({
        nextId: "slider2next",
        prevId: "slider2prev"
    });
    $("#slider_3").easySlider({
        nextId: "slider3next",
        prevId: "slider3prev"
    });
    $("#slider_4").easySlider({
        nextId: "slider4next",
        prevId: "slider4prev"
    });
	
    $('.lista_vagas > li:first').css({
        'padding-top':'3px'
    });
	
    $('.lista_vagas > li:last').css({
        'margin-bottom':'0'
    });
	
    $('.exp_cadastradas table tr:first td, .formacao_cadastradas table tr:first td').each(function(){
        $(this).css({
            'padding-top':'2px'
        });
    });
	
    $("#slider_5").easySlider({
        nextId: "slider5next",
        prevId: "slider5prev"
    });
	
    $('.bt_item').click(function(){
        if( !$(this).hasClass('active') ){
            $('.bt_item').removeClass('active');
            $('.itens_home img').slideDown('fast');
            $('.desc_item').slideUp('fast');
            $(this).prev().slideUp('fast');
            $(this).next().slideDown('fast');
            $(this).addClass('active');
            return false;
        }else{
            $('.itens_home img').slideDown('fast');
            $('.desc_item').slideUp('fast');
            $('.bt_item').removeClass('active');
            return false;
        }
		
    });
	
    $('.imagens_detalhe .legenda').html($('.imagens_detalhe #slider_2 li.active img').attr('alt'));
	

});

function ativar_menu_topo(){
    // menu empresas do grupo
    $('.conteudo.empresas').parent().find('.menu_topo .mn_empresas').addClass('active');
	
    // menu sustentabilidade
    $('.conteudo.sustent').parent().find('.menu_topo .mn_sustentab').addClass('active');
	
    // menu contato
    $('.conteudo.contato').parent().find('.menu_topo .mn_contato').addClass('active');
	
    // menu novidades
    $('.conteudo.novidades').parent().find('.menu_topo .mn_novidades').addClass('active');
	
    // menu trabalhe conosco
    $('.conteudo.trabalhe').parent().find('.menu_topo .mn_trabalhe').addClass('active');
	
    // menu o grupo
    $('.conteudo.novidades.sobre, .conteudo.novidades.historico, .conteudo.novidades.estrutura,').parent().find('.menu_topo .mn_novidades').removeClass('active');
    $('.conteudo.novidades.sobre, .conteudo.novidades.historico, .conteudo.novidades.estrutura,').parent().find('.menu_topo .mn_grupo').addClass('active');
};

function retira_margem_galeria(){
    $('.lista_item_empresa > li:first').addClass('bg_prod_1');
    $(".lista_item_empresa > li").each(function (i) {
        if( $(this).hasClass('bg_prod_1')) {
            $(this).next('li').addClass('bg_prod_2');
        }
        if( $(this).hasClass('bg_prod_2')) {
            $(this).next('li').addClass('without_marg');
        }
        if( $(this).hasClass('without_marg')) {
            $(this).next('li').addClass('bg_prod_1');
        }
    });

};

function retira_margem_financeira(){
    $('.lista_item_financeira > li:first').addClass('item_left');
    $(".lista_item_financeira > li").each(function (i) {
        if( $(this).hasClass('item_left')) {
            $(this).next('li').addClass('item_right');
        }
        if( $(this).hasClass('item_right')) {
            $(this).next('li').addClass('item_left');
        }
    });

};

function controla_abas_contato(){
    $('.conteudo.contato .botoes_abas a').click(function(){
        if(!$(this).hasClass('active') ){
            $('.botoes_abas a').removeClass('active');
            $('.cont_aba_financeira').addClass('none').show();
            $(this).addClass('active');
			
            if( $(this).hasClass('aba_borrachas') ){
                $('.cont_aba_borrachas').show();
                $('.endereco_contato').fadeOut('',function(){
					
                    });
                $('.txt_canal').attr('value', 'Vipal Borrachas');
                $('.end1').fadeIn();
            }
            if( $(this).hasClass('aba_plasticos') ){
                $('.cont_aba_borrachas').show();
                $('.endereco_contato').fadeOut('', function(){
				
                    });
                $('.txt_canal').attr('value', 'Vipal Plásticos');
                $('.end2').fadeIn();
				
            }
            if( $(this).hasClass('aba_financeira') ){
			
			
                $('.cont_aba_borrachas').hide();
                $('.cont_aba_financeira').removeClass('none').show();           
                $('.endereco_contato').fadeOut('',function(){
					
                    });
                $('.txt_canal').attr('value', 'Vipal Financeira');
                $('.end3').fadeIn();
            }
			
            return false;
        }else{
			
            return false;
        }
    });
}

function controla_abas_estrutura(){
    $('.conteudo.estrutura .botoes_abas a').click(function(){
        if(! $(this).hasClass('active') ){
            $('.botoes_abas a').removeClass('active');
            $(this).addClass('active');
			
            if( $(this).hasClass('aba_borrachas') ){
                $('.dados_aba').fadeOut('',function(){
                    if( $('.cont_aba_borrachas').hasClass('aba_grupo') ){
                        $('.conteudo_abas').css({
                            'height':2047
                        });
                    }					
                });
                $('.cont_aba_borrachas').fadeIn();
            }
            if( $(this).hasClass('aba_plasticos') ){
                $('.dados_aba').fadeOut('', function(){
                    if( $('.cont_aba_banco_vipal').hasClass('aba_grupo') ){
                        $('.conteudo_abas').css({
                            'height':835
                        });
                    }
				
                });
				
                $('.cont_aba_banco_vipal').fadeIn();
				
            }
            if( $(this).hasClass('aba_financeira') ){
                $('.dados_aba').fadeOut('',function(){
                    if( $('.cont_aba_financeira').hasClass('aba_grupo') ){
                        $('.conteudo_abas').css({
                            'height':425
                        });
                    }
                });
                $('.cont_aba_financeira').fadeIn();
            }
			
			
			
            return false;
        }else{
			
            return false;
        }
    });
}

function tira_bg_last_td(){
    $('.exp_cadastradas tr').each(function(){
        $(this).find('td:last').css({
            'background':'#F8F8F8'
        });
    });
	
    $('.formacao_cadastradas tr').each(function(){
        $(this).find('td:last').css({
            'background':'#F8F8F8'
        });
    });
}

function menu_slide_noticias(){
    if( $('.menu_left .mn_noticias').hasClass('active') ){
        $('.submenu_noticias').show();
    }
	
    $('.mn_noticias').click(function(){
        if(! $(this).hasClass('active') ){
            $(this).next('ul').slideDown();
            $(this).addClass('active')
            return false;
        }else{
            $(this).next('ul').slideUp();
            $(this).removeClass('active');
            return false;
        }
    });
}

function abrir_lembrar_senha(){
    $('.lk_lembrar_senha').click(function(){
        $('.box_remember').fadeIn();
        $('.box_remember').mouseover(function(){
            $('.overlay_remember').fadeIn();
            $('.overlay_remember').mouseover(function(){
                $('.box_remember, .overlay_remember').fadeOut();
                return false;
            });
        });
        return false;
    });
	
}

function selecionar_area_interesse(){
    var itens_cache;
    /* ATIVA / DESATIVA ITEM */
    $('.box_point span').click(function(){
		
        if( !$(this).hasClass('active') ){
            $(this).addClass('active');
        }else{
            $(this).removeClass('active');
        };
        return false;
    });
    /* ATIVA / DESATIVA ITEM - END */
	
    /* ADICIONA ITENS */
    $('.bt_right').click(function(){
		
        $('.itens_interesse span.active').each(function(){
            $('.itens_selecionado .scroll').append(this);
            $('.itens_selecionado .scroll span').removeClass('active');
            $('#areas_fake').append('<input type="checkbox" checked="checked" name="areas_fake[]" id="'+$(this).attr('id')+'" value="'+$(this).attr('id')+'" />')
        });
		
        return false;
    });
    /* ADICIONA ITENS - END */
	
    /* REMOVE ITENS */
    $('.bt_left').click(function(){
        $('.itens_selecionado span.active').each(function(){
            $('.itens_interesse .scroll').append(this);
            $('.itens_interesse .scroll span').removeClass('active');
            $('#areas_fake').find('#'+$(this).attr('id')).remove();
			
        });
        return false;
    });
/* REMOVE ITENS - END */
};

function remove_linha(){
    $('.exp_cadastradas .bt_excluir, .formacao_cadastradas .bt_excluir').click(function(){
        $(this).closest('.bts_control').find('.tooltip').fadeIn('fast');
        return false;
    });
	
    $('.lk_nao').click(function(){
        $(this).closest('.tooltip').fadeOut('fast');
        return false;
    });
	
    $('.lk_sim').click(function(){
        if($(this).attr('rel')=='emprego'){
            var id_emprego;
            id_emprego = $(this).closest('.bts_control').find('.bt_excluir').attr('rel')
            base_url = $('base').attr('href') + 'trabalhe_conosco/exclui_emprego';
            vet_dados = 'id_emprego='+id_emprego;
            $.ajax({
                type: "POST",
                url: base_url,
                data: vet_dados,
                success: function(msg) {


                }
            })
        }else if($(this).attr('rel')=='formacao'){
            var id_formacao;
            id_formacao = $(this).closest('.bts_control').find('.bt_excluir').attr('rel')
            base_url = $('base').attr('href') + 'trabalhe_conosco/exclui_formacao';
            vet_dados = 'id_formacao='+id_formacao;
            $.ajax({
                type: "POST",
                url: base_url,
                data: vet_dados,
                success: function(msg) {


                }
            });
        }else{
            var id_emprego;
            id_emprego = $(this).closest('.bts_control').find('.bt_excluir').attr('rel')
            base_url = $('base').attr('href') + 'trabalhe_conosco/exclui_item';
            vet_dados = 'id_emprego='+id_emprego;
            $.ajax({
                type: "POST",
                url: base_url,
                data: vet_dados,
                success: function(msg) {


                }
            });
        }
				
				
        $(this).closest('tr').fadeOut('',function(){
            $(this).remove();
        });
				
        return false;
    });
}

function adicionar_experiencia(){
	
    /* ADICIONA EXPERIENCIA */
    $('.bt_salvar_experiencia').click(function(){
        var status_valida = 2;
        /* empresa */
        if( $(this).closest('form').find('#empresa').val() == "" ){
            $(this).closest('form').find('#empresa').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#empresa').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* empresa.end

	/* area */
        if( $(this).closest('form').find('#areas').val() == "" ){
            $(this).closest('form').find('#areas').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#areas').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* area.end */

	
        /* estado_emprego */
        if( $(this).closest('form').find('#estado_emprego').val() == "" ){
            $(this).closest('form').find('#estado_emprego').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#estado_emprego').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* estado_emprego.end */

        /* cidade_emprego */
        if( $(this).closest('form').find('#cidade_emprego').val() == "" ){
            $(this).closest('form').find('#cidade_emprego').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#cidade_emprego').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* cidade_emprego.end */

        /* atividades */
        if( $(this).closest('form').find('#atividades').val() == "" ){
            $(this).closest('form').find('#atividades').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#atividades').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* atividades.end */

        /* referencia */
        if( $(this).closest('form').find('#referencia').val() == "" ){
		
            $(this).closest('form').find('#referencia').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#referencia').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* referencia.end */
		
        if( $(this).closest('form').find('#mes_inicio').val() == "" || $(this).closest('form').find('#ano_inicio').val() == "" ){
		
            $(this).closest('form').find('#mes_inicio').closest('div').find('.alerta_validacao').fadeIn();
            status_valida=1;
		
        } else{
            $(this).closest('form').find('#mes_inicio').closest('div').find('.alerta_validacao').fadeOut();
        }

		
		


        /* data de inicio */

        /* data de inicio.end */




        /* data de fim */
		
        if( $(this).closest('form').find('#mes_termino').val() == "" || $(this).closest('form').find('#ano_termino').val() == "" ){
				
            $("input[name='trabalha']").change(function(){
				
                if ($("input[name='trabalha']:checked").val() == '1'){
					
                    $(this).closest('form').find('#mes_termino').closest('div').find('.alerta_validacao').fadeOut();
					
			
									
                }
                if ($("input[name='trabalha']:checked").val() == '0'){
					
											
                    if( $(this).closest('form').find('#mes_termino').val() == "" || $(this).closest('form').find('#ano_termino').val() == "" ){
					
                        $(this).closest('form').find('#mes_termino').closest('div').find('.alerta_validacao').fadeIn();
                        status_valida=1;
						
			
                    } else{
                        $(this).closest('form').find('#mes_termino').closest('div').find('.alerta_validacao').fadeOut();
                    }
					
					
                }
            });
					
	
        } else{
            $(this).closest('form').find('#mes_termino').closest('div').find('.alerta_validacao').fadeOut();
        }
				
				
				
		
						
		
		

		
		
		
        /* data de fim.end */

        if(status_valida==1){
		
            //$('.alerta_erro').fadeIn();
            return false;
        }

        $('.box_ultimo_emprego h2 .alerta_validacao').hide();
										   
		
        var empresa, mes_ini, ano_ini, mes_fim, ano_fim, area_atuacao, cargo, estado, cidade
		
        empresa = $('.box_ultimo_emprego #empresa').val();
        area_atuacao = $('.box_ultimo_emprego #areas').parent().find('.select-fake2').html();
        estado = $('.box_ultimo_emprego #estado_emprego').parent().find('.select-fake2').html();
        cidade = $('.box_ultimo_emprego #cidade_emprego').parent().find('.select-fake2').html();
        mes_ini = $('.box_ultimo_emprego #mes_inicio').val();
        ano_ini = $('.box_ultimo_emprego #ano_inicio').val();
        mes_fim = $('.box_ultimo_emprego #mes_termino').val();
        ano_fim = $('.box_ultimo_emprego #ano_termino').val();
					
        var estado_val = $('#estado_emprego').val();
        var cidade_val = $('#cidade_emprego').val();
        var area_atuacao_val = $('#areas').val();
        var referencia = $('#referencia').val();
        var ddd_contato = $('#ddd_contato').val();
        var telefone_contato = $('#telefone_contato').val();
        var atividades = $('#atividades').val();
        var id_emprego = $('#id_emprego').val();

        base_url = $('base').attr('href') + 'trabalhe_conosco/salva_experiencia';
        var vet_dados = 'empresa='+empresa+'&area_atuacao='+area_atuacao_val+'&area_atuacao_txt='+area_atuacao+'&estado='+estado_val+
        '&estado_text='+estado+'&cidade='+cidade_val+'&cidade_text='+cidade+'&mes_ini='+mes_ini+'&ano_ini='+ano_ini+'&mes_fim='+mes_fim+
        '&ano_fim='+ano_fim+'&referencia='+referencia+'&ddd_contato='+ddd_contato+'&telefone_contato='+telefone_contato+
        '&atividades='+atividades+'&id_emprego='+id_emprego;

        $.ajax({
            type: "POST",
            url: base_url,
            data: vet_dados,
            success: function(msg) {
							
                id_emprego = msg;
                $('.tt_experiencias').removeClass('none');
                if( $('.exp_cadastradas tr').hasClass('edit') ){
                    $('.exp_cadastradas .edit .exp_emp').html(empresa);
                    $('.exp_cadastradas .edit .exp_area').html(area_atuacao);
				
                    $('.exp_cadastradas .edit .exp_cidade').html(estado+' - '+cidade);
                    $('.exp_cadastradas .edit .exp_datas').html(mes_ini+'/'+ano_ini+' - '+mes_fim+'/'+ano_fim);

                    $('.exp_cadastradas tr').removeClass('edit');
                }else{
									
                    $('.box_ultimo_emprego tbody').append('\
									<tr> \
											<td class="bts_control""> \
													<div class="box_tooltip"> \
														<div class="tooltip"> \
															<p>Você tem certeza que quer excluir este arquivo?</p> \
															<p>A exclusão dele será permanente e sem recuperação das informações</p> \
															<a class="lk_nao replace" href="#">Nao</a> \
															<a class="lk_sim replace" rel="emprego" href="#">Sim</a> \
														</div> \
													</div> \
													<a title="Editar" class="bt_editar replace" href="#">editar</a> \
													<a title="Excluir" rel="'+id_emprego+'" class="bt_excluir replace" href="#">excluir</a> \
											</td> \
											<td class="exp_id none">'+id_emprego+'</td> \
											<td class="referencia none">'+referencia+'</td> \
											<td class="ddd none">'+ddd_contato+'</td> \
											<td class="telefone none">'+telefone_contato+'</td> \
											<td class="atividades none">'+atividades+'</td> \
											<td class="exp_emp">'+empresa+'</td> \
											<td class="exp_datas">'+mes_ini+'/'+ano_ini+' - '+mes_fim+'/'+ano_fim+'</td> \
											<td class="exp_area">'+area_atuacao+'</td> \
											<td class="exp_cidade">'+estado+' - '+cidade+'</td> \
									</tr> \
									');
                    $('.box_ultimo_emprego tbody .none').fadeIn('');
                    remove_linha();
                    tira_bg_last_td();
                    edita_experiencia();
                }
                limpa_campos_empregos();

            }
						
        })
		
		
        return false;
    });
    /* ADICIONA EXPERIENCIA / END */


    /* ADICIONA EXPERIENCIA */
    $('.bt_salvar_experiencia2').click(function(){
        var status_valida = 2;
        /* empresa */
        if( $(this).closest('form').find('#empresa').val() == "" ){
            $(this).closest('form').find('#empresa').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#empresa').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* empresa.end

	/* area */
        if( $(this).closest('form').find('#areas').val() == "" ){
            $(this).closest('form').find('#areas').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#areas').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* area.end */


        /* estado_emprego */
        if( $(this).closest('form').find('#estado_emprego').val() == "" ){
            $(this).closest('form').find('#estado_emprego').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#estado_emprego').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* estado_emprego.end */

        /* cidade_emprego */
        if( $(this).closest('form').find('#cidade_emprego').val() == "" ){
            $(this).closest('form').find('#cidade_emprego').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#cidade_emprego').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* cidade_emprego.end */

        /* atividades */
        if( $(this).closest('form').find('#atividades').val() == "" ){
            $(this).closest('form').find('#atividades').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#atividades').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* atividades.end */

        /* referencia */
        if( $(this).closest('form').find('#referencia').val() == "" ){

            $(this).closest('form').find('#referencia').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#referencia').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* referencia.end */

        /* data de inicio */
        if( $(this).closest('form').find('#mes_inicio').val() == "" || $(this).closest('form').find('#ano_inicio').val() == "" ){

            $(this).closest('form').find('#mes_inicio').closest('div').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#mes_inicio').closest('div').find('.alerta_validacao').fadeOut();
        }
        /* data de inicio.end */

        /* data de fim */
        if( $(this).closest('form').find('#mes_termino').val() == "" || $(this).closest('form').find('#ano_termino').val() == "" ){

            $(this).closest('form').find('#mes_termino').closest('div').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#mes_termino').closest('div').find('.alerta_validacao').fadeOut();
        }
        /* data de fim.end */

        if(status_valida==1){

            //$('.alerta_erro').fadeIn();
            return false;
        }



        var empresa, mes_ini, ano_ini, mes_fim, ano_fim, area_atuacao, cargo, estado, cidade

        empresa = $('.box_ultimo_emprego #empresa').val();
        area_atuacao = $('.box_ultimo_emprego #areas').parent().find('.select-fake2').html();
        estado = $('.box_ultimo_emprego #estado_emprego').parent().find('.select-fake2').html();
        cidade = $('.box_ultimo_emprego #cidade_emprego').parent().find('.select-fake2').html();
        mes_ini = $('.box_ultimo_emprego #mes_inicio').val();
        ano_ini = $('.box_ultimo_emprego #ano_inicio').val();
        mes_fim = $('.box_ultimo_emprego #mes_termino').val();
        ano_fim = $('.box_ultimo_emprego #ano_termino').val();

        var estado_val = $('#estado_emprego').val();
        var cidade_val = $('#cidade_emprego').val();
        var area_atuacao_val = $('#areas').val();
        var referencia = $('#referencia').val();
        var ddd_contato = $('#ddd_contato').val();
        var telefone_contato = $('#telefone_contato').val();
        var atividades = $('#atividades').val();
        var id_emprego = $('#id_emprego').val();

        base_url = $('base').attr('href') + 'trabalhe_conosco/salva_experiencia2';
        var vet_dados = 'empresa='+empresa+'&area_atuacao='+area_atuacao_val+'&area_atuacao_txt='+area_atuacao+'&estado='+estado_val+
        '&estado_text='+estado+'&cidade='+cidade_val+'&cidade_text='+cidade+'&mes_ini='+mes_ini+'&ano_ini='+ano_ini+'&mes_fim='+mes_fim+
        '&ano_fim='+ano_fim+'&referencia='+referencia+'&ddd_contato='+ddd_contato+'&telefone_contato='+telefone_contato+
        '&atividades='+atividades+'&id_emprego='+id_emprego;

        $.ajax({
            type: "POST",
            url: base_url,
            data: vet_dados,
            success: function(msg) {

                id_emprego = msg;
                $('.tt_experiencias').removeClass('none');
                if( $('.exp_cadastradas tr').hasClass('edit') ){
                    $('.exp_cadastradas .edit .exp_emp').html(empresa);
                    $('.exp_cadastradas .edit .exp_area').html(area_atuacao);

                    $('.exp_cadastradas .edit .exp_cidade').html(estado+' - '+cidade);
                    $('.exp_cadastradas .edit .exp_datas').html(mes_ini+'/'+ano_ini+' - '+mes_fim+'/'+ano_fim);

                    $('.exp_cadastradas tr').removeClass('edit');
                }else{

                    $('.box_ultimo_emprego tbody').append('\
									<tr> \
											<td class="bts_control""> \
													<div class="box_tooltip"> \
														<div class="tooltip"> \
															<p>Você tem certeza que quer excluir este arquivo?</p> \
															<p>A exclusão dele será permanente e sem recuperação das informações</p> \
															<a class="lk_nao replace" href="#">Nao</a> \
															<a class="lk_sim replace" rel="emprego" href="#">Sim</a> \
														</div> \
													</div> \
													<a title="Editar" class="bt_editar replace" href="#">editar</a> \
													<a title="Excluir" rel="'+id_emprego+'" class="bt_excluir replace" href="#">excluir</a> \
											</td> \
											<td class="exp_id none">'+id_emprego+'</td> \
											<td class="referencia none">'+referencia+'</td> \
											<td class="ddd none">'+ddd_contato+'</td> \
											<td class="telefone none">'+telefone_contato+'</td> \
											<td class="atividades none">'+atividades+'</td> \
											<td class="exp_emp">'+empresa+'</td> \
											<td class="exp_datas">'+mes_ini+'/'+ano_ini+' - '+mes_fim+'/'+ano_fim+'</td> \
											<td class="exp_area">'+area_atuacao+'</td> \
											<td class="exp_cidade">'+estado+' - '+cidade+'</td> \
									</tr> \
									');
                    $('.box_ultimo_emprego tbody .none').fadeIn('');
                    remove_linha();
                    tira_bg_last_td();
                    edita_experiencia();
                }
                limpa_campos_empregos();

            }

        })


        return false;
    });

};

function edita_experiencia(){
    var empresa, mes_ini, ano_ini, mes_fim, ano_fim, area_atuacao, cargo, estado, cidade
	
    $('.exp_cadastradas .bt_editar').click(function(){
        $('.exp_cadastradas tr.edit').removeClass('edit');
        $(this).closest('tr').addClass('edit');

        id_emprego = $('.exp_cadastradas .edit .exp_id').html();
        //alert(id_emprego)
        empresa = $('.exp_cadastradas .edit .exp_emp').html();
        area_atuacao = $('.exp_cadastradas .edit .exp_area').html();
        referencia = $('.exp_cadastradas .edit .referencia').html();
        ddd = $('.exp_cadastradas .edit .ddd').html();
        telefone = $('.exp_cadastradas .edit .telefone').html();
        atividades = $('.exp_cadastradas .edit .atividades').html();
        estado = $('.exp_cadastradas .edit .exp_cidade').html().split(' - ')[0];
        cidade = $('.exp_cadastradas .edit .exp_cidade').html().split(' - ')[1];
        mes_ini = $('.exp_cadastradas .edit .exp_datas').html().split(' - ')[0].split('/')[0];
        ano_ini = $('.exp_cadastradas .edit .exp_datas').html().split(' - ')[0].split('/')[1];
        mes_fim = $('.exp_cadastradas .edit .exp_datas').html().split(' - ')[1].split('/')[0];
        ano_fim = $('.exp_cadastradas .edit .exp_datas').html().split(' - ')[1].split('/')[1];

        $('.box_ultimo_emprego #id_emprego').attr('value',id_emprego);
        $('.box_ultimo_emprego #empresa').attr('value',empresa);
        $('.box_ultimo_emprego #areas').parent().find('.select-fake2').html(area_atuacao);
        $('.box_ultimo_emprego #referencia').attr('value',referencia);
        $('.box_ultimo_emprego #ddd_contato').attr('value',ddd);
        $('.box_ultimo_emprego #telefone_contato').attr('value',telefone);
        $('.box_ultimo_emprego #atividades').attr('value',atividades);
        $('.box_ultimo_emprego #estado_emprego').parent().find('.select-fake2').html(estado);
        $('.box_ultimo_emprego #cidade_emprego').parent().find('.select-fake2').html(cidade);
        $('.box_ultimo_emprego #mes_inicio').attr('value',mes_ini);
        $('.box_ultimo_emprego #ano_inicio').attr('value',ano_ini);
        $('.box_ultimo_emprego #mes_termino').attr('value',mes_fim);
        $('.box_ultimo_emprego #ano_termino').attr('value',ano_fim);
        return false;
    });


};

function limpa_campos_empregos(){
    $('.box_ultimo_emprego input').attr('value','');
    $('.box_ultimo_emprego textarea').attr('value','');
    $('.box_ultimo_emprego #areas').parent().find('.select-fake2').html('Selecione');
    $('.box_ultimo_emprego #cargos').parent().find('.select-fake2').html('Selecione');
    $('.box_ultimo_emprego #estado_emprego').parent().find('.select-fake2').html('Selecione');
    $('.box_ultimo_emprego #cidade_emprego').parent().find('.select-fake2').html('Selecione');
}

function adicionar_formacao(){

    /* ADICIONA FORMACAO */
    $('.bt_salvar_formacao').click(function(){
        var status_valida = 3;
        /* empresa */
        if( $(this).closest('form').find('#instituicao').val() == "" ){
            $(this).closest('form').find('#instituicao').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#instituicao').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* empresa.end

	/* area */
        if( $(this).closest('form').find('#niveis').val() == "" ){
            $(this).closest('form').find('#niveis').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#niveis').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* area.end */


        /* estado_emprego */
        if( $(this).closest('form').find('#curso').val() == "" ){
            $(this).closest('form').find('#curso').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#curso').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* estado_emprego.end */

        /* cidade_emprego */
        if( $(this).closest('form').find('#semestre').val() == "" ){
            $(this).closest('form').find('#semestre').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#semestre').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* cidade_emprego.end */

	  

        if(status_valida==1){

            //$('.alerta_erro').fadeIn();
            return false;
        }		
		
        $('.box_formacao h2 .alerta_validacao').hide();

        var instituicao, nivel, curso, semestre, ano_conclusao, id_formacao;
		
        instituicao = $('.box_formacao #instituicao').val();
        curso = $('.box_formacao #curso').val();
        nivel = $('.box_formacao #niveis').parent().find('.select-fake2').html();
        semestre = $('.box_formacao #semestre').val();
        ano_conclusao = $('.box_formacao #anos').parent().find('.select-fake2').html();
        id_formacao = $('#id_formacao').val();
   
        base_url = $('base').attr('href') + 'trabalhe_conosco/salva_formacao';

        var vet_dados = 'instituicao='+instituicao+'&curso='+curso+'&nivel='+nivel+'&semestre='+semestre+
        '&ano_conclusao='+ano_conclusao+'&id_formacao='+id_formacao;
	 
        $.ajax({
            type: "POST",
            url: base_url,
            data: vet_dados,
            success: function(msg) {
                id_formacao = msg;
                $('.tt_experiencias2').removeClass('none');
                if( $('.formacao_cadastradas tr').hasClass('edit') ){
                    $('.formacao_cadastradas .edit .instituicao').html(instituicao);
                    $('.formacao_cadastradas .edit .nivel').html(nivel);
                    $('.formacao_cadastradas .edit .curso').html(curso);
                    $('.formacao_cadastradas .edit .conclusao').html(semestre+'/'+ano_conclusao);

                    $('.formacao_cadastradas tr').removeClass('edit');
                }else{
                    $('.formacao_cadastradas tbody').append('\
									<tr class=""> \
											<td class="bts_control""> \
													<div class="box_tooltip"> \
														<div class="tooltip"> \
															<p>Você tem certeza que quer excluir este arquivo?</p> \
															<p>A exclusão dele será permanente e sem recuperação das informações</p> \
															<a class="lk_nao replace" href="#">Nao</a> \
															<a class="lk_sim replace" rel="emprego" href="#">Sim</a> \
														</div> \
													</div> \
													<a title="Editar" class="bt_editar replace" href="#">editar</a> \
													<a title="Excluir" rel="'+id_formacao+'" class="bt_excluir replace" href="#">excluir</a> \
											</td> \
											<td class="id_formacao none">'+id_formacao+'</td> \
											<td class="instituicao">'+instituicao+'</td> \
											<td class="nivel">'+nivel+'</td> \
											<td class="curso">'+curso+'</td> \
											<td class="conclusao">'+semestre+'/'+ano_conclusao+'</td> \
									</tr> \
									');
                    $('.formacao_cadastradas tbody .none').fadeIn('');
                    remove_linha();
                    tira_bg_last_td();
                    edita_formacao();
                }
                limpa_campos_formacao();
            }

        });
	
        return false;
    });
    /* ADICIONA FORMACAO / END */

    $('.bt_salvar_formacao2').click(function(){
        var status_valida = 3;
        /* empresa */
        if( $(this).closest('form').find('#instituicao').val() == "" ){
            $(this).closest('form').find('#instituicao').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#instituicao').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* empresa.end

	/* area */
        if( $(this).closest('form').find('#niveis').val() == "" ){
            $(this).closest('form').find('#niveis').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#niveis').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* area.end */


        /* estado_emprego */
        if( $(this).closest('form').find('#curso').val() == "" ){
            $(this).closest('form').find('#curso').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#curso').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* estado_emprego.end */

        /* cidade_emprego */
        if( $(this).closest('form').find('#semestre').val() == "" ){
            $(this).closest('form').find('#semestre').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#semestre').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* cidade_emprego.end */

	  

        if(status_valida==1){

            //$('.alerta_erro').fadeIn();
            return false;
        }		
		
        $('.box_formacao h2 .alerta_validacao').hide();

        var instituicao, nivel, curso, semestre, ano_conclusao, id_formacao;

        instituicao = $('.box_formacao #instituicao').val();
        curso = $('.box_formacao #curso').val();
        nivel = $('.box_formacao #niveis').parent().find('.select-fake2').html();
        semestre = $('.box_formacao #semestre').val();
        ano_conclusao = $('.box_formacao #anos').parent().find('.select-fake2').html();
        id_formacao = $('#id_formacao').val();

        base_url = $('base').attr('href') + 'trabalhe_conosco/salva_formacao2';

        var vet_dados = 'instituicao='+instituicao+'&curso='+curso+'&nivel='+nivel+'&semestre='+semestre+
        '&ano_conclusao='+ano_conclusao+'&id_formacao='+id_formacao;

        $.ajax({
            type: "POST",
            url: base_url,
            data: vet_dados,
            success: function(msg) {
                id_formacao = msg;
                $('.tt_experiencias2').removeClass('none');
                if( $('.formacao_cadastradas tr').hasClass('edit') ){
                    $('.formacao_cadastradas .edit .instituicao').html(instituicao);
                    $('.formacao_cadastradas .edit .nivel').html(nivel);
                    $('.formacao_cadastradas .edit .curso').html(curso);
                    $('.formacao_cadastradas .edit .conclusao').html(semestre+'/'+ano_conclusao);

                    $('.formacao_cadastradas tr').removeClass('edit');
                }else{
                    $('.formacao_cadastradas tbody').append('\
									<tr class=""> \
											<td class="bts_control""> \
													<div class="box_tooltip"> \
														<div class="tooltip"> \
															<p>Você tem certeza que quer excluir este arquivo?</p> \
															<p>A exclusão dele será permanente e sem recuperação das informações</p> \
															<a class="lk_nao replace" href="#">Nao</a> \
															<a class="lk_sim replace" rel="emprego" href="#">Sim</a> \
														</div> \
													</div> \
													<a title="Editar" class="bt_editar replace" href="#">editar</a> \
													<a title="Excluir" rel="'+id_formacao+'" class="bt_excluir replace" href="#">excluir</a> \
											</td> \
											<td class="id_formacao none">'+id_formacao+'</td> \
											<td class="instituicao">'+instituicao+'</td> \
											<td class="nivel">'+nivel+'</td> \
											<td class="curso">'+curso+'</td> \
											<td class="conclusao">'+semestre+'/'+ano_conclusao+'</td> \
									</tr> \
									');
                    $('.formacao_cadastradas tbody .none').fadeIn('');
                    remove_linha();
                    tira_bg_last_td();
                    edita_formacao();
                }
                limpa_campos_formacao();
            }

        });

        return false;
    });

};

function edita_formacao(){
    var instituicao, nivel, curso, semestre, ano_conclusao;
	
    $('.formacao_cadastradas .bt_editar').click(function(){
        $('.formacao_cadastradas tr.edit').removeClass('edit');
        $(this).closest('tr').addClass('edit');

        id_formacao = $('.formacao_cadastradas .edit .id_formacao').html();
        instituicao = $('.formacao_cadastradas .edit .instituicao').html();
        nivel = $('.formacao_cadastradas .edit .nivel').html();
        curso = $('.formacao_cadastradas .edit .curso').html();
        semestre = $('.formacao_cadastradas .edit .conclusao').html().split('/')[0];
        ano_conclusao = $('.formacao_cadastradas .edit .conclusao').html().split('/')[1];
	
        $('.box_formacao #id_formacao').attr('value',id_formacao);
        $('.box_formacao #instituicao').attr('value',instituicao);
        $('.box_formacao #niveis').parent().find('.select-fake2').html(nivel);
        $('.box_formacao #curso').attr('value',curso);
        $('.box_formacao #semestre').attr('value',semestre);
        $('.box_formacao #anos').parent().find('.select-fake2').html(ano_conclusao);
        return false;
    });


};

function limpa_campos_formacao(){
    $('.box_formacao input').attr('value','');
    $('.box_formacao textarea').attr('value','');
    $('.box_formacao #cursos').parent().find('.select-fake2').html('Selecione');
    $('.box_formacao #niveis').parent().find('.select-fake2').html('Selecione');
    $('.box_formacao #anos').parent().find('.select-fake2').html('2011');
}

function abrir_detalhes_vaga(){
    $('.lk_info_mais').click(function(){
        $(this).closest('.links_vagas').addClass('open');
        $(this).closest('.links_vagas').prev().find('.box_obs').fadeIn();
        $(this).closest('.links_vagas').prev().find('.box_linhas').fadeIn();
        $(this).closest('.links_vagas').find('.lk_candidatar').removeClass('none');
        $(this).closest('.links_vagas').find('.lk_enviar_amigo').removeClass('none');
        $(this).addClass('none');
        $(this).next().removeClass('none');
		
        fechar_detalhes_vaga();
        return false;
    });
}

function fechar_detalhes_vaga(){
    $('.lk_info_menos').click(function(){
        $(this).closest('.links_vagas').prev().find('.box_obs').fadeOut();
        $(this).closest('.links_vagas').prev().find('.box_linhas').fadeOut();
        $(this).closest('.links_vagas').find('.lk_candidatar').addClass('none');
        $(this).closest('.links_vagas').find('.lk_enviar_amigo').addClass('none');
        $(this).closest('.links_vagas').removeClass('open');
        $(this).addClass('none');
        $(this).prev().removeClass('none');
		
        return false;
    });
}

function abrir_envie_vaga(){
    $('.lk_enviar_amigo').click(function(){
        $(this).next('.box_enviar_amigo').fadeIn('fast');
        //$(this).parent().find('.overlay_box').fadeIn();
	
        fechar_envie_vaga();
        return false;
    });
};

function fechar_envie_vaga(){
    $('.box_enviar_amigo').mouseover(function(){
        $(this).parent().find('.overlay_box').fadeIn();
        $(this).parent().find('.overlay_box').mouseover(function(){
            $(this).fadeOut();
            $(this).prev().fadeOut();
            return false;
        });
    });
    return false;
};

function trocar_decada(){
    avanca_volta_historico();
    /* TROCAR DECADAS */
    $('.lista_decadas a').click(function(){
									
        var decada_atual;
        if(! $(this).hasClass('active') ){
            $('.lista_decadas a').removeClass('active');
            $(this).addClass('active');
		
            decada_atual = $(this).attr('lang');
		
            $('.right_tempo > div').fadeOut('',function(){
                $(this).removeClass('active');
            });
            $('.right_tempo > div.result_'+decada_atual+'').fadeIn('',function(){
                $('.result_anos div').removeClass('active').hide();
                $('.lista_anos a').removeClass('active');
                if ( !$('.result_decadas').hasClass('controle') ){
                    $(this).find('.result_anos > div:first').addClass('active').show();
                    $(this).find('.lista_anos > li:first a').addClass('active');
                    $('.result_decadas').removeClass('controle');
                }else{
                    $(this).find('.result_anos > div:last').addClass('active').show();
                    $(this).find('.lista_anos > li:last a').addClass('active');
                    $('.result_decadas').removeClass('controle');
                }
			
												
            }).addClass('active');
		
            trocar_anos();
		
            return false;
		
        };
		
	
    });

/* TROCAR DECADAS / END */
}

function trocar_anos(){
    /* TROCAR ANOS */
    $('.lista_anos a').click(function(){
        var ano_atual;
        if(! $(this).hasClass('active') ){
            $('.lista_anos a').removeClass('active');
            $(this).addClass('active');
		
            ano_atual = $(this).attr('alt');
            $('.result_anos > div').fadeOut('',function(){
                $(this).removeClass('active');
            });
            $('.result_anos > div.'+ano_atual+'').fadeIn('',function(){
                $(this).addClass('active');
            });
        }
	
    });
/* TROCAR ANOS / END */
}

function avanca_volta_historico(){
    /* avanca historico */
    $('.bt_right_ano').click(function(){
        var lk_decada_atual = $('.lista_decadas a.active');
        var dados_decada_atual = $('.right_tempo > div.active');
        var lk_ano_atual = $('.lista_anos a.active');
        var dados_ano_atual = $('.result_anos > div.active');
        var lk_prev_ano;
        var lk_next_ano;
				
        /* proximo link_decada */
	
        if( !$('.right_tempo > div.active .result_anos > div:last').hasClass('active') ){
            $('.lista_anos a').removeClass('active');
            lk_ano_atual.parent().next().children('a').click().addClass('active');
        }else{
            if( !$('.right_tempo > div:last').hasClass('active') ){
                $('.lista_decadas a').removeClass('active');
                lk_decada_atual.parent().next().children('a').click().addClass('active');
            }
        }
    /* proximo link_decada */
	
	
						  
	
    });

    $('.bt_left_ano').click(function(){
        var lk_decada_atual = $('.lista_decadas a.active');
        var dados_decada_atual = $('.right_tempo > div.active');
        var lk_ano_atual = $('.lista_anos a.active');
        var dados_ano_atual = $('.result_anos > div.active');
				
        /* anterior link_decada */
        if( !$('.right_tempo > div.active .result_anos > div:first').hasClass('active') ){
            $('.lista_anos a').removeClass('active');
            $(this).addClass('active');
            lk_ano_atual.parent().prev().children('a').click().addClass('active');
        }else{
            if( !$('.right_tempo > div:first').hasClass('active') ){
                $('.lista_decadas a').removeClass('active');
                lk_decada_atual.parent().prev().children('a').click().addClass('active');
                //dados_decada_atual.prev().find('.lista_anos > li:last a').attr('alt');
                $('.result_decadas').addClass('controle');
            }
		
        }
    /* anterior link_decada */
						  
	
    });
/* avanca historico */

};

function trocar_premiacao(){
    $('.lista_premios > li a[alt*=1998]').hover(function(){
        $('.lista_premios > li a[alt*=1998]').addClass('hover_item');
    },function(){
        $('.lista_premios > li a[alt*=1998]').removeClass('hover_item');
    });
    $('.lista_premios > li a').click(function(){
        var ano_atual;
	
        ano_atual = $(this).attr('alt');
	
	
        if(! $(this).hasClass('active') ){
            if( $(this).attr('alt')=='1998'){
                $('.lista_premios > li a').removeClass('active');
                $('.lista_premios > li a[alt*=1998]').addClass('active');
            }else{
                $('.lista_premios > li a').removeClass('active');
                $(this).addClass('active');
            }
		
		
            $('.item_result').fadeOut().removeClass('active');
            $('.item_result#'+ano_atual+'').fadeIn('',function(){
                var tamanho_lista;
                tamanho_lista = $('.item_result.active').innerHeight();
                $('.result_premios').css({
                    'height':tamanho_lista
                });
            }).addClass('active');
		
		
			
		
            return false;
        }else{
            return false;
        }
    });
}

function abrir_submenu(){
    $('.mn_empresas').parent().hover(
        function () {
		
            $('.submenu_empresas').slideDown(200,function(){
                $('.mn_empresas').addClass('open');
            });
        },
        function () {
            $('.submenu_empresas').stop(true, true).slideUp("200", function(){
                $('.mn_empresas').removeClass('open');
            });

        /*$('.mn_empresas').parent().mouseout(function(){
	$(this).mouseleave(function(){											   
		$('.submenu_empresas').slideUp('',function(){});
	});
});*/
        });
};

function checkMail(mail){

    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);

    if(typeof(mail) == "string"){

        if(er.test(mail)){
            return true;
        }

    }else if(typeof(mail) == "object"){

        if(er.test(mail.value)){

            return true;

        }

    }else{

        return false;

    }

}

function validar_contato(){

    $('#enviar').click(function(){
							   
        var status_valida=0;
	
        if( $(this).closest('form').find('#nome').val() == "" ){
            $(this).closest('form').find('#nome').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#nome').closest('li').find('.alerta_validacao').fadeOut();
        }
	
        if( $(this).closest('form').find('#email').val() == "" ){
            $(this).closest('form').find('#email').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else
        if(!checkMail($(this).closest('form').find('#email').val())){
            $(this).closest('form').find('#email').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;
        }else{
            $(this).closest('form').find('#email').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#estado').val() == "" ){
            $(this).closest('form').find('#estado').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#estado').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#cidade2').val() == "" ){
            $(this).closest('form').find('#cidade2').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#cidade2').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#telefone').val() == "" ){
            $(this).closest('form').find('#telefone').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#telefone').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#assunto').val() == "" ){
            $(this).closest('form').find('#assunto').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#assunto').closest('li').find('.alerta_validacao').fadeOut();
        }
	
        if( $(this).closest('form').find('#mensagem').val() == "" ){
            $(this).closest('form').find('#mensagem').prev().fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#mensagem').prev().fadeOut();
        }
	
	
	
        if(status_valida==1){
            //$('.alerta_erro').fadeIn();
            return false;
        }
    });
};

function validar_cadastro_curriculos(){
    $('.bt_salvar_curriculo').click(function(){
        var status_valida=0;
	
        /* nome */
        if( $('#nome').val() == "" ){
            $('#nome').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $('#nome').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* nome.end */
	
        /* data nascimento */
        if( $(this).closest('form').find('#data_nascimento').val() == "" ){
            $('#data_nascimento').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $('#data_nascimento').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* data nascimento.end */
	
        /* email */
        if( $(this).closest('form').find('#email').val() == "" ){
            $('#email').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else
        if(!checkMail($(this).closest('form').find('#email').val())){
            $('#email').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;
        }else{
            $('#email').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* email.end */
	
        /* endereco */
        if( $(this).closest('form').find('#endereco').val() == "" ){
            $('#endereco').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $('#endereco').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* endereco.end */
	
        /* numero */
        if( $(this).closest('form').find('#numero').val() == "" ){
            $('#numero').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $('#numero').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* numero.end */
	
        /* bairro */
        if( $(this).closest('form').find('#bairro').val() == "" ){
            $('#bairro').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $('#bairro').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* bairro.end */
	
        /* estado */
        if( $(this).closest('form').find('#estado_cad').val() == "" ){
            $(this).closest('form').find('#estado_cad').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#estado_cad').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* estado.end */
	
        /* cidade */
        if( $(this).closest('form').find('#cidade_cad').val() == "" ){
            $(this).closest('form').find('#cidade_cad').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#cidade_cad').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* cidade.end */
	
        /* grau de instrucao */
        if( $(this).closest('form').find('#grau_instrucao').val() == "" ){
            $(this).closest('form').find('#grau_instrucao').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#grau_instrucao').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* grau de instrucao.end */
	
        /* telefone cadastro */
        if( $(this).closest('form').find('#ddd').val() == "" || $(this).closest('form').find('#telefone').val() == "" ){
            $(this).closest('form').find('#ddd').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#ddd').closest('li').find('.alerta_validacao').fadeOut();
        }
        /* telefone cadastro.end */
		
        /* idiomas */
        var cont_idiomas = 0;
        $('.box_idiomas table tr').each(function(){
			
            if( $(this).find('input:radio')[0]){		
                if( !$(this).find('input:radio').is(':checked') ){
                    //alert('selecione');
					
                    $(this).find('.cell_idiomas').css({
                        'color':'#E51838'
                    });
                    cont_idiomas = 1;
					
	
                } else{
                    $(this).find('.cell_idiomas').css({
                        'color':'#005199'
                    });
					
                //$(this).closest('form').find('#ddd').closest('li').find('.alerta_validacao').fadeOut();
                }
				
				
            }
			
        });
		
        if(cont_idiomas==1){
            $('.box_idiomas').find('.alerta_validacao').show();
            //alert('stop');
            status_valida=1;
        }
        else{
            //alert('go');
            $('.box_idiomas').find('.alerta_validacao').hide();
        }
        /* idiomas.end */
		
        /* experiencias */
        if( !$('.exp_cadastradas tr')[0]){
            $('.box_ultimo_emprego h2 .alerta_validacao').show();
            status_valida=1;
        }
        else{
            $('.box_ultimo_emprego h2 .alerta_validacao').hide();
        }
        /* experiencias.end */
		
        /* formacao */
        if( !$('.formacao_cadastradas tr')[0]){
            $('.box_formacao h2 .alerta_validacao').show();
            status_valida=1;
        }
        else{
            $('.box_formacao h2 .alerta_validacao').hide();
        }
        /* formacao.end */
		
        /* formacao */
        if( !$('.box_selecao .itens_selecionado .scroll span')[0]){
            $('.box_info_profissional .campos_left .alerta_validacao').show();
            status_valida=1;
        }
        else{
            $('.box_info_profissional .campos_left .alerta_validacao').hide();
        }
        /* formacao.end */
		
		
	
		
        if(status_valida==1){
            //$('.alerta_erro').fadeIn();
            return false;
        }
	
    });
}

function somente_letras(e)
{
    var keycode =  e.keyCode ? e.keyCode : e.which;
    //alert('keycode');
    if(keycode == 33 || keycode == 34 || keycode == 35 || keycode == 36 || keycode == 37 || keycode == 38 || keycode == 39 || keycode == 40 || keycode == 41 || keycode == 42 || keycode == 43 || keycode == 44 || keycode == 45 || keycode == 46 || keycode == 47 || keycode == 48 || keycode == 49 || keycode == 50 || keycode == 51 || keycode == 52 ||keycode == 53 || keycode == 54 || keycode == 55 || keycode == 56 || keycode == 57 || keycode == 58 || keycode == 59 || keycode == 60 || keycode == 61 || keycode == 62 || keycode == 63 || keycode == 64 || keycode == 91 || keycode == 92 || keycode == 93 || keycode == 94 || keycode == 95 || keycode == 96 || keycode == 123 || keycode == 124 || keycode == 125 || keycode == 126 || keycode == 127 || keycode == 128 || keycode == 130 || keycode == 131 || keycode == 132 || keycode == 133 || keycode == 134 || keycode == 135 || keycode == 136 || keycode == 137 || keycode == 138 || keycode == 139 || keycode == 140 || keycode == 142 || keycode == 145 || keycode == 146 || keycode == 147 || keycode == 148 || keycode == 149 || keycode == 150 || keycode == 151 || keycode == 152 || keycode == 153 || keycode == 154 || keycode == 155 || keycode == 156 ){ // backspace
        return false;
    }
}



function somente_numeros(e)
{
    var keycode =  e.keyCode ? e.keyCode : e.which;
    //alert(keycode);
    if(keycode == 33 || keycode == 34 || keycode == 35 || keycode == 36 || keycode == 37 || keycode == 38 || keycode == 39 || keycode == 40 || keycode == 41 || keycode == 42 || keycode == 43 || keycode == 44 || keycode == 45 || keycode == 46 || keycode == 47 || keycode == 58 || keycode == 59 || keycode == 60 || keycode == 61 || keycode == 62 || keycode == 63 || keycode == 64 || keycode == 65 || keycode == 66 || keycode == 67 || keycode == 68 || keycode == 69 || keycode == 70 || keycode == 71 || keycode == 72 || keycode == 73 || keycode == 74 || keycode == 75 || keycode == 76 || keycode == 77 || keycode == 78 || keycode == 79 || keycode == 80 || keycode == 81 || keycode == 82 || keycode == 83 || keycode == 84 || keycode == 85 || keycode == 86 || keycode == 87 || keycode == 88 || keycode == 89 || keycode == 90 || keycode == 91 || keycode == 92 || keycode == 93 || keycode == 94 || keycode == 95 || keycode == 96 || keycode == 97 || keycode == 98 || keycode == 99 || keycode == 100 || keycode == 101 || keycode == 102 || keycode == 103 || keycode == 104 || keycode == 105 || keycode == 106 || keycode == 107 || keycode == 108 || keycode == 109 || keycode == 110 || keycode == 111 || keycode == 112 || keycode == 113 || keycode == 114 || keycode == 115 || keycode == 116 || keycode == 117 || keycode == 118 || keycode == 119 || keycode == 120 || keycode == 121 || keycode == 122 || keycode == 123 || keycode == 124 || keycode == 125 || keycode == 126 || keycode == 127 || keycode == 128 || keycode == 130 || keycode == 131 || keycode == 132 || keycode == 133 || keycode == 134 || keycode == 135 || keycode == 136 || keycode == 137 || keycode == 138 || keycode == 139 || keycode == 140 || keycode == 142 || keycode == 145 || keycode == 146 || keycode == 147 || keycode == 148 || keycode == 149 || keycode == 150 || keycode == 151 || keycode == 152 || keycode == 153 || keycode == 154 || keycode == 155 || keycode == 156 )
    { // backspace
        return false;
    }
}


function validar_envio_vaga(){
    $('.vagas .bt_enviar_red').click(function(){
        var status_valida=0;
	
        if( $(this).closest('form').find('#email').val() == "" ){
            $(this).closest('form').find('#email').prev().fadeIn();
            status_valida=1;

        }else
        if(!checkMail($(this).closest('form').find('#email').val())){
            $(this).closest('form').find('#email').prev().fadeIn();
            status_valida=1;
        }else{
            $(this).closest('form').find('#email').prev().fadeOut();
        }
	
        if(status_valida==1){
            //$('.alerta_erro').fadeIn();
            return false;
        }
    });
}


/************************* FUNÇÕES DO SISTEMA ****************************/

function get_cidades(){
    $('.estado').change(function(){
		
        $('.cidade-geral .select-fake2').html('Carregando Cidades');
        var estado = $(this).val();
        $.post($('base').attr('href')+'contato/ajax_cidades', {
            estado: estado
        },function(data){
			
            if(data)
				
                $('.cidade').html(data);
            $('.cidade-geral .select-fake2').html('------');
        }, 'html')
    })

    $('.estado2').change(function(){
			
        $('.select_cidade2 .select-fake2').html('Carregando Cidades');
        var estado = $(this).val();
        $.post('contato/ajax_cidades', {
            estado: estado
        },function(data){
	
            if(data)
	
                $('.cidade2').html(data);
            $('.select_cidade2 .select-fake2').html('------');
        }, 'html')
    })


    $('.estado3').change(function(){
        $('.select_cidade .select-fake2').html('Carregando Cidades');
        var estado = $(this).val();
        $.post('contato/ajax_cidades', {
            estado: estado
        },function(data){
            if(data)
                $('.cidade3').html(data);
            $('.select_cidade .select-fake2').html('------');
        }, 'html')
    })
}

function recupera_senha(val){
	
    $('.alerta_validacao').hide();
    $.post('trabalhe_conosco/recupera_senha',{
        email: val
    },function(data){
        if(data == 'ok'){
            $('.alerta_validacao').html('Sua senha foi enviada por email com sucesso!');
            $('.alerta_validacao').show();
        }else{
            $('.alerta_validacao').show()
        }
    },'html');
}

function load_estados(pais)
{
    var idSelectCidade = 'estado';
    
    if(pais == 33){
         
        $('#' + idSelectCidade).parent('div').find('.select-fake2').html("Carregando...");
        $('#' + idSelectCidade).parent('div').find('.select-fake').html("Carregando...");

        $("#" + idSelectCidade).load("rede_autorizada/ajax_estados/" + pais, '', function() {
            $('#' + idSelectCidade).parent('div').find('.select-fake').html("Selecione um Estado");
            $('#' + idSelectCidade).parent('li').find('.select-fake2').html("Selecione um Estado");
            $('#' + idSelectCidade).parent('div').find('.select-fake2').html("Selecione um Estado");
            $('#' + idSelectCidade).closest('li').removeClass('desativado');
        });
        
    }else{
        

        $('#' + idSelectCidade).parent('div').find('.select-fake').html("");
        $('#' + idSelectCidade).parent('div').find('.select-fake2').html("");
        $('#estado').closest('li').addClass('desativado');
    }
}

function load_cidades(estado,campo)
{
    var idSelectCidade = campo;
    
         
        $('#' + idSelectCidade).parent('div').find('.select-fake2').html("Carregando...");
        $('#' + idSelectCidade).parent('div').find('.select-fake').html("Carregando...");

        $("#" + idSelectCidade).load("cadastro/ajax_estados/" + estado, '', function() {
            $('#' + idSelectCidade).parent('div').find('.select-fake').html("Selecione uma cidade");
            $('#' + idSelectCidade).parent('li').find('.select-fake2').html("Selecione uma cidade");
            $('#' + idSelectCidade).parent('div').find('.select-fake2').html("Selecione uma cidade");
        });
       
}

function send_busca(){
    
    alert($('#ecotread').is(':checked'));
    
    if(!$('#ecotread').is(':checked')){
        $('#ecotread').attr('value',1);
    }else{
        $('#ecotread').attr('value','');
    }
    
    if(!$('#desenho').is(':checked')){
        $('#desenho').attr('value',1);
    }else{
        $('#desenho').attr('value','');
    }
    
    $('#filtro').submit();
}

function load_redes_by_pais(pais)
{
    $('#resp_results').html('');
    
	    if(pais != ""){

        $('#resp_results').html('Carregando Resultados...');
        
        /*if($('#chkRedeAutorizada').is(':checked')){
            categoria2 = $('#chkRedeAutorizada').val();
        }else{
            categoria2 = "";
        }

        if($('#chkReformadoresAgribusiness').is(':checked')){
            categoria = $('#chkReformadoresAgribusiness').val();
        }else{
            categoria = "";
        }*/

        vet_dados = "pais="+pais+"&estado=&chkRedeAutorizada="+$('#chkRedeAutorizada').is(':checked')+"&chkReformadoresAgribusiness="+$('#chkReformadoresAgribusiness').is(':checked');

        base_url  = $('base').attr('href')+"rede_autorizada/ajax_redes_by_pais";
        $.ajax({
            type: "POST",
            url: base_url,
            data: vet_dados,
            success: function(msg) {

                $('#resp_results').html(msg);

            }
        });
    }
}

function load_redes_by_estado(estado)
{
    $('#resp_results').html('Carregando Resultados...');
    
    /*if($('#chkRedeAutorizada').is(':checked')){
        categoria2 = $('#chkRedeAutorizada').val();
    }else{
        categoria2 = "";
    }
    
    if($('#chkReformadoresAgribusiness').is(':checked')){
        categoria = $('#chkReformadoresAgribusiness').val();
    }else{
        categoria = "";
    }*/
    
    vet_dados = "pais=33&estado="+estado+"&chkRedeAutorizada="+$('#chkRedeAutorizada').is(':checked')+"&chkReformadoresAgribusiness="+$('#chkReformadoresAgribusiness').is(':checked');
	   
    base_url  = $('base').attr('href')+"rede_autorizada/ajax_redes_by_pais";
    $.ajax({
        type: "POST",
        url: base_url,
        data: vet_dados,
        success: function(msg) {

            $('#resp_results').html(msg);

        }
    });
}

function load_mapa(rede)
{
    $('#map').html('Carregando Mapa...');
    
    vet_dados = "rede="+rede;
	   
    base_url  = $('base').attr('href')+"rede_autorizada/ajax_mapa";
    $.ajax({
        type: "POST",
        url: base_url,
        data: vet_dados,
        success: function(msg) {

            $('#map').html(msg);

        }
    });
}

function load_categorias(campo,campo2)
{
    var estado = $('#estado').val();
    
    var pais = $('#pais').val();
    var RedeAutorizada = false;
    var ReformadoresAgribusiness = false;
    setTimeout(function()
    {
    if($('#chkRedeAutorizada').is(':checked')){
        RedeAutorizada = true;
    }    
    
    if($('#chkReformadoresAgribusiness').is(':checked')){
        ReformadoresAgribusiness = true;
    }
    
    vet_dados = "pais="+pais+"&estado="+estado+"&chkRedeAutorizada="+RedeAutorizada+"&chkReformadoresAgribusiness="+ReformadoresAgribusiness;
    
    //alert(vet_dados);
    
    $('#resp_results').html('Carregando Resultados...');
    
    base_url  = $('base').attr('href')+"rede_autorizada/ajax_redes_by_pais";
    $.ajax({
        type: "POST",
        url: base_url,
        data: vet_dados,
        success: function(msg) {

            $('#resp_results').html(msg);

        }
    });
    },500);
}

/****************************** Validação do formulário de FISPQ *********************************/ 

function validar_fispq(){

    $('#enviar_fispq').click(function(){
							   
        var status_valida=0;
	
        if( $(this).closest('form').find('#nome').val() == "" ){
            $(this).closest('form').find('#nome').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#nome').closest('li').find('.alerta_validacao').fadeOut();
        }
	
        if( $(this).closest('form').find('#email').val() == "" ){
            $(this).closest('form').find('#email').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else
        if(!checkMail($(this).closest('form').find('#email').val())){
            $(this).closest('form').find('#email').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;
        }else{
            $(this).closest('form').find('#email').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#empresa').val() == "" ){
            $(this).closest('form').find('#empresa').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#empresa').closest('li').find('.alerta_validacao').fadeOut();
        }
	
        if( $(this).closest('form').find('#endereco').val() == "" ){
            $(this).closest('form').find('#endereco').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#endereco').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#cnpj').val() == "" ){
            $(this).closest('form').find('#cnpj').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#cnpj').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#cargo').val() == "" ){
            $(this).closest('form').find('#cargo').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#cargo').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#produto').val() == "" ){
            $(this).closest('form').find('#produto').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#produto').closest('li').find('.alerta_validacao').fadeOut();
        }
	
	
	
        if(status_valida==1){
            //$('.alerta_erro').fadeIn();
            return false;
        }
    });
};






function cadastrar(){

    $('#cadastrar').click(function(){
							   
        var status_valida=0;
	
        if( $(this).closest('form').find('#nome').val() == "" ){
            $(this).closest('form').find('#nome').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#nome').closest('li').find('.alerta_validacao').fadeOut();
        }
	
        if( $(this).closest('form').find('#email').val() == "" ){
            $(this).closest('form').find('#email').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else
        if(!checkMail($(this).closest('form').find('#email').val())){
            $(this).closest('form').find('#email').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;
        }else{
            $(this).closest('form').find('#email').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        /*if( $(this).closest('form').find('#empresa').val() == "" ){
            $(this).closest('form').find('#empresa').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        } else{
            $(this).closest('form').find('#empresa').closest('li').find('.alerta_validacao').fadeOut();
        }
	
        if( $(this).closest('form').find('#enderecoComercial').val() == "" ){
            $(this).closest('form').find('#enderecoComercial').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#enderecoComercial').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#numeroComercial').val() == "" ){
            $(this).closest('form').find('#numeroComercial').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#numeroComercial').closest('li').find('.alerta_validacao').fadeOut();
        }
        
        if( $(this).closest('form').find('#estadoComercial').val() == "" ){
            $(this).closest('form').find('#estadoComercial').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#estadoComercial').closest('li').find('.alerta_validacao').fadeOut();
        }*/
        
        if( $(this).closest('form').find('#perfil').val() == "" ){
            $(this).closest('form').find('#perfil').closest('li').find('.alerta_validacao').fadeIn();
            status_valida=1;

        }else{
            $(this).closest('form').find('#perfil').closest('li').find('.alerta_validacao').fadeOut();
        }
	
	
	
        if(status_valida==1){
            //$('.alerta_erro').fadeIn();
            return false;
        }
    });
};
