// initialise the howdoi_popup helpWin avail and obtain variable used when checking existence
var howdoi_popup = null;
var helpWin = null;

//========================== How Do I and Help Functions ================================

function getTitle(helpDir)
{
	var title = "WebSPIRS - ";
	if (helpDir == "assistance/en")
	{
		title += "How Do I?";
	}
	else if (helpDir == "assistance/fr")
	{
		title += "Comment puis-je ?";
	}
	else if (helpDir == "assistance/de")
	{
		title += "Wie kann ich...?";
	}
	else if (helpDir == "assistance/es")
	{
		title += "¿Cómo...?";
	}
	else if (helpDir == "assistance/it")
	{
		title += "?????";
	}
	return title;
}


// function to create howdoi_popup frameset
function createHowdoiFrameset(offset, filename, helpDir)	{
    var thePath = offset + helpDir + "/howdoi/";
	//alert("In createHowdoiFrameset. Path = " + thePath + ". filename = " + filename);
	var windowprops = "height=400,width=260,location=no,directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=yes,left=100,top=100,screenX=100,screenY=100";
	howdoi_popup = window.open("","howDoI",windowprops);
	howdoi_popup.document.open();
	howdoi_popup.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"> ');
	howdoi_popup.document.write('<html><head><title>' + getTitle(helpDir) + '</title></head>');
	howdoi_popup.document.write('<frameset rows="45,*" framespacing="0" border="0" frameborder="0">');
	howdoi_popup.document.write('<frame name="howdoi_top" src="' + thePath + 'top_bar.htm" scrolling="no">');
	howdoi_popup.document.write('<frame name="howdoi_content" src="' + thePath + filename + 
								'" scrolling="auto" target="_self"></frameset></html>');
	howdoi_popup.document.close();
	howdoi_popup.opener=window;
}

// function to take input from howdoi selection box and create or change howdoi_popup window
function openHowDoIFromForm(form, helpDir)
{
    if (form.main.selectedIndex > 0)
    {
        openHowDoI("", form.main.options[form.main.selectedIndex].value, helpDir);
        // Reset index to show How Do I? again - allows redisplay after
        // viewing a page then closing it
        form.main.selectedIndex = 0;
    }
}

function openHowDoI(offset, doc, helpDir)
{
    var theUrl = offset + helpDir + '/howdoi/';
    if (doc != 'none')	{
	    if (howdoi_popup == null)	{
   			createHowdoiFrameset(offset, doc, helpDir)
		}
		else if (howdoi_popup.closed == true)	{
			createHowdoiFrameset(offset, doc, helpDir)
		}
		else	{
			howdoi_popup.frames[1].location.href = theUrl+doc;
		}
	}
	howdoi_popup.focus();
}

//function to open help window
function openHelp(offset, helpDir)	{
    var location = offset + helpDir + "/help/wwhelp/js/html/frames.htm";
	var helpprops;
    // If on a mac and not using IE then show status bar as netscape has a bug
    // displaying the scroll bars without this.
	if ((navigator.platform == "MacPPC" || navigator.platform == "Mac68k") &&
	    (navigator.userAgent.indexOf("MSIE") == -1))
	{
	    helpprops = "height=500,width=740,location=no,directories=no,location=no,menubar=no,status=yes,toolbar=no,resizable=yes,left=30,top=30,screenX=100,screenY=500";
	}
	else
	{
	    helpprops = "height=500,width=740,location=no,directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=yes,left=30,top=30,screenX=100,screenY=500";
	}
	
	helpWin = window.open(location,"helpWin",helpprops);
	helpWin.opener=window;
	helpWin.focus();
}

// function to close howdoi_popup and start open help function
function helpWindow(offset, helpDir)	{
	closeHelp();
	if (howdoi_popup == null)	{
   		openHelp(offset, helpDir);
	}
	else if (howdoi_popup.closed == true)	{
		openHelp(offset, helpDir);
	}
	else	{
		//top.howdoi_popup.close();
		openHelp(offset, helpDir);
	}
}

// function to close the help window
function closeHelp()	{
	if (helpWin == null)	{
	}
	else if (helpWin.closed == true)	{
	
	}
	else {
	
	top.helpWin.close();
	}
}


