function doAjax(url, type, data, div)
{
	$(div).empty().html('<img src="/media/generic_site_content/images/ajax-loading.gif" border="0"/>');
	$.ajax({
			url: url,
		  	type: type,
    		data: data,
    		cache: false,
		  	success: function(data, textStatus) {
			  		doAjaxSuccess(data, textStatus, div)
		   	 	},
		   		error: function(xhr, textStatus, errorThrown) {
			   		doAjaxError(xhr, textStatus, errorThrown, div)
		  		},
		  		timeout: 8000
		});
}

function doAjaxSuccess(data, textStatus, div)
{
	if (jQuery.startsWith(jQuery.trim(data), "<!DOCTYPE"))
	{
		var error = '<div>Please refresh screen and try again.</div><br/>';
		//var error = '<h1 class="SEO">Error</h1><font size=4 color="red"><b>Server encountered problems while processing the request. Please try again later.</b></font><br />';
		$(div).html(error);
	}
	else
	{
		$(div).html(data);
	}
}

function doAjaxError(xhr, textStatus, errorThrown, div)
{
	var error = '<div>Refresh screen and try again.</div><br/>';
	//var error = '<h1 class="SEO">Error</h1><font size=4 color="red"><b>Server encountered problems while processing the request. Please try again later.</b></font><br />';
	$(div).html(error);
}
