/************************************************************************
 * Copyright (C) 2003 Cognos Incorporated. All Rights Reserved. 
 * Cognos and the Cognos logo are trademarks of Cognos Incorporated.
 ************************************************************************/
//<script>
//-- Browser detection 
var isNS = false; isIE = false;
navigator.appName == "Netscape" ? isNS = true : isIE = true;

var windowHelp = null;

function getHelp(sTopic, sSection)
{
	popup('/cognos/cgi-bin/aide.html');
}

/*
function getHelp(sTopic, sSection)
{
	// ensure optional parameter is always a string
	sSection = sSection ? sSection : '';
   	
	// If gateways to BI providers are not defined, empty string will be used
  	var sCQPath = g_sCQPath ? g_sCQPath : '';
  	var sIWRPath = g_sIWRPath ? g_sIWRPath : '';
  	var sPPESPath = g_sPPESPath ? g_sPPESPath : '';
  	var sCogVizPath = g_sCogVizPath ? g_sCogVizPath : '';

 	var sFeatures = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=450,height=440";

 	var sURL = g_sUserHelpPath + "/upf_ug_hlp_mn.html#topic=" + sTopic + "&section="  + sSection + "&cq=" + sCQPath + "&iwr=" + sIWRPath + "&ppes=" + sPPESPath + "&viz=" + sCogVizPath;
  	
	// opens a help window if one is not already open
	windowHelp = window.open(sURL, "helpwindow", sFeatures);
	
	// To make sure that the topic is updated, if the help window was already open	
	if (windowHelp.helpTopic)
	{
		windowHelp.helpTopic(sTopic, sSection, sCQPath, sIWRPath, sPPESPath, sCogVizPath);
		windowHelp.focus();
 	}
}
*/
 
function replace(target, oldTerm, newTerm, caseSens, wordOnly) 
{
	var work = target;
	var ind = 0;
	var next = 0;
	if (!caseSens) 
	{
		oldTerm = oldTerm.toLowerCase();
		work = target.toLowerCase();
	}
	while ((ind = work.indexOf(oldTerm,next)) >= 0) 
	{
		if (wordOnly) 
		{
			var before = ind - 1;
			var after = ind + oldTerm.length;
			if (!(space(work.charAt(before)) && space(work.charAt(after)))) 
			{
				next = ind + oldTerm.length;
				continue;
			}
   		}	
  		target = target.substring(0,ind) + newTerm + target.substring(ind+oldTerm.length,target.length);
		work = work.substring(0,ind) + newTerm + work.substring(ind+oldTerm.length,work.length);
		next = ind + newTerm.length;
   		if (next >= work.length) 
		{ 
			break; 
		}
  	}
	return target;
}

// Removes leading and trailing spaces
function trim(s)
{
	var j = s.length;
	for (var i = 0; i < j; i++)
		if (s.charAt(i) != ' ')
			break;
		
	if (i < j - 1)
		for (; j > i; j--)
			if (s.charAt(j - 1) != ' ')
				break;
		
	return s.substring(i, j);
}

function wrapInCDATA(s)
{
	return "<![CDATA[" + s + "]]>";
}

function getPage(s)
{
	return "<GetPage><Template>" + s + "</Template></GetPage>";
}

function formCommand(s, sMode)
{
	if (sMode == null)
		sMode = "nodebug";
	return "<FormCommand " +  ((sMode.toLowerCase() == "debug") ? "debug='true'" : "" ) + "><Template>" + s + "</Template></FormCommand>";
}

function ascendNum()
{
	var now = new Date();
	return now.getTime();
}
function popup(url)
{
	varpopup = window.open(url,"popup","width=420,height=380,scrollbars=yes");
	varpopup.focus();
}

function popupA(url)
{
	varpopup = window.open(url, '', 'toolbar=no,location=no,copyhistory=no');
	varpopup.focus();
}

function popupgrand(url)
{
	varpopup = window.open(url,"popupgrand","width=600,height=500,scrollbars=auto");
	varpopup.focus();
}

