//=====================================================================
// File:         cbd.js
// Version:      1.60
// Date:         2007-05-19
// Description:  Javascript Module
// Organization: Secretariat of the Convention on Biological Diversity
//=====================================================================

//=====================================================================
// List of Functions
//=====================================================================
// Main CBD Functions
// ------------------
// - function CBD_Context()
// - function CBD_GetCode(i_sType, i_sCode)
// - function CBD_WriteBox(i_sType, i_sInfo)
// - function CBD_WriteOptions(i_sType, i_sGroup, i_sLine1, i_sValues)
// - function CBD_UpdateOptions(i_sType, i_sGroup, i_sLine1, i_sValues, io_oSelect)
// - function CBD_CopyOptions(i_selFrom, io_selTo, i_sSelected)
// - OLD function CBD_WriteHeader(i_sOptions)
// - OLD function CBD_WriteFooter(i_sOptions, i_sUpdated)
// - function CBD_WriteMenu(i_sType, i_sHref, i_sText)
// - function CBD_WriteEmail(i_sEmail)
// - function CBD_WriteEmail2(i_sEmail, i_sText)

// Utility Functions
// -----------------
// - function U_W(i_sText)
// - function U_WL(i_sText)
// - function U_Set(io_idVal, i_sVal)
// - function U_SetGo(io_idVal, i_sVal)
// - function U_Return(i_bOK)
// - function U_Left(i_sText, i_iLength)
// - function U_Right(i_sText, i_iLength)
// - function U_Mid(i_sText, i_iStart, i_iLength)
// - function U_Contains(i_sList, i_sText, i_sSep)
// - function U_StartsWith(i_sText, i_sStart)
// - function U_Replace(i_sText, i_sOld, i_sNew)
// - function U_IsOK(i_sValue)
// - function U_IfOK(i_sValue, i_sText)
// - function U_YesNo(i_sMsg)
// - function U_Go(i_sHref)
// - function U_Redirect(i_sFrom, i_sTo)
// - function U_L2(i_sNr)
// - function U_RomanToDigit(i_sNr)
// - function U_Break(i_sText)
// - function U_BreakElement(io_elt)
// - function U_ShowIf(io_idShow, i_idIf)
// - function U_ShowIfElement(io_eltShow, i_eltIf)
// - function U_ShowHide(i_btnId, i_txtId, i_cmdTxt)
// - function U_ShowWhen(i_bWhen, i_ctlId)
// - function U_ShowRows(i_sel, i_ctlGroupId, i_aRows)

// ID Functions
// ------------
// - function ID_Get(i_id)
// - function ID_GetValue(i_id)

// Date Functions
// --------------
// - function DATE_GetMonthName(i_dt)
// - function DATE_IsDMY(i_sDMY, i_bAlert)
// - function DATE_ToDMY(i_dt)
// - function DATE_ToYMD(i_dt)
// - function DATE_FromDMY(i_sDMY, i_bAlert)
// - function DATE_FromYMD(i_sYMD)

// Form Processing Functions
// -------------------------
// - function FORM_GetRequest(i_sParam)
// - function FORM_GetParam(i_aNames, i_aValues, i_sName)
// - function FORM_GetParams(o_aNames, o_aValues)
// - function FORM_GetQueryStringWithout(i_sParam)

// Window Creation Functions
// -------------------------
// - function WIN_Popup(i_sHref)
// - function WIN_Popup2(i_sHref, i_iWidth, i_iHeight)
// - function WIN_Open(i_sHref)

// Navigator Information Functions
// -------------------------------
// - function NAV_IsOK()
// - function NAV_WriteMaxWidth(i_bAlways)
// - function NAV_MaxWidth(i_bAlways)
// - function NAV_AddHeight(i_iHeight)
// - function NAV_RowLine(i_iColSpan, i_sBgColor)
// - function NAV_IsIE5()
// - function NAV_IsNS5()
// - function NAV_IsOldIE()
// - function NAV_IsIE(i_iVer)
// - function NAV_IsNS(i_iVer)
// - function NAV_Get()

// List Processing Functions
// -------------------------
// - function LIST_GetSelections(i_select, i_bMultiData)
// - function LIST_IsMatch(i_sSelections, i_sData, i_bMultiData)

// XML Processing Functions
// ------------------------
// - function XML_GetDoc(i_sUrl)
// - function XML_GetRoot(i_sUrl)
// - function XML_GetElements(i_xmlDoc, i_sTag)
// - function XML_Move(io_rs, i_sMove)
// - function XML_FindRecord(io_rs, i_sField, i_sValue)
// - function XML_FindRecord_ns(i_xRoot, i_sTag, i_sValue)
// - function XML_GetValue(i_sTag, i_bIE5, i_rs, i_xRecord)
// - function XML_GetValue_ns(i_sTag, i_xRecord)
// - function XML_IsMatch(i_sSelections, i_sTag, i_bMultiData, i_bIE5, i_rs, i_xRecord)
// - function XML_SetOptions(i_selID, i_xmlID, i_sQS, i_sValueTag, i_sTextTag)
// - function XML_SetOptions_ns(i_selID, i_sUrl, i_sQS, i_sValueTag, i_sTextTag)


//=====================================================================
// Javascript Global Initializations
//=====================================================================
var j_ctx = new CBD_Context();

//=====================================================================
// Compatibility layer for old names
//=====================================================================
function cbd_header(i_sLangCode, i_sOptions) { 
    CBD_WriteHeader(i_sOptions); 
}
function cbd_footer(i_sLangCode, i_sUpdated, i_sContact, i_sContactHref) { 
    CBD_WriteFooter("", i_sUpdated); 
}
function cbd_box(i_sType, i_sInfo) { 
    CBD_WriteBox(i_sType, i_sInfo);
}
function cbd_menu(i_sType, i_sHref, i_sText) {
    CBD_WriteMenu(i_sType, i_sHref, i_sText);
}
function cbd_options(i_sType, i_sGroup, i_sLine1, i_sValues) {
    CBD_WriteOptions(i_sType, i_sGroup, i_sLine1, i_sValues); 
}
function cbd_ShowHide(i_btnId, i_txtId, i_cmdTxt) {
	   U_ShowHide(i_btnId, i_txtId, i_cmdTxt);
}
function email     (i_sEmail) 	{ CBD_WriteEmail(i_sEmail); }
function cbd_email (i_sEmail) 	{ CBD_WriteEmail(i_sEmail); }
function cbd_open  (i_sHref) 	{ WIN_Open  (i_sHref); }
function popup     (i_sHref)	{ WIN_Popup (i_sHref); }
function cbd_popup (i_sHref) 	{ WIN_Popup (i_sHref); }
function popup2    (i_sHref) 	{ WIN_Popup2(i_sHref, i_iWidth, i_iHeight); }
function cbd_popup2(i_sHref) 	{ WIN_Popup2(i_sHref, i_iWidth, i_iHeight); }
function go        (i_sHref)	{ U_Go      (i_sHref); }
function cbd_go    (i_sHref) 	{ U_Go      (i_sHref); }
function cbd_confirm(i_sMsg)    { U_YesNo(i_sMsg); }


//=====================================================================
// Main CBD Functions
//=====================================================================
//---------------------------------------------------------------------
// CBD_Context
//---------------------------------------------------------------------
function CBD_Context() {

	// URL info
	this.sHref       = ''+window.location.href;
	this.sHost       = ''+window.location.host;
	this.sPath       = ''+window.location.pathname;
	this.sSearch     = (''+window.location.search).slice(1);
	this.sPathSearch = ''+window.location.pathname + window.location.search;

	// Navigator info
	this.sNavName    = navigator.appName;
	this.sNavVersion = navigator.appVersion;
	this.bIE5        = NAV_IsIE(5);
	this.bNS5        = NAV_IsNS(5);
	this.bNavOK      = NAV_IsOK();

	// Language info
	var rLg = ''+U_GetParam('lg');
	switch(rLg.toLowerCase()) {
	case '1': case 'es': 
		this.iLang     = 1; 
		this.qsLang    = '?lg=1';
		this.qsLangAnd = '?lg=1&';
	break;
	case '2': case 'es': 
		this.iLang = 2; 
		this.qsLang    = '?lg=2';
		this.qsLangAnd = '?lg=2&';
	break;
	default:             
		this.iLang = 0;
		this.qsLang    = '';
		this.qsLangAnd = '?';
	}
	this.asLangCodes = new Array("en","es","fr");
	this.sLangCode   = this.asLangCodes[this.iLang];

	// Final check
	if (0<this.sPath.indexOf('/ok-test.asp')) {
//		alert('');
	}
return this;
}

//---------------------------------------------------------------------
// CBD_GetCode(i_sCode)
//---------------------------------------------------------------------
function CBD_GetCode(i_sType, i_sCode) {
var o_sCode='';
	if (U_IsOK(i_sCode)) {
		var sCode =  (''+i_sCode).replace(/\\/g,'/');
		var aNr = sCode.split('/');
		var sNr1 = U_RomanToDigit(aNr[0]); 
		var sNr2 = U_L2(aNr[1]); 
		switch(i_sType) {
		case 'COP'   : o_sCode='COP-'    + sNr1 + '-DEC-' + sNr2 ; break;
		case 'SBSTTA': o_sCode='SBSTTA-' + sNr1 + '-REC-' + sNr2 ; break;
		}
	}
return o_sCode;
}


//---------------------------------------------------------------------
// Write a box
//---------------------------------------------------------------------
function CBD_WriteBox(i_sType, i_sInfo) {
var o_sHtml = "";
var sPfx = "";

	switch (i_sType) {

	// Rounded-Corner Search Box
	// -------------------------
	case 'BB-CD': sPfx=".."; // Box Begin with CD-ROM Adjustment
	case 'BB': 		 // Box Begin
		o_sHtml = "\n <table class='Box' cellSpacing='0' cellPadding='0' align='center'>"
			+ "\n <tr><td class='BoxCorner' valign='top' align='left' width='16'><table border='0' cellpadding='0' cellspacing='0'>"
			+ "\n   <tr><td valign='top' align='left' ><img src='"+sPfx+"/images/rnd-top-left.gif'  border='0' align='top' ></td></tr>"
			+ "\n </table></td><td class='BoxTitle' valign='top' >"
			+ i_sInfo
			+ "\n </td><td class='BoxCorner' valign='top' align='right' width='16'><table border='0' cellpadding='0' cellspacing='0'>"
			+ "\n   <tr><td valign='top' align='right'><img src='"+sPfx+"/images/rnd-top-right.gif' border='0' align='top' ></td></tr>"
			+ "\n </table></td></tr>"
			+ "\n <tr><td>&nbsp;</td><td valign='top' align='left'>"

	break;
	case 'BE-CD': sPfx=".."; // Box End with CD-ROM Adjustment
	case 'BE': 		 // Box End
		o_sHtml = "\n </td><td>&#160;</td></tr>"
			+ "\n <tr><td valign='bottom' align='left'><table  border='0' cellpadding='0' cellspacing='0'>"
			+ "\n   <tr><td valign='bottom' align='left' ><img src='"+sPfx+"/images/rnd-bot-left.gif'  border='0' align='bottom' ></td></tr>"
			+ "\n </table></td><td>&#160;</td>"
			+ "\n <td valign='bottom' align='right'><table border='0' cellpadding='0' cellspacing='0'>"
			+ "\n   <tr><td valign='bottom' align='right'><img src='"+sPfx+"/images/rnd-bot-right.gif' border='0' align='bottom' ></td></tr>"
			+ "\n </table></td></tr></table> &nbsp;"
	break;

	// Right Box
	// ---------
	case 'RBB': // Right Box Begin
		o_sHtml = "\n <table class='RightBox' cellspacing='0'>"
				+ "\n <tr><td class='RightBoxTitle' valign='top'>"
				+ i_sInfo
				+ "\n </td></tr>"
				+ "\n <tr><td width='100%' valign='top' class='RightBox'>";
	break;
	case 'RBE': // Right Box End
		o_sHtml = "\n </td></tr>"
				+ "\n </table>"
				+ "\n &nbsp;<br>";
	break;

	}

	document.writeln(o_sHtml);
	return true;
}

//---------------------------------------------------------------------
// CBD_WriteOptions (requires cbd-lists-en.js)
//---------------------------------------------------------------------
function CBD_WriteOptions(i_sType, i_sGroup, i_sLine1, i_sValues) {
var aList = new cbd_list(i_sType);
var bGroup = (0<(i_sGroup).length);
var bValues = (0<(i_sValues).length);
var sSel;
var i;
var aOpt;
var bOpt = false;

	if (0<(i_sLine1).length) {
		document.write( "\n\t<option value=''>&lt;" + i_sLine1 + "&gt;</option>" );
	}

	for (i=0; i<aList.length; i++) {
		aOpt = aList[i].split('|');
		if (bGroup)  { 
			bOpt = 0<=aOpt[2].indexOf(i_sGroup); 
		} else { 
			bOpt=true; 
		}
		if (bOpt) { 
			if (bValues) { 
				sSel = ( 0<=(' '+i_sValues+' ').indexOf(' '+aOpt[0]+' ') ? ' selected ' : ''); 
			} else { 
				sSel=''; 
			}
			document.write("\n\t<option value='"+aOpt[0]+"'"+sSel+">"+aOpt[1]+"</option>"); 
		}
	} 
}

//---------------------------------------------------------------------
// CBD_UpdateOptions (requires cbd-lists-en.js)
//---------------------------------------------------------------------
function CBD_UpdateOptions(i_sType, i_sGroup, i_sLine1, i_sValues, io_oSelect) {
var aList = new cbd_list(i_sType);
var bGroup = (0<(i_sGroup).length);
var bValues = (0<(i_sValues).length);
var bSel = false;
var i=0;
var j=0;
var aOpt;
var bOpt = false;
// alert('target='+io_oSelect.name+ ' group='+i_sGroup);

	// Delete existing options
	io_oSelect.options.length = 0;

	// First option
	if (0<(i_sLine1).length) { io_oSelect.options[0] = new Option("<" + i_sLine1 + ">", ''); }

	// Other options
	for (i=0; i<aList.length; i++) {
		aOpt = aList[i].split('|');
		if (bGroup)  { 
			bOpt = 0<=aOpt[2].indexOf(i_sGroup); 
		} else { 
			bOpt=true; 
		}
		if (bOpt) { 
			if (bValues) { 
				bSel = ( 0<=(' '+i_sValues+' ').indexOf(' '+aOpt[0]+' ') ? true : false); 
			} else { 
				bSel=false; 
			}
			j++;
			io_oSelect.options[j] = new Option(aOpt[1], aOpt[0], false, bSel); 
		}
	} 
}

//---------------------------------------------------------------------
// CBD_CopyOptions
//---------------------------------------------------------------------
function CBD_CopyOptions(i_selFrom, io_selTo, i_sSelected) {
var i=0;
var bSel=false;
	io_selTo.options.length = 0;
	for (i=0; i<i_selFrom.options.length; i++) {
		bSel = ( i_selFrom.options[i].value==i_sSelected ? true : false ); 
		io_selTo.options[i] = new Option(i_selFrom.options[i].text, i_selFrom.options[i].value, false, bSel); 
	} 
}

//---------------------------------------------------------------------
// CBD_WriteHeader
//---------------------------------------------------------------------
function CBD_WriteHeader(i_sOptions) {
var o_sHtml = "";
var asTx;
var iTx = 0;
var qsLg    = '';
var qsLgAnd = '';
var qsLgEn  = '';
var qsLgEs  = '';
var qsLgFr  = '';
var qsNoLg  = U_RemoveParam('lg');
var bLang   = (0<=(''+i_sOptions).toUpperCase().indexOf('L'));
var bWeb    = (0<=(''+i_sOptions).toUpperCase().indexOf('W'));
var bIntra  = (0<=(''+i_sOptions).toUpperCase().indexOf('I'));
var bIntern = (0<=j_ctx.sPath.indexOf('/internal/'));
var bBanner = !(0<=(''+i_sOptions).toUpperCase().indexOf('B'));
var sLang   = '';
var sWeb    = '';
var sIntra  = '';
var c    = "";
var c1   = "";
var c2   = "";
var s2   = "";
var sIn  = "";
var sBut = "";
var sep1 = "";
var sep2 = "";
var bg1  = "";
var bg2  = "";
var f1b  = "";
var f2b  = "";
var fe   = "";
var trW5 = "";
var trG5 = "";
var trG1 = "";

	if (j_ctx.bNavOK) {
		c  = " class='TopMenu' ";
		c1 = " class='TopMenuLine1' ";
		c2 = " class='TopMenuLine2' ";
		s2 = " style='PADDING-TOP: 2px; PADDING-BOTTOM: 2px;' ";
		sIn= " style='height: 13pt; font-size:8pt;' ";
		sBut= " style='height: 14pt; font-size: 8pt;' ";
		sep1 = "&nbsp;|&nbsp;";
		sep2 = "&nbsp;|&nbsp;";
	} else {
		bg1  = " bgcolor='#656D5B' ";
		bg2  = " bgcolor='#FFFFFF' ";
		f1b = "<font color='#FFFFFF'>";
		f2b = "<font color='#656D5B'>";
		fe  = "</font>"

		c1 = bg1 + " valign='bottom' ";
		c2 = bg2;
		sep1 = "&nbsp;"+f1b+"|"+fe+"&nbsp;";
		sep2 = "&nbsp;"+f2b+"|"+fe+"&nbsp;";

		trW5 = NAV_RowLine(5,'#FFFFFF');
		trG5 = NAV_RowLine(5,'#656D5B');
		trG1 = NAV_RowLine(1,'#656D5B');
	}

	if (bWeb) {
		var hWeb  = (bWeb ? 'http://www.biodiv.org'+j_ctx.sPathSearch : '');
		sWeb = "&nbsp;<a "+c2+" href='" + hWeb + "'>"+f2b+"WWW"+fe+"</a>&nbsp;" ;
	}

	if (bIntra) {
		var hIntra  = (bIntra ? 'http://intranet.biodiv.org'+j_ctx.sPathSearch : '');
		sIntra = "&nbsp;<a  "+c2+" href='" + hIntra + "'>"+f2b+"INTRANET"+fe+"</a>&nbsp;";
	}
	if (bIntern) {
		sWeb = "&nbsp;<a "+c2+" href='http://www.biodiv.org/'>"+f2b+"WWW"+fe+"</a>&nbsp;" ;
	}
	switch(j_ctx.iLang) {
	case 1:
		qsLg='?lg=1';
		qsLgAnd='?lg=1&';
		if (U_IsOK(qsNoLg)) {
			qsLgEn = '?'+qsNoLg;
			qsLgFr = '?lg=2&'+qsNoLg;
		} else {
			qsLgEn = j_ctx.sPath;
			qsLgFr = '?lg=2';
		}

		asTx = new Array( "Secretariat del Convenio sobre la Diversidad Biol&oacute;gica", "Ir", "BUSCAR POR:",
			"INICIO", "CONVENIO", "PROT&Oacute;COLO", "DECISIONES", "PROGRAMAS",
			"CHM", "BCH", "PARTICIPACI&Oacute;N", "SECRETARIA", "DOCUMENTOS", "REUNIONES", "MAPA DEL SITIO");
		if (bLang) { 
			sLang =   "<a "+c2+"' href='"+qsLgEn+"'>"+f2b+"ENGLISH"+fe+"</a>&nbsp;&nbsp;"
				+ "<a "+c2+"' href='"+qsLgFr+"'>"+f2b+"FRAN&Ccedil;AIS"+fe+"</a>&nbsp;"
		}
	break;
	case 2:
		qsLg='?lg=2';
		qsLgAnd='?lg=2&';
		if (U_IsOK(qsNoLg)) {
			qsLgEn = '?'+qsNoLg;
			qsLgEs = '?lg=1&'+qsNoLg;
		} else {
			qsLgEn = j_ctx.sPath;
			qsLgEs = '?lg=1';
		}
		asTx = new Array( "Secr&eacute;tariat de la Convention sur la Diversit&eacute; Biologique", "Aller", "RECHERCHER:",
			"Accueil", "Convention", "Protocole", "D&eacute;cisions", "Programmes",
			"CHM", "BCH", "PARTICIPATION", "SECR&Eacute;TARIAT", "DOCUMENTS", "R&Eacute;UNIONS", "PLAN DU SITE");
		if (bLang) { 
			sLang =   "<a "+c2+"' href='"+qsLgEn+"'>"+f2b+"ENGLISH"+fe+"</a>&nbsp;&nbsp;"
				+ "<a "+c2+"' href='"+qsLgEs+"'>"+f2b+"ESPA&Ntilde;OL"+fe+"</a>&nbsp;"
		}
	break;
	default:
		qsLg='';
		qsLgAnd='?';
		if (U_IsOK(qsNoLg)) {
			qsLgEs = '?lg=1&'+qsNoLg;
			qsLgFr = '?lg=2&'+qsNoLg;
		} else {
			qsLgEs = '?lg=1';
			qsLgFr = '?lg=2';
		}
		asTx = new Array( "Secretariat of the Convention on Biological Diversity", "Go", "SEARCH FOR:",
			"HOME", "CONVENTION", "PROTOCOL", "DECISIONS", "PROGRAMMES",
			"CHM", "BCH", "PARTICIPATION", "SECRETARIAT", "DOCUMENTS", "MEETINGS", "SITE MAP");
		if (bLang) { 
			sLang =   "<a "+c2+"' href='"+qsLgEs+"'>"+f2b+"ESPA&Ntilde;OL"+fe+"</a>&nbsp;&nbsp;"
				+ "<a "+c2+"' href='"+qsLgFr+"'>"+f2b+"FRAN&Ccedil;AIS"+fe+"</a>&nbsp;"
		}
	}


	for (iTx=2; iTx < 8; iTx++) {
		asTx[iTx] = "<font color='#FFFFFF'><b>"+asTx[iTx]+"</b></font>";
	}
	for (iTx=8; iTx < asTx.length; iTx++) {
		asTx[iTx] = "<font color='#656D5B'><b>"+asTx[iTx]+"</b></font>";
	}		

	o_sHtml = "<table cellspacing='0' cellpadding='0' border='0' width='100%'>";
	
	if(bBanner)
	{
		o_sHtml += "\n <tr width='100%'>" 
				+ "\n <td><a name='top'><img name='banner' border='0' src='/images/ban-cbd-"+j_ctx.sLangCode+".jpg' " 
				+ "\n 	alt='"+asTx[0]+"' width='670' height='90' ></a></td>" 
				+ "\n </tr>";
	}

	o_sHtml += "\n <tr width='100%'>" 
		+ "\n <td>" 
		+ "\n 	<table "+c+" border='0' cellspacing='0' cellpadding='1' width='100%'>" 
		+ "\n" + trG5 
		+ "\n 	<tr width='100%'>" 
		+ "\n 	<td "+c1+" nowrap='nowrap'>&nbsp;" 
		+ "\n 		<a "+c1+" href='/"+qsLg+"'>"                       +asTx[3]+"</a>"+sep1
		+ "\n 		<a "+c1+" href='/convention/articles.asp"+qsLg+"'>"+asTx[4]+"</a>"+sep1
		+ "\n 		<a "+c1+" href='/biosafety/'>"                     +asTx[5]+"</a>"+sep1
		+ "\n 		<a "+c1+" href='/decisions/"+qsLg+"'>"             +asTx[6]+"</a>"+sep1
		+ "\n 		<a "+c1+" href='/programmes/"+qsLg+"'>"            +asTx[7]+"</a>" 
		+ "\n 	</td>" 
		+ "\n 	<td "+c1+" colspan='2' nowrap='nowrap' align='right' >" 
		+ "\n 		"+asTx[2]+"&nbsp;" 
		+ "\n 	</td>" 
		+ "\n 	<td "+c1+" nowrap='nowrap' align='left' valign='middle' width='100'>" 
		+ "\n 		<input type='text' name='qu' size='10' " + sIn 
		+ "\n 		onkeyup=\" if( (13==event.which || 13==event.keyCode) && (0<this.value.length) ) { top.location='http://www.biodiv.org/search/default.aspx"+qsLgAnd+"qu='+this.form.qu.value; } \" >&nbsp;" 
		+ "\n 	</td>" 
		+ "\n 	<td "+c1+" nowrap='nowrap' align='left' valign='middle'>" 
		+ "\n 		<input type='button' "+sBut+" value=' "+asTx[1]+" '"
		+ "\n 		onclick=\"top.location='http://www.biodiv.org/search/default.aspx"+qsLgAnd+"qu='+this.form.qu.value;\" >" 
		+ "\n 		<input type='hidden' name='lg' value='0' >&nbsp;" 
		+ "\n 	</td>" 
		+ "\n 	</tr>" 
		+ "\n" + trW5 
		+ "\n 	<tr>" 
		+ "\n 	<td "+c2+" colspan='2' nowrap='nowrap' "+s2+" >&nbsp;" 
		+ "\n 		<a "+c2+" href='/chm/"+qsLg+"'>"                 + asTx[8]+"</a>"+sep2
		+ "\n 		<a "+c2+" href='http://bch.biodiv.org/"+qsLg+"'>"+ asTx[9]+"</a>"+sep2
		+ "\n 		<a "+c2+" href='/world/parties.asp"+qsLg+"'>"    +asTx[10]+"</a>"+sep2
		+ "\n 		<a "+c2+" href='/secretariat/"+qsLg+"'>"         +asTx[11]+"</a>"+sep2
		+ "\n 		<a "+c2+" href='/doc/"+qsLg+"'>"                 +asTx[12]+"</a>"+sep2
		+ "\n 		<a "+c2+" href='/meetings/"+qsLg+"'>"            +asTx[13]+"</a>"+sep2
		+ "\n 		<a "+c2+" href='/map.asp"+qsLg+"'>"              +asTx[14]+"</a>" 
		+ "\n 	</td>" 
		+ "\n 	<td "+c2+" nowrap='nowrap' align='right' "+s2+">" 
		+ "\n 		<b>" + sIntra + sWeb + "</b>" 
		+ "\n 		&nbsp;" 
		+ "\n 	</td>" 
		+ "\n 	<td "+c2+" colspan='2' nowrap='nowrap' align='left'>" 
		+ "\n 		<b>" + sLang +"</b>&nbsp;"
		+ "\n 	</td>" 
		+ "\n 	</tr>" 
		+ "\n" + trW5 
		+ "\n 	</table>" 
		+ "\n </td>" 
		+ "\n </tr>" 
		+ "\n"+ trG1
		+ "\n </table>" ;

document.write(o_sHtml);
}

//---------------------------------------------------------------------
// CBD_WriteFooter
//---------------------------------------------------------------------
function CBD_WriteFooter(i_sOptions, i_sUpdated) {
var o_sHtml  = '';
var sStyle   = (j_ctx.bNavOK ? " style='BORDER-TOP: 1px solid black;' " : "");
var sContact ='';
var sPrivacy ='';
var sTerms ='';

	switch(j_ctx.iLang) {
	case 1:
		sContact = "Contact&eacute;nos";
		sPrivacy = "Pol&iacute;tica de privacidad";
		sTerms = "Condiciones de utilizaci&oacute;n";
	break;
	case 2:
		sContact = "Contactez-nous";
		sPrivacy = "D&eacute;claration de confidentialit&eacute;";
		sTerms = "Conditions d’utilisation";		
	break;
	default:
		sContact = "Contact us";
		sPrivacy = "Privacy Statement";
		sTerms = "Terms of Use";		
	break;
	}


	if (!U_IsOK(i_sUpdated)) { i_sUpdated=''; }

	o_sHtml = ""
		+ "<table cellspacing='0' cellpadding='0' width='100%' border='0' "+sStyle+">"
		+ NAV_RowLine(3, '#000000')
		+ "\n\t <tr><td align='left' width='100%' colspan='3'></td></tr>"
		+ "\n\t <tr><td>"
		+ "\n\t\t &#160;<a href='/secretariat/contact.asp" + j_ctx.qsLang + "'><font size='1'>" + sContact + "</font></a>"
		+ "\n\t\t &#160;&#160;<a href='/privacypolicy.shtml" + j_ctx.qsLang + "'><font size='1'>" + sPrivacy + "</font></a>"
		+ "\n\t\t &#160;&#160;<a href='/terms.shtml" + j_ctx.qsLang + "'><font size='1'>" + sTerms + "</font></a>"		
		+ "\n\t\t <br>&#160;"
		+ "\n\t </td><td>&#160;</td><td align='right' nowrap>"
		+ "\n\t\t <font size='1'>" + i_sUpdated + "&#160;<br>&#160;</font>"
		+ "\n\t </td></tr>"
		+ "\n\t <tr><td valign='bottom' align='left'><img src='/images/img-footer-" + j_ctx.sLangCode + ".gif' border='0' >"
		+ "\n\t </td><td>&#160;</td><td valign='bottom' align='right'>"
		+ "\n\t\t <table cellspacing='0' cellpadding='0' border='0'>"
		+ "\n\t\t <tr><td valign='top' width='50'>"
		+ "\n\t\t\t <a href='http://www.unep.org/'><img src='/images/log-unep-" + j_ctx.sLangCode + ".gif' width='50' border='0' ></a>"
		+ "\n\t\t </td><td valign='top' width='56'>"
		+ "\n\t\t\t <a href='http://www.un.org/'><img src='/images/log-un.gif' width='56' border='0' ></a>"
		+ "\n\t\t </td></tr>"
		+ "\n\t\t </table>"
		+ "\n\t </td></tr>"
		+ "</table>"

	document.writeln(o_sHtml);
}


//---------------------------------------------------------------------
// CBD_WriteMenu
//---------------------------------------------------------------------
function CBD_WriteMenu(i_sType, i_sHref, i_sText) {
var o_sHtml = "";
var bgColorSection = "#CECF9C";
var bgColorItems   = "#E9EEE3";
var bgColorLine    = "#67684E";
var fgColorSection = "#412700";
var fgColorItems   = "#80786a";
var sWidth = "200";

	//i_sText.replace(/'/g," ");
	switch (i_sType) {
	case 'LMB': // Left Menu Begin
		o_sHtml = "<table bgcolor='" + bgColorItems + "' width='" + sWidth + "' border='0' "  
				+ " cellpadding='" + (NAV_IsOK() ? '0': '3') +"' cellspacing='0'>";
	break;
	case 'LME': // Left Menu End
		o_sHtml = "\n </table>";
	break;
	case 'LML': // Left Menu Line
		o_sHtml = "\n <tr width='" + sWidth + "' height='1' bgcolor='" + bgColorLine + "'><td width='" + sWidth + "' height='1'></td></tr>";
	break;
	case 'LMR': // Left Menu Empty Row
		o_sHtml = "\n <tr width='" + sWidth + "' bgcolor='" + bgColorItems + "'><td width='" + sWidth + "' >&nbsp;</td></tr>";
	break;
	case 'LMS': // Left Menu Section 
	if (j_ctx.bNavOK) {
		o_sHtml = "\n <tr width='" + sWidth + "'>"
			+ "\n <td width='" + sWidth + "' bgcolor='"+bgColorSection+"' align='right' valign='top' "
			+ "\n\t ><table width='" + sWidth + "' bgcolor='"+bgColorSection+"' border='0' cellpading='0' cellspacing='0' align='right'>"
			+ "\n\t\t <tr width='" + sWidth + "'>"
			+ "\n\t\t <td width='" + sWidth + "' bgcolor='"+bgColorSection+"' "
			+ "\n\t\t ><table width='" + sWidth + "' bgcolor='"+bgColorSection+"' border='0' cellpading='0' cellspacing='0' align='right'>"
			+ "\n\t\t <tr width='" + sWidth + "' height='1'>"
			+ "\n\t\t <td width='" + sWidth + "' nowrap height='1' bgcolor='"+bgColorSection+"'>"
			+ "\n\t\t </td>"
			+ "\n\t\t </tr>"
			+ "\n\t\t <tr>"
			+ "\n\t\t <td width='" + sWidth + "' valign='top' height='32' class='menuTit'>"
			+ "\n\t\t <b>"+i_sText+"</b>"
			+ "\n\t\t </td>"
			+ "\n\t\t </tr>"
			+ "\n\t\t </table></td>"
			+ "\n\t\t </tr>"
			+ "\n\t </table></td>"
			+ "\n </tr>";
	} else {
		i_sText = "<font color='"+fgColorSection+"'>" + (''+i_sText).toUpperCase() + "</font>";
		o_sHtml = "\n <tr width='" + sWidth + "'>"
			+ "\n <td width='" + sWidth + "' bgcolor='"+bgColorSection+"' valign='top'> "
			+ "\n\t <b>"+i_sText+"</b>"
			+ "\n </td>"
			+ "\n </tr>";
	}
	break;
	case 'LMI': // Left Menu Item
	if (j_ctx.bNavOK) {
		o_sHtml = "\n <tr><td valign='top' class='MenuOpt' align='right'>" 
			+ "\n <a class='MenuOpt' href='" + i_sHref + "'>" + i_sText + "</a>"
			+ "\n </td></tr>";
	} else {
		i_sText = "<font color='"+fgColorItems+"'><b>" + (''+i_sText).toUpperCase() + "<b></font>";
		o_sHtml = "\n <tr><td align='right' valign='top' >" 
			+ "\n <a href='" + i_sHref + "' >" + i_sText + "</a>";
			+ "\n </td></tr>";
	}
	break;
	case 'LMIW': // Left Menu Item Window
	if (j_ctx.bNavOK) {
		o_sHtml = "\n <tr><td valign='top' class='MenuOpt' align='right'>" 
			+ "\n <a class='menuOpt' onclick=\"window.open('" + i_sHref + "')\" href='#'>" + i_sText + "</a>"
			+ "\n </td></tr>";
	} else {
		i_sText = "<font color='"+fgColorItems+"'><b>" + (''+i_sText).toUpperCase() + "<b></font>";
		o_sHtml = "\n <tr><td valign='top' align='right'>" 
			+ "\n <a onclick=\"window.open('" + i_sHref + "')\" href='#'>" + i_sText + "</a>"
			+ "\n </td></tr>";
	}

	break;
	}
	document.writeln(o_sHtml);
	return true;
}


//---------------------------------------------------------------------
// CBD_WriteEmail: CBD e-mail decoding
//---------------------------------------------------------------------
function CBD_WriteEmail(i_sEmail) {
var sEmail = i_sEmail.replace(/=/g,'biodiv.org').replace(/#/g,'@');
	document.write("<a href=\"mailto:" + sEmail + "\">" + sEmail + "</a>");
}

//---------------------------------------------------------------------
// CBD_WriteEmail2
//---------------------------------------------------------------------
function CBD_WriteEmail2(i_sEmail, i_sText) {
var sEmail = i_sEmail.replace(/=/g,'biodiv.org').replace(/#/g,'@');
var sText = i_sText.replace(/=/g,'biodiv.org').replace(/#/g,'@');
	document.write("<a href=\"mailto:" + sEmail + "\">" + i_sText + "</a>");
}


//=====================================================================
// Utility Functions
//=====================================================================
//---------------------------------------------------------------------
// U_W
//---------------------------------------------------------------------
function U_W(i_sText) {
	document.write(i_sText);
}

//---------------------------------------------------------------------
// U_WL
//---------------------------------------------------------------------
function U_WL(i_sText) {
	document.writeln(i_sText);
}

//---------------------------------------------------------------------
// U_Set
//---------------------------------------------------------------------
function U_Set(io_idVal, i_sVal) {
var ctlVal=ID_Get(io_idVal);
	ctlVal.value = i_sVal;
}

//---------------------------------------------------------------------
// U_SetGo
//---------------------------------------------------------------------
function U_SetGo(io_idVal, i_sVal) {
var ctlVal=ID_Get(io_idVal);
	ctlVal.value = i_sVal;
	ctlVal.form.submit();
}

//---------------------------------------------------------------------
// U_Return
//---------------------------------------------------------------------
function U_Return(i_bOK) {
var o_bOK = ( i_bOK ? true : false );
	event.returnValue = o_bOK;
	return o_bOK;
}

//---------------------------------------------------------------------
// U_Left
//---------------------------------------------------------------------
function U_Left(i_sText, i_iLength) {
var o_sText = '';
	if (0<i_iLength) { 
		o_sText = (''+i_sText).substring(0, i_iLength); 
	}
return o_sText;
}

//---------------------------------------------------------------------
// U_Right
//---------------------------------------------------------------------
function U_Right(i_sText, i_iLength) {
var o_sText = '';
var iLength = (''+i_sText).length;
var iStart = ( iLength > i_iLength ? iLength-i_iLength : 0);
	if (0<i_iLength) { 
		o_sText = (''+i_sText).substring(iStart); 
	}
return o_sText;
}

//---------------------------------------------------------------------
// U_Mid
//---------------------------------------------------------------------
function U_Mid(i_sText, i_iStart, i_iLength) {
var o_sText = '';
	if (0<i_iStart && 0<i_iLength) { 
		o_sText = (''+i_sText).substring(i_iStart-1, i_iStart-1+i_iLength);
	}
return o_sText;
}

//---------------------------------------------------------------------
// U_Contains
//---------------------------------------------------------------------
function U_Contains(i_sList, i_sText, i_sSep) {
return ( 0 <= (i_sSep + i_sList + i_sSep).indexOf(i_sSep + i_sText + i_sSep) );
}

//---------------------------------------------------------------------
// U_StartsWith
//---------------------------------------------------------------------
function U_StartsWith(i_sText, i_sStart) {
var o_bYes = false;
var iStartLength = i_sStart.length;
	o_bYes = ( i_sStart.toLowerCase() == U_Left(i_sText.toLowerCase(), iStartLength) );
return o_bYes;
}

//---------------------------------------------------------------------
// U_Replace (with Old and New not null)
//---------------------------------------------------------------------
function U_Replace(i_sText, i_sOld, i_sNew) {
var o_sText = ''+i_sText;
	if (U_IsOK(i_sText) && U_IsOK(i_sOld) && U_IsOK(i_sNew)) { 
		o_sText = o_sText.split(i_sOld).join(i_sNew);
	}
return o_sText;
}

//---------------------------------------------------------------------
// U_IsOK
//---------------------------------------------------------------------
function U_IsOK(i_sValue) {
var o_bOK; 
	switch(typeof i_sValue) {
	case 'string' : o_bOK = (0<i_sValue.length); break;
	case 'number' : o_bOK = (0<i_sValue);        break;
	case 'boolean': o_bOK = (i_sValue);          break;
	default:        o_bOK = (0<(''+i_sValue).length) && ('null'!=''+i_sValue);
	}
return o_bOK;
}

//---------------------------------------------------------------------
// U_IfOK
//---------------------------------------------------------------------
function U_IfOK(i_sValue, i_sText) {
return (U_IsOK(i_sValue) ? ''+i_sText : '');
}

//---------------------------------------------------------------------
// U_YesNo: Prompt for user confirmation
//---------------------------------------------------------------------
function U_YesNo(i_sMsg) { 
var o_bOK = confirm(i_sMsg); 
	event.returnValue = o_bOK;
	return o_bOK;
}

//---------------------------------------------------------------------
// U_Go: Go to specified URL
//---------------------------------------------------------------------
function U_Go(i_sHref) {
	window.location.href = i_sHref;
}

//---------------------------------------------------------------------
// U_Redirect
//---------------------------------------------------------------------
function U_Redirect(i_sFrom, i_sTo) {
var sLocation = location.pathname.toLowerCase().split("\\").join("/");
var iIndex    = sLocation.indexOf(i_sFrom);
var sRoot     = location.pathname.substr(0, iIndex);
	window.location = sRoot+i_sTo;
}


//---------------------------------------------------------------------
// U_L2(i_sNr)
//---------------------------------------------------------------------
function U_L2(i_sNr) {
var o_sNr = (''+i_sNr);
	if (1==o_sNr.length) { o_sNr = '0'+i_sNr; }
return o_sNr;
}

//---------------------------------------------------------------------
// U_RomanToDigit(i_sRoman)
//---------------------------------------------------------------------
function U_RomanToDigit(i_sNr) {
var o_sNr = '';

	switch(i_sNr) {
	case 'IX'  : o_sNr='09'; break;
	case 'VIII': o_sNr='08'; break;
	case 'VII' : o_sNr='07'; break;
	case 'VI'  : o_sNr='06'; break;
	case 'V'   : o_sNr='05'; break;
	case 'IV'  : o_sNr='04'; break;
	case 'III' : o_sNr='03'; break;
	case 'II'  : o_sNr='02'; break;
	case 'I'   : o_sNr='01'; break;
	}

return o_sNr;
}

//---------------------------------------------------------------------
// U_Break
//---------------------------------------------------------------------
function U_Break(i_sText) {
var o_sText = ''+i_sText;
	o_sText = i_sText.replace(/\n/g,'\n<br>').replace(/; /g,'\n<br>');

	if ( 0<= o_sText.indexOf(o_sText, '&lt;') ) { 
		o_sText = o_sText.replace(/&lt;p&gt;/g,'\n<p>').replace(/&lt;\/p&gt;/g,'\n</p>').replace(/&lt;br&gt;/g,'\n<br>');
	}

return o_sText;
}

//---------------------------------------------------------------------
// U_BreakElement
//---------------------------------------------------------------------
function U_BreakElement(io_elt) {
io_elt.innerHTML = U_Break(io_elt.innerHTML);
}

//---------------------------------------------------------------------
// U_ShowIf
//---------------------------------------------------------------------
function U_ShowIf(io_idShow, i_idIf) {
var eltShow = document.getElementById(io_idShow);
var eltIf   = document.getElementById(i_idIf);
	o_bShow = U_ShowIfElement(eltShow, eltIf);
return o_bShow;
}

//---------------------------------------------------------------------
// U_ShowIfElement
//---------------------------------------------------------------------
function U_ShowIfElement(io_eltShow, i_eltIf) {
var o_bShow = ( 0<(""+i_eltIf.innerHTML).length );
var bHidden = ('none' == io_eltShow.style.display);
	if (!o_bShow) { 
		if (!bHidden) { io_eltShow.style.display = 'none'}; 
	} else { 
		if (bHidden)  { io_eltShow.style.display = 'block'}; 
	}
return o_bShow;
}

//---------------------------------------------------------------------
// U_ShowHide
//---------------------------------------------------------------------
function U_ShowHide(i_btnId, i_txtId, i_cmdTxt) {
var btn = document.getElementById(i_btnId);
var txt = document.getElementById(i_txtId);

	if ('none'== txt.style.display) {
		txt.style.display = 'block';
		btn.value = 'Hide ' + i_cmdTxt;
	} else {
		txt.style.display = 'none';
		btn.value = 'Show ' + i_cmdTxt;
	}
}

//---------------------------------------------------------------------
// U_ShowWhen
//---------------------------------------------------------------------
function U_ShowWhen(i_bWhen, i_ctlId) {
var ctl=ID_Get(i_ctlId);
var o_n=0;
	if (null != ctl) {
		ctl.style.display = ( i_bWhen ? 'block' : 'none' ); 
		o_n = ( i_bWhen ? 1 : 0 );
	} else {
		alert(i_ctlId + ' not found');
	}
return o_n;
}

//---------------------------------------------------------------------
// U_ShowRows
//---------------------------------------------------------------------
function U_ShowRows(i_sel, i_ctlGroupId, i_aRows) {
var iOpt=0;
var iRow=0;
var o_n=0;
	for (iOpt=0; iOpt<i_sel.options.length; iOpt++) {
		for (iRow=i_aRows[iOpt]; iRow<i_aRows[iOpt+1]; iRow++) {
			o_n += U_ShowWhen(i_sel.options[iOpt].selected, i_ctlGroupId+'_TR_'+iRow );
		}
	}
	U_ShowWhen(0<o_n, i_ctlGroupId+'_TR_0');
return o_n;
}


//=====================================================================
// ID Functions
//=====================================================================
//---------------------------------------------------------------------
// ID_Get
//---------------------------------------------------------------------
function ID_Get(i_id) {
	return document.getElementById(i_id);
}

//---------------------------------------------------------------------
// ID_GetValue
//---------------------------------------------------------------------
function ID_GetValue(i_id) {
	return document.getElementById(i_id).value;
}


//=====================================================================
// Date Functions
//=====================================================================
//---------------------------------------------------------------------
// DATE_GetMonthName
//---------------------------------------------------------------------
function DATE_GetMonthName(i_dt) {
	if (null==i_dt) { i_dt = new Date(); }
	var iMonth = i_dt.getMonth();
	var asMonths = Array("January","February","March","April","May","June",
					"July","August","September","October","November","December");
	return asMonths[iMonth];
}

//---------------------------------------------------------------------
// DATE_IsDMY
//---------------------------------------------------------------------
function DATE_IsDMY(i_sDMY, i_bAlert) {
	return (null != DATE_FromDMY(i_sDMY, i_bAlert));
}

//---------------------------------------------------------------------
// DATE_ToDMY
//---------------------------------------------------------------------
function DATE_ToDMY(i_dt) {
var o_sDMY = "";	
var iD = 0 + i_dt.getDate();
var iM = 1 + i_dt.getMonth();
var iY = 0 + i_dt.getFullYear();
var bOK = (0<iD) && (0<iM) && (0<iY);

	if (bOK) {
		if (1000 > iY) { iY = 2000 + iY; }
		var sD = ( 10>iD ? "0" : "") + iD;
		var sM = ( 10>iM ? "0" : "") + iM;
		var sY = iY;
		o_sDMY = sD + "/" + sM + "/" + sY;
	}
	return o_sDMY;
}

//---------------------------------------------------------------------
// DATE_ToYMD
//---------------------------------------------------------------------
function DATE_ToYMD(i_dt) {
var o_sYMD = "";	
var iD = 0 + i_dt.getDate();
var iM = 1 + i_dt.getMonth();
var iY = 0 + i_dt.getFullYear();
var bOK = (0<iD) && (0<iM) && (0<iY);

	if (bOK) {
		if (1000 > iY) { iY = 2000 + iY; }
		var sD = ( 10>iD ? "0" : "") + iD;
		var sM = ( 10>iM ? "0" : "") + iM;
		var sY = iY;
		o_sYMD = sY + "-" + sM + "-" + sD;
	}
	return o_sYMD;
}

//---------------------------------------------------------------------
// DATE_FromDMY
//---------------------------------------------------------------------
function DATE_FromDMY(i_sDMY, i_bAlert) {
var o_dt = null;
var sMsg = "";
var bOK = true;
	if (10 != i_sDMY.length) {
		bOK = false;
		sMsg = "Please enter the date in the following format: dd/mm/yyyy";
	}
	if (bOK) {
		var sD = i_sDMY.substring(0,2);
		var sM = i_sDMY.substring(3,5);
		var sY = i_sDMY.substring(6,10);
		o_dt = new Date(sY, sM-1, sD);

		if (i_sDMY != DATE_ToDMY(o_dt)) {
			o_dt = null;
			bOK = false;
			sMsg = "Please specify a valid date";
		}
	}
	if (i_bAlert && !bOK) { alert(sMsg); }
	return o_dt;
}	

//---------------------------------------------------------------------
// DATE_FromYMD
//---------------------------------------------------------------------
function DATE_FromYMD(i_sYMD) {
var o_dt = null;
var bOK = true;
var sYMD = (''+i_sYMD).substring(0,10);

	if (10 > sYMD.length) {
		bOK = false;
	}
	if (bOK) {
		var sY = sYMD.substring(0,4);
		var sM = sYMD.substring(5,7);
		var sD = sYMD.substring(8,10);

		o_dt = new Date(sY, sM-1, sD);

		if (sYMD != DATE_ToYMD(o_dt)) {
			o_dt = null;
			bOK = false;
		}
	}
	return o_dt;
}	


//=====================================================================
// Form Processing Functions
//=====================================================================

function U_GetParam(i_sParam) 
   { return FORM_GetRequest(i_sParam); }

function U_RemoveParam(i_sParam)
   { return FORM_GetQueryStringWithout(i_sParam); }

//---------------------------------------------------------------------
// FORM_GetRequest
//---------------------------------------------------------------------
function FORM_GetRequest(i_sParam) {
var o_sParam = '';
var aParam;
var i;
var sQS = window.location.search.slice(1);
var aQS = sQS.split('&');

	for (i=0; i<aQS.length; i++) {
		aParam = aQS[i].split('=');
		if (i_sParam == aParam[0]) { 
			o_sParam = ''+aParam[1];
			break;
		}
	}
return o_sParam;
}

//---------------------------------------------------------------------
// FORM_GetFormParam()
//---------------------------------------------------------------------
function FORM_GetParam(i_aNames, i_aValues, i_sName) {
var o_sValue = '';
var iParam = 0;

	for (iParam=0; iParam<i_aNames.length; iParam++) {
		if (i_aNames[iParam]==i_sName) {
			o_sValue = i_aValues[iParam];
			break;
		}
	}	
return o_sValue;
}

//---------------------------------------------------------------------
// FORM_GetParams()
//---------------------------------------------------------------------
function FORM_GetParams(o_aNames, o_aValues) {
var o_sQS = '';
var nParam = 0;
var iParam = 0;
var aParam;
var sLoc = window.location.toString();
var iQS = 1+sLoc.indexOf('?');

	if (0<iQS) {
		o_sQS = sLoc.slice(iQS);
		var aQS = o_sQS.split('&');

		for(iParam=0; iParam<aQS.length; iParam++) {
			aParam = aQS[iParam].split('=');
			o_aNames[nParam]  = aParam[0];
			o_aValues[nParam] = aParam[1];
			nParam++;
		}
	}
return o_sQS;
}


//---------------------------------------------------------------------
// FORM_GetQueryStringWithout
//---------------------------------------------------------------------
function FORM_GetQueryStringWithout(i_sParam) {
var o_sQS = '';
var sSep = '';
var sParam = '';
var aParam;
var i;
var sQS = window.location.search.slice(1);
var aQS = sQS.split('&');

	for (i=0; i<aQS.length; i++) {
		aParam = aQS[i].split('=');
		if (i_sParam == aParam[0]) { 
			// Remove this parameter
		} else {
			if (U_IsOK(aParam[1])) { 
				// Include in new Query String
				o_sQS += sSep + aParam[0]+'='+aParam[1];
				sSep = '&';
			}
		}
	}

return o_sQS;
}


//=====================================================================
// Window Creation Functions
//=====================================================================
//---------------------------------------------------------------------
// WIN_Popup
//---------------------------------------------------------------------
function WIN_Popup(i_sHref) {
	wPopup = window.open(i_sHref,"win","toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450");
}

//---------------------------------------------------------------------
// WIN_Popup2
//---------------------------------------------------------------------
function WIN_Popup2(i_sHref, i_iWidth, i_iHeight) {
	wPopup = window.open(i_sHref,"win","toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=" + i_iWidth + ",height=" + i_iHeight);
}

//---------------------------------------------------------------------
// WIN_Open
//---------------------------------------------------------------------
function WIN_Open(i_sHref) {
	wPopup = window.open(i_sHref,"win", "");
}


//=====================================================================
// Navigator Information Functions
//=====================================================================
//---------------------------------------------------------------------
// NAV_IsOK (At least MSIE 5 or Netscape 5)
//---------------------------------------------------------------------
function NAV_IsOK() {
var o_bYes = (NAV_IsIE(4) || NAV_IsNS5());
return o_bYes;
}

//---------------------------------
// NAV_WriteMaxWidth()
//---------------------------------
function NAV_WriteMaxWidth(i_bAlways) {
	document.writeln(NAV_MaxWidth(i_bAlways));
}

//---------------------------------
// NAV_MaxWidth()
//---------------------------------
function NAV_MaxWidth(i_bAlways) {
var o_sHtml = "";
	if (i_bAlways || !j_ctx.bNavOK) {
		var o_sHtml = ""
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>"
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>"
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>"
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>"
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>"
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>"
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>"
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>"
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>"
		+ "\n<img src='/images/1-trsp.gif' height='1' width='50'><img src='/images/1-trsp.gif' height='1' width='50'>";
	}
return o_sHtml;
}

//---------------------------------------------------------------------
// NAV_AddHeight()
//---------------------------------------------------------------------
function NAV_AddHeight(i_iHeight) {
var o_sHtml = "";
	if (!j_ctx.bNavOK) {
		o_sHtml = "<img src='/images/1-black.gif' width='1' height='"+i_iHeight+"'>";
	}
return o_sHtml;
}

//---------------------------------------------------------------------
// NAV_RowLine()
//---------------------------------------------------------------------
function NAV_RowLine(i_iColSpan, i_sBgColor) {
var o_sHtml = "";
	if (!j_ctx.bNavOK) {
		var o_sHtml = "\n" 
			+ "<tr><td colspan='"+i_iColSpan+"' bgcolor='"+i_sBgColor+"' width='100%' height='1'>"
			+ "<img src='/images/1-trsp.gif' width='1' height='1' border='0'>" 
			+ "</td></tr>";
	}
return o_sHtml;
}

//---------------------------------------------------------------------
// NAV_IsIE5
//---------------------------------------------------------------------
function NAV_IsIE5() {
return NAV_IsIE(5);
}

//---------------------------------------------------------------------
// NAV_IsNS5
//---------------------------------------------------------------------
function NAV_IsNS5() {
return NAV_IsNS(5);
}

//---------------------------------------------------------------------
// NAV_IsIE
//---------------------------------------------------------------------
function NAV_IsIE(i_iVer) {
var sBrowser = NAV_Get(); 
var pMSIE = sBrowser.indexOf('MSIE ');
var iExplorerVersion = ( 0<pMSIE ? parseInt(sBrowser.substring(pMSIE+5,pMSIE+8) ) : 0);
var o_bYes = (i_iVer<=iExplorerVersion);
return o_bYes;
}

//---------------------------------------------------------------------
// NAV_IsOldIE
//---------------------------------------------------------------------
function NAV_IsOldIE() {
var sBrowser = NAV_Get(); 
var pMSIE = sBrowser.indexOf('MSIE ');
var iVer = ( 0<pMSIE ? parseInt(sBrowser.substring(pMSIE+5,pMSIE+8) ) : 0);
var o_bYes = (0<iVer) && (iVer<7);
return o_bYes;
}

//---------------------------------------------------------------------
// NAV_IsNS
//---------------------------------------------------------------------
function NAV_IsNS(i_iVer) {
var pNS = navigator.appName.indexOf('Netscape');
var iNetscapeVersion = ( 0<=pNS ? parseInt(navigator.appVersion) : 0);
var o_bYes = (i_iVer<=iNetscapeVersion);
return o_bYes;
}

//---------------------------------------------------------------------
// NAV_Get
//---------------------------------------------------------------------
function NAV_Get() {
return '' + navigator.appName + ': ' + navigator.appVersion;
}


//=====================================================================
// List Processing Functions
//=====================================================================
//---------------------------------------------------------------------
// LIST_GetSelections
//---------------------------------------------------------------------
function LIST_GetSelections(i_select, i_bMultiData) {
var iOpt = 0;
var iSel = 0;
var o_sSel = "";

	if (i_bMultiData) {
		for (iOpt=0; iOpt<i_select.options.length; iOpt++) {
			if (i_select.options[iOpt].selected) { 
				if (i_select.options[iOpt].value.length>0) {
					o_sSel = o_sSel + (0<o_sSel.length?' ':'') + i_select.options[iOpt].value; 
				}
			}
		}
	} else {
		if (i_select.selectedIndex>=0) { 
			if (i_select.options[i_select.selectedIndex].value.length>0) { 
				o_sSel = i_select.options[i_select.selectedIndex].value; 
			}
		}
	}
return o_sSel;
}

//---------------------------------------------------------------------
// LIST_IsMatch
//---------------------------------------------------------------------
function LIST_IsMatch(i_sSelections, i_sData, i_bMultiData) {
var o_bMatch = true;

	if (0<i_sSelections.length) {	
		var sData = (""+i_sData).toLowerCase();
		var asSel = (""+i_sSelections).toLowerCase().split(' ');
		var sSel;
		var iSel = 0;
		var nSel = asSel.length;

		for (iSel=0; iSel<nSel; iSel++) {
			sSel = asSel[iSel];
			if (i_bMultiData) { // Exact match of any selected item
				o_bMatch = ( 0<= (' '+ sData +' ').indexOf(' '+sSel+' ')  );
			} else { // Data equals or contains the selection (to increase text matches)
				o_bMatch = ( 0<= sData.indexOf(sSel) );
			}
			if (o_bMatch) break;
		}
	}
return o_bMatch;
}


//=====================================================================
// XML Processing Functions
//=====================================================================

// XML Node Types
// --------------
// -  1 Élément
// -  2 Attribut
// -  3 Text
// -  4 CDATA Section
// -  5 Entity Reference
// -  6 Entity
// -  7 Processing Instruction
// -  8 Comment
// -  9 Document
// - 10 Document Type
// - 11 Document Fragment
// - 12 Notation

//---------------------------------------------------------------------
// XML_GetDoc(i_sUrl)
//---------------------------------------------------------------------
function XML_GetDoc(i_sUrl) {
var o_xmlDoc;
	if (window.ActiveXObject) { // IE
		o_xmlDoc = new ActiveXObject("MSXML2.DOMDocument");
		o_xmlDoc.async = false;
		o_xmlDoc.load(i_sUrl);
	} else if (window.XMLHttpRequest) { //NS
		var xhr = new XMLHttpRequest();
		xhr.open("GET", i_sUrl, false);
		xhr.send(null);
		o_xmlDoc = xhr.responseXML;
	}
return o_xmlDoc;
}

//---------------------------------------------------------------------
// XML_GetRoot
//---------------------------------------------------------------------
function XML_GetRoot(i_sUrl) {
var o_axRecords;
var o_xRoot;
var x0 = XML_GetDoc(i_sUrl);
var x1;
var n1 = x0.childNodes.length;
var i1 = 0;
var n2;
var i2 = 0;
var x2;
	for (i1=0; i1<n1; i1++) {
		x1 = x0.childNodes[i1];
		if (1==x1.nodeType) {
			n2 = x1.childNodes.length;

			// Only keep child nodes whose type is 1 (Elements)
			for (i2=n2-1; i2>=0; i2--) {
				x2 = x1.childNodes[i2];
				if (1 != x2.nodeType) {
					x1.removeChild(x2);
				}
			}			
			o_xRoot = x1;
			break;
		}
	}
return o_xRoot;
}

//---------------------------------------------------------------------
// XML_GetElements(i_xmlDoc, i_sTag)
//---------------------------------------------------------------------
function XML_GetElements(i_xmlDoc, i_sTag) {
var o_aNodes = i_xmlDoc.getElementsByTagName(i_sTag);
return o_aNodes;
}

//---------------------------------------------------------------------
// XML_Move
//---------------------------------------------------------------------
function XML_Move(io_rs, i_sMove) {

	switch (i_sMove) {
	case 'F': 
		io_rs.moveFirst();
	break;
	case 'P':
		io_rs.movePrevious; if (p_rs.BOF) io_rs.moveFirst();
	break;
	case 'N':
		io_rs.moveNext; if (p_rs.EOF) io_rs.moveLast();
	break;
	case 'L':
		io_rs.moveLast();
	break;	
	}
//<!--  Example on how to use this function:
//	<button onclick="Move(p_rs, 'F')">First</button>
//	<button onclick="Move(p_rs, 'P')">Previous</button>
//	<button onclick="Move(p_rs, 'N')">Next</button>
//	<button onclick="Move(p_rs, 'L')">Last</button>
//-->
}

//---------------------------------------------------------------------
// XML_FindRecord
//---------------------------------------------------------------------
function XML_FindRecord(io_rs, i_sField, i_sValue) {
var o_bFound = false;

	io_rs.moveFirst();
	while (!io_rs.EOF && !o_bFound) {
		o_bFound = (io_rs(i_sField) == i_sValue);
		if (o_bFound) { 
			break; 
		} else {
			io_rs.moveNext();
		}
	}

return o_bFound;
}

//---------------------------------------------------------------------
// XML_FindRecord_ns
//---------------------------------------------------------------------
function XML_FindRecord_ns(i_xRoot, i_sTag, i_sValue) {
var o_xRecord = null;
var xRecord = null;
var i;
var sValue ='';
var n = i_xRoot.childNodes.length;
//alert('+Find '+i_sTag+'='+i_sValue+' n='+n);
	if (U_IsOK(i_sValue)) {
		for (i=0; i<n; i++) {
			xRecord = i_xRoot.childNodes[i];
			if ( 1 == xRecord.nodeType ) {

				sValue = XML_GetValue_ns(i_sTag, xRecord);
				if (i_sValue == sValue) {
					o_xRecord = xRecord;
					break; 
				}
			}
		}
	}
//alert('-Find '+(null!=o_xRecord));
return o_xRecord;
}

//---------------------------------------------------------------------
// XML_GetValue
//---------------------------------------------------------------------
function XML_GetValue(i_sTag, i_bIE5, i_rs, i_xRecord) {
var o_sValue = '';
	if (i_bIE5) {
		o_sValue = U_IfOK( i_rs(i_sTag), i_rs(i_sTag) );
	} else {
		o_sValue = XML_GetValue_ns(i_sTag, i_xRecord);

	}
return o_sValue;
}

//---------------------------------------------------------------------
// XML_GetValue_ns
//---------------------------------------------------------------------
function XML_GetValue_ns(i_sTag, i_xRecord) {

var o_sValue ='';
var x2 = i_xRecord;

//	alert('+Get ' + i_sTag);
	if (1==x2.nodeType) {
		var n3 = x2.childNodes.length;
		var x3;
		var i3=0;

		for (i3=0; i3<n3; i3++) {
//			alert('Field '+i3 + '/' + n3);
			x3 = x2.childNodes[i3];
			if (1==x3.nodeType) {
				if (x3.nodeName == i_sTag) { 
					o_sValue = ''+x3.firstChild.nodeValue;
//					alert('value i3 found:'+i3+'='+o_sValue);
					break;
				}
			}
		}
	} else {
//		alert('skip type=' + x2.nodeType);
	}

//	alert('-Get ' + i_sTag +'='+o_sValue);

return o_sValue;
}

//---------------------------------------------------------------------
// XML_IsMatch
//---------------------------------------------------------------------
function XML_IsMatch(i_sSelections, i_sTag, i_bMultiData, i_bIE5, i_rs, i_xRecord) {
var o_bMatch = true;
	if (0<i_sSelections.length) {	
		var sData = XML_GetValue(i_sTag, i_bIE5, i_rs, i_xRecord);
		o_bMatch = LIST_IsMatch(i_sSelections, sData, i_bMultiData) 
	}
return o_bMatch;
}

//---------------------------------------------------------------------
// XML_SetOptions
//---------------------------------------------------------------------
function XML_SetOptions(i_selID, i_xmlID, i_sQS, i_sValueTag, i_sTextTag) {
var rs = i_xmlID.recordset;
var iOpt = 0;
	rs.moveFirst();
	while (! rs.EOF) {
		iOpt = i_selID.options.length;
		i_selID.options[iOpt] = new Option(rs(i_sTextTag), rs(i_sValueTag));
		if ( 0<=i_sQS.indexOf(i_selID.name+'='+rs(i_sValueTag)) ) {
			i_selID.options[iOpt].selected = true;
			i_selID.options[0].selected = false;
		}
		rs.moveNext();
	}
}

//---------------------------------------------------------------------
// XML_SetOptions_ns
//---------------------------------------------------------------------
function XML_SetOptions_ns(i_selID, i_sUrl, i_sQS, i_sValueTag, i_sTextTag) {

var xml0 = XML_GetDoc(i_sUrl);
//alert('Level 0 length: '+xml0.childNodes.length);

var i1=0;
var i2=0;
var i3=0;
var xml1;
var xml2;
var xml3;

var iOpt = 0;
var sValue;
var sText;

	for (i1=0; i1<xml0.childNodes.length; i1++) {
		xml1 = xml0.childNodes[i1];
		if (xml1.nodeType == 1) {
//			alert('Level 1 Name='+ xml1.nodeName +' Children='+xml1.childNodes.length);
	
			for (i2=0; i2<xml1.childNodes.length; i2++) {
				xml2 = xml1.childNodes[i2];
				if (xml2.nodeType == 1) {
//					alert('Level 2 Name='+ xml2.nodeName +' Children='+xml2.childNodes.length);

					sValue ='';
					sText ='';

					for (i3=0; i3<xml2.childNodes.length; i3++) {
						xml3 = xml2.childNodes[i3];
						if (xml3.nodeType == 1) {
//							alert('Level 3 Name='+ xml3.nodeName +' Text='+xml3.firstChild.nodeValue);
							if (xml3.nodeName == i_sValueTag) { 
								sValue = ''+xml3.firstChild.nodeValue;
							}
							if (xml3.nodeName == i_sTextTag) { 
								sText = ''+xml3.firstChild.nodeValue;
							}
						}
					}

					iOpt = i_selID.options.length;
					i_selID.options[iOpt] = new Option(sText, sValue);
					if ( 0<=i_sQS.indexOf(i_selID.name+'='+sValue) ) {
						i_selID.options[iOpt].selected = true;
						i_selID.options[0].selected = false;
					}
				}
			}
		}
	}
}


//=====================================================================
// Unused Functions
//=====================================================================

//---------------------------------
// Home Page Functions (Not Used)
//---------------------------------
function HomeBrochure(i_sImg, i_sInfo) {
//alert("HomeBrochure");
	document.getElementById("spanBrochureInfo").innerHTML = i_sInfo;
	document.cover.src = i_sImg;
}
function HomeLoad() {
	HomeBrochure("/images/cov-life-en.jpg", 
		"See how the Convention on Biological Diversity helps preserve the environment");
}


//---------------------------------
// MENU FUNCTIONS (TEST)
//---------------------------------
function menu_write(i_sType, i_sHref, i_sText, i_iCurrent) {
var sCurrent = (1==i_iCurrent ? "Current" : "" );
var sImg = ""; 
var o_sHtml = "";

	switch (i_sType) {
	case 'TMB': // Top Menu Begin
		o_sHtml = "<table class='TopMenu' cellspacing='0' width='100%'><tr class='TopMenu'>";
	break;
	case 'TME': // Top Menu End
		o_sHtml = "</tr></table>";
	break;
	case 'TMI1': // Top Menu Item 1
		o_sHtml = "<td class='TopMenu1" + sCurrent + "'>" 
			+ "<a class='TopMenu" + sCurrent + "' href='" + i_sHref + "'>" + i_sText + "</a>" 
			+ "</td>";
	break;
	case 'TMI': // Top Menu Item
		o_sHtml = "<td class='TopMenu" + sCurrent + "'>" 
			+ "<a class='TopMenu" + sCurrent + "' href='" + i_sHref + "'>" + i_sText + "</a>" 
			+ "</td>";
	break;
	case 'LMB': // Top Menu Begin
		o_sHtml = "<table class='LeftMenu' cellspacing='0' width='150'>";
	break;
	case 'LME': // Top Menu End
		o_sHtml = "</table>";
	break;
	case 'LMS': // Left Menu Section 
		sImg = "<img src='/images/tri-" + (1==i_iCurrent ? "down.gif" : "right.gif" ) + "' border='0' >";
		sCurrent = (2==i_iCurrent ? "Current2" : sCurrent );
		o_sHtml = "<tr class='LeftMenuSection" + sCurrent + "'><td class='LeftMenuSection" + sCurrent + "'>"
			+ "<a class='LeftMenuSection" + sCurrent + "' href='" + i_sHref + "'>" + sImg + "</a>"
			+ "</td><td class='LeftMenuSection" + sCurrent + "'>" 
			+ "<a class='LeftMenuSection" + sCurrent + "' href='" + i_sHref + "'>" + i_sText  + "</a>" 
			+ "</td></tr>";
	break;
	case 'LMI': // Left Menu Item
			o_sHtml = "<tr><td class='LeftMenuItem" + sCurrent + "Left'>-</td>" 
			+ "<td class='LeftMenuItem" + sCurrent + "'>" 
			+ "<a class='LeftMenuItem" + sCurrent + "' href='" + i_sHref + "'>" + i_sText + "</a>"
			+ "</td></tr>";
	break;
	}
	document.writeln(o_sHtml);
	return true;
}

