// ----------
//
//	sponsorLogoRotate()
//
//	Tim Snoots (http://snoots-tech.com), 2008
//
//	Description:
//	Shifts an element's CSS background-position X value to create an
//	image rotation effect with no preloading.
//	
//	Usage:
//	Create a div or span with an id then set the following CSS to prep:
//	
//		display: block;
//		width: 150px;
//		overflow: hidden;
//		padding: 0 0 150px 0;
//		background: url(SponsorRotate.png) 0 0 no-repeat;
//
// ----------

function sponsorLogoRotate() {

	var elemID = "sponsor-rotate";
	var numFrames = 8;
	var frameWidth = 150;
	var intervalSeconds = 4;
	var xPos = 0;

	// Compatibility checks
	if (!document.getElementById) return false;
	if (!document.getElementById(elemID)) return false;
	
	// Nested function to shift CSS background image
	function timedChange() {
		var elem = document.getElementById(elemID);
	
		if (xPos < (frameWidth * (numFrames - 1))) {
			xPos = xPos + frameWidth;
		} else {
			xPos = 0;
		}
		elem.style.backgroundPosition = "-"+xPos+"px 0";
	}
	
	// Repeat at interval
	setInterval(timedChange, intervalSeconds * 1000);
	
}

// Add function to Window.OnLoad stack
addLoadEvent(sponsorLogoRotate);
