// JavaScript Document

// This was written for Pockets Online by James Parenti of Visuale
// Be sure to link to this file in the header section of any page
// within the site that you plan to apply the form to.

// IMPORTANT, MAKE SURE WHEN IMPLEMENTING THAT THE FORM SCRIPT TO BE USED
// HAS THE FORM TAG SET WITH PARAMETER onSubmit="return false" OR SCRIPT FAILS.

window.onload = initQuickForm;
function initQuickForm() {
	getQuickForm(); 
}

function getQuickForm() {
		var url = "includes/ajaxQuickForm.php";
		new Ajax.Request(url,
		{
			method:'get',
			onSuccess:function(transport) {
				var destinationId = $('formBox');
				destinationId.innerHTML = transport.responseText;
			}
		});
}

/* -----------------Process Submission for CURL --------------------*/
// This processes the form if being sent via CURL
function doQuickForm() {
	var string = $('theForm').serialize();
	var tgt = "includes/quick_form_process.php"+"?"+string;

	new Ajax.Request(tgt,{
					 method:'get',
					 onSuccess:function(transport) {
							var result = "<div id=\"formBox\">"+transport.responseText+"</div>";
							$('formBox').replace(result);
							setTimeout('getQuickForm()',700);
					 }
					 });
	
}
