/*
Toggle Group Object
Version		: 1.0
Created		: 01/04/08
Created By	: Martin Webb
Modified	: 01/04/08

Class to create a group of toggled display items.

*/

// =====================================================
// CONSTRUCTOR
ToggleGroup = function(sRootID, iCount, bSingle){
	this.rootID = sRootID;
	this.count = iCount;
	this.single = bSingle;
	this.aItems = new Array();
	this.init();
};

ToggleGroup.prototype.init = function(){
	var oItem = null;
	
	for(var i=1; i<=this.count; i++){
		oItem = this.getItem(i);
		if(oItem){
			this.aItems.push(oItem);
		}
	}
	this.hideAll();
};
// =====================================================
// seters for optional parametrers

// =====================================================

// call to toggle an element
ToggleGroup.prototype.toggle = function(iPosition){
	var oItem = this.getItem(iPosition);
	if(this.single){
		for(var i=0; i<this.aItems.length; i++){
			if(this.aItems[i] != oItem){
				this.aItems[i].style.display = "none";
			}else{
				oItem.style.display = (oItem.style.display) ? "" : "none"; // switch
			}
		}
	}else{
		oItem.style.display = (oItem.style.display) ? "" : "none"; // switch
	}
};

// hide all elements
ToggleGroup.prototype.hideAll = function(iPosition){
	for(var i=0; i<this.aItems.length; i++){
		this.aItems[i].style.display = "none";
	}
};

// get an item
ToggleGroup.prototype.getItem = function(iPosition){
	return document.getElementById(this.rootID + "" + iPosition);
};