
function Rotator(obj_params)
{
	this.currentImage = 0;
	
	/**
	 * The expected format of the parameters object
	 */
	this.params = {
		"elementid" : "",
		"rotateOnClick" : false,
		"images" : []
	};
	
	for (var property in obj_params) {
		this.params[property] = obj_params[property];
	}
	
	//if the rotateOnClick=true then add an onclick event handler to the specified element
	if (obj_params && obj_params["rotateOnClick"] && obj_params["elementid"]) {
		var obj_this = this;
		
		$('#'+obj_params["elementid"]).click(function() { obj_this.rotateBackground(); });
	}
	
	this.rotateBackground = function() {
		//update the current image pointer
		if (++this.currentImage > this.params.images.length - 1) {
			this.currentImage = 0;
		}
		
		var newUrl = this.params.images[this.currentImage];
		newUrl = (newUrl == 'none' || newUrl === '') ? "none" : "url(" + newUrl + ")";
		
		$('#'+this.params.elementid).css("backgroundImage", newUrl);
	};
}

