var linkInfo = new Array();
var root = "";

//linkInfo[0] = { "name": '', "url": root+'', "description": ''}
linkInfo[0] = { "name": 'home', "url": root+'index.php', "description": 'Home'}
linkInfo[1] = { "name": 'manageadmin', "url": root+'adminManageAdminAccount.php', "description": 'Go to Management Admin Account'}
linkInfo[2] = { "name": 'contacts', "url": root+'contactUs.php', "description": 'Contacts'}
linkInfo[3] = { "name": 'manageadminadd', "url": root+'redirectManageAdminAccountAdd.php', "description": 'Add New Admin Account'}
linkInfo[4] = { "name": 'aboutus', "url": root+'aboutUs.php', "description": 'About Us'}
linkInfo[5] = { "name": 'board', "url": root+'boardMember.php', "description": 'PCNC Board'}
linkInfo[6] = { "name": 'ngolistadd', "url": root+'redirectAddOrgInfo.php', "description": 'Add New Organization'}
linkInfo[7] = { "name": 'newsletter', "url": root+'NewsLetterList.php', "description": 'NewsLetter'}
linkInfo[8] = { "name": 'map', "url": root+'Map.html', "description": 'Map'}
linkInfo[9] = { "name": 'application', "url": root+'application.php', "description": 'Apply Now for Certified NGOs'}
linkInfo[10] = { "name": 'background', "url": root+'background.php', "description": 'Background & Rationale'}
linkInfo[11] = { "name": 'comments', "url": root+'Feedback.php', "description": 'See PCNC online Comments & Feedback!'}
linkInfo[12] = { "name": 'logout', "url": root+'codes/processLogout.php', "description": 'Log out'}
linkInfo[13] = { "name": 'applicationprocess', "url": root+'adminApplicationProcess.php', "description": 'Go to Certification Application Process'}
linkInfo[14] = { "name": 'applicationprocess1', "url": root+'adminApplicationProcess1.php', "description": 'Go to Certification Application Process'}
linkInfo[15] = { "name": 'applicationprocess2', "url": root+'adminApplicationProcess2.php', "description": 'Go to Certification Application Process'}
linkInfo[16] = { "name": 'ngolistadmin', "url": root+'adminNGOList.php', "description": 'Go to NGO List Admin'}
linkInfo[17] = { "name": 'ngolistadmin1', "url": root+'adminNGOList1.php', "description": 'Go to NGO List Admin'}
linkInfo[18] = { "name": 'ngolistadmin2', "url": root+'adminNGOList2.php', "description": 'Go to NGO List Admin'}
linkInfo[19] = { "name": 'ngolist', "url": root+'NGOList.php', "description": 'List of NGO'}
linkInfo[20] = { "name": 'feedbackadmin', "url": root+'adminFeedback.php', "description": 'Go to Comments and Feedback Admin'}
linkInfo[21] = { "name": 'boardadmin', "url": root+'adminBoardMember.php', "description": 'Go to PCNC Board Admin'}
linkInfo[22] = { "name": 'boardadminadd', "url": root+'redirectBoardMemberAdd.php', "description": 'Go to PCNC Board Admin'}
linkInfo[23] = { "name": 'maindisplayadmin', "url": root+'adminMainDisplay.php', "description": 'Go to Main Display Content Admin'}
linkInfo[24] = { "name": 'documentadmin', "url": root+'adminDocuments.php', "description": 'Go to Document Management'}
linkInfo[25] = { "name": 'documentadd', "url": root+'redirectDocumentAdd.php', "description": 'Add New Document'}
linkInfo[26] = { "name": 'sitevisitor', "url": root+'adminSiteVisitors.php', "description": 'Go to PCNC Site Visitors'}
linkInfo[27] = { "name": 'changepassword', "url": root+'changePassword.php', "description": 'Change Password'}
linkInfo[28] = { "name": 'newsletteradmin', "url": root+'adminNews.php', "description": 'Go to NewsLetter Admin'}
linkInfo[29] = { "name": 'newsletteradminadd', "url": root+'redirectNewsAdd.php', "description": 'Go to NewsLetter Admin'}
linkInfo[30] = { "name": 'muncitmgmt', "url": root+'adminMunCity.php', "description": 'Go to Municipality/City Management'}
linkInfo[31] = { "name": 'muncitmgmtadd', "url": root+'redirectMunCityAdd.php', "description": 'Go to Municipality/City Management'}
linkInfo[32] = { "name": 'regions', "url": root+'adminRegions.php', "description": 'Go to Regions'}
linkInfo[33] = { "name": 'regionsadd', "url": root+'redirectRegionAdd.php', "description": 'Go to Regions'}
linkInfo[34] = { "name": 'pam', "url": root+'PAM.php', "description": 'Go to Public Accountability Mechanism'}
linkInfo[35] = { "name": 'newapplicants', "url": root+'NewApplicant.php', "description": 'Go to New Applicants'}
linkInfo[36] = { "name": 'presidentmessageadmin', "url": root+'adminPresidentMessage.php', "description": 'Go to President Message Admin'}
linkInfo[37] = { "name": 'evaluatorsdatabase', "url": root+'adminEvalDB.php', "description": 'Go to PCNC Evaluators Database'}
linkInfo[38] = { "name": 'evaluatoradd', "url": root+'redirectAddEvaluator.php', "description": 'Add New Evaluator'}

function BindNavigation() {
	var allLinkElements = document.getElementsByTagName("A");
	var allInputElements = document.getElementsByTagName("Input");
	var allButtonElements = new Array();
	var i, linkName, linkInfo;
	
	for(i=0;i<allInputElements.length;i++) {
		if(allInputElements[i].type=="button")
			allButtonElements.push(allInputElements[i]);
	}
	
	for(i=0;i<allLinkElements.length;i++) {
		if(allLinkElements[i].attributes["link"]) {
			linkName = allLinkElements[i].attributes["link"].value;			
			linkInfo = GetLink(linkName);
			if(linkInfo) {
				allLinkElements[i].href = linkInfo["url"];
				allLinkElements[i].title = linkInfo["description"];
			}
		}
	}
	
	for(i=0;i<allButtonElements.length;i++) {
		if(allButtonElements[i].attributes["link"]) {
			linkName = allButtonElements[i].attributes["link"].value;
			linkInfo = GetLink(linkName);					
			if(linkInfo) {
				allButtonElements[i].onclick = function() {
					linkName = this.attributes["link"].value;
					linkInfo = GetLink(linkName);					
					window.location.href=linkInfo["url"];
				}				
				allButtonElements[i].title = linkInfo["description"];
			}
		}
	}
}

function GetLink(linkName) {
	var x;
	for(x=0;x<linkInfo.length;x++) {
		if(linkInfo[x]["name"]==linkName) {			
			return linkInfo[x];
		}
	}
	return null;
}

var OnLoad = window.onload;
window.onload = function() {
	if(OnLoad) OnLoad();
	BindNavigation();
}


function OpenPopUp(url,w,h,l,t) {
	var wScreenHeight=600;
	var wScreenWidth=800;
	var wWidth=w;
	var wHeight=h;
	var iLeft=100;
	var iTop=100;		
	if(screen.height) {
		wScreenHeight=screen.height;
		wScreenWidth=screen.width;
		iTop=(wScreenHeight/2)-(wHeight/2);
		iLeft=(wScreenWidth/2)-(wWidth/2);
	}
	if(l!=null)iLeft=l;
	if(t!=null)iTop=t;
	var newWindow=window.open(url,'_blank','toolbars=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width='+wWidth+',height='+wHeight+',top='+iTop+',left='+iLeft);
	if (newWindow.opener == null) { newWindow.opener = self; }
	if (newWindow.blur) { newWindow.focus(); }			
}

function ToPrint(ctrl) {	
	var newWindow=window.open(null,'_blank','toolbars=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,top=1,left=1');
	newWindow.document.open();
	newWindow.document.write("<html><head><title>PRINT</title><link rel=\"stylesheet\" rev=\"stylesheet\" href=\"style.css\">");
	newWindow.document.write("<script language='javascript'>window.onload = function() { window.print();alert('Click OK if printing is complete!');window.close(); }</script>");
	newWindow.document.write("</head><body>");
	newWindow.document.write(ctrl.innerHTML);
	newWindow.document.write("</body></html>");
	newWindow.document.close();
	if (newWindow.opener == null) { newWindow.opener = self; }
	if (newWindow.blur) { newWindow.focus(); }
}
