/*
**  Core JavaScript include for the United Biscuits 123 Healthy Balance website.
**
**  @author Rob Green, Wheel:, London, GB
**  @version $Id: common.js,v 1.9 2004/12/15 18:43:08 rgreen Exp $
*/

/*	Tabset Function
**
**	Specifying the tabset, and the active tab in the tabset will hide all
**	the currently unused tabs, and display the requested active tab. Tabs
**	need to be declared in an array matching the name of the tabset.
*/
function tabset(tabset, activetab) {
	// alert('[' + new Node(activetab).style.display + "]\n[" + tabset + "]\n[" + activetab + ']');

	var ourIds = new Array();

	if (tabset == "meals") {
		ourIds[ourIds.length] = "tabset-meals-breakfast";
		ourIds[ourIds.length] = "tabset-meals-lunch";
		ourIds[ourIds.length] = "tabset-meals-dinner";
	}
	else if (tabset == "meals-rhn") {
		ourIds[ourIds.length] = "tabset-meals-rhn-breakfast";
		ourIds[ourIds.length] = "tabset-meals-rhn-lunch";
		ourIds[ourIds.length] = "tabset-meals-rhn-dinner";
	}
	else if (tabset == "keepactive") {
		ourIds[ourIds.length] = "tabset-active-first";
		ourIds[ourIds.length] = "tabset-active-making";
		ourIds[ourIds.length] = "tabset-active-serious";
	}
	else if (tabset == "homepage") {
		ourIds[ourIds.length] = "tabset-homepage-fitnessfun";
		ourIds[ourIds.length] = "tabset-homepage-balanceddiet";
		ourIds[ourIds.length] = "tabset-homepage-snackstosuit";
	}

	for (var i = 0; i < ourIds.length; i++) {
		var node = new Node(ourIds[i]);
		if (node != null || ourIds[i] != activetab) {
			node.style.display = "none";
		}
		var node = new Node(ourIds[i] + '-btn');
		if (node != null || ourIds[i] != activetab) {
			node.src = node.src.replace(/-on/, "-off"); //'/i/tabsets/' + ourIds[i] + '-off.gif';
		}
	}

	(new Node(activetab)).style.display = "block";
	var currentImage = (new Node(activetab + '-btn'));
	currentImage.src = currentImage.src.replace(/-off/, "-on"); // '/i/tabsets/' + activetab + '-on.gif';
}

function Node(id) {
	try {
		return (document.getElementById) ? document.getElementById(id) : document.getElementsByName(id);
	} catch (foo) {
		return null;
	}
}