function WriteMenu(depth) {

if ("on" == "on")
{
	var relpath = getpath(depth);

	MenuWriter(relpath);

	document.write('</table>');

	SearchWriter(relpath);
}
}


function ModelMenu(depth) {

if ("on" == "on")
{
	var relpath = getpath(depth);

	MenuWriter(relpath);

	document.write('<tr>');
	document.write('<td class="menuItem">');
	document.write('&nbsp;');
	document.write('</td>');
	document.write('</tr>');

	document.write('<tr id="modelsLink">');
	document.write('<td class="menuItem">');
	document.write('<a href="#models" class="menuLink">View Models</a>');
	document.write('</td>');
	document.write('</tr>');
	document.write('<tr id="fieldsLink">');
	document.write('<td class="menuItem">');
	document.write('<a href="#fields" class="menuLink">View Fields</a>');
	document.write('</td>');
	document.write('</tr>');

	document.write('</table>');

	SearchWriter(relpath);
}

}

function MenuWriter(relpath) {
var name1 = "Home Page";
var name2 = "Back";
var name3 = "Contents";
var name4 = "Earth Policy Institute";
var name5 = "International Monetary Fund";
var name6 = "Food and Agriculture Organization of the United Nations";
var name7 = "World Resources Institute";
var name8 = "Organization for Economic Co-operation and Development";

var link1 = "Default.htm";
var link2 = "javascript:history.go(-1);";
var link3 = "HelperPages/moreabout.htm";
var link4 = "http://www.earth-policy.org/";
var link5 = "http://www.imf.org/external/";
var link6 = "http://faostat.fao.org/default.aspx";
var link7 = "http://www.wri.org/#";
var link8 = "http://www.oecd.org/home/0,2987,en_2649_201185_1_1_1_1_1,00.html";

var type1 = "";
var type2 = "abs";
var type3 = "";
var type4 = "abs";
var type5 = "abs";
var type6 = "abs";
var type7 = "abs";
var type8 = "abs";

var menutitle = "Navigation";
var menusubtitle = "Main Menu";

document.write('<table width="150" class="menu">');

if (menutitle != "") {
	document.write('<tr><td class="menuTitle"><b>' + menutitle + '</b></td></tr>');	
}

if (menusubtitle != "") {
	document.write('<tr><td class="menuSubTitle">' + menusubtitle + '</td></tr>');	
}

if (name1 != "") {
	document.write('<tr>');
	document.write('<td class="menuItem">');
	if (type1 == "abs") {
		document.write('<a href="' + link1 +'" class="menuLink">' + name1 + '</a>');
	} else {
		document.write('<a href="' + relpath + link1 + '" class="menuLink">' + name1 + '</a>');
	}
	document.write('</td>');
	document.write('</tr>');
}

if (name2 != "") {
	document.write('<tr>');
	document.write('<td class="menuItem">');
	if (type2 == "abs") {
		document.write('<a href="' + link2 +'" class="menuLink">' + name2 + '</a>');
	} else {
		document.write('<a href="' + relpath + link2 + '" class="menuLink">' + name2 + '</a>');
	}
	document.write('</td>');
	document.write('</tr>');
}

if (name3 != "") {
	document.write('<tr>');
	document.write('<td class="menuItem">');
	if (type3 == "abs") {
		document.write('<a href="' + link3 +'" class="menuLink">' + name3 + '</a>');
	} else {
		document.write('<a href="' + relpath + link3 + '" class="menuLink">' + name3 + '</a>');
	}
	document.write('</td>');
	document.write('</tr>');
}

if (name4 != "") {
	document.write('<tr>');
	document.write('<td class="menuItem">');
	if (type4 == "abs") {
		document.write('<a href="' + link4 +'" class="menuLink">' + name4 + '</a>');
	} else {
		document.write('<a href="' + relpath + link4 + '" class="menuLink">' + name4 + '</a>');
	}
	document.write('</td>');
	document.write('</tr>');
}

if (name5 != "") {
	document.write('<tr>');
	document.write('<td class="menuItem">');
	if (type5 == "abs") {
		document.write('<a href="' + link5 +'" class="menuLink">' + name5 + '</a>');
	} else {
		document.write('<a href="' + relpath + link5 + '" class="menuLink">' + name5 + '</a>');
	}
	document.write('</td>');
	document.write('</tr>');
}

if (name6 != "") {
	document.write('<tr>');
	document.write('<td class="menuItem">');
	if (type6 == "abs") {
		document.write('<a href="' + link6 +'" class="menuLink">' + name6 + '</a>');
	} else {
		document.write('<a href="' + relpath + link6 + '" class="menuLink">' + name6 + '</a>');
	}
	document.write('</td>');
	document.write('</tr>');
}

if (name7 != "") {
	document.write('<tr>');
	document.write('<td class="menuItem">');
	if (type7 == "abs") {
		document.write('<a href="' + link7 +'" class="menuLink">' + name7 + '</a>');
	} else {
		document.write('<a href="' + relpath + link7 + '" class="menuLink">' + name7 + '</a>');
	}
	document.write('</td>');
	document.write('</tr>');
}

if (name8 != "") {
	document.write('<tr>');
	document.write('<td class="menuItem">');
	if (type8 == "abs") {
		document.write('<a href="' + link8 +'" class="menuLink">' + name8 + '</a>');
	} else {
		document.write('<a href="' + relpath + link8 + '" class="menuLink">' + name8 + '</a>');
	}
	document.write('</td>');
	document.write('</tr>');
}	
}   

function SearchWriter(relpath) {
document.write('<table width="150" class="menu">');
document.write('<tr>');
document.write('<td class="menuSubTitle2">Search</td>');
document.write('</tr>');
document.write('<tr valign="top">');
document.write('<td class="menuItem">');
document.write('<input type="text" id="txtSimpleSearchTerms" value="" size="10" onkeypress="if (event.keyCode==13) return DoClientSearch (\'' + relpath + 
'\');" />&nbsp;');
document.write('<a href="#" onclick="return DoClientSearch(\'' + relpath + '\');" class="menuLink"><img src="' + relpath + '/Images/Search.png" alt="Search"/></a>');
document.write('</td>');
document.write('</tr>');
document.write('</table>');
}

function WriteHeader (depth) {

if ("on" == "on")
{
	var relpath = getpath(depth);

	var hdr1 = "Images/ap-small.jpg";
	var hdr2 = "";
	var hdr3 = "Eco-economy Indicators";

	var type1 = "image";
	var type2 = "text";
	var type3 = "";

	document.write('<table width="100%"');
	document.write('<colgroup span="3">');
	document.write('<col width="33%"></col>');
	document.write('<col width="34%"></col>');
	document.write('<col width="33%"></col>');
	document.write('</colgroup>');
	document.write('<tr>');

	if (type1 == "image") {
	document.write('<td class="hdrArea"><img src="' + relpath + hdr1 + '" alt="" /></td>');
	} 
	else {
	document.write('<td class="hdrArea">' + hdr1 + '</td>');
	}

	if (type2 == "image") {
	document.write('<td align="center" class="hdrArea"><img src="' + relpath + hdr2 + '" alt="" /></td>');
	} 
	else {
	document.write('<td align="center" class="hdrArea">' + hdr2 + '</td>');
	}

	if (type3 == "image") {
	document.write('<td align="right" class="hdrArea"><img src="' + relpath + hdr3 + '" alt="" /></td>');
	} 
	else {
	document.write('<td align="right" class="hdrArea">' + hdr3 + '</td>');
	}

	document.write('</tr></table>');
}

}


function WriteContent () {

}


function getpath(depth) {

if (depth == "1") {
	pathstring = "../";
} else if (depth == "2") {
	pathstring = "../../";
}
return pathstring;

}

//global variables that can be used by ALL the function son this page. 
var inputs; 
var imgFalse = 'false.png'; 
var imgTrue = 'true.png'; 

//this function runs when the page is loaded, put all your other onload stuff in here too. 
function init() { 
    replaceChecks(); 
} 

function replaceChecks() { 
     
    //get all the input fields on the page 
    inputs = document.getElementsByTagName('input'); 

    //cycle trough the input fields 
    for(var i=0; i < inputs.length; i++) { 

        //check if the input is a checkbox 
        if(inputs[i].getAttribute('type') == 'checkbox') { 
             
            //create a new image 
            var img = document.createElement('img'); 
             
            //check if the checkbox is checked 
            if(inputs[i].checked) { 
                img.src = imgTrue; 
            } else { 
                img.src = imgFalse; 
            } 

            //set image ID and onclick action 
            img.id = 'checkImage'+i; 
            //set image 
            img.onclick = new Function('checkChange('+i+')'); 
            //place image in front of the checkbox 
            inputs[i].parentNode.insertBefore(img, inputs[i]); 
             
            //hide the checkbox 
            inputs[i].style.display='none'; 
        } 
    } 
} 

//change the checkbox status and the replacement image 
function checkChange(i) { 

    if(inputs[i].checked) { 
        inputs[i].checked = ''; 
        document.getElementById('checkImage'+i).src=imgFalse; 
    } else { 
        inputs[i].checked = 'checked'; 
        document.getElementById('checkImage'+i).src=imgTrue; 
    } 
} 

window.onload = init;
