/* Legacy code */

function open_window(url)
{
	mywin = window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,left=80,top=50,width=800,height=500')
}

/* Interface JS */
function MM_preloadImages() { var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}
function MM_swapImgRestore() { var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; }
function MM_findObj(n, d) { 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); if(!x && d.getElementById) x=d.getElementById(n); return x; }
function MM_swapImage() { var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}
function formHandler(form) { var windowprops = "top=10,left=10,height=600,width=1000,location=no,"+ "scrollbars=no,menubars=no,toolbars=no,resizable=no"; var URL = form.site.options[form.site.selectedIndex].value; popup = window.open(URL,"MenuPopup",windowprops); }
function showForm(id){ document.getElementById("" + id + "").style.visibility = "visible"; document.getElementById("" + id + "").style.display = "block"; }
function hideForm(id){ if (document.getElementById(id))	{ var idtag = document.getElementById(id); if(idtag != null) {
document.getElementById("" + id + "").style.visibility = 'hidden'; document.getElementById("" + id + "").style.display = 'none';	}}}
function menuShow(e,nodes) {
	var elementID = "/" + e + "/g";
	var submenus = document.getElementsByTagName("li");
	var subicons = document.getElementsByTagName("img");
	for(var i = 0 ; i <= nodes ; i++){
		if(((matchClassVisible(document.getElementById(e+i).getAttribute('className')) || matchClassVisible(document.getElementById(e+i).getAttribute('class'))) && document.getElementById(e+i).style.display != 'none') || (document.getElementById(e+i).style.display == 'block' && document.getElementById(e+i).style.visibility == 'visible'))
		{
			document.getElementById(e+i).style.display = 'none';
			document.getElementById(e+i).style.visibility = 'hidden';	
			for(var j = 0 ; j < submenus.length ; j++){
				if(typeof submenus[j].id != 'undefined'){ 
					
					if(submenus[j].id.match(""+e+i+".")){ 
						document.getElementById(submenus[j].id).style.display = 'none';
						document.getElementById(submenus[j].id).style.visibility = 'hidden';	
					}
				}
			}
			for(var j = 0 ; j < subicons.length ; j++){
				if(typeof subicons[j].id != 'undefined'){ 
					
					if(subicons[j].id.match(""+e+i+".")){ 
						document.images[subicons[j].id].src='/images/asc.gif'; 	
					}
				}
			}
		} else if(document.getElementById(e+i).style.display != 'block' && document.getElementById(e+i).style.visibility != 'visible'){
			document.getElementById(e+i).style.display = 'block';
			document.getElementById(e+i).style.visibility = 'visible';		
		} 
	} 
	if(document.images[e+"img"].src == "http://www.theglobalfund.org/images/abc.gif")
	{	document.images[e+"img"].src = 'http://www.theglobalfund.org/images/abo.gif'; } 
	else if(document.images[e+"img"].src == "http://www.theglobalfund.org/images/abo.gif")
	{	document.images[e+"img"].src = 'http://www.theglobalfund.org/images/abc.gif'; }
	if(document.images[e+"img"].src == "http://www.theglobalfund.org/images/asc.gif")
	{	document.images[e+"img"].src = 'http://www.theglobalfund.org/images/aso.gif';	}
	else if(document.images[e+"img"].src == "http://www.theglobalfund.org/images/aso.gif")
	{	document.images[e+"img"].src='http://www.theglobalfund.org/images/asc.gif';	}
}
function matchClassVisible(classValues){
	var visiblepattern = /V/g;
	if(classValues){
	if(classValues.match(visiblepattern)){ return true; } else { return false; }
	}
}

function classChange() {


    //document.getElementById('d000').style.backgroundColor ='#000000';
	//document.getElementById('d111').style.backgroundColor ='#000000';
	for (i=0;i<document.getElementsByTagName("td").length; i++) {
		
		
		if (document.getElementsByTagName("td").item(i).className == "header"){
  
			   document.getElementsByTagName("td").item(i).style.display = 'none';
               document.getElementsByTagName("td").item(i).style.visibility = 'hidden';
		}
		else if (document.getElementsByTagName("td").item(i).className == "details"){
		
			if (document.getElementsByTagName("td").item(i).style.display != 'block') 
            {
			   document.getElementsByTagName("td").item(i).style.display = 'block';
			   document.getElementsByTagName("td").item(i).style.visibility = 'visible';	   	   
			}
			else
            {
              document.getElementsByTagName("td").item(i).style.display = 'none';
              document.getElementsByTagName("td").item(i).style.visibility = 'hidden';
         
		    }	
        }   
	}
}
function classChange2() {

	  //document.getElementById('d000').style.backgroundColor ='#000000';
	  //document.getElementById('d111').style.backgroundColor ='#000000';
	
	for (i=0;i<document.getElementsByTagName("td").length; i++) {
			
		if (document.getElementsByTagName("td").item(i).className == "details"){
  
			   document.getElementsByTagName("td").item(i).style.display = 'none';
               document.getElementsByTagName("td").item(i).style.visibility = 'hidden';
		}
		else if (document.getElementsByTagName("td").item(i).className == "header"){
		
			if (document.getElementsByTagName("td").item(i).style.display != 'block') 
            {
			   document.getElementsByTagName("td").item(i).style.display = 'block';
			   document.getElementsByTagName("td").item(i).style.visibility = 'visible';	   	   
			}
			else
            {
              document.getElementsByTagName("td").item(i).style.display = 'none';
              document.getElementsByTagName("td").item(i).style.visibility = 'hidden';
         
		    }	
        }   
	}
}
function showForm(id)
{
	document.getElementById("" + id + "").style.visibility = "visible";
	document.getElementById("" + id + "").style.display = "block";
}

function hideForm(id)
{
	if (document.getElementById(id))
	{
		var idtag = document.getElementById(id);
		if(idtag != null)
		{
			document.getElementById("" + id + "").style.visibility = 'hidden';
			document.getElementById("" + id + "").style.display = 'none';
		}
	}
}

function hideFormDR()
{
	document.getElementById("DR").style.visibility='hidden';
	document.getElementById("DR").style.display = 'none';
}



// Simple follow the mouse script

var divName = 'DR'; // div that is to follow the mouse
                       // (must be position:absolute)
var offX = 15;          // X offset from mouse position
var offY = 0;          // Y offset from mouse position

function mouseX(evt) {
if (!evt) evt = window.event; 
if (evt.pageX) 
return evt.pageX; 
else if (evt.clientX)
return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); 
else return 0;
}

function mouseY(evt) {
if (!evt) evt = window.event; 
if (evt.pageY) return evt.pageY; 
else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 
else return 0;}

function follow(evt) {
	var obj = document.getElementById("DR").style; 
	obj.left = (parseInt(mouseX(evt))+offX) + 'px';
	obj.top = (parseInt(mouseY(evt))+offY) + 'px';
}


		function toggleBlock(pstrID)
		{
		var myDiv = document.getElementById('d' + pstrID);
		if (myDiv){
			if (myDiv.style.display == 'none'){
			showBlock(pstrID);
			} else{
			hideBlock(pstrID);
			}
		}
		}
		function showBlock(pstrID)
		{
		var myDiv = document.getElementById('d' + pstrID);
		if (myDiv){
			myDiv.style.display = 'block';
			var myImage = document.getElementById('i' + pstrID);
			if (myImage){
			myImage.src = '/programs/images/up.gif';
			myImage.alt = 'Hide';
			}
		}
		}
		function hideBlock(pstrID)
		{
		var myDiv = document.getElementById('d' + pstrID);
		if (myDiv){
			myDiv.style.display = 'none';
			var myImage = document.getElementById('i' + pstrID);
			if (myImage){
			myImage.src = '/programs/images/down.gif';
			myImage.alt = 'Show';
			}
		}
		
		}

// email obfuscator
function email(user, domain, suffix)
{
	var theEmail = user + "@" + domain + "." + suffix;                     
	document.write("<a href=\"mailto:" + theEmail + "\">" + theEmail + "</a>");
}