$(document).ready(function(){
		
		$(".ul-projects li a").hover(
      	function () {
      		var image = $(this).find('img').attr('src');
      		$(this).css('background-image','url('+image+')');
      	}, 
      	function () {
      		$(this).css('background-image','none');
      	}
    	);
    	
    	$('.div-project-container').serialScroll({
			items:'li',
			prev:'.div-project a.prev',
			next:'.div-project a.next',
			offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
			start:0, //as we are centering it, start at the 2nd
			duration:300,
			force:true,
			stop:true,
			lock:false,
			cycle:false, //don't pull back once you reach the end
			jump: false //click on the images to scroll to them
		});

		$('.ul-project li a').live('click',function() {
			
			imageLoader($(this).attr('href'));
			return false;
		});
		
		$('.ul-projects a').click(function() {
			var p = {};
			p['project_id']=$(this).attr('href');
			
			$('.ul-project').load('/index.php/portfolio/load_project/',p,function() {});
			
			return false;
		});
		
  
	}); 
	
	function imageLoader (src) {
		var img = new Image();
		$(img).load(function() {
			$(this).hide();
			$('.div-image').removeClass('loading').html(this);
			$(this).fadeIn();
		}).error(function() {
			alert('error');
		}).attr('src',src);
	}

