// open a new window for help topics.

// helper variables needed to maintain the different windows

var newwin = '';
var standardwin = '';
var legalwin = '';
var glossarywin = '';

var standardWinName = 'help';
var legalWinName = 'AribaLegalWindow';
var glossaryWinName = 'AribaGlossaryWindow';

// helper function - does most of the grunt work in opening a new window

function newWindow(theURL,winName,features) {
    if (winName == glossaryWinName)
    {
        newwin = glossarywin;
    }
    else if (winName == legalWinName)
    {
        newwin = legalwin;
    }
    else
    {
        newwin = standardwin;
    }

	if (newwin.location && !newwin.closed)
	{
		newwin.location.href = theURL;
	}
	else
	{
		newwin=window.open(theURL,winName,features);
		if (!newwin.opener) newwin.opener = self;
	}
	if (window.focus) {newwin.focus()}

    if (winName == glossaryWinName)
    {
        glossarywin = newwin;
    }
    else if (winName == legalWinName)
    {
        legalwin = newwin;
    }
    else
    {
        standardwin = newwin;
    }
}

function resizeWindow(width, height) {

  window.resizeTo(width,height);
}

// functions to be used by the doc team to open new help windows

// standard size for how to, screen details, contents, index, search
function openStandard(theURL) {
    newWindow(theURL, standardWinName, "toolbar=yes,addressbar=no,scrollbars=yes,resizable=yes,width=668, height=400");
}

// custom size for legal notices 
function openLegal(theURL) {
    newWindow(theURL, legalWinName, "menubar=yes,addressbar=yes,scrollbars=yes,resizable=yes,width=550,height=400");
}

// custom size for glossary terms 
function openGlossary(theURL) {
    newWindow(theURL, glossaryWinName, "toolbar=no,scrollbars=yes,resizable=no,width=380, height=200");
}

// wrapper functions for the page hint

function openScreenDetails(theURL) {
    openStandard(theURL);
}

function openHowTo(theURL) {
    var isDebug = document.title.indexOf("ARWNLString");
    var i = document.title.indexOf(">") +1;
    var j = document.title.indexOf("<", i);
    var title;
    
    if (i>0 && j>0 && j-i>0 && isDebug!=-1) {
        title = document.title.substring(i, j);
        theURL += "&debug=" + title
    }

    openStandard(theURL);
}

function setTitle(title) {
  document.title=title;
}

function shutPrevious()
{
if (self.opener)
	{
	self.opener.blur();
	}
if (document.layers)
	{
	parent.blur();
	}
}
