/* 
Coder: VC
Date: June 2009
Notes: JS for casestudy. 
Requires: JQuery
 */
var total_casestudy_items = 0;
jQuery(document).ready(function() {

	$('.primary-content .casestudy_listing').css('backgroundImage','none');// don't include dotted line below each row of 3 if jas has kicked in
	//Add carousel if more than 3
	total_casestudy_items = jQuery('#casestudy_listing li').length;
	if(total_casestudy_items > 3){
		jQuery('<div id="casestudy-scroller"><a href="#" class="prev">Prev</a><a href="#" class="next">Next</a><p class="info">1-3 of '+total_casestudy_items+'</p></div>').
		insertBefore('#casestudy_listing');
		jQuery('#casestudy_listing').wrap('<div class="carousel_wrapper"></div>');

		jQuery(".carousel_wrapper").jCarouselLite({
			btnNext: "#casestudy-scroller .next",
			btnPrev: "#casestudy-scroller .prev",
			vertical: false,
			scroll: 3,
			//scroll: 1,
			//circular: false,
			visible: 3,
			afterEnd: function(a) {
				var firstind = parseInt(jQuery(a).attr('class').split('_')[1]);
				var lastind = firstind + 2;
				if(lastind > total_casestudy_items){
					lastind = lastind - total_casestudy_items;
				};
				jQuery('#casestudy-scroller .info').text(firstind + '-' + lastind + ' of ' + total_casestudy_items);
			}
		});
	};
	
	//Add onclick so each profile can be clicked
	/* jQuery('#casestudy_listing li').css('cursor', 'pointer');
	jQuery('#casestudy_listing li').click(function(){
		var newlocation = jQuery(this).find('a:first').attr('href');
		document.location = newlocation;
	}); */
	

});