
function tabbed_rotator(prefix, numElems)
{
	this.initialtab=[1, prefix+"focus1"];
	this.previoustab="";

	var arrayElems = prefix + "focus1";
	for(i=2;i<=numElems;i++)
		arrayElems += "," + prefix + "focus" + i;
	this.order = arrayElems.split(",");
	
	this.curpos = -1;
	var numElements = numElems;
	this.dorotate = 1;
	
	this.expandcontent = function(cid, aobject)
	{
		if (document.getElementById)
		{
			this.highlighttab(aobject);
			if (this.previoustab!="") document.getElementById(this.previoustab).style.display="none";
			document.getElementById(cid).style.display="block";
			this.previoustab=cid;
		}
				
		//set curpos to current cid
		this.curpos = 0;
		while (cid != this.order[this.curpos])
		{
			this.curpos++;
		}
	}
		
	this.changePosition = function(id,left,top,width,height)
	{
		if (left == "") left = 0;
		if (top == "") top = 0;

		document.getElementById(id).style.top = top + 'px';
		document.getElementById(id).style.left = left + 'px';
		document.getElementById(id).style.width = width + 'px';
		document.getElementById(id).style.height = height + 'px';
	}
	
	this.changeImage = function(id,image)
	{
		document.getElementById(id).style.backgroundImage = "url("+image+")";
	}
	
	this.highlighttab = function(aobject)
	{
		if (typeof this.tabobjlinks=="undefined")
			this.collectfocustabs();
		for (i=0; i<this.tabobjlinks.length; i++)
			this.tabobjlinks[i].className="";
		aobject.className="current";
	}
	
	this.collectfocustabs = function()
	{
		this.tabobj=document.getElementById(prefix+"focustabs");
		this.tabobjlinks=this.tabobj.getElementsByTagName("A");

	}
	
	this.rotate = function()
	{
		if (this.dorotate == 1)
		{
			this.curpos++;
			if (this.curpos >= numElements) this.curpos = 0;
	
			this.expandcontent(this.order[this.curpos], this.tabobjlinks[this.curpos]);			
		}
	}

	this.rotateright = function()
	{
		this.curpos++;
		if (this.curpos >= numElements) this.curpos = 0;
			
		this.expandcontent(this.order[this.curpos], this.tabobjlinks[this.curpos]);
	}


	this.rotateleft = function()
	{
		this.curpos--;
		if (this.curpos <= -1) this.curpos = numElements-1;
	
		this.expandcontent(this.order[this.curpos], this.tabobjlinks[this.curpos]);
	}

	this.toggle_rotate = function()
	{
		if (this.dorotate == 0) 
		{
			this.dorotate = 1;
			this.rotate();
		}
		else if	(this.dorotate == 1) this.dorotate = 0;
	}
	
	
	
	this.do_onload = function()
	{	
		this.collectfocustabs();
	}
}
