// THIS SCRIPT HANDLES LAYER SWITCHING FOR THE MEMBERS AND CREATIVE COMMUNICATIONS SECTIONS.
// THIS DOES NOT NEED TO BE MODIFIED WHEN MAKING UPDATES TO THOSE SECTIONS OF THE SITE.


function DivGroup(aryDivNames, strDefaultName)
{	this.divs = new Array();
		
	if(aryDivNames && aryDivNames.length > 0)
	{	for(a = 0; a < aryDivNames.length; a++)
		{	this.divs[this.divs.length] = new Div(aryDivNames[a]);
		}
	}
	
	this.defaultDiv = this.getDiv(strDefaultName);
	
	return this;
}

DivGroup.prototype.getDefault = function()
{	return this.defaultDiv;
}

DivGroup.prototype.setDefault = function(strDivId)
{	this.defaultDiv = this.getDiv(strDivId);
	if(this.defaultDiv != null) this.defaultDiv.setVisible(true);
}

DivGroup.prototype.addDiv = function(div)
{	this.divs[this.divs.length] = div;
}

DivGroup.prototype.getDiv = function(strDivId)
{	if(strDivId && strDivId != null)
	{	for(a = 0; a < this.divs.length; a++)
		{	if(this.divs[a].getId() == strDivId)
				return this.divs[a];			
		}
	}
	
	return null;
}

DivGroup.prototype.countDivs = function()
{	return this.divs.length;
}

DivGroup.prototype.containsDiv = function(strDivId)
{	if(strDivId && strDivId != null)
	{	for(a = 0; a < this.divs.length; a++)
		{	if(this.divs[a].getId() == strDivId)
				return true;
		}
	}
	
	return false;
}

DivGroup.prototype.show = function(divName)
{	if(this.containsDiv(divName))
	{	this.hideAll();
		if(this.defaultDiv != null) this.defaultDiv.setVisible(false);
		this.getDiv(divName).setVisible(true);
	}
}

DivGroup.prototype.hide = function(divName)
{	if(this.containsDiv(divName))
	{	this.getDiv(divName).setVisible(false);
	}
}

DivGroup.prototype.hideAll = function()
{	for(a = 0; a < this.divs.length; a++)
	{	div = this.divs[a];
		if(this.defaultDiv != null && div.getId() == this.defaultDiv.getId())
			div.setVisible(true);
		else div.setVisible(false);
	}
}

DivGroup.prototype.toString = function()
{	return "[object DivGroup]";
}
