jQuery(document).ready(function(){

	jQuery('#black_overlay').fadeTo(0.1,0.5);
	jQuery('#black_overlay').css('height', '2000px');

	
		jQuery("#searchImprensa").selectbox();
		
		/*
		jQuery('#cotacoesBolsa a').click(function(){
			jQuery('#cotacoesBolsa').css({
				background: '#111C22 url(/v2/wp-content/themes/hera/images/bg_bolsa.jpg) no-repeat 0 bottom', float:'left', height:'64px', width:'942px'
			});
		});
		*/


	jQuery("#phone").mask("(99) 9999-9999");
	jQuery("#celular").mask("(99) 9999-9999");
	jQuery("#data_nascimento").mask("99/99/9999");
	jQuery("#cpf").mask("999.999.999-99");
	jQuery("#cep").mask("99999-999");

	jQuery('#modal').hide();
	jQuery('#carregando').hide();

	jQuery("#carregando").ajaxStart(function(){
		jQuery('#feedback').fadeOut('fast');
		jQuery(this).show();		
		jQuery("#foot").hide();
	});
	
	jQuery("#carregando").ajaxStop(function(){
		jQuery(this).hide();
		jQuery('#foot').show();
	});

	jQuery('.abrirCadastro').click(function(){
		jQuery('#modal').fadeIn('slow');
		jQuery('#black_overlay').fadeIn();
		jQuery('html, body').animate({scrollTop: '100px'}, 500);
		return false;
	});
	

	jQuery('#close').click(function(){
		jQuery('#modal').fadeOut('slow');			
		jQuery('#black_overlay').fadeOut(300);
		return false;
	});
	

	jQuery('#cadastro').submit(function() {
		//Executa o AJAX
		jQuery(this).ajaxSubmit({
			success: resultado,
			type: 'post'
		});
		return false;
	});

})


function resultado(responseText, statusText) {
	if (responseText) {
		if (responseText=='sucessoConta') {
			jQuery('#feedback').html('<div id="sucesso" style="padding: 9px;"><h6 style="font-weight: bold; font-size: 14px;">Seu cadastro foi efetuado com sucesso.</h6><p>Entraremos em contato para continuarmos a abertura da sua conta.</p></div>');
			jQuery('#cadastro').resetForm();
			jQuery('#cadastro').fadeOut();
			jQuery('#feedback').css('width','400px');
			jQuery('#feedback').fadeIn('slow');
			pageTracker._trackPageview('/abra-sua-conta/enviado');
			
		} else if (responseText=='sucessoTrabalhe') {
			jQuery('#feedback').html('<div id="sucesso" style="padding: 9px;"><h6 style="font-weight: bold; font-size: 14px;">Obrigado! Seu curriculo foi efetuado com sucesso.</h6></div>');
			jQuery('#cadastro').resetForm();
			jQuery('#cadastro').fadeOut();
			jQuery('#feedback').css('width','400px');
			jQuery('#feedback').fadeIn('slow');
			pageTracker._trackPageview('/trabalhe-conosco/enviado');	
			
		}
		 else if (responseText=='sucessoHera') {
			jQuery('#feedback').html('<h6 style="font-weight: bold; font-size: 14px;">Obrigado! Seu cadastro foi realizado com sucesso.</h6>');
			jQuery('#cadastro').resetForm();
			jQuery('#cadastro').fadeOut();
			jQuery('#feedback').css('width','400px');
			jQuery('#feedback').fadeIn('slow');
			pageTracker._trackPageview('/educacional/cadastro-efetuado');			
		}
		else if (responseText=='sucessoAtendimento') {
			jQuery('#feedback').html('<h6 style="font-weight: bold; font-size: 14px;">Obrigado! Seu Contato será retornado em breve.</h6>');
			jQuery('#cadastro').resetForm();
			jQuery('#cadastro').fadeOut();
			jQuery('#feedback').css('width','400px');
			jQuery('#feedback').fadeIn('slow');
			pageTracker._trackPageview('/atendimento/enviado');
			
		}
		
		else {
			jQuery('#feedback').html(responseText);
			jQuery('#feedback').fadeIn();
		}
	} else {
		alert('Ocorreu um erro ao enviar Mensagem!');
	}
}
