function validate_email(field,alerttxt){
	with (field)
	  {
	  apos=value.indexOf("@");
	  dotpos=value.lastIndexOf(".");
	  if (apos<1||dotpos-apos<2)
	    {alert(alerttxt);return false;}
	  else {return true;}
	  }
}

function sendRequest() {
//alert("matt's working here");
//alert( $("#emailAlertsForm input[name=contact_page]").val());
	if (document.emailAlertsForm.first_name.value == "First Name")
	{
	 	alert("Please enter your first name.");
		document.emailAlertsForm.first_name.focus();
		return false;
	}
	if (document.emailAlertsForm.last_name.value == "Last Name")
	{
	 	alert("Please enter your last name.");
		document.emailAlertsForm.last_name.focus();
		return false;
	}
	if (validate_email(document.emailAlertsForm.newsletter_email,"Please enter a valid email address")==false)
  {
  	document.emailAlertsForm.newsletter_email.focus();return false;
  }
	//alert("donevalidation");
	//$('emailAlerts').innerHTML= "<p>thank we've added you to our newsletter</p>";
	//alert("doingajax8");
	
	$.ajax({
   type: "POST",
   url: "/lib/php/internal-contact.php",
   data: "first_name="+$('#first_name').val()+"&last_name="+$('#last_name').val()+"&email="+$('#newsletter_email').val()+"&contact_page="+$('#contact_page').val()+"",
   success: function(msg){
   		$("#emailAlerts").html(msg);
   }
 });
	//alert("done with ajax");
	// works $("#emailAlerts").html("<h3>Sign Up For Email Alerts</h3><p>You're email address has been added to our newsletter!</p>");
	//$('#emailAlerts').html('This is done and other info');
	//new Ajax.Request("/lib/php/internal-contact.php", 
	//{
	//method: 'post', 
	//postBody: 'first_name='+ $F('first_name')+'&last_name='+ $F('last_name')+'&pref_contact='+ $F('pref_contact')+'&email='+ $F('email')+'&phone='+ $F('phone')+'&zip='+ $F('zip')+'&contactpage='+ $F('contactpage'),
	//onComplete: showResponse 
	//});

}
function showResponse(req){
	$('contactForm').innerHTML= req.responseText;
}

