// Ajax based PDF Download
function GeneratePDFDownload() {
	var domain = document.domain;
	
	$('Message').innerHTML = "<p><img class='loadingImage' src='../images/misc/loading.gif' alt='Loading...' />Please wait whilst the Property Register PDF is being generated...</p>";		
  
	new Ajax.Request('/download-register/index.cfm?action=generate_pdf',
	{
		method:'get',
		onSuccess: function(transport){
			
		var response = transport.responseText || "no response text";
		  
		console.log("Success! \n\n" + response);
		$('Message').innerHTML = "<p>Your Property Register PDF has been generated, <strong>please right click on the link below and press 'Save As' to save to your computer</strong>.</p>";
		$('Message').innerHTML += "<p>Please note; this download will be deleted in one hours time.</p>";				
		$('SaveLink').style.display = "block";
		
		},
		onFailure: function(){
			var response = transport.responseText || "no response text";
			console.log("Failed! \n\n" + response);
		}
	 });

}
// Prototype multiple onload function
Event.observe(window, "load", GeneratePDFDownload);
