function MM_preloadImages() { //v3.0
  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() { //v3.0
  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) { //v4.01
  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() { //v3.0
  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];}
}


				
				
				
				var childText = new Array(
	"In 2004 Turkmenistan became the fourth country in the world to achieve universal salt iodization and the first nation in Central Asia to eliminate iodine deficiency disorders. Political will and global health partnerships have proved decisive in the country’s campaign to help protect hundreds of thousands of children from this debilitating condition.<br /><br /><a href=\"profiles/1_turkmenistan.php\">Learn more about national salt iodization in Turkmenistan &gt;&gt;</a><br /><br /><a href=\"profiles/political_commitment.php\">Learn more about national political commitment for child health and survival &gt;&gt;</a><br /><br />",
	"A community-based initiative in north-eastern Argentina’s Misiones Province offers new hope to children with disabilities, as it places a strong emphasis on the role of families and their communities in rehabilitation efforts.<br /><br /><a href=\"profiles/2_argentina.php\">Learn more about the inclusion of children with disabilities in Argentina &gt;&gt;</a><br /><br /><a href=\"profiles/child_health.php\">Learn more about how approaches to child health and survival have evolved over the last century &gt;&gt;</a><br /><br /><br />",
	"In Niger today more than half the population lives at least 5 kilometres away from any kind of health facility. The Government of Niger, UNICEF and partners are setting up community health posts in underserved areas to provide essential primary health care to millions of children living across this vast and arid country.<br /><br /><a href=\"profiles/3_niger.php\">Learn more about community health posts in Niger &gt;&gt;</a><br /><br /><a href=\"profiles/health_system.php\">Learn more about health-system strengthening for child health and survival &gt;&gt;</a><br /><br />",
	"By recognizing that a homeless family has more needs than shelter alone, Nicholas House, a non-profit organization based in the city of Atlanta in the United States, offers parents and their children the skills and stability necessary to rebuild their homes and their lives.<br /><br /><a href=\"profiles/4_usa.php\">Learn more about a community partnership to help homeless families in the USA &gt;&gt;</a><br /><br /><a href=\"profiles/community_partnerships.php\">Learn more about community partnerships for child health and survival &gt;&gt;</a><br /><br /><br />",
	"Spread out along the banks of the Nile south of Cairo, Upper Egypt’s landscape is dotted with small cities and farming villages. As vital health messages are passed on from health clinic to community health worker to village, pregnant women and new mothers grow more confident about the health system.<br /><br /><a href=\"profiles/5_egypt.php\">Learn more about building bridges between a community and a health clinic in Egypt &gt;&gt;</a><br /><br /><a href=\"profiles/continuum.php\">Learn more about a continuum of care for maternal, newborn and child &gt;&gt;</a>",
	"Community health workers provide vital health services in rural areas of the ancient province of Herat, western Afghanistan. Here, harsh weather, inadequate roads and political instability hamper the regular provision of health services. These challenges have prompted the country’s Ministry of Public Health to expand health-care services through a nationwide network of community-based health workers. <br /><br /><a href=\"profiles/6_afghanistan.php\">Learn more about community health workers in Afghanistan &gt;&gt;</a><br /><br /><a href=\"profiles/child_survival.php\">Learn more about where we stand globally on child survival today &gt;&gt;</a><br /><br /><br /><br /><br />",
	"In Kenya today, many more children than before are surviving one of the country’s biggest killers, malaria. Thanks to efforts by the Kenyan Government and international partners, greater access to long-lasting, insecticide-treated mosquito nets is largely responsible for this boost to child survival.<br /><br /><a href=\"profiles/7_kenya.php\">Learn more about Kenya's campaign against Malaria &gt;&gt;</a><br /><br /><a href=\"profiles/global_partnerships.php\">Learn more about global health partnerships to address malaria and other threats &gt;&gt;</a><br /><br />",
	"In the northern Malaysian state of Kedah, Prostanita, a local non-governmental organization, helps empower women affected by HIV through raising awareness, offering lessons on life skills and discussing health issues.<br /><br /><a href=\"profiles/8_malaysia.php\">Learn more about raising HIV awareness among women in Malaysia  &gt;&gt;</a><br /><br /><a href=\"profiles/uniting.php\">Learn more about uniting for child survival to address HIV and other threats &gt;&gt;</a><br /><br /><br />"
);
var videoLink = new Array(
	"profiles/1_turkmenistan.php",
	"profiles/2_argentina.php",
	"profiles/3_niger.php",
	"profiles/4_usa.php",
	"profiles/5_egypt.php",
	"profiles/6_afghanistan.php",
	"profiles/7_kenya.php",
	"profiles/8_malaysia.php"
	);

var profileNames = new Array(
	"<strong>Turkmenistan</strong>",
	"<strong>Argentina</strong>",
	"<strong>Niger</strong>",
	"<strong>USA</strong>",
	"<strong>Egypt</strong>",
	"<strong>Afghanistan</strong>",
	"<strong>Kenya</strong>",
	"<strong>Malaysia</strong>"
);

function homePageFlip(num) {
	document.getElementById('profilename').innerHTML = profileNames[num - 1];
	document.getElementById('feature').src = "images/profile" + num + ".jpg";
	document.getElementById('child_text').innerHTML = childText[num - 1];
	document.getElementById('featureimglink').href = videoLink[num - 1];
	document.getElementById('viewvideolink').href = videoLink[num - 1];
	document.getElementById('profile' + num).className = "on";
}

function change(num) {
	document.getElementById('profilename').innerHTML = profileNames[num - 1];
	document.getElementById('feature').src = "images/profile" + num + ".jpg";
	document.getElementById('child_text').innerHTML = childText[num - 1];
	document.getElementById('featureimglink').href = videoLink[num - 1];
	document.getElementById('viewvideolink').href = videoLink[num - 1];
	clearHighlights();
	document.getElementById('profile' + num).className = "on";
}

function clearHighlights() {
	for (i=1; i<=8; i++) {
		document.getElementById('profile' + i).className = "";
	}
}

function showName(num) {
	document.getElementById('profilename').innerHTML = profileNames[num - 1];
}

function revertName() {
	document.getElementById('profilename').innerHTML = profileNameOrig;
}

function switchPage() {
	var val = document.chapters.chapter_select.options[document.chapters.chapter_select.selectedIndex].value;
	if (val != "") {
		location.href = val;
	}
}

var newWin = null;
function popUp(strURL, strType, strWidth, strHeight) {  
 if (newWin != null && !newWin.closed)    
  newWin.close();  
 var strOptions="";  
 
 if (strType=="fixednooptions")    
  strOptions="height="+strHeight+",width="+strWidth; 
	 newWin = window.open(strURL, 'newWin', strOptions);  
 newWin.focus();
}

// ---------------------------------------------------------------------
//                  function.apply (if unsupported)
// ---------------------------------------------------------------------
if (!Function.prototype.apply) {
  Function.prototype.apply = function(oScope, args) {
    var sarg = [];
    var rtrn, call;
    if (!oScope) oScope = window;
    if (!args) args = [];
    for (var i = 0; i < args.length; i++) {
      sarg[i] = "args["+i+"]";
    };
    call = "oScope.__applyTemp__(" + sarg.join(",") + ");";
    oScope.__applyTemp__ = this;
    rtrn = eval(call);
    oScope.__applyTemp__ = null;
 return rtrn;
  };
};

// ---------------------------------------------------------------------
//                             addClass()
//                 appends the specified class to the object
// ---------------------------------------------------------------------
function addClass(theClass) {
  if (this.className != '') {
    this.className += ' ' + theClass;
  } else {
    this.className = theClass;
  }
}
Object.prototype.addClass = addClass;

// ---------------------------------------------------------------------
//                               inArray()
//                           [Port from PHP]
//               Hunts for a value in the specified array
// ---------------------------------------------------------------------
function inArray(needle) {
  for (var i=0; i < this.length; i++) {
    if (this[i] === needle) {
      return i;
    }
  }
  return false;
}
Array.prototype.inArray = inArray;

/*------------------------------------------------------------------------------
Function:       footnoteLinks()
------------------------------------------------------------------------------*/
function footnoteLinks(containerID,targetID) {

   if (!document.getElementById || 
      !document.getElementsByTagName ||
      !document.createElement) return false;
  if (!document.getElementById(containerID)|| !document.getElementById(targetID)) return false;

document.getElementById('tagline').firstChild.src = "/sowc08/images/header_tagline_print_eng.gif";
document.getElementById('logo').firstChild.src = "/sowc08/images/header_logo_print_eng.gif";

var container = document.getElementById(containerID);
var target    = document.getElementById(targetID);
var h2        = document.createElement('h2');
addClass.apply(h2,['printOnly']);
var h2_txt    = document.createTextNode('Links');
h2.appendChild(h2_txt);
var coll = container.getElementsByTagName('A');
var ol   = document.createElement('ol');
addClass.apply(ol,['printOnly']);
var myArr = [];
var thisLink;
var num = 1;
for (var i=0; i<coll.length; i++) {
    var thisClass = coll[i].className;
    if ( (coll[i].getAttribute('href') ||
          coll[i].getAttribute('cite'))  && coll[i].getAttribute('href').indexOf("mailto") == -1 &&
          (thisClass == '' ||
           thisClass.indexOf('ignore') == -1) || thisClass == ('mailto')) { 
      thisLink = coll[i].getAttribute('href') ? coll[i].href : coll[i].cite;
   coll[i].innerHTML = coll[i].innerHTML + "&nbsp;";
      var note = document.createElement('sup');
      addClass.apply(note,['printOnly']);
      var note_txt;
      var j = inArray.apply(myArr,[thisLink]);
      if ( j || j===0 ) {
        note_txt = document.createTextNode(j+1);
      } else {
        var li     = document.createElement('li');
        var li_txt = document.createTextNode(thisLink);
        li.appendChild(li_txt);
        ol.appendChild(li);
        myArr.push(thisLink);
        note_txt = document.createTextNode(num);
        num++;
      }
      note.appendChild(note_txt);
      if (coll[i].tagName.toLowerCase() == 'blockquote') {
        var lastChild = lastChildContainingText.apply(coll[i]);
        lastChild.appendChild(note);
      } else {
        coll[i].parentNode.insertBefore(note, coll[i].nextSibling);
      }
    }
  }
  target.appendChild(h2);
  target.appendChild(ol);
  addClass.apply(document.getElementsByTagName('html')[0],['noted']);
  return true;
}
