function NewsletterSignUp()
{
	if (IsValidEmail(document.SignupForNewsletter.EMAIL.value))
	{
		document.getElementById('mce-EMAIL').value = document.SignupForNewsletter.EMAIL.value;
		document.SignUpNewsletter.submit();
		ShowPopup(true, "Email Sent", "A confirmation e-mail has been sent to " +document.SignupForNewsletter.EMAIL.value+ ".  You must click on the link in this e-mail to sign up for the newsletter.");

//AjaxCall("POST","newsletter_subscribe.php","ConfirmNewsletter=1&Email=" + document.SignupForNewsletter.EMAIL.value, "AfterConfirmEmail", true);
	}
	else
		ShowPopup(true, "ERROR", "Please enter a valid e-mail address.");

}

function AfterConfirmEmail(xml, text)
{
	ShowPopup(true, "SUCCESS", "An e-mail has been delivered to the address specified.<br /><br />You must click on the link in the e-mail to confirm that this is your e-mail address.");
}






function SubmitPostalCodeOnEnter(e)
{
	if(enter_pressed(e))
		SearchPostalCode();
}


function SearchPostalCode()
{
	//Make sure its a valid postal code
	//Search system to see if its covered
	
	PostalCode = document.getElementById('SearchPostalCode').value;
	
	if (IsValidPostalCode(PostalCode))
		AjaxCall("POST","/index.php","ConfirmPostalCode=1&PostalCode=" + PostalCode, "AfterSearchPostalCode", true);
	else
	{
		//document.getElementById('ErrorMessageDiv').innerHTML = "Please enter a postal code in the format 'A1A 1A1'.";
		ShowPopup(true, "ERROR", "Please enter a valid postal code.");
	}
}




function AfterSearchPostalCode(xml, text)
{
	if (text.length <= 0)
	{
		//the postal code was set in the session variables, send them to book online page
		location.href = "/book_online.php";
	}
	else
	{
		ShowPopup(true, "ERROR", text);
		//document.getElementById('ErrorMessageDiv').innerHTML = text;
	}

}

function ShowHidePostalCodeMessage()
{
	var MyValue = document.getElementById('SearchPostalCode').value;
	
	if (MyValue.toLowerCase() == "postal code")
		document.getElementById('SearchPostalCode').value = "";
	else if  (MyValue == "")
		document.getElementById('SearchPostalCode').value = "POSTAL CODE";
}

function enter_pressed(e)
{
	var keycode;
	if (window.event)
		keycode = window.event.keyCode;
	else if (e)
		keycode = e.which;
	else
		return false;

	return (keycode == 13);
}