
var lastLinkElem = null;

function loadAjaxContent(linkElem, docId, docUrl) {
	if (lastLinkElem) lastLinkElem.className = '';
	linkElem.className = 'active';
	lastLinkElem = linkElem;
    // Setup the parameters and make the ajax call
	var pars = Object.toQueryString({
		q: 'assets/snippets/AjaxContent/AjaxContent.php',
		docId: docId,
	  	allowEdit: AjaxContent_allowEdit ? 1 : 0
	});

	var docUrl2 = docUrl;
	var doResponse = function (request) {
		doAjaxContentResponse(request, docUrl2);
	};

    var ajaxReq = new Ajax('index-ajax.php', {postBody: pars, onComplete: doResponse});
	ajaxReq.request();
    return false;
}

function doAjaxContentResponse(request, docUrl) {
	// if we find a snippet tag, then go to that page
	if (request.indexOf('[!') > -1)
	{
		document.location.href = docUrl;
	}
	else
	{
    	$('AjaxContentOutput').setHTML(request);
		var elem = $('right-border');
		if (elem)
		{
			he(elem);
		}
	}
}

