//IMPORTANT! This library assumes that the following libraries have been loaded by the calling page:
//	javascript_library.js
//	yui/build/yahoo/yahoo-min.js
//	yui/build/yahoo/dom-min.js
//	yui/build/yahoo/event-min.js
//	yui/build/yahoo/container-min.js

YAHOO.namespace("container");

function YAHOOinitContextualHelp() {
	YAHOO.container.ContextualHelp = 
		new YAHOO.widget.Panel("ContextualHelp", { visible:false,
			iframe:false,
			visible:false,
			close:true,
			draggable:true,
			modal:false,
			underlay:'none',
			width:'400px'
		} );

	YAHOO.container.ContextualHelp.render();
}

YAHOO.util.Event.onDOMReady(YAHOOinitContextualHelp);

function HelpLink_OnClick(HelpID)
{
	var ContainerHd = document.getElementById('ContextualHelpHead');
	if(ContainerHd.innerHTML.length==0)
		ContainerHd.innerHTML = '<img src="/global_graphics/icons/icon_more_info.gif" align="left" alt="" border=0 height=16 width=16 vspace=3> Help';
	
	var ContainerBd = document.getElementById('ContextualHelpBody');
	ContainerBd.innerHTML = 'Loading...';
	
	YAHOO.container.ContextualHelp.cfg.setProperty('context', ['HelpLink_'+ HelpID,'tl','br']);
	
	//IE hack: underlay size does not change with panel size; resize it now
	if(document.all) YAHOO.container.ContextualHelp.sizeUnderlay();
	
	YAHOO.container.ContextualHelp.show();
	
	var xmlhttp = null;
	if (window.XMLHttpRequest)
	{	//code for Mozilla, etc.
		xmlhttp = new XMLHttpRequest();
	} else if(window.ActiveXObject)
	{	//code for IE
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if(xmlhttp)
	{	//wire up the event to handle the response on successful load
		xmlhttp.onreadystatechange = function() {
			if(xmlhttp.readyState==4 && xmlhttp.status==200 && xmlhttp.responseText!='') {
				ContainerBd.innerHTML = xmlhttp.responseText;
				
				//IE hack: underlay size does not change with panel size; resize it now
				if(document.all) YAHOO.container.ContextualHelp.sizeUnderlay();
			}
		}
		
		xmlhttp.open("GET",'/get_help_topic.asp?id='+ HelpID,true);
		xmlhttp.send(null);
	}
	
	return false;
}

function getHelpLink(HelpID)
{
	document.write('<a id="HelpLink_'+ HelpID +
		'" href="#" title="Help is available" onclick="return HelpLink_OnClick(\''+ HelpID +
		'\')"><img src="/global_graphics/icons/helpme.gif" border=0 height=13 width=11 vspace=2></a>'
	);
}
