var helpReq;
var browserIsIE = false;
var urlForHelp;

function loadHelp(url, helpUrl){
urlForHelp = helpUrl;
var helpHTML;
helpHTML = document.getElementById('helpContainer');
if(helpHTML){
	showdiv('helpContainer');
	helpHTML.innerHTML = '<h1>Help</h1><span class="smaller">Loading...</span>';
}
   // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        helpReq = new XMLHttpRequest();
        helpReq.onreadystatechange = processHelp;
        helpReq.open("GET", urlForHelp, true);   
		helpReq.setRequestHeader("location", url);
		helpReq.send(null);
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
        browserIsIE = true;
        helpReq = new ActiveXObject("Microsoft.XMLHTTP");
        if (helpReq) {
            helpReq.onreadystatechange = processHelp;
            helpReq.open("GET", urlForHelp, true);   
			helpReq.setRequestHeader("location", url);
            helpReq.send('');
        }
    }
}

function openAssistanceWindow(link, windowName)
{
	var href, messageWindow;

	if (typeof(link) == 'string')
		href=link;
	else
		href=link.href;

	messageWindow = window.open('',windowName,'left=20,top=20,width=260,height=800,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1');
	if (messageWindow.location.href == 'about:blank')
	{
		messageWindow = window.open(href,windowName);
	}
	else
	{
		if (window.focus) {messageWindow.focus()}
	}
	return false;
}

function processHelp()
{
if(helpReq)
{
// if xmlhttp shows ""loaded""
if (helpReq.readyState==4)
  {
  // if ""OK""
  if (helpReq.status==200)
    {
	parseHelpResults();
    }
  else
    {
    alert("Problem retrieving help information");
    }
  }
 }
}

function parseHelpResults()
{
var div, helpHTML;
helpHTML = helpReq.responseText;
	try
	{	

		div = document.getElementById('helpContainer');
		if(div)
		{
			div.innerHTML = helpHTML;
		}
	}
	catch(e){}
}

function closeHelp()
{
	var div;
	try
	{	
		hidediv('helpContainer');
	}
	catch(e){}
}

function showAnswer(id){
var questions;
questions=document.getElementById('helpContainer').getElementsByTagName("span");
 for (var i=0; i < questions.length; i++)
  {
	if (questions.item(i).className.indexOf('answer') != -1)
	{
		hidediv(questions.item(i).id);
	}
  }

showdiv('_a_' + id);
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}