//pop-up window
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



// Defines rollover images for prefetch
if (document.images)
{
	var home0 = new Image();
	home0.src = "/hdf/newasp/images/imgNavHomeOff.gif";
	var home1 = new Image();
	home1.src = "/hdf/newasp/images/imgNavHomeOn.gif";
	
	var what0 = new Image();
	what0.src = "/hdf/newasp/images/imgNavWhatOff.gif";
	var what1 = new Image();
	what1.src = "/hdf/newasp/images/imgNavWhatOn.gif";
	
	var programs0 = new Image();
	programs0.src = "/hdf/newasp/images/imgNavHDFProgramsOff.gif";
	var programs1 = new Image();
	programs1.src = "/hdf/newasp/images/imgNavHDFProgramsOn.gif";
	
	var help0 = new Image();
	help0.src = "/hdf/newasp/images/imgNavHelpOff.gif";
	var help1 = new Image();
	help1.src = "/hdf/newasp/images/imgNavHelpOn.gif";
	
	var about0 = new Image();
	about0.src = "/hdf/newasp/images/imgNavAboutHDFOff.gif";
	var about1 = new Image();
	about1.src = "/hdf/newasp/images/imgNavAboutHDFOn.gif";	
	
	var offoff = new Image();
	offoff.src = "/hdf/newasp/images/imgNavCornerOffOff.gif";
	
	var onoff = new Image();
	onoff.src = "/hdf/newasp/images/imgNavCornerOnOff.gif";
	
	var offon = new Image();
	offon.src = "/hdf/newasp/images/imgNavCornerOffOn.gif";
	
	var onon = new Image();
	onon.src = "/hdf/newasp/images/imgNavCornerOnOn.gif";
}

// Defines sections for rollovers and dropdowns
var arrSections = new Array("home","what","programs","help","about")

// Simple rollover function
function rollOut(imgName) 
{
    if (document.images) 
    {
        document[imgName].src = eval(imgName+"0.src");
    }
}

// Simple rollout function
function rollIn(imgName)
{
    if (document.images)
    {
        document[imgName].src = eval(imgName+"1.src");
    }
}


// Gets page element by name
function returnElement(sContent)
{
	var objLocation;
	var sElement;
	
	if(document.getElementById)
	{
		sElement = "document.getElementById('" + sContent + "')";
	}
	else if(document.all)
	{
		sElement = "document.all['" + sContent + "']";
	}
	
	objLocation = eval(sElement);
	return objLocation;
}



// Hides form elements to prevent from showing through
function prepareForm(sVisibilityToggle) 
{
	for(var i=0; i < document.forms.length; i++)
	{
		for(var j=0; j < document.forms[i].elements.length; j++) 
		{
			if (document.forms[i].elements[j].type.indexOf("select") != -1)
			{
				document.forms[i].elements[j].style.visibility = sVisibilityToggle;
			}
		}
	}
}

// This function changes the overlapping corners
// sSubnav is the menu to be diplayed
// sCurrentSection is the default highlighted section
// sType is either display or hide
function changeCorners(sSubnav, sCurrentSection, sType)
{
	var nBefore = 0;
	var nAfter = 0;
	
	// Loop through the sections array and identify
	// the position of the corners of both the default highlight and the one to be changed
	for (var i in arrSections)
	{
		if (arrSections[i] == sSubnav)
		{
			nChangeBefore = parseInt(i);
			nChangeAfter = parseInt(i)+1;
		}
		
		if (arrSections[i] == sCurrentSection)
		{
			nDefaultBefore = parseInt(i);
			nDefaultAfter = parseInt(i)+1;
		}
	}
		
	// Determine if the corners match
	// If so, change the image
	var bBeforeCurrentlyOn = false;
	var bAfterCurrentlyOn = false;
	if (nChangeBefore == nDefaultAfter)
	{
		bBeforeCurrentlyOn = true;
	}
	
	if (nChangeAfter == nDefaultBefore)
	{
		bAfterCurrentlyOn = true;
	}
	
	// Show different images depending on mode
	if (sType == "display")
	{
		var sBeforeImage = offon.src;
		var sAfterImage = onoff.src;
		if (bBeforeCurrentlyOn)
		{
			sBeforeImage = onon.src;
		}
		
		if (bAfterCurrentlyOn)
		{
			sAfterImage = onon.src;
		}
	}
	else
	{
		var sBeforeImage = offoff.src;
		var sAfterImage = offoff.src;
		if (bBeforeCurrentlyOn)
		{
			sBeforeImage = onoff.src;
		}
		
		if (bAfterCurrentlyOn)
		{
			sAfterImage = offon.src;
		}
	}	

	if (nChangeBefore > 0 && nChangeBefore < arrSections.length)
	{
		var objBeforeImage = "sep"+nChangeBefore;
		document[objBeforeImage].src = sBeforeImage;
	}
	
	if (nChangeAfter > 0 && nChangeAfter < arrSections.length)
	{
		var objAfterImage = "sep"+nChangeAfter;
		document[objAfterImage].src = sAfterImage;
	}
}

// Displays the submenu 
// sSubnav is the menu to be diplayed
// sCurrentSection is the default highlighted section
function displaySubnav(sSubnav, sCurrentSection)
{
	changeCorners(sSubnav, sCurrentSection, 'display');
	
	rollIn(sSubnav);
	
	var sSubnavName = sSubnav + "Menu";
	var objLocation = returnElement(sSubnavName);	
	if (objLocation)
	{
		objLocation.style.visibility = 'visible';
	}
	
	prepareForm('hidden');
}

// Hides the submenu
// sSubnav is the menu to be hidden
function hideSubnav(sSubnav, bRemoveHighlight, sCurrentSection)
{
	if (bRemoveHighlight)
	{
		changeCorners(sSubnav, sCurrentSection, 'hide');
		
		rollOut(sSubnav);
	}
	
	var sNav = returnElement(sSubnav+"Menu");
	if (sNav)
	{
		sNav.style.visibility = 'hidden';
	}
	
	prepareForm('visible');
	
}

// arrSubNav defines the urls and names for the dropdown menus
var arrSubnav = new Array();

arrSubnav[0] = new Array("what",
-205, // pixels from left
216,	// width of menu
"Introduction",
"http://www.hdf.com/hdf/newasp/whatIsHD/whatIsHD.asp?t=Introduction",
"Human Development Concept",
"http://www.hdf.com/hdf/newasp/whatIsHD/whatIsHD.asp?t=HDConcept",
"Definitions",
"http://www.hdf.com/hdf/newasp/whatIsHD/whatIsHD.asp?t=definitions",
"Human Development in Pakistan",
"http://www.hdf.com/hdf/newasp/whatIsHD/whatIsHD.asp?t=hdInPak",
"Human Development in South Asia",
"http://www.hdf.com/hdf/newasp/whatIsHD/whatIsHD.asp?t=hdInSAsia",
" Human Development in OIC member countries",
"http://www.hdf.com/hdf/newasp/whatIsHD/whatIsHD.asp?t=hdInOIC"
);

arrSubnav[1] = new Array("programs",
10, // pixels from left
216,	// width of menu
"Introduction",
"http://www.hdf.com/hdf/newasp/hdfprograms/hdfprograms.asp?t=Introduction",
"Development Organization",
"http://www.hdf.com/hdf/newasp/hdfprograms/hdfprograms.asp?t=DevOrg",
"Health",
"http://www.hdf.com/hdf/newasp/hdfprograms/hdfprograms.asp?t=Health",
"Education",
"http://www.hdf.com/hdf/newasp/hdfprograms/hdfprograms.asp?t=Education",
"Micro Enterprises",
"http://www.hdf.com/hdf/newasp/hdfprograms/hdfprograms.asp?t=MicroEnterprise"
);

arrSubnav[2] = new Array("help",
133, // pixels from left
216,	// width of menu

"Introduction",
"http://www.hdf.com/hdf/newasp/howyoucanhelp/howyoucanhelp.asp?t=Introduction",
"Volunteer",
"http://www.hdf.com/hdf/newasp/howyoucanhelp/howyoucanhelp.asp?t=Volunteer",
"Donate",
"http://www.hdf.com/hdf/newasp/howyoucanhelp/howyoucanhelp.asp?t=Donate"
);

arrSubnav[3] = new Array("about",
245, // pixels from left
133,	// width of menu

"Introduction",
"http://www.hdf.com/hdf/newasp/aboutus/aboutus.asp?t=introduction",
"History",
"http://www.hdf.com/hdf/newasp/aboutus/aboutus.asp?t=history",
"Mission",
"http://www.hdf.com/hdf/newasp/aboutus/aboutus.asp?t=mission",
"Vission",
"http://www.hdf.com/hdf/newasp/aboutus/aboutus.asp?t=vission",
"Strategic Plan",
"http://www.hdf.com/hdf/newasp/aboutus/aboutus.asp?t=strategicPlan"
);

// Initializes the dropdown menus
function loadSubnav(sHexBGColor, sHexOverColor, sHexFontColor, sHexFontOverColor, sHexLineColor, sThisSection)
{
	if((document.all) || (document.getElementById))
	{
		var this_arrSubnav = new Array();
		this_arrSubnav = arrSubnav;
		var sSubnav = "";
		
		for (j = 0; j < this_arrSubnav.length; j++)
		{			
			var sCurrent = this_arrSubnav[j][0];
			var arrCurrent = this_arrSubnav[j];
			var bInArray = false;
			
			for (var k = 0; k < arrCurrent.length; k++)
			{
				if (sThisSection == arrCurrent[k])
				{
					bInArray = true;
				}			
			}
			
			if (bInArray)
			{
				sSubnav += "<div id=\"" + sCurrent + "Menu\" style=\"z-index:999;position: absolute; left:50%; margin-left: " + this_arrSubnav[j][1] + "; width: " + this_arrSubnav[j][2] + ";  visibility: hidden\" onmouseover=\"displaySubnav('" + sCurrent + "','" + sThisSection + "');\" onmouseout=\"hideSubnav('" + sCurrent + "', false);\">";
			}
			else
			{
				sSubnav += "<div id=\"" + sCurrent + "Menu\" style=\"z-index:999;position: absolute; left:50%; margin-left: " + this_arrSubnav[j][1] + "; width: " + this_arrSubnav[j][2] + ";  visibility: hidden\" onmouseover=\"displaySubnav('" + sCurrent + "','" + sThisSection + "' );\" onmouseout=\"hideSubnav('" + sCurrent + "', true);\">";
			}
			
			sSubnav += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"" + this_arrSubnav[j][2] + "\">";
			
			for (i=3; i < this_arrSubnav[j].length-1; i=i+2)
			{
				sSubnav += "<tr>";
				sSubnav += "<td width=\"1\" bgcolor=\"" + sHexLineColor + "\"><img src=\"images\imgSpacer.gif\" width=\"1\" height=\"22\"></td>";
				sSubnav += "<td bgcolor=\"" + sHexBGColor + "\" class=\"subNav\" onClick=\"document.location.href='" + this_arrSubnav[j][i+1] + "'\" onmouseover=\"this.bgColor='" + sHexOverColor + "';this.style.color='" + sHexFontOverColor+ "';\" onmouseout=\"this.bgColor='" + sHexBGColor + "';this.style.color='" + sHexFontColor + "'\" style=\"color: " + sHexFontColor + "\"><div style=\"padding-left:17px;\">" + this_arrSubnav[j][i] + "</a></div></td>";
				sSubnav += "<td width=\"1\" bgcolor=\"" + sHexLineColor + "\"><img src=\"images\imgSpacer.gif\" width=\"1\" height=\"22\"></td>";
				sSubnav += "</tr>";
				sSubnav += "<tr>";
				sSubnav += "<td colspan=\"3\" bgcolor=\"" + sHexLineColor + "\" height=\"1\"><img src=\"images\imgSpacer.gif\" width=\"1\" height=\"1\"></td>";
				sSubnav += "</tr>";
			}
			
			sSubnav += "</table>";
			sSubnav += "</div>";
		}
		document.write(sSubnav);
	}
}