// JavaScript Document

/************************************************
 bool ValidateEmail(string input)
 Return true or false
 if the email is valid or not.
 checks for @ and .
**************************************************/
function ValidateEmail(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("^([-!#$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,4}$","gi"))>=0);
 if(s.indexOf)
 {
  at_character=s.indexOf('@');
  if(at_character<=0 || at_character+4>s.length)
   return false;
 }
 if(s.length<6)
  return false;
 else
  return true;
}
 
/************************************************
 bool ValidateName(string input)
 Return true or false
 if the email is valid or not.
**************************************************/
function ValidateName(theinput){
 var s=theinput;
 if(s.search)
  return (s.search(new RegExp("^[^&'^`]+$","gi"))>=0);
 if(s.length<3)
  return false;
 else
  return true;
}
 

function CheckRTHForm(){
	var error="";
	if(!ValidateEmail(document.frmRTH.email.value))
		error+="A valid email address is required.";
	else if(!ValidateName(document.frmRTH.name.value))
			error+="You must include your name.";
	else if(document.frmRTH.message.value=="")
			error+="Please include your message.";
	
	if(error!="")
		alert("Error! Please check:\n"+error);
	else
		document.frmRTH.submit();
	
	return;
}

function startmenu()
{
	document.getElementById('menu_0').style.display = "none";
	document.getElementById('menu_1').style.display = "none";
	document.getElementById('menu_2').style.display = "none";
	document.getElementById('menu_4').style.display = "none";
	document.getElementById('menu_6').style.display = "none";
}

function menufunc(menuId)
{
	if(document.getElementById(menuId).style.display == "none")
	{
		startmenu();
		document.getElementById(menuId).style.display = "block";
	}
	else
	{
		startmenu();
	}
}
