//////////////////////////////////////////////////////////////////////
// This file contains JavaScript functions which are unique to the
// associated web page.
//////////////////////////////////////////////////////////////////////

// holds error text
var errorText;

//////////////////////////////////////////////////////////////////
// called on form load.
//////////////////////////////////////////////////////////////////
function loadProcessing()
{ 
	// Dialog			
	$('#dialog').dialog(
	{
		autoOpen: false,
		width: 600,
		buttons: 
		{
			"Ok": function() 
			{ 
				$(this).dialog("close"); 
			}
		}
	});
	
}

//////////////////////////////////////////////////////////////////
// submitForm
//////////////////////////////////////////////////////////////////
function showEditorialPolicy()
{ 
	$('#dialog').dialog('open');
}

//////////////////////////////////////////////////////////////////
// Validate
//////////////////////////////////////////////////////////////////
function validateForm(inForm)
{ 
	var valid = true;
	errorText = '';
	var validEmail = false;
	

	if (! isValidEmail(fieldValue('emailAddress')))
	{
		errorText += "Please enter a valid email address\n";
	}
	
	if (errorText != '')
	{
		valid = false;
	}

	// if the form is NOT invalid
	if ( !valid )
	{
		// slap them around...
		alert(errorText);
		return false;
	}
	
	return valid;
}

//////////////////////////////////////////////////////////////////
// sendEmail
//////////////////////////////////////////////////////////////////
function submitForm(inForm)
{ 
	// if the form is NOT invalid
	if ( !validateForm(inForm) )
	{
		// slap them around...
		alert(errorText);
		return false;
	}
	
	inForm.submit();
}
