function saveAndShow (id)
{
	var element = document.getElementById("input_next");
	element.value = 1;
	element = document.getElementById("input_tab");
	element.value = id;

	saved = true;
	element.form.submit();
}

function showTab (id)
{
	var element = document.getElementById("tab_" + id);

	if (element)
	{
		var visibleTabs = getElementsByClassName(document, "div", "tabbox_section_active");
		if (visibleTabs.length > 0)
		   { visibleTabs[0].className = "tabbox_section"; }

		element.className = "tabbox_section_active";

		// Grey out all tab buttons
		var buttons = document.getElementById("tabbox_index").getElementsByTagName("a");
		for (var i = 0; i < buttons.length; i++)
		{
			buttons[i].className = "";
		}

		// Highlight active tab
		var button = document.getElementById("tabbox_button_" + id)
		button.className = "active";
	}
}

function getElementsByClassName(root, tagName, className)
{
	var elements = root.getElementsByTagName(tagName);
	var elementsFound = new Array();
	for (var i = 0; i < elements.length; i++)
	{
		if (elements[i].className == className)
		{
			elementsFound.push(elements[i]);
		}
	}
	return elementsFound;
}

// Copy ALT text into the TITLE attribute, to ensure mouseover
// hints appear in Firefox.

function altToTitle ()
{
	var imgs = document.getElementsByTagName("img");
	for (var i = 0; i < imgs.length; i++)
	{
		imgs[i].title = imgs[i].alt;
	}
}

function tableInit (id)
{
	var table = document.getElementById(id);
	if (!table)
	   { return; }

	// Add horizontal stripes to tab table
        var trs = table.getElementsByTagName("tr");
        for (var i = 0; i < trs.length; i++)
        {
                if (i % 2 == 1)
                {
			trs[i].className = "stripe";
                }
        }
}

function validate_numbers (e)
{
	var unicode= e.charCode ? e.charCode : e.keyCode
	if ((unicode > 64) && (unicode < 123))
	   { return false }
	if ((unicode == 8) || (unicode == 10) || (unicode == 13))
	   { return true; }
	// if ((unicode < 48) || (unicode > 57))
	//    { return false }

	return true;
}

window.onload = function () {
	tableInit("tabbox_box");
	altToTitle();
};

function deobfuscate (address)
{
	address_plaintext = address.replace(/-nospam/, "");
	address_plaintext += "@";
	address_plaintext += "artsline.org.uk";
	document.write("<a href='mailto:" + address_plaintext + "'>" + address_plaintext + "</a>");
}
