
function ChangingPanels(var_name) {
	this.name = var_name;
}
ChangingPanels.prototype.name = "";
ChangingPanels.prototype.panels = Array();
ChangingPanels.prototype.links = Array();
ChangingPanels.prototype.addPanel = function(id, link_id) {
	this.panels.push(id);
	this.links.push(link_id);
	document.getElementById(id).style.display = "none";
	document.getElementById(link_id).onclick = this.togglePanel;
	document.getElementById(link_id).var_name = this.name;
	document.getElementById(link_id).panel = id;
}
ChangingPanels.prototype.displayPanel = function(id) {
	// Hide any visible panels.
	for(var i=0; i < this.panels.length; i++)
		document.getElementById(this.panels[i]).style.display = "none";
	// Show the one we want.
	document.getElementById(id).style.display = "block";
}
ChangingPanels.prototype.togglePanel = function() {
	var panels = window[this.var_name];
	panels.displayPanel(this.panel);
}
var panels = new ChangingPanels("panels");
panels.addPanel("p1","p1-link");
panels.addPanel("p2","p2-link");
panels.addPanel("p1","p21-link");
panels.addPanel("p2","p22-link");
panels.displayPanel("p1");
