// Animated CSS sprites - by Fat Pixel
// www.fatpixel.nl 

var counter = 1; // initialise the counter
var csspos = 1; // initialise the css class number
var timer = null; // initialise the timer variable

function swapImages(){
	if (csspos == 12) { csspos = 0; } // if we cycle 12 sprites, start at the beginning
	if ((window.startpos > 0)&&(counter == 1)){ csspos = window.startpos + 1; } // if the starting position is not the beginning of the sprites, change the css class number
	$("#rad"+window.radnum).attr("class", "pos"+csspos); // change the sprite
	counter++; 
	csspos++;
	if(counter > window.numcycle){ clearInterval(timer); } // if we've had enough animation, stop the timer.
}
