$(document).ready(function() {

	  $(".projectItem").css({ opacity: 0 });
	  $(".subTitleAnime").css({ opacity: 0 });
	  
	  
	     setTimeout(function(){
      $(loopImages);
  		},5000);
	  
	  	  
/*------START MAIN STAGGER ANIMATION--------*/
	  function loopImages() {
		$(".projectItem").each(function (i) {
		  var $item = $(this); 
		  setTimeout(function() { 
			$item.animate({"opacity": 1}, 1000);
		  }, 500*i);
		});
		myTimeOut = setTimeout(restoreImages, 5000); 
		
		
		$('.subTitleAnime').animate({opacity: 1}, 2000, function() {});



		
		
		
		
	  }
				
	  function restoreImages() {
		$(".projectItem").each(function (i) {
		  var $item = $(this); 
		  setTimeout(function() { 
			$item.animate({"opacity": 0}, 1000);
		  }, 500*i);
		});
	   myTimeOut2 = setTimeout(loopImages, 5000);
	  } 
/*------END MAIN STAGGER ANIMATION--------*/

/*------START HOVER STOP AND STARTS--------*/
    $('.projectItem').hover(
            function() { 
				$('.projectItem').pause();
 			 $('.projectItem').css({ opacity: 0 });
				
			 
				 $(this).css({ opacity: 1 });

				
				if(typeof myTimeOut !== "undefined"){
  					clearTimeout(myTimeOut);
				}else{}
				
				if(typeof myTimeOut2 !== "undefined"){
  					clearTimeout(myTimeOut2);
				}else{}

 
					 
					 
            },
            function() { 
			});

	 $('#slideHolder').hover(
            function() {},
            function() { 
					$(loopImages);
				 
					$('.projectItem').resume();
            });
/*------END HOVER STOP AND STARTS--------*/			

 });
