
	// throbber image for display while ajax call in progress
	loading_img = new Image();
	loading_img.src = "/images/loadingAnimation.gif";
	var loading_html = "<div style='width: 100%; height: 20px; margin-right: 25px;margin-top: 10px; background: url(" + loading_img.src + ") center no-repeat;'>&nbsp;</div>";

	// Show throbber image inside user defined container (identified via elementId)
	function loading(consumerId, _document){
		iterator = new DomIterator(_document);
		iterator.applyValue(consumerId, loading_html, true);
	}
			
	// Show Errors using alert() function
	function showError(e){
		alert(e);
	}
	
	// Custom effect for while data is being processed
	function processingEffect() {
		Element.hide(message.consumer);
	}
	
	// Custom effect for displaying data after process
	function appearFormFunction() {
		Element.hide(message.consumer);
		new Effect.BlindDown(message.consumer, {duration: 1, queue: 'end'});
	}
	
	// Main ajax call function to fetch data, accepts dataUrl, ID of container in which to display data, boolean to define loading throbber
	function ajax_get(url, consumerId, applyLoading){
		message = new Message();
		message.method = "GET";
		message.address = url;
		message.consumer = consumerId;
		message.onError = showError;
		// onComplete gets assigned to the new appearFunction which will hopefully display our content elegantly once the ajax call completes
		message.onComplete = appearFormFunction;
		if (applyLoading == true) {
			loading(consumerId, message.document);
			Connection.sendMessage(message);
			//new Effect.BlindUp(message.consumer, {duration: 0.2, queue: 'front'});
		}
	} 
	
	// Ajax form posting (Using form ID) - include form ID, ID of container for display of output, and boolan for Throbber
	function ajax_formID(formId, consumerId, applyLoading){
		form = null;
		forms = document.getElementsByTagName("form");
		for(var i = 0; i <= forms.length; ++i){
			if(forms[i] != null) {
				if(forms[i].id == formId) {
					form = forms[i];
				break;
				}
			}
		}
		
		message = new Message();
		message.address = form.action;
		message.consumer = consumerId;
		message.onError = showError;
		message.onComplete = appearFormFunction;
		if (applyLoading == true)
			loading(consumerId, message.document);
			Connection.sendFormByMessage(message, form);
	}