// JavaScript Document
$(window).load(function() {
	$('.nivo-caption').hide();
	if (document.getElementById('slider'))
	{
		$('#slider').nivoSlider({
			effect:'random',
			animSpeed:500,
			pauseTime:5000,
			directionNav:true, //Next & Prev
			directionNavHide:true, //Only show on hover
			controlNav:false, //1,2,3...
			keyboardNav:true, //Use left & right arrows
			pauseOnHover:false, //Stop animation while hovering
			manualAdvance:false, //Force manual transitions
			captionOpacity:0.8 //Universal caption opacity
		});
		
		$('#slider').hover(
			function () {
				$('.nivo-caption').slideDown("slow");
			}, 
			function () {
				$('.nivo-caption').slideUp("slow");
			}
		);
	}
	
	// Animação da Home
	var homeProjects = {
		init: function() {
			var project = $('#homeProjects > ul > li');
				
			project.hover(
				function () {
					$(this).children('.homeProjectsHover').removeClass('disabled'); 
				}, 
				function () { 
					$(this).children('.homeProjectsHover').addClass('disabled');
				}
			);
			
		}
	};
	homeProjects.init();
	
	var homeProjectsAnim = {
		init: function() {
			var project = $('#homeProjects > ul > li');

			
			project.children('.homeProjectsHover').css({left: '0px'})
			project.children().children('.homeProjectsHoverBg').fadeTo(1, 0.0)
			project.children().children('.homeProjectHoverTitle').css({left: '-225px'})
				
			project.hover(
				function () {
					$(this).css({'background-color': '#101010'});
					$(this).children().children('.homeProjectHoverTitle').css({left: '-225px'});
					$(this).children().children('.homeProjectsHoverBg').stop().fadeTo(400, 0.90);
					$(this).children().children('.homeProjectHoverTitle').stop().animate({left: '0px'} , { queue: false, duration: 750, easing: 'easeOutQuint' });
				}, 
				function () {
					$(this).css({'background-color': '#222222'});
					$(this).children().children('.homeProjectsHoverBg').stop().fadeTo(600 , 0.0);
					$(this).children().children('.homeProjectHoverTitle').stop().animate({left: '225px'} , { queue: false, duration: 800, easing: 'easeOutQuint' });
				}
			);
			
		}
	};
	homeProjectsAnim.init();
	
	/* Animação dos Projetos */
	var fancyHover = {
		init: function() {
			var project = $('#projectsList > li');
				
			project.hover(
				function () {
					$(this).children('.projectsHover').removeClass('disabled'); 
				}, 
				function () { 
					$(this).children('.projectsHover').addClass('disabled');
				}
			);
			
		}
	};
	fancyHover.init();
	
	var hoverAnim = {
		init: function() {
			var project = $('#projectsList > li');			
			project.children('.projectsHover').css({left: '0px'})
			project.children().children('.projectsHoverBg').fadeTo(1, 0.0)
			project.children().children('.projectHoverTitle').css({left: '-225px'})
				
			project.hover(
				function () {
					$(this).children().children('.projectHoverTitle').css({left: '-225px'});
					$(this).children().children('.projectsHoverBg').stop().fadeTo(400, 0.90);
					$(this).children().children('.projectHoverTitle').stop().animate({left: '0px'} , { queue: false, duration: 750, easing: 'easeOutQuint' });
				}, 
				function () {
					$(this).children().children('.projectsHoverBg').stop().fadeTo(600 , 0.0);
					$(this).children().children('.projectHoverTitle').stop().animate({left: '225px'} , { queue: false, duration: 800, easing: 'easeOutQuint' });
				}
			);
			
		}
	};
	hoverAnim.init();
	
	/* Animação imagens Blog Home */
	var newsImageHover = {
		init: function() {
			var project = $('#newsImage > li');
				
			project.hover(
				function () {
					$(this).children('.newsHover').removeClass('disabled'); 
				}, 
				function () { 
					$(this).children('.newsHover').addClass('disabled');
				}
			);
			
		}
	};
	newsImageHover.init();
	
	var newsImageAnim = {
		init: function() {
			var project = $('#newsImage > li ');			
			project.children('.newsHover').css({left: '0px'})
			project.children().children('.newsHoverBg').fadeTo(1, 0.0)
		
			project.hover(
				function () {
					$(this).children().children('.newsHoverBg').stop().fadeTo(400, 0.90);
					$(this).children().children('p > a').css('color','#F0530F');
				}, 
				function () {
					$(this).children().children('.newsHoverBg').stop().fadeTo(600 , 0.0);
					$(this).children().children('p > a').css('color','#FFFFFF');
				}
			);
			
		}
	};
	newsImageAnim.init();
	
});

$(document).ready(function() {
	if (document.getElementById('firstClient'))
	{
		$('#secondClient').html($('#firstClient').html());
		$('#thirdClient').html($('#firstClient').html());
		$('#firstClient').cycle({
			random: 1,
			fx: 'fade',
			speed: 1500,
			timeout:3000
		});
		$('#secondClient').cycle({
			random: 1,
			fx: 'fade',
			speed: 1500,
			timeout:3500
		});
		$('#thirdClient').cycle({
			random: 1,
			fx: 'fade',
			speed: 1500,
			timeout:4000
		});
	}
	$("#fieldName, #fieldEmail, #fieldMessage, #sfSearch").defaultvalue("nome", "e-mail", "mensagem", "busca");
});
