/*
	Image rotator

	Routine to rotate image with specific "id" (i.e <img ... id="MySlideShow">)
	This function uses path of the original image specified in the HTML markup and simply replaces numeric index in the file name.
	Obviously, all files participating in this slideshow must reside in the same folder and be of the same size and type.

	Example:

		Slides  : /images/slide1.jpg, /images/slide2.jpg, /images/slide3.jpg

		HTML    : <img src="/images/slide1.jpg" id="MySlideShow">

		JS Code : RotateSpotlightImage("MySlideShow",3);	// must be called after image tag
*/
function RotateSpotlightImage( ImgID, maxCount ) {
	var rotatorValue = readCookie("counter");                               // Try to get last counter value from cookie
	    rotatorValue = (rotatorValue != null) ? parseInt(rotatorValue) : 1; // use value from cookie or default counter to 1
	if (rotatorValue > maxCount) rotatorValue = 1;                          // make sure we're not exceding maxCount
	createCookie("counter", rotatorValue+1, 365);

	if( document.images[ImgID] ) {                                          // replace image
		document.images[ImgID].src = document.images[ImgID].src.replace(/\d\.([pngifj]{3})/, rotatorValue + ".$1");
	}
}
