// Simple element display switcher 
// Nathan Pugh, J. Willard Marriott Library at The University of Utah - 2007-04-09
// Purpose:  A lightweight method of toggling visibility between two block-level html elements.

// ElementSwitcher(): 
// 	Purpose:	A .js class which keeps track of the html elements to be switched. 
//		Input:	elem_id_1 and elem_id_2 - String values containing the id of the elements to be switched.
function ElementSwitcher(elem_id_1, elem_id_2) 
{
	this.e1 = document.getElementById(elem_id_1); 
	this.e2 = document.getElementById(elem_id_2); 
	this.init(); 
}
//	ElementSwitcher_toggle():	Toggles the display mode for both of the elements.
function ElementSwitcher_toggle() 
{
	if( this.e1 && this.e2 )
	{
		this.e1.style.display = this.e1.style.display == 'block' ? 'none' : 'block'; 
		this.e2.style.display = this.e2.style.display == 'block' ? 'none' : 'block'; 
	}
}
// ElementSwitcher_init():	Sets the first element (the first argument in the ElementSwitcher constructer) 
//									to display 'block', and the second to display 'none'. 
function ElementSwitcher_init() 
{
	if( this.e1 && this.e2 ) 
	{
		this.e1.style.display = 'block'; 
		this.e2.style.display = 'none'; 
	}
}
// Assign the init and toggle functions to the ElementSwitcher object's prototype.
ElementSwitcher.prototype.init = ElementSwitcher_init; 
ElementSwitcher.prototype.toggle = ElementSwitcher_toggle; 
