var g_httpCgiUrl = "/wcm/idcplg?IdcService=SS_GET_PAGE&";

/////////////////////////////////////////////////////////////////////////////
// Function : NavNode (constructor)
// Comments :
/////////////////////////////////////////////////////////////////////////////
function NavNode(id, label, href, parent)
{
	this.m_parent = null;
	this.m_level = 0;

	if (parent)
	{
		this.m_parent = parent;
		this.m_level = parent.m_level+1;
	}

	this.m_id = id;

	// assume that m_label will most often be used directly as HTML
	this.m_rawlabel = label;

	label = label.replace(/&/g, '&amp;');
	label = label.replace(/</g, '&lt;');
	label = label.replace(/>/g, '&gt;');
	label = label.replace(/"/g, '&quot;');

	this.m_label = label;

	this.m_href = href;
	this.m_subNodes = new Array();

	var argValues = NavNode.arguments;
	var argCount = NavNode.arguments.length;

	for (i = 4 ; i < argCount ; i++)
	{
		var attrName = argValues[i].split("==")[0];
		var attrValue = argValues[i].split("==")[1];

		eval("this.cp_" + attrName + " = '" + attrValue + "';");
	}

	NavNode.prototype.addNode = addNode;
	NavNode.prototype.isSelected = isSelected;
}

/////////////////////////////////////////////////////////////////////////////
// Function : addNode
// Comments :
/////////////////////////////////////////////////////////////////////////////
function addNode(id, label, href)
{
	var newIndex = this.m_subNodes.length;
	var newNode = new NavNode(id, label, href, this);

	var argValues = addNode.arguments;
	var argCount = addNode.arguments.length;

	for (i = 3 ; i < argCount ; i++)
	{
		var attrName = argValues[i].split("==")[0];
		var attrValue = argValues[i].split("==")[1];

		eval("newNode.cp_" + attrName + " = '" + attrValue + "';");
	}

	this.m_subNodes[newIndex] = newNode;
	return newNode;
}

/////////////////////////////////////////////////////////////////////////////
// Function : isSelected
// Comments :
/////////////////////////////////////////////////////////////////////////////
function isSelected()
{
    var pos = window.location.href.lastIndexOf("/");
    var docname = window.location.href.substring(pos+1, window.location.href.length);

    pos = this.m_href.lastIndexOf("/");
    var myname = this.m_href.substring(pos+1, this.m_href.length);

    if (docname == myname)
		return true;
	else
		return false;
}

/////////////////////////////////////////////////////////////////////////////
// Function : isTrue
// Comments :
/////////////////////////////////////////////////////////////////////////////
function isTrue( boolStr )
{
	if( boolStr.length > 0 )
	{
		var boolChar = boolStr.substring(0,1).toUpperCase();
		if( ( boolChar == '1' ) || ( boolChar == 'T' ) )
		{
			return true;
		}
	}

	return false;
}

/////////////////////////////////////////////////////////////////////////////
// Function : customSectionPropertyExists
// Comments :
/////////////////////////////////////////////////////////////////////////////
function customSectionPropertyExists(csp)
{
	return (typeof csp != _U && csp != null);
}

/////////////////////////////////////////////////////////////////////////////
// Function : getCustomSectionProperty
// Comments :
/////////////////////////////////////////////////////////////////////////////
function getCustomSectionProperty(csp)
{
	if (customSectionPropertyExists(csp))
	{
		return csp;
	}
	else
	{
		return "";
	}
}

/////////////////////////////////////////////////////////////////////////////
// Function : link
// Comments :
/////////////////////////////////////////////////////////////////////////////
function link(dDocName,ssTargetNodeId)
{
	if ((dDocName.search("http://") != -1) || (dDocName.search("https://") != -1))
		window.open(dDocName);
	else
	{
		var newUrl = "";
		newUrl += g_httpCgiUrl;
		newUrl += "ssDocName=" + dDocName;

		var currentUrl = "" + window.location;

		// Continue propagation of the "SSContributor" parameter
		if( SSContributor )
		{
			var paramName = "SSContributor=";
			var pos = currentUrl.indexOf( paramName );
			if( pos != -1 )
			{
				var subStr = currentUrl.substring( pos+paramName.length, pos+paramName.length+1 );
				if( isTrue( subStr ) )
				{
					newUrl += "&" + paramName + "true";
				}
			}
		}

		// Continue propagation of the "previewId" parameter
		var previewId = "previewId=";
		var posStart = currentUrl.indexOf( previewId );
		if( posStart != -1 )
		{
			var posEnd = currentUrl.indexOf("&", posStart);
			var value = "";
			if (posEnd == -1)
			{
				value = currentUrl.substring(posStart+previewId.length, currentUrl.length);
			}
			else
			{
				value = currentUrl.substring(posStart+previewId.length, posEnd);
			}
			newUrl += "&" + previewId + value;
		}

		// We now always add the node that the link is on as part of the URl also.
		if( g_ssSourceNodeId != _U && g_ssSourceNodeId != null )
			newUrl += "&ssSourceNodeId=" + g_ssSourceNodeId;

		// If we have a specific target nodeId then add that to the URL also
		if( ssTargetNodeId != _U && ssTargetNodeId != null )
			newUrl += "&ssTargetNodeId=" + ssTargetNodeId;

		// Navigate to the new url
		window.location = newUrl;
	}
}

/////////////////////////////////////////////////////////////////////////////
// Function : nodelink
// Comments :
/////////////////////////////////////////////////////////////////////////////
function nodelink(nodeId)
{
	var newUrl = "";
	newUrl += g_httpCgiUrl;
	newUrl += "nodeId=" + nodeId;

	var currentUrl = "" + window.location;

	// Continue propagation of the "SSContributor" parameter
	if( SSContributor )
	{
		var paramName = "SSContributor=";
		var pos = currentUrl.indexOf( paramName );
		if( pos != -1 )
		{
			var subStr = currentUrl.substring( pos+paramName.length, pos+paramName.length+1 );
			if( isTrue( subStr ) )
			{
				newUrl += "&" + paramName + "true";
			}
		}
	}

	// Continue propagation of the "previewId" parameter
	var previewId = "previewId=";
	var posStart = currentUrl.indexOf( previewId );
	if( posStart != -1 )
	{
		var posEnd = currentUrl.indexOf("&", posStart);
		var value = "";
		if (posEnd == -1)
		{
			value = currentUrl.substring(posStart+previewId.length, currentUrl.length);
		}
		else
		{
			value = currentUrl.substring(posStart+previewId.length, posEnd);
		}
		newUrl += "&" + previewId + value;
	}

	// We now always add the node that the link is on as part of the URl also.
	if( g_ssSourceNodeId != _U && g_ssSourceNodeId != null )
		newUrl += "&ssSourceNodeId=" + g_ssSourceNodeId;

	// Navigate to the new url
	window.location = newUrl;
}
/////////////////////////////////////////////////////////////////////////////
var g_navNode_Root = new NavNode('760','TCC','javascript:cnslink(0)',null);
g_navNode_1=g_navNode_Root.addNode('761','Report\x20a\x20Barrier','javascript:cnslink(1)','secondaryUrlVariableField==region8');
g_navNode_2=g_navNode_Root.addNode('762','Trade\x20Agreements','javascript:cnslink(2)','resultcount==500','tccQuery==dDocType\x20\x3csubstring\x3e\x20\x60TradeAgreement\x60\x20\x20\x3cAND\x3e\x20\x20dSecurityGroup\x20\x3csubstring\x3e\x20\x60Tcc\x60\x20\x20\x3cAND\x3e\x20\x20xparentId\x20\x3cmatches\x3e\x20\x60\x60');
g_navNode_2_0=g_navNode_2.addNode('770','Exporters\x20Guides','javascript:cnslink(3)','tccSortColumn==dDocTitle','resultcount==500','tccQuery==dDocType\x20\x3cmatches\x3e\x20\x60ExportGuide\x60\x20\x20\x3cAND\x3e\x20\x20dSecurityGroup\x20\x3cmatches\x3e\x20\x60TradeDataAnalysis\x60\x20\x20\x3cAND\x3e\x20\x20dDocAccount\x20\x3cmatches\x3e\x20\x60TCC\x60\x20\x3cAND\x3e\x20\x3cNOT\x3e\x20xAgreementType\x20\x3cmatches\x3e\\x27Bilateral\x20Investment\x20Treaty\\x27');
g_navNode_2_1=g_navNode_2.addNode('779','All\x20Trade\x20Agreements','javascript:cnslink(4)','testcount==500','secondaryUrlVariableField==region8','tccSortColumn==dDocTitle','taQuery==dDocType\x20\x3csubstring\x3e\x20\x60TradeAgreement\x60\x20\x20\x3cAND\x3e\x20\x20xWebsites\x20\x3ccontains\x3e\x20\x60760\x60','resultcount==300','tccQuery==dDocType\x20\x3cmatches\x3e\x20\x60TradeAgreement\x60\x20\x20\x3cAND\x3e\x20\x20dSecurityGroup\x20\x3cmatches\x3e\x20\x60TradeDataAnalysis\x60\x20\x20\x3cAND\x3e\x20\x20dDocAccount\x20\x3cmatches\x3e\x20\x60TCC\x60\x20\x3cAND\x3e\x20xParent_ID\x20\x3cmatches\x3e\\x27\\x27');
g_navNode_2_2=g_navNode_2.addNode('786','Intellectual\x20Property\x20Rights','javascript:cnslink(5)','secondaryUrlVariableField==region8','tccSortColumn==dDocTitle','resultcount==500','tccQuery==dDocType\x20\x3cmatches\x3e\x20\x60TradeAgreement\x60\x20and\x20dSecurityGroup\x20\x3cmatches\x3e\x20\x60TradeDataAnalysis\x60\x20and\x20dDocAccount\x20\x3cmatches\x3e\x20\x60TCC\x60\x20and\x20xparentId\x20\x3cmatches\x3e\x20\\x27\\x27\x20and\x20xAgreementType\x20\x3cmatches\x3e\x20\\x27Intellectual\x20Property\x20Rights\\x27');
g_navNode_2_3=g_navNode_2.addNode('787','WTO\x20Agreements','javascript:cnslink(6)','secondaryUrlVariableField==region8','tccSortColumn==dDocTitle','resultcount==500','tccQuery==dDocType\x20\x3cmatches\x3e\x20\x60TradeAgreement\x60\x20and\x20dSecurityGroup\x20\x3cmatches\x3e\x20\x60TradeDataAnalysis\x60\x20and\x20dDocAccount\x20\x3cmatches\x3e\x20\x60TCC\x60\x20and\x20xparentId\x20\x3cmatches\x3e\x20\\x27\\x27\x20and\x20xAgreementType\x20\x3cmatches\x3e\x20\\x27WTO\\x27');
g_navNode_2_4=g_navNode_2.addNode('788','Free\x20Trade\x20Agreements','javascript:cnslink(7)','secondaryUrlVariableField==region8','tccSortColumn==dDocTitle','resultcount==500','tccQuery==dDocType\x20\x3cmatches\x3e\x20\x60TradeAgreement\x60\x20and\x20dSecurityGroup\x20\x3cmatches\x3e\x20\x60TradeDataAnalysis\x60\x20and\x20dDocAccount\x20\x3cmatches\x3e\x20\x60TCC\x60\x20and\x20xparentId\x20\x3cmatches\x3e\x20\\x27\\x27\x20and\x20xAgreementType\x20\x3cmatches\x3e\x20\\x27Free\x20Trade\\x27');
g_navNode_2_5=g_navNode_2.addNode('789','Preview\x20Free\x20Trade\x20Agreements','javascript:cnslink(8)','secondaryUrlVariableField==region8','tccQuery==dDocType\x20\x3csubstring\x3e\x20\x60TradeAgreement\x60\x20\x20\x3cAND\x3e\x20\x20dSecurityGroup\x20\x3csubstring\x3e\x20\x60Tcc\x60\x20\x20\x3cAND\x3e\x20\x20\x28xparentId\x20\x3cmatches\x3e\x20\x60\x60\x29');
g_navNode_2_6=g_navNode_2.addNode('790','Bilateral\x20Investment\x20Treaties','javascript:cnslink(9)','secondaryUrlVariableField==region8','tccSortColumn==dDocTitle','resultcount==500','tccQuery==dDocType\x20\x3cmatches\x3e\x20\x60TradeAgreement\x60\x20and\x20dSecurityGroup\x20\x3cmatches\x3e\x20\x60TradeDataAnalysis\x60\x20and\x20dDocAccount\x20\x3cmatches\x3e\x20\x60TCC\x60\x20\x3cAND\x3e\x20xParent_ID\x20\x3cmatches\x3e\\x27\\x27\x20and\x20xAgreementType\x20\x3cmatches\x3e\x20\\x27Bilateral\x20Investment\x20Treaty\\x27');
g_navNode_4=g_navNode_Root.addNode('764','Country\x20Market\x20Research','javascript:cnslink(10)','resultcount==0');
g_navNode_5=g_navNode_Root.addNode('765','Bribery','javascript:cnslink(11)');
g_navNode_6=g_navNode_Root.addNode('766','News','javascript:cnslink(12)','secondaryUrlVariableField==region8','resultcount==1');
g_navNode_7=g_navNode_Root.addNode('767','Search\x20TCC','javascript:cnslink(13)');
// introduced by connection server
var g_cnsnodes = new Array();
g_cnsnodes[0] = '/index.asp';
g_cnsnodes[1] = '/Report_a_Barrier/index.asp';
g_cnsnodes[2] = '/Trade_Agreements/index.asp';
g_cnsnodes[3] = '/Trade_Agreements/Exporters_Guides/index.asp';
g_cnsnodes[4] = '/Trade_Agreements/All_Trade_Agreements/index.asp';
g_cnsnodes[5] = '/Trade_Agreements/Intellectual_Property_Rights/index.asp';
g_cnsnodes[6] = '/Trade_Agreements/WTO_Agreements/index.asp';
g_cnsnodes[7] = '/Trade_Agreements/Free_Trade_Agreements/index.asp';
g_cnsnodes[8] = '/Trade_Agreements/Preview_Free_Trade_Agreements/index.asp';
g_cnsnodes[9] = '/Trade_Agreements/Bilateral_Investment_Treaties/index.asp';
g_cnsnodes[10] = '/Country_Market_Research/index.asp';
g_cnsnodes[11] = '/Bribery/index.asp';
g_cnsnodes[12] = '/News/index.asp';
g_cnsnodes[13] = '/Search_TCC/index.asp';
function cnslink(pageid) {
var newUrl = '';
newUrl += g_prefixToStaticRoot;
newUrl += g_cnsnodes[pageid];
window.location = newUrl;
}