var imgCount = -1, curInd = 0, time = 5000, timerCntr;

$(document).ready(function() {
	$("body").pngFix();
	var i = 0;
	
	while ($("div#bnnr img").index($("div#bnnr img")[i]) != -1) {
		imgCount = i;
		i++;
	};
	
	if (imgCount != -1) {
		$("div#bnnr img").eq(curInd).css("display", "block");
		timerCntr = setTimeout(changeImgDefault, time);
	};
});

function changeImg(move, cancelTimeout) {
	if (cancelTimeout) {
		window.clearTimeout(timerCntr);
	};
	
	var prevInd = curInd;
	
	if ((curInd + move) > imgCount) {
		curInd = 0;
	} else if ((curInd + move) < 0) {
		curInd = imgCount;
	} else {
		curInd = curInd + move;
	};
	
	$("div#bnnr img").eq(prevInd).fadeOut("fast");
	$("div#bnnr img").eq(curInd).fadeIn("slow");
	
	timerCntr = setTimeout(changeImgDefault, time);
	return true;
};

function changeImgDefault() {
	changeImg(1);
};
