// Address of CGI script to process forms
var strCGIMailForm = "http://www.travelman.co.uk/cgi-bin/FormMail.pl";
// EMail address to send processed forms to
# var emailSender = "FormMail@travelman.co.uk";
var emailRecipient = "alexanderwaugh-virgin.net@travelman.co.uk";
// If confirmation page is auto-generated, this is the background colour
var confirmationBGColor = "F3FFBB";
// Send some extra user information (e.g. which Web browser they use) along with the email. "true" is enabled.
var emailEnvironment = true;


// ****************************************
// ** Order Page configuration
// ****************************************

// Text to appear in subject of EMail
var emailSubject_Order = "Order recieved from www.travelman.co.uk";
// URL to redirect user to after processing form. Used as a confirmation page. If left blank, a page is auto-generated
var emailRedirect_Order = "http://www.travelman.co.uk/travelman/confirmation.htm";
// If confirmation page is auto-generated, this is the title, and header of the page
var confirmationTitle_Order = "Thankyou for your order";
// If confirmation page is auto-generated, this is the URL of an included link
var emailReturnLinkURL_Order = "http://www.travelman.co.uk/travelman/index.htm";
// If confirmation page is auto-generated, this is the Title of the included link
var emailReturnLinkTitle_Order = "Return";

// ****************************************
// ** Download Page configuration
// ****************************************

// Text to appear in subject of EMail
var emailSubject_Download = "Download request recieved from www.travelman.co.uk";
// URL to redirect user to after processing form. Used as a confirmation page. If left blank, a page is auto-generated
var emailRedirect_Download = "http://www.travelman.co.uk/travelman/actualDownload.htm";
// If confirmation page is auto-generated, this is the title, and header of the page
var confirmationTitle_Download = "Thankyou for your order";
// If confirmation page is auto-generated, this is the URL of an included link
var emailReturnLinkURL_Download = "http://www.travelman.co.uk/travelman/index.htm";
// If confirmation page is auto-generated, this is the Title of the included link
var emailReturnLinkTitle_Download = "Return";


function configureFormMail( strPage )
{
	if( strPage == "Order" )
	{
		emailSubject = emailSubject_Order;
		emailRedirect = emailRedirect_Order;
		confirmationTitle = confirmationTitle_Order;
		emailReturnLinkURL = emailReturnLinkURL_Order;
		emailReturnLinkTitle = emailReturnLinkTitle_Order;
	}
	else if( strPage == "Download" )
	{
		emailSubject = emailSubject_Download;
		emailRedirect = emailRedirect_Download;
		confirmationTitle = confirmationTitle_Download;
		emailReturnLinkURL = emailReturnLinkURL_Download;
		emailReturnLinkTitle = emailReturnLinkTitle_Download;
	}
	else
	{
		return;
	}
	
	document.writeln( "<form name='form" + strPage + "' method='POST' action='" + strCGIMailForm + "' onSubmit='return( validateForm( \"form" + strPage + "\" ) )'>" );
	document.writeln( "<input type='hidden' name='recipient' value='" + emailRecipient + "'>" );
	# document.writeln( "<input type='hidden' name='recipient' value='" + emailSender + "'>" );
	document.writeln( "<input type='hidden' name='subject' value='" + emailSubject + "'>" );
	document.writeln( "<input type='hidden' name='print_config' value='email,subject'>" );
	if( emailRedirect != "" )
	{
		document.writeln( "<input type='hidden' name='redirect' value='" + emailRedirect + "'>" );
	}
	else
	{
		document.writeln( "<input type='hidden' name='title' value='" + confirmationTitle + "'>" );
		document.writeln( "<input type='hidden' name='return_link_url' value='" + emailReturnLinkURL + "'>" );
		document.writeln( "<input type='hidden' name='return_link_title' value='" + emailReturnLinkTitle + "'>" );
		document.writeln( "<input type='hidden' name='bgcolor' value='" + confirmationBGColor + "'>" );
	}
	if( emailEnvironment == true )
	{
		document.writeln( "<input type='hidden' name='env_report' value='REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT'>" );
	}
}// End configureFormMail()

function validateForm( strForm )
{
	if( strForm == "formOrder" )
	{
		if( ( formOrder.email.value == "" ) || ( formOrder.Name.value == "" ) || ( formOrder.Address_House_Name.value == "" ) || ( formOrder.Address_Street.value == "" ) || ( formOrder.Address_City.value == "" ) || ( formOrder.Address_County.value == "" ) || ( formOrder.PostCode_Zip.value == "" ) || ( formOrder.CreditCard_Number.value == "" ) || ( formOrder.CreditCard_Type.value == "" ) )
		{
			alert( "Please make sure that you have filled in all required fields." );
			return false;
		}
		if( formOrder.email.value.indexOf( "@", 0 ) == -1 )
		{
			alert( "Your email address is invalid, please re-enter." );
			return false;
		}
	}
	else if( strForm == "formDownload" )
	{
		if( ( formDownload.email.value == "" ) || ( formDownload.Name.value == "" ) )
		{
			alert( "Please make sure that you have filled in all required fields." );
			return false;
		}
		if( formDownload.email.value.indexOf( "@", 0 ) == -1 )
		{
			alert( "Your email address is invalid, please re-enter." );
			return false;
		}
	}
	return true;
}// End validateForm()

