function toggleSwitch()
{
	var imgFileArray = document.images.dayNight.src.split("/");
	var imgFile = imgFileArray[imgFileArray.length-1];

	var newFile = (imgFile.indexOf("night")>= 0) ? "../images/global/toilet-day.gif" : "../images/global/toilet-night.gif";
	document.images.dayNight.src = newFile;
}

function topImage()
{
	var topImage01 = document.getElementById("top-middle");
	var topImages = new Array("top-jonnyglow.gif","quote-01.gif");

	var strLocation = window.location.toString();
	var strFolders = strLocation.split("/");
	var strFolder = strFolders[strFolders.length-2]

	if(strFolder=="about")
	{
		topImage01.src = "../images/global/" + topImages[1];
	}
	else
	{
		topImage01.src = "../images/global/" + topImages[0];
	}
}

function trim(s)
{
	return s.replace(/^\s+|\s+$/g, '');
}

function validEmail(ea)
{
	var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp(emailReg);
	return regex.test(ea);
  }

function validate(f,el)
{
	var address = trim(document.getElementById(el).value);
	var valid = validEmail(address);

	if(!valid)
	{
		alert("\"" + address + "\" is not a valid email address. A valid email address is required to submit this form.");
		f.focus();
		f[el].select();
		return false;
	}
	else return true;
}
