function onPageLoad()
{

	var sDocId; //If doc id is missing
		
	try	
	{
  		if (msOnDemandDocumentId) 
		{
			sDocId = msOnDemandDocumentId
		}
	}
	catch (e) 
	{
		sDocId = -1;
	}

	if(sDocId == 23821)
	{
	
		var aValues = msOnDemandContextId.split('&');
		var aVariableTX = aValues[0].split('=');
		var sTX = aVariableTX[1];

		var sParam = 'method=SITE_PAYPAL_PDT_GET&site=971&url=' + escape('https://www.paypal.com/cgi-bin/webscr?cmd=_notify-synch' +
					'&tx=' + sTX + 
					'&at=GtEQ_EmUOaEGUJdR90QRqHAELyIdzqGArAksKY0f3GCn7LZCxQKE92UT9O4')

		var sReturn = onDemandSiteAsync(sParam);
	}
}

//////////////NEWS SUB FORM ////////////////////

function NewsletterSub()
{

	var sReturn;
	var sParam;
	
	
	var divWorking = document.getElementById('divWorking');


	if (NewsletterSubValidate())
	{			
						
			divWorking.innerHTML = 'Sending please wait...';
			divWorking.style.width = '200px';
			divWorking.style.display = 'block';	
			
			if (document.getElementById('cboSurvey6918').value=30858){
			sParam = 'method=SITE_SEND_ENQUIRY&select=1098&site=971&group=3635&sendnews=1';
			}
			
			else if  (document.getElementById('cboSurvey6918').value=30859){
			sParam = 'method=SITE_SEND_ENQUIRY&select=1098&site=971&group=3636&sendnews=1';
			}
			
			else{

			sParam = 'method=SITE_SEND_ENQUIRY&select=1098&site=971&group=6903&sendnews=1';
			
			sReturn = onDemandSite(sParam);

			sParam = sParam + '&firstname=' + document.getElementById('txtFirstname').value; //first name
			sParam = sParam + '&surname=' + document.getElementById('txtSurname').value; //surname
			sParam = sParam + '&email=' + document.getElementById('txtEmail').value; //email

			}

			if (sReturn.substring(0, 2) == 'OK')
			{
			
				document.location.href = '/newsletter_subscribe'
			}
			else
			{
				divWorking.style.display = 'none';
				window.alert('Could not send!');
			
			}
		}

}

function NewsletterSubValidate() 
{

	sOnDemandValidateMessage = '';
	sOnDemandValidateObject = '';


	onDemandValidate('txtSurname', 'Surname', '');
	onDemandValidate('txtEmail', 'Email', '');
	
	onDemandValidate('txtmPostCode', 'PostCode', '');
	
	
	if (!onDemandIsEmail(document.getElementById('txtEmail').value))
	{
		sOnDemandValidateMessage = sOnDemandValidateMessage + '\r\n # Not a valid email address.';
	}

	if (sOnDemandValidateMessage != '')
	{
		window.alert('Sorry can\'t submit your registration as:\r\n' + sOnDemandValidateMessage);
		//document.getElementById(sOnDemandValidateObject).focus();
		return (false);
	}
	
	else
	{
		return (true);
	}
}	


