$(document).ready(function(){
	
	//SCRIPT PARA FADE OPACITY NO SOCIAL MENU
	$('.menuHome').hover(function(){
		$(this).animate({opacity:'0.5'},{queue:false,duration:200});
		}, function(){
		$(this).animate({opacity:'1'},{queue:false,duration:200});
	});

	//FADEOUT NO MENU DA HOME E FADEIN NO MENUTOP
	$("#bt_portfolio_home").click(function(){
		$("#home").animate({opacity:'0',top:'300px'},500,function(){
			$("#menu_top").fadeIn().animate({right:'90px'},{queue:false,duration:500});
			$("#bt_portfolio").addClass("bt_cvonline_selected");
			$("#jobs").fadeIn().animate({top:'190px'},{queue:false,duration:500});
			//$( '#jobs_ul li:first' ).fadeIn().animate({left:'0'},{queue:false,duration:500});
		});
	});
	
	//FADEOUT NO MENUTOP E NO JOB E FADEIN NA HOME
	$("#bt_fechar_menutop").click(function(){
		$("#menu_top").fadeOut().animate({right:'60px'},300,function(){
			$("#jobs").fadeOut().animate({top:'210px'},{queue:false,duration:500});
			$("#home").animate({opacity:'1',top:'260px'},{queue:false,duration:1000});
		});
	});

	//SCRIPT PARA FADE OPACITY NO SOCIAL MENU
	$('.si_action').hover(function(){
		$(this).animate({opacity:'0.3'},{queue:false,duration:200});
	}, function(){
		$(this).animate({opacity:'1'},{queue:false,duration:200});
	});

	//FADEOUT BOTAO CTTO E FADEIN NO FORM DE CTTO
	$("#bt_ctto_sim").click(function(){
		$(this).animate({opacity:'0', right:'-30px', display:'none'},500,function(){
			//$(this).hide();
			$("#div_form_ctto").fadeIn().animate({right:'0'},{queue:false,duration:500});
			//$("#div_form_ctto").animate({opacity:'1', right:'-30px', display:''},{queue:false,duration:500});
		});
	});
	
	//FECHAR FORM CTTO
	$("#bt_fechar_ctto").click(function(){
		$("#div_form_ctto").fadeOut().animate({right:'-30px'},300,function(){
			$("#bt_ctto_sim").animate({opacity:'1', right:'0px', display:''},{queue:false,duration:500});
		});
	});

	//SCRIPT DE BOTÕES DE NAVEGAÇÃO
	$("#nav_left").hover(function(){
		$(this).animate({opacity:'0.5', left:'-10px'},{queue:false,duration:500});
	}, function(){
		$(this).animate({opacity:'1', left:'0px'},{queue:false,duration:500});
	});

	$("#nav_right").hover(function(){
		$(this).animate({opacity:'0.5', right:'-10px'},{queue:false,duration:500});
	}, function(){
		$(this).animate({opacity:'1', right:'0px'},{queue:false,duration:500});
	});

	//SCRIPT BOTOES THUMB JOBS
	$(".thumb_job").hover(function(){
		$(this).find('img').animate({opacity:'0.5'},{queue:false,duration:200});
		}, function(){
		$(this).find('img').animate({opacity:'1'},{queue:false,duration:200});
	});
	
	//SCRIPT CONFIG FANCYBOX
	$("a[rel=gallery]").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titlePosition'		: 'over',
		'overlayColor'		: '#000'
	});
	
	$(".iframe").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'overlayColor'	: '#000',
		'width'			: '75%',
		'height'		: '75%',
	});
	
	//SCRIPT NAVEGACAO JOBS
	$('#jobs_content').cycle({ 
	    fx:     'fade', 
		speed:  'slow', 
		timeout: 0,
		next:   '#nav_right', 
	    prev:   '#nav_left' ,
	});
	
	//SCRIPT ENVIO CTTO
	$("#errorConsole").hide();
	
	$("form#formContato").submit(function() {

		$.post('envia_ctto.php',{campo_nome: $('#txt_nome').val(), campo_email: $('#txt_email').val(),  campo_mnsg: $('#txt_mensagem').val()},
			function(data){
				if (data.sucesso)
				{
					$('#errorConsole').html(data.message).fadeIn().delay(3000).fadeOut('slow');;
					$("#div_form_ctto").delay(3000).fadeOut().animate({right:'-30px'},300,function(){
						$("#bt_ctto_sim").animate({opacity:'1', right:'0px', display:''},{queue:false,duration:500});
					});
				}
				else
				{
					$('#errorConsole').html(data.message).fadeIn('slow');
					$(data.campo).focus();
					$('#errorConsole').delay(3000).fadeOut('slow');
				}
		}, 'json');

	return false;
	});

});
