var section = null;
var subsect = null;

var visButtons = null;   // whichever buttons are currently visible
var activeH2 = null;     // the section heading for those buttons (for rollover colours)
var tHideButtons = null; // timer to hide the currently visible buttons after mouseout+delay
var saveTag = null;      // whichever tag you're fiddling with
var saveTagText = null;  // the text it had before you fiddled with it

function showButtons(sectionName)
{
	var newButtons = null;
	var newHead = null;

  // If DOM1 supported ...
  if(document.getElementById){

		clearTimeout(tHideButtons);
		// the new buttons to be shown
		newButtons = document.getElementById(sectionName + 'Butts');
		newHead = document.getElementById(sectionName + 'Head');

		// if newButtons==visButtons then enough to just cancel any button timeout that's been set by a mouseout
		// but otherwise, change visButtons over
		if (newButtons!=visButtons)
		{

			// hide any currently visible buttons
			if (visButtons!=null)
			{
				visButtons.style.visibility = 'hidden';
				visButtons = null;

				activeH2.className = '';
				activeH2 = null;
			}

			// show any newly visible buttons
			if (newButtons!=null)
			{
				visButtons = newButtons;
				visButtons.style.visibility = 'visible';

				activeH2 = newHead;
				activeH2.className='hover';
			}

		}
	}
}

function buttonTimer(delay)
{
		if (delay==undefined) {
			delay = 1500;
		}

		tHideButtons=setTimeout("showButtons(null);", delay);
}


function showTag(tagID, tagText)
{
	var theTag = null;

  // If DOM1 supported ...
  if(document.getElementById){

		// the tag to write to
		theTag = document.getElementById(tagID);

		if (theTag!=null) {

			saveTag = theTag;
			saveTagText = theTag.innerHTML;
			theTag.innerHTML = tagText;
			theTag.className = 'liveTag';

		}
	}

}

function restoreTag()
{
	var theTag = null;

	if (saveTag!=null) {

		saveTag.innerHTML = '';
		saveTag.className = '';
		saveTag.innerHTML = saveTagText;
		saveTag = null;

	}
}

function CheckEmail(theForm)
{
	var emailReg = /^[^\s!\@]+\@([^\.\s\@]+\.)+[^\.\s\@]{2,}$/

	if (!emailReg.test(theForm.eFrom.value)) {

		alert("Please enter a valid email address so we can get back to you");

		theForm.eFrom.select();
		theForm.eFrom.focus();

		return false;
	}
	alert(theForm.email.value + ' contains ' + emailReg.source);

	return true;

}
