// Enter here the last page number of this report
var LastPageOfReport = 330;

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); 
  if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function CurrentPageNumber() {
	return parseInt(location.pathname.substr(location.pathname.length-7,3),10);
}

function ChapterSelected(lo,hi,idp) {
	if ((CurrentPageNumber() >= lo) && (CurrentPageNumber() <= hi)) {
		return(' selected');
	} else {
		return('');
	}
}

function ShowChapterJumpMenu(idp) {
	document.write ('<select class="field" name="ChapterJumpMenu" onChange="MM_jumpMenu(\'parent\',this,1)">');
	document.write ('<option value="index.php?idp=0">Table of contents</option>');
	// Set the values in the call to ChapterSelected as the first and last web page numbers of the chapter.
	// Set the option value to the first web page of the chapter.
	document.write ('<option' + ChapterSelected(500,500,idp) + ' value="index.php?idp=500">Foreword</option>');
	document.write ('<option' + ChapterSelected(500,500,idp) + ' value="index.php?idp=500&#preface">Preface</option>');
	document.write ('<option' + ChapterSelected(501,516,idp) + ' value="index.php?idp=501">Summary for Policymakers</option>');
	document.write ('<option' + ChapterSelected(1,5,idp) + ' value="index.php?idp=1">Chapter 1: Introduction</option>');
	document.write ('<option' + ChapterSelected(6,41,idp) + ' value="index.php?idp=6">Chapter 2: Africa</option>');
	document.write ('<option' + ChapterSelected(42,57,idp) + ' value="index.php?idp=42">Chapter 3: The Arctic and the Antarctic</option>');
	document.write ('<option' + ChapterSelected(58,90,idp) + ' value="index.php?idp=58">Chapter 4: Australasia</option>');
	document.write ('<option' + ChapterSelected(91,121,idp) + ' value="index.php?idp=91">Chapter 5: Europe</option>');
	document.write ('<option' + ChapterSelected(122,152,idp) + ' value="index.php?idp=122">Chapter 6: Latin America</option>');
	document.write ('<option' + ChapterSelected(153,172,idp) + ' value="index.php?idp=153">Chapter 7: Middle East and Arid Asia</option>');
	document.write ('<option' + ChapterSelected(173,238,idp) + ' value="index.php?idp=173">Chapter 8: North America</option>');
	document.write ('<option' + ChapterSelected(239,259,idp) + ' value="index.php?idp=239">Chapter 9: Small Island States</option>');
	document.write ('<option' + ChapterSelected(260,280,idp) + ' value="index.php?idp=260">Chapter 10: Temperate Asia</option>');
	document.write ('<option' + ChapterSelected(281,304,idp) + ' value="index.php?idp=281">Chapter 11: Tropical Asia</option>');
	document.write ('<option' + ChapterSelected(305,305,idp) + ' value="index.php?idp=305">Annex A</option>');
	document.write ('<option' + ChapterSelected(306,314,idp) + ' value="index.php?idp=306">Annex B</option>');
	document.write ('<option' + ChapterSelected(315,324,idp) + ' value="index.php?idp=315">Annex C</option>');
	document.write ('<option' + ChapterSelected(325,326,idp) + ' value="index.php?idp=325">Annex D</option>');
	document.write ('<option' + ChapterSelected(326,326,idp) + ' value="index.php?idp=326">Annex E</option>');
	document.write ('<option' + ChapterSelected(327,327,idp) + ' value="index.php?idp=327">Annex F</option>');
	document.write ('<option' + ChapterSelected(328,328,idp) + ' value="index.php?idp=328">Annex G</option>');
	document.write ('<option' + ChapterSelected(329,329,idp) + ' value="index.php?idp=329">Annex H</option>');
	document.write ('<option' + ChapterSelected(330,330,idp) + ' value="index.php?idp=330">Annex I</option>');
	document.write ('</select> ');
	//document.write ('<input type="button" class="field" name="Button1" value="Go" onClick="MM_jumpMenuGo(\'ChapterJumpMenu\',\'parent\',1)">');
}

function PrevNext(p_idp, p_lastpage) {
	var prevPage, nextPage;
	idp=parseInt(p_idp);
	lastpage=parseInt(p_lastpage);
	
	//if (isNaN(CurrentPageNumber())) { 
	if (isNaN(idp)) {
		document.write('Table of contents | <a href="index.php?idp=1" target="_top">Next page</a>');
		//document.write('Table of contents | <a href="500.htm">Next page</a>');
	} else {
		if (idp == 1) { 
		//if (idp == 0) {
			//prevPage= -1; 
			prevPage= -1; 
			//prevPage='index';
		} else { 
			//prevPage=CurrentPageNumber() - 1; 
			 prevPage=idp - 1; 
			 //prevPage=idp - 2; 
			 if (prevPage > 330 && prevPage < 500) prevPage = prevPage - 169;
		}
		
		/*
		if (prevPage < 10) { prevPage = '0' + prevPage; }
		if (prevPage < 100) { prevPage = '0' + prevPage; }	
		if (prevPage == 499) { prevPage = 'index'; }	
		if (nextPage == 002){ prevPage = '516'; }
		*/
		if (prevPage >= 0) {
			document.write('<a href="index.php?idp=0" target="_top">Table of contents</a> | <a href=index.php?idp=' + prevPage + '>Previous page</a>');
		}
		//document.write('<a href="index.htm">Table of contents</a> | <a href=' + prevPage + '.htm>Previous page</a>');
		if (idp != lastpage) {
		//if (CurrentPageNumber() != LastPageOfReport) {
			//nextPage = CurrentPageNumber() + 1;
			 nextPage = idp + 1;
			/*
			if (nextPage < 10) { nextPage = '0' + nextPage; }
			if (nextPage < 100){ nextPage = '0' + nextPage; } 
			if (prevPage == 515){ nextPage = '001'; } 
			*/
			if (nextPage > 330 && nextPage < 500) nextPage=nextPage+169;
			document.write(' | <a href=index.php?idp=' + nextPage + '>Next page</a>');
			//document.write(' | <a href=' + nextPage + '.htm>Next page</a>');
		} else { 
			//if (CurrentPageNumber() == LastPageOfReport){
			if (idp == lastpage) {
			document.write(' | End of report');}
		}
	}
}

function showFootnote (chapter,name) {
	theURL = 'fn' + chapter + '.htm#' + name;
	window.open(theURL,'references_win','width=350,height=200,scrollbars,resizable'); 
}
