
var currentAjaxCall = -1;
var currentAttempt = 0;

function get(content){
	
	// Reset attempts holder
	currentAttempt = 0;
	
	// Convert content variable to object containing variables
	contentObject = parseForKeyValuePairs(content);
	
	// Simulate click on menu item
	upListItem(document.getElementById(contentObject.category+'ListItem'),'','Sidebar');
	
	// Update ajax history object
	ajaxHistoryAdd(content);
	
	// Check for open call
	if(currentAjaxCall != -1) cancelAjaxRequest(currentAjaxCall);
	
	// Make new call
	currentAjaxCall = getDataReturnText( 'help.documentation.php?'+content, getHandler, getErrorHandler, false );
}

function getHandler(text, url){
	
	// Reset the ajax call holder
	currentAjaxCall = -1;
	
	// Get the div with id "main"
	var main = document.getElementById("main");
	// Replace contents of the div with data received
	main.innerHTML = text;
	
}

function getErrorHandler(status, url, attempts){
	
	// Reset the ajax call holder
	currentAjaxCall = -1;
	
	// Check number of attempts
	if(attempts<3){
		
		// Make the call again
		currentAjaxCall = getDataReturnText( url, getHandler, getErrorHandler, false, attempts );
		
	} else {
		
		// Alert user
		alert(messages.ajaxError);
		
	}
}