//spinner class definition
//** class to create a spinner and add it to a specified element **
//** requires jQuery 1.2+
function spinner(imagesrc){
	this.identifier=Math.floor(Math.random()*101)
	this.spinnertext="&nbsp;Please wait&nbsp;";
	this.imagesrc=imagesrc;
	this.imageHTML="<img src='" + this.imagesrc + "' border=0>";
	this.container="<div id='_spinner'></div>";
	this.jqContainer=$(this.container).html(this.imageHTML + this.spinnertext);

	//override the default text and position as it pertains to the spinner
	this.setText=function(text, pos){
		if (pos == "before") {
			this.jqContainer=$(this.container).html(text + "&nbsp;" + this.imageHTML);
		}else{
			this.jqContainer=$(this.container).html(this.imageHTML +  "&nbsp;" +text);		
		}
	}
	
	//expects jQuery element
	// - cleanEle determines if the element spec should be cleared
	this.addToElement=function(ele, clearEle){ 
		if (clearEle){ele.empty()};
		this.jqContainer.attr("id", this.identifier);
		this.jqContainer.prependTo(ele);
	}
	
	//expects jQuery element
	this.remove=function(){
		$("#"+ this.identifier).remove();
	}
	
}