/*
Fancy Folio
Created: 15/10/2009
By: Catalin Pinte
Contact Info: pinte_catalin@yahoo.com
*/

var slideShow = function() {
   var $start,
       $stop;
   return {
	    $start : function(){  $start = setInterval("Slide_Show()", 4000 /* slide durration miliseconds */);  },  
	
	    $stop : function(){
		   clearInterval($start);
		}
   }
}();


slideShow.$start();	 // this starts slideshow		
var $timeout;
$("#recent_area a").click(function(){
		    clearTimeout($timeout);
			slideShow.$stop(); // stops slideshow because user selected a project
			$timeout = setTimeout(function(){ slideShow.$start(); }, 3000); // continue  slideshow after 5 seconds
			
			$this = $(this);
			$("#recent_area a").attr("style","text-decoration:none");
			$this.attr("style","text-decoration:underline");
			
			$("#recent_area li.active").removeClass("active").addClass('last-active');
				
            Change_Slide($this);
			return false;
			
	});


//this is slide_show function 
function Slide_Show(){
			var $active = $('#recent_area li.active');
			if ($active.length == 0) $active = $('#recent_area li:first');
			var $next =  $active.next("li").length ? $active.next("li").find("a")
			: $('#recent_area li:first').find("a");   
			$active.removeClass("active").addClass('last-active');
		    Change_Slide($next);
}

//this changes slide image
function Change_Slide($element){
			$element.parent().addClass('active');
	        $("#project img").animate({ opacity: 0}, 400).queue(function(){
			   	$("#recent_area a").attr("style","text-decoration:none");
				$element.attr("style","text-shadow: 1px 1px 5px  white; text-decoration:underline;");
				$(this).attr('src', $element.attr("href")).animate({ opacity: 1}, 800);;
				$(this).dequeue();
			})
}