function mysetFocus()
{
	document.forms.addgbform.elements.fmsecode.focus();
}

function showGbAddForm()
{
	var targetDiv = document.getElementById('addgbdiv');
	targetDiv.style.display = 'block';
	mysetFocus();
}

function isEmailCorrect(email)
{
	var re = /^\w+([\.-]?\w+)*@(((([a-z0-9]{2,})|([a-z0-9][-][a-z0-9]+))[\.][a-z0-9])|([a-z0-9]+[-]?))+[a-z0-9]+\.([a-z]{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum))$/i;
	if(re.test(email))
		return true;
	else
		return false;

}

function validateAddgbForm(theForm)
{
	if (theForm.fmname.value == '')
	{
	  alert('Please enter a value for the \"Your Name\" field.');
	  theForm.fmname.focus();
	  return false;
	}

	if (theForm.fmtext.value == '')
	{
	  alert('Please type some text in the \"Tribute\" field.');
	  theForm.fmtext.focus();
	  return false;
	}

	if( theForm.fmemail.value != '')
	{
		if(!isEmailCorrect(theForm.fmemail.value))
		{
			alert('Please enter correct e-mail address in the \"E-mail Address\" field.');
	  		theForm.fmemail.focus();
	  		return false;
	  	}
	}

	if (theForm.fmsecode.value == '')
	{
	  alert('Please enter Security Code exactly as on image to the right of \"Security code\" field');
	  theForm.fmsecode.focus();
	  return false;
	}

	return true;

}

function validateAddObitForm(theForm)
{
	if( theForm.fmname.value == '')
	{
	  alert('Please enter a value for the \"Name\" field.');
	  theForm.fmname.focus();
	  return false;
	}

	if (theForm.fmmonth.value == '' || theForm.fmday.value == '' || theForm.fmyear.value == '')
	{
	  alert('Please fill in all fields in \"Date of death\" line.');
	  theForm.fmmonth.focus();
	  return false;
	}

	if( theForm.fmemail.value != '')
	{
		if(!isEmailCorrect(theForm.fmemail.value))
		{
			alert('Please enter correct e-mail address in the \"Feedback e-mail\" field.');
	  		theForm.fmemail.focus();
	  		return false;
	  	}
	}

	if (theForm.fmtext.value == '')
	{
	  alert('Please type some text in the \"Obituary text\" field.');
	  theForm.fmtext.focus();
	  return false;
	}

	return true;
}

