$(document).ready(function(){
  
	var containerWidth = 120; //This is the width of the area where the accordion goes
	var initialItemCount = $("#pressitems ul").children().size(); //How many list items we have
	var itemCount = parseInt(initialItemCount-1); //How many list items minus the one which is already expanded
	var itemWidth = parseInt((containerWidth / itemCount)-1); //The determined width of each accordion fold
	
  	lastBlock = $(".initial"); //
  	lastBlockImg = $(".initial img");
    maxWidth = 500;
	minWidth = itemWidth;	
	
	$("#pressitems ul li").not(lastBlock).width(itemWidth);
	$("#pressitems ul li img").not(lastBlockImg).animate({opacity:"0.5"}, "slow");
    
    $("#pressitems ul li").click(	
		function(){			
			$(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:400 });
			$(lastBlockImg).animate({opacity:"0.5"}, "fast");
			$(lastBlock).removeClass("active");
			$(this).addClass("active");
			$(this).animate({width: maxWidth+"px"}, { queue:false, duration:400});
			$(this).children("img").animate({opacity:"1"}, "fast");
			currentBlock = this;				
			lastBlock = this;
			lastBlockImg = $(this).children("img");
			
			var pressTitle = $(this).children("h2").html();
			var pressBody = $(this).children("p").html();
			$("#pressdescription h2").html(pressTitle);
			$("#pressdescription p").html(pressBody);
	    }
	);

});