// Enter here the last page number of this report
var LastPageOfReport = 481;

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 ((idp >= lo) && (idp <= hi)) {
		return(' selected');
	} else {
		return('');
	}
}
/*
function ChapterSelected(lo,hi) {
	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.htm">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(1,1,idp) + ' value="index.php?idp=1">Foreword</option>');
	document.write ('<option' + ChapterSelected(2,2,idp) + ' value="index.php?idp=2">Preface</option>');
	document.write ('<option' + ChapterSelected(3,9,idp) + ' value="index.php?idp=3">Summary for Policymakers</option>');
	document.write ('<option' + ChapterSelected(10,47,idp) + ' value="index.php?idp=10">Technical Summary</option>');
	document.write ('<option' + ChapterSelected(48,67,idp) + ' value="index.php?idp=48">1. Setting the Stage: Climate Change and Sustainable Development</option>');
	document.write ('<option' + ChapterSelected(68,88,idp) + ' value="index.php?idp=68">2. Greenhouse Gas Emission Mitigation Scenarios and Implications</option>');
	document.write ('<option' + ChapterSelected(89,154,idp) + ' value="index.php?idp=89">3. Technological and Economic Potential of Greenhouse Gas...</option>');
	document.write ('<option' + ChapterSelected(155,178,idp) + ' value="index.php?idp=155">4. Technological and Economic Potential of Options to Enhance...</option>');
	document.write ('<option' + ChapterSelected(179,223,idp) + ' value="index.php?idp=179">5. Barriers, Opportunities, and Market Potential of Technologies...</option>');
	document.write ('<option' + ChapterSelected(224,265,idp) + ' value="index.php?idp=224">6. Policies, Measures, and Instruments</option>');
	document.write ('<option' + ChapterSelected(266,318,idp) + ' value="index.php?idp=266">7. Costing Methodologies</option>');
	document.write ('<option' + ChapterSelected(319,352,idp) + ' value="index.php?idp=319">8. Global, Regional, and National Costs and Ancillary Benefits...</option>');
	document.write ('<option' + ChapterSelected(353,378,idp) + ' value="index.php?idp=353">9. Sector Costs and Ancillary Benefits of Mitigation</option>');
	document.write ('<option' + ChapterSelected(379,450,idp) + ' value="index.php?idp=379">10. Decision-making Frameworks</option>');
	document.write ('<option' + ChapterSelected(451,451,idp) + ' value="index.php?idp=451">Appendices</option>');
	document.write ('<option' + ChapterSelected(452,453,idp) + ' value="index.php?idp=452">Appendix I: List of Authors and Reviewers</option>');
	document.write ('<option' + ChapterSelected(454,475,idp) + ' value="index.php?idp=454">Appendix II: Glossary</option>');
	document.write ('<option' + ChapterSelected(476,476,idp) + ' value="index.php?idp=476">Appendix III: Acronyms, Abbreviations, and Chemical Compounds</option>');
	document.write ('<option' + ChapterSelected(477,477,idp) + ' value="index.php?idp=477">Appendix IV: Units, Conversion Factors, and GDP Deflators</option>');
	document.write ('<option' + ChapterSelected(478,479,idp) + ' value="index.php?idp=478">Appendix V: List of Annex I, Annex II, and Annex B Countries</option>');
	document.write ('<option' + ChapterSelected(480,480,idp) + ' value="index.php?idp=480">Appendix VI: List of Major IPCC Reports </option>');
	document.write ('<option' + ChapterSelected(481,481,idp) + ' value="index.php?idp=481">Appendix VII: Figures and Tables in this Report</option>');
	
	document.write ('</select> ');
	//document.write ('<input class="field" type="button" name="Button1" value="Go" onClick="MM_jumpMenuGo(\'ChapterJumpMenu\',\'parent\',1)">');
}

function PrevNext(p_idp, p_lastpage) {
	var prevPage, nextPage;
	/*
	idp=<?php print($idp); ?>;
	lastpage=<?php print($nb_file); ?>;
	*/
	
	idp=parseInt(p_idp);
	lastpage=parseInt(p_lastpage);

	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="001.htm" target="_top">Next page</a>');
	} 
	else {
		//if (CurrentPageNumber() == 1) { 
		if (idp == 1) { 
		//if (idp == 0) {
			//prevPage= -1; 
			prevPage= -1; 
			//prevPage='index';
		} else { 
			//prevPage=CurrentPageNumber() - 1; 
			 prevPage=idp - 1; 
			 //prevPage=idp - 2; 
		}
		/*
		if (prevPage < 10) { prevPage = '0' + prevPage; }
		if (prevPage < 100) { prevPage = '0' + prevPage; }		
		*/
		
		if (prevPage >= 0) {
			document.write('<a href=index.php?idp=0>Table of contents</a> | <a href="index.php?idp=' + prevPage + '">Previous page</a>');
		}
		
		//document.write('<a href="index.htm" target="_top">Table of contents</a> | <a href=' + prevPage + '.htm target="_top">Previous page</a>');
		if (idp != lastpage) {
		//if (CurrentPageNumber() != LastPageOfReport) {
			//nextPage = CurrentPageNumber() + 1;
			//nextPage = idp; // + 1;
			nextPage = idp + 1;
			/*
			if (nextPage < 10) { nextPage = '0' + nextPage; }
			if (nextPage < 100){ nextPage = '0' + nextPage; } 
			*/
			document.write(' | <a href="index.php?idp=' + nextPage + '">Next page</a>');
			//document.write(' | <a href=' + nextPage + '.htm target="_top">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'); 
}
