// JavaScript Document
function sendMailTo()
{
	 var email = "gunshows@crossroadsgunshows.com";
	 var subject = "E-Mail Notification";							 
	 var body = "Name: " + document.mailForm.Name.value + "<br>";
	 body += "E-mail: " + document.mailForm.eMail.value + "<br>";							 
	 
	 body += "<br>Shows " + document.mailForm.Name.value + " is interested in:<br>"; 
	 
	 for (i=0; i < document.mailForm.length; i++)
	 {
		if (document.mailForm[i].checked == true)
		{
		 body += document.mailForm[i].value + "<br>";
		}
	 }
	 
	 var mailString = "mailto:" + email + "?subject=" + subject + "&body=" + body;

	 window.location.replace(mailString)
}	

function validateForm()
{
	var errorMsg = "";
	
	if (document.mailForm.Name.value == "")
	{
		errorMsg += "Please Enter a Name\n";					
	}
	
	var countChecked = 0;	

	for (i=0; i < document.mailForm.length; i++)
	 {
		if (document.mailForm[i].checked == true)
		{
			countChecked++;
		}
	 }
	 
	 if (countChecked == 0)
	 {
		errorMsg += "Please check at least one show\n";
	 }
	 
	 validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
	 emailAddress = document.mailForm.eMail.value;
	
	 // search email text for regular exp matches
	 if (emailAddress.search(validRegExp) == -1) 
	 {
	 	errorMsg += "A valid e-mail address is required.\n";		
	 }

	 if (errorMsg == "")
	 {
		sendMailTo();
		return true;
	 }
	 else 
	 {
		alert(errorMsg);
		return false;
	 }
}

window.onload = "document.mailForm.Name.focus()";