function prompt_newsletter(){
	show_dialog('<p>Enter your email to join our mailing list</p><p><input type=text class="textbox" id="email_prompt" /></p>',
	'Join Mailing List',
	{
      "Ok": function(){process_prompt(0);},
      "Cancel": function(){close_dialog();}
   });
}
function prompt_share(){
	show_dialog('<p>Enter your email to share this site</p><p><input type=text class="textbox" id="email_prompt" /></p>',
	'Share this Site',
	{
      "Ok": function(){process_prompt(1);},
      "Cancel": function(){close_dialog();}
   });
}
function process_prompt(thetype){
	if(thetype != 1){
		thetype = 0;	
	}
	close_dialog();
	var the_email = $('#email_prompt').val();
	if(validate_email(the_email)){
   	$.ajax({
   	   type: "get",
   	   url: "ajax_do_send.php?email="+the_email+"&thetype="+thetype+"&ms=" + (new Date().getTime()) ,
   	   dataType: "xml",
   	   error: function(msg){
   		   show_dialog('<p>'+msg.status+'</p><p>'+msg.statusText+'</p><p>'+msg.responseText+'</p>','Communications Error');
   		},
   	   success: function(xmlDocument){
   	      if($('success',$(xmlDocument)).size()){
   	      	show_dialog('<p>Thank You</p><p>Your email has been submitted</p>');
            }else if($('error',$(xmlDocument)).size()){
            	show_dialog('<p>There was an error submitting your email address please try again later</p>','Communications Error');
            }
   	   }
      }); /* $.ajax */
		
	}else{
		show_dialog('Not a valid email address','Email Error');
	}
}

function validate_email(inputvalue){	
   var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
   return pattern.test(inputvalue);
}
