$(document).ready(function()
	{	
	$('#dialog').dialog(
		{
		autoOpen: false,
		width: 300,
		modal:true,
		bgiframe: true,
		buttons: 
			{
			"Ok": function() 
				{
				$(this).dialog("close"); 
				}
			}
		});
	$('#errorDialog').dialog(
		{
		autoOpen: false,
		width: 300,
		modal:true,
		bgiframe: true,
		buttons: 
			{
			"Ok": function() 
				{
				$(this).dialog("close"); 
				}
			}
		});	
	$('#newsLetterLink').click(function(event)
		{
			event.preventDefault();
			if (validateEmail('newsLetterInput')==false)
				{
				$('#errorDialog').dialog('open');
				return;
				}
			else
				{
				$.ajax({
					type: "POST",
					url: "action/subscribeAddressToNewsLetter.php",
					data: "email="+$('#newsLetterInput').val(),
					success: function(msg)
						{
						if (msg==1)$('#dialog').dialog('open');
						if (msg==-1)$('#errorDialog').dialog('open');
						},	
					error: function()
						{
						alert('Something went wrong. The connection failed.');
						}
					});
				}
		});
	});