var helpDiv = "<div id='helpDiv' class='helpDiv'><span style='display:none'>.</span></div>"
var helpXML;

function showHelp(keyword) {
	dhtmlwindow.open("helpBox","inline",helpDiv,'MyAgentDesk.com Help',"width=450px,height=100px,resize=1,center=1,scrolling=1");;
	
	if (helpXML)
	{
		loadHelp(keyword)
	}
	else
	{
		loadXML(keyword)
	}
}

function loadXML(keyword) {
        var req = new AjaxRequest();
        req.onError = errorHandler;
        req.url = context + "/help.xml";
        req.onSuccess=function()
        {
                helpXML = req.responseXML;
		loadHelp(keyword);
	}
	req.process();
}

function loadHelp(keyword) {
	var help = "";
	var xml = helpXML.getElementsByTagName(keyword);
	if (xml && xml.length > 0)
	{
		var label = xml.item(0).getElementsByTagName('label');
		if (label && label.length > 0)
		{
			help += "<span class='label'>" + label.item(0).firstChild.nodeValue + " </span> - ";
		}
		var text = xml.item(0).getElementsByTagName('text');
		if (text && text.length > 0)
		{
			help += text.item(0).firstChild.nodeValue;
		}
	}
	else
	{
		help += "Sorry, help is not available for this item. [" + keyword + "]";
	}
	document.getElementById('helpDiv').innerHTML = help;
}

