/************************************************************************************************
*
*	DIV switcher
* shows only one of all DIVs with css-class classname at a time
*
*************************************************************************************************/
function _dswSetDivVisibility(id, visible)
{
	if (this.divs[id] && (id != '')) {
		var vis = (visible) ? 'visible' : 'hidden';
		document.getElementById(id).style.visibility = vis;
		this.divs[id].visible = visible;
	}
}

function _dswShowDiv(id)
{
	for (var cid in this.divs) {
		if (cid != id)
			this.setDivVisibility(cid, false);
	}
	this.setDivVisibility(id, true);
}

function _dswHideDiv(id) 
{
	this.setDivVisibility(id, false);
	if (this.alwaysvisible != String(id))
	{
		this.showDiv(this.alwaysvisible);
	}
}

function _dswAlwaysShow(id)
{
	this.alwaysvisible = String(id);
	this.reset();
}

function _dswReset()
{
	this.showDiv(this.alwaysvisible);
}

function _dswToggleDiv(id)
{
	if (this.divs[id]) {
		if (this.divs[id].visible) {
			this.hideDiv(id);
		} else {
			this.showDiv(id);
		}
	}
}

function DivSwitcher(ids)
{
	if (!ids.pop)
		throw "DivSwitcher must be called with an array as parameter.";
	this.divs = new Object();
	this.alwaysvisible = '';
	var cid = '';
	for (var i=0; i < ids.length; i++) {
		cid = ids[i];
		this.divs[cid] = new Object();
		this.divs[cid].visible = false;
		this.divs[cid].id = cid;
	}
	this.showDiv = _dswShowDiv;
	this.hideDiv = _dswHideDiv;
	this.setDivVisibility = _dswSetDivVisibility;
	this.alwaysShow = _dswAlwaysShow;
	this.toggleDiv = _dswToggleDiv;
	this.reset = _dswReset;
	this.showDiv(ids[0]);
}
/***********************************************************************************************/
