// JavaScript Document
jQuery.thmg = function(tns) {
			var tgt = $('#mycarousel > li');
			var numItems = tgt.size();	
			var curr = $.cookie('position') ? ($.cookie('position')-1) : 0;
			var total = tns;
			$("#caro > p:first").html($.cookie('showing') ? $.cookie('showing') : "Showing " + (curr+1) + " - " + (curr + 5) + " of " + total);
	
		$('.jcarousel-next').bind('click', function() {		
			//alert(curr);
			if (curr >= ((numItems-(numItems-total))-6)) {
				$('.jcarousel-next').disable;
				//alert(curr);
				if (curr+5 < total) {
					addFive();
				}
				return;	
			}
			addFive();
		});	
		
		$('.jcarousel-prev').bind('click', function() {
			//alert(curr);
			if (curr <= 0) {
				$('.jcarousel-prev').disable;
				//alert(curr);
				if (curr > 0) {
					subtractFive();
				}
				return;
			}
			subtractFive();
			//alert(curr);
		});
		

		function subtractFive() {
			curr -= 5; 
			$("#caro > p:first").html("Showing " + (curr+1) + " - " + (curr+5) + " of " + total);
			setMinusCookie();
		}
		function addFive() {
			curr += 5;
			$("#caro > p:first").html("Showing " + (curr+1) + " - " + (curr > ((numItems-(numItems-total))-6) ? total : (curr+5)) + " of "+ total);
			setAddCookie();
		}
		function setAddCookie() {  
			$.cookie('position', (curr+1), {path: '/screening-room/'});
			$.cookie('showing', ("Showing " + (curr+1) + " - " + (curr > ((numItems-(numItems-total))-6) ? total : (curr+5)) + " of " + total), {path: '/screening-room/'});
		}
		function setMinusCookie() {  
			$.cookie('position', (curr+1), {path: '/screening-room/'});
			$.cookie('showing', ("Showing " + (curr+1) + " - " + (curr+5) + " of " + total), {path: '/screening-room/'});
		}
};
