// DELAY PLUGIN

$.fn.delay = function(time, callback){
    // Empty function:
    jQuery.fx.step.delay = function(){};
    // Return meaningless animation, (will be added to queue)
    return this.animate({delay:1}, time, callback);
}



// ----------------------------------------------- INIT
$(document).ready(function() {
	
			
			
		$(".pf_thumbs").click ( function () {
			
				
				if (!$(".info_container").is(':animated')) { 
					
					id_clicked = ($(this).attr('id'));
					var my_number = id_clicked.substring(3,4);
					swapProjects(my_number);
				
				}
				
			
		});
		
		$('.info_container').css({ 'opacity' : 0 });
		$('.info_container').css("margin-left","50px");
		$('.info_container.active').css({ 'opacity' : 1 });
		$('.info_container.active').css("margin-left","0px");
		
	
});
		


function reset_thunder(project, num){
	
	
	switch(project){
		
		
	case "1":
		
		$("#thunder_"+project+" img").attr("src", "images/portfolio/thunder/th_bershka_shop_"+num+".jpg");
	
	break;
	
	
	}
}

function swapProjects (cual) {
	
				var info_layer = "#info_cont_"+cual;
				
				var thunder = "#thunder_"+cual;
				
				//var circle_btns = "#circle_btns_"+cual;
				
				
				
				$(".info_container.active").animate({
						 
						marginLeft: ['-=50', 'easeInOutSine'],
						opacity: ['0', 'easeOutExpo']
						
					  },1000 , function() {
							
							$(this).css("margin-left","50px");
							$(this).removeClass("active");
							
				  		});
				
				setTimeout (function () { 
				
					$(info_layer).animate({
						
						marginLeft: ['0', 'easeOutSine'],
						opacity: ['1', 'easeOutSine']
						
					  }, 1000 ,function () { $(this).addClass("active") });
				
					}, 500 );
					
					
				
				setTimeout (function () { 
				
					$(".project_thunder.active").animate({
							 
							opacity: ['0', 'easeOutSine']
							
						  },1300, function () { 
						  
						  	$(this).removeClass("active");
							
							//reset_thunder('1', '2');
							
							 });
					
					$(thunder).animate({
							 
							opacity: ['1', 'easeOutSine']
							
						  },1300, function () { $(this).addClass("active"); } );
					  
				}, 1000);
				
				//$(circle_btns_current).removeClass("invisible");
				//$(circle_btns).addClass("active");
				//alert(circle_btns_current);
				//$(circle_btns_current).css("display","none");
				//$(circle_btns).css("display","block");
				
				//
}


// ----------------------------------------------- INIT
$(document).ready(function() {
	
	
			$('.slideshow').cycle({
				
				fx:'fade',
				speed: 2000, 
				timeout: 6000, 
				easing: "easeInOutSine"
				
			});
			
			
			$("#btn_portfolio").mouseover( function () {
				
				if ($('#container_projects_thumbs').height() == 0) {
				
					$('#container_projects_thumbs').animate({
						
						height: ['80px', 'easeInOutSine']
						
					  }, 400 );
				 }	
			});
			
			$("#btn_portfolio").mouseout ( function () {
				
				
					$('#container_projects_thumbs').animate({
						
						height: ['0px', 'easeInOutSine']
						
					  }, 400 );
				
			
			
			});
			
			
		});
		

// Cuando ponemos el ratón por encima de las imagenes, hacemos fade.

function wedidit_over(e) {
	
	 // $(e).fadeOut(500);
	  
	$(function() {
		// OPACITY OF BUTTON SET TO 50%
		//$(e).css("opacity","0.5");
				
		// ON MOUSE OVER
		$(e).hover(function () {
												  
		// SET OPACITY TO 100%
		$(this).stop().animate({
		opacity: 0.0
		}, "slow");
		},
				
		// ON MOUSE OUT
		function () {
					
		// SET OPACITY BACK TO 50%
		$(this).stop().animate({
		opacity: 1.0
		}, "slow");
		});
		});
		
}
