var nextImg = 1;
function crossfadeImage(str_divId, imgCount, imgName)
{
	nextImg = nextImg == imgCount ? 1 : nextImg+1;
	var nextName = imgName.replace(/%no%/, nextImg);
	var img = new Image();
	$(img).attr('src', nextName).load(function() {
		$('#'+str_divId).prepend("<div class='slide'><img src='"+nextName+"'></div>");
		$('#'+str_divId+' .slide:last').fadeOut(1000, function() {
			$(this).remove();
		});
	});
}

var rotateCount = 0;
var maxRotate = 3;
function rotateImages(direction)
{
	rotateCount = direction == "right" ? rotateCount+1 : rotateCount-1;
	rotateCount = rotateCount > maxRotate ? 0 : rotateCount;
	rotateCount = rotateCount < 0 ? maxRotate : rotateCount;
	
	$("#mainimages .scrollbox").animate({marginLeft: (-1067*rotateCount)+"px"}, 1000);
}
