$(document).ready(function() {
	if($.fn.cycle!=undefined) {
		$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) {
			$(pager).find('p').removeClass('control-btn-active')
		  	.filter('p:eq('+currSlideIndex+')').addClass('control-btn-active');
		  $(pager).find('p img').unbind();
		  $(pager).find('p img').attr('src', $(pager).find('p img:first').attr('norollover'));
		  $(pager).find('p.control-btn img').each(function(index) {
		  	if($(this).attr('norollover')==undefined) $(this).attr('norollover', $(this).attr('src'));
		  	if($(this).parent().hasClass('control-btn-active')) {
		  		$(this).attr('src', $(this).attr('rollover'));
		  		return;
		  	}
		  	$(this).hover(
		  		function () {
						$(this).attr('src', $(this).attr('rollover'));
					},
					function () {
						$(this).attr('src', $(this).attr('norollover'));
					}
				);
			});
		};
		var nCount = 0;
		$('#cookin').cycle({
			fx: 'scrollHorz',
			speed:500,
			timeout: 10000,
		  pager:  '.csr-control',
		  pagerAnchorBuilder: function(idx, slide) {
		  	nCount++;
		  	if(nCount>6) {
		  		var nWidthBtn = $('.control-btn').width();
					nWidthBtn += parseInt($('.control-btn').css('margin-left'));
					nWidthBtn += parseInt($('.control-btn').css('margin-right'));
			  	var nTmp = $('#cooking-control').width();
			  	$('#cooking-control').width(nTmp+nWidthBtn);
			  	nTmp = parseInt($('#cooking-control').css('padding-left'))-nWidthBtn;
			  	$('#cooking-control').css('padding-left', nTmp+'px');
			  }
		  	return '<p class="control-btn"><img rollover="i/csr-mouseover.gif" src="i/csr-mouseout.gif" /></p>';
		  },
		  after: function(imgprev, imgafter, opts) {
		  	cycleStat(imgafter);
		  }
		});
	}
});
function cycleStat(myImage)
{
	var szTmp = document.location.href;
	szTmp = szTmp.substr(0, szTmp.lastIndexOf('/'));
	szTmp = myImage.src.replace(szTmp, '');
	pageTracker._trackPageview('/'+CLASSID+' '+szTmp);
}