/* ----------------------------------
Showone - a javascript library to show one of multiple components on a web page
at a time, with the facility to switch the visible component. 

Copyright (c) 2006 Electric Imagination

IMPORTANT!! Requires Prototype Library. http://www.prototypejs.org

Components are identified by ID. The item to be displayed by default is the item
in position 0 of the showone_objects array. If you want no item to be displayed 
at first then set showone_objects[0] = ""

Useage: 
1. Make sure you include this file. If you are using sparx then all you need to
do is include a line like this:
	$js_require = array('showone');
2. Define the components that are to be hidden / revealed like this:
	<script language="javascript" type="text/javascript">
	<!--
		showone_objects = ['history', 'screens', 'facilities'];
	//-->
	</script>
3. Make sure you identify the components correctly using id="history" (for example)
4. Finally, make links to switch between components. Just set the onclick attribute to:
	onclick="return showone_switchto('facility');"
Where 'facility' is substituted for whatever id="" you are showing by clickingt 
that link.


---------------------------------- */

Event.observe(window, 'load', showone_initialise);

function showone_initialise(){
	if(showone_objects.length){
		showone_switchto(showone_objects[0]);
		//bit of a hack to get the images to show in IE7...
		setTimeout("showone_switchto(showone_objects[0]);",500);
	}
}

function showone_switchto(component){
	showone_hideall();
	showone_reveal(component);
	return false;
}

function showone_hideall(){
	for(i=0;i<showone_objects.length;i++){
		myelement = document.getElementById(showone_objects[i]);
		myelement.setAttribute("class", "hide");
		myelement.className = "hide";
	}
}

function showone_reveal(component){
	myComponent = document.getElementById(component);
	myComponent.setAttribute("class", "");
	myComponent.className = "";
}