/*
	Image rotator
	See img_rotator.txt for help and examples.

*/
function RotateSpotlightImage1( ImgID, AnchorID, arr ) {
	var rotatorValue = readCookie("counter");                               // Try to get last counter value from cookie
	    rotatorValue = (rotatorValue != null) ? parseInt(rotatorValue) : 0; // use value from cookie or default counter to 0 (first element in my array)

	if ( rotatorValue > arr.length-1 ) rotatorValue = 0;                    // make sure we're not exceding max. number of elements in this array. Reset counter if this is the case.

	var obj_myAnchor = document.getElementById(AnchorID);					// document.links[AnchorID] doesnt work in IE

	if( document.images[ImgID] && obj_myAnchor ) {							// continue if all objects are found
		//alert(document.images[ImgID].useMap);
		//alert(arr[rotatorValue][0] + "\n" + arr[rotatorValue][1] );
		document.images[ImgID].src    = arr[rotatorValue][0];				// replace image
		if( arr[rotatorValue][1] != "" ) {
			if( arr[rotatorValue][1].substr(0,1) != "#") {
				arr[rotatorValue][1] = "#" + arr[rotatorValue][1];			// automatically prefix map name with "#", if missing.
			}
			document.images[ImgID].useMap = arr[rotatorValue][1];			// change image map
		}
		obj_myAnchor.href             = arr[rotatorValue][2];				// replace url
		//alert(document.images[ImgID].useMap);
	}

	createCookie("counter", rotatorValue+1, 365);							// save last counter value
}

function RotateSpotlightImage2( ImgID, AnchorID, arr ) {
	var rotatorValue = readCookie("counter");                               // Try to get last counter value from cookie
	    rotatorValue = (rotatorValue != null) ? parseInt(rotatorValue) : 0; // use value from cookie or default counter to 0 (first element in my array)

	if ( rotatorValue > arr.length-1 ) rotatorValue = 0;                    // make sure we're not exceding max. number of elements in this array. Reset counter if this is the case.

	var obj_myAnchor = document.getElementById(AnchorID);					// document.links[AnchorID] doesnt work in IE

	if( document.images[ImgID] && obj_myAnchor ) {							// continue if all objects are found
		document.images[ImgID].src    = arr[rotatorValue][0];				// replace image
		obj_myAnchor.href             = arr[rotatorValue][2];				// replace url
	}

	createCookie("counter", rotatorValue+1, 365);							// save last counter value
}



function RotateSpotlightImage_old() {
	// This function achives the same effect by replacing a digit in original image file name.
	// Discontinued because it does not change URLs
	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");
	}
}
