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(
	"Community health workers across rural Afghanistan enter into a transparent and vital contract with their community, delivering health messages and services where they are needed most.<br /><br /><a href=\"profiles/1_afghanistan.php\">Community health workers on the frontlines of health care &gt;&gt;</a>",
	"Collaborating with the government and local NGOs, UNICEF is enabling women to learn from other women about life skills and health issues, ensuring that women from lower income groups know how to protect themselves and their children from HIV.<br /><br /><a href=\"profiles/2_malaysia.php\">Raising HIV awareness one conversation at a time  &gt;&gt;</a><br /><br /><br />",
	"Serving primarily rural indigenous communities, Para Centres act as a one-stop delivery points for basic social services in Bangladesh. Here, children learn valuable lessons about health, nutrition, water and sanitation and receive a pre-primary education.<br /><br /><a href=\"profiles/3_bangladesh.php\">Bringing good hygiene to rural Bangladesh &gt;&gt;</a><br /><br />",
	"Self-sustaining cooperatives, supported by the Nepalese Government and UNICEF, seek to empower women from lower castes by teaching them about their rights and the rights of their children, giving them a voice and encouraging them to make decisions.<br /><br /><a href=\"profiles/4_nepal.php\">'Untouchable' women in Nepal get the opportunity they never had &gt;&gt;</a><br /><br /><br />",
	"Ka Hang's 'Model Mothers' are actively supporting exclusive breastfeeding to reduce infant mortality rates in Cambodia. Today, Cambodia's Mother Support Groups initiative covers 2,675 villages - 20 per cent of all the villages in the country.<br /><br /><a href=\"profiles/5_cambodia.php\">Promoting exclusive breastfeeding in Cambodia &gt;&gt;</a>",
	"In Timor-Leste, an innovative network of community-based volunteers is working to expand health care provision in rural areas, training local residents to become behaviour-change agents, encouraging their communities to adopt simple disease-prevention practices.  <br /><br /><a href=\"profiles/6_timor.php\">Bridging the gap between rural communities and health centres &gt;&gt;</a><br /><br /><br /><br /><br />",
	"In rural learning centres, young women are provided with opportunities to gain basic literacy and other life skills such as health, hygiene, child-rearing, and sewing, while also learning about the position of women and girls in society, child labour and the consequences of child marriage.<br /><br /><a href=\"profiles/7_india.php\">For a young married girl in India, education is a dream come true &gt;&gt;</a>",
		"UNICEF is working with nearly 30 local governments across the Indonesian archipelago to train more midwives and to encourage the community as a whole to seek professional maternal health care.<br /><br /><a href=\"profiles/8_indonesia.php\">Partnering for women’s health in Indonesia &gt;&gt;</a>",
		"UNICEF has been helping to improve immunization programmes in remote areas such as Bougainville as well as promoting increased immunization coverage throughout Papua New Guinea. <br /><br /><a href=\"profiles/9_papuanewguinea.php\">Long journeys but rising immunization rates in Bougainville  &gt;&gt;</a>",
	"<!--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_afghanistan.php",
	"profiles/2_malaysia.php",
	"profiles/3_bangladesh.php",
	"profiles/4_nepal.php",
	"profiles/5_cambodia.php",
	"profiles/6_timor.php",
	"profiles/7_india.php",
	"profiles/8_indonesia.php",
	"profiles/9_papuanewguinea.php"
	);

var profileNames = new Array(
	"<strong>Afghanistan</strong>",
	"<strong>Malaysia</strong>",
	"<strong>Bangladesh</strong>",
	"<strong>Nepal</strong>",
	"<strong>Cambodia</strong>",
	"<strong>Timor-Leste</strong>",
	"<strong>India</strong>",
	"<strong>Indonesia</strong>",
	"<strong>Papua New Guinea</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<=9; 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;
}
