var caption_indexes      = new Array();

var timecodes = new Array();
timecodes[0] = 0;
timecodes[1] = 182000;
timecodes[2] = 202000;
timecodes[3] = 242000;
timecodes[4] = 364000;
timecodes[5] = 418000;
timecodes[6] = 526000;
timecodes[7] = 535000;
timecodes[8] = 610000;
timecodes[9] = 717000;
timecodes[10] = 748000;
timecodes[11] = 813000;
timecodes[12] = 859000;
timecodes[13] = 914000;
timecodes[14] = 948000;
timecodes[15] = 1001000;
timecodes[16] = 1051000;
timecodes[17] = 1076000;
timecodes[18] = 1128000;
timecodes[19] = 1178000;
timecodes[20] = 1279000;
timecodes[21] = 1353000;
timecodes[22] = 1405000;
timecodes[23] = 1468000;
timecodes[24] = 1532000;
timecodes[25] = 1574000;
timecodes[26] = 1619000;
timecodes[27] = 1639000;
timecodes[28] = 1717000;
timecodes[29] = 1798000;
timecodes[30] = 1891000;
timecodes[31] = 2013000;
timecodes[32] = 2144000;
timecodes[33] = 2201000;
timecodes[34] = 2303000;
timecodes[35] = 2379000;


var captions = new Array();
captions[0] = "Africa’s Future:Improving the Health of Mothers and ChildrenJune 5, 2009Rayburn House Office Building, Washington, DC|";
captions[1] = "Population Growth and Policy OptionsIn Sub-Saharan Africa|2";
captions[2] = "Outline|3";
captions[3] = "Population Trends|4";
captions[4] = "Population Growth|";
captions[5] = "Adverse effects of rapid population growth|";
captions[6] = "The demographic impact of the AIDS epidemic|7";
captions[7] = "HIV Invection Level|";
captions[8] = "Population size|9";
captions[9] = "The benefits of family planning programs|10";
captions[10] = "123 million women in the developing world have an unmet need for contraception|11";
captions[11] = "Fertility Levels|";
captions[12] = "Pregnancy outcomes in sub-Saharan Africa, 2003|";
captions[13] = "Reducing unintended pregnancies and population growth contributes to:|";
captions[14] = "Development Gains|";
captions[15] = "Conclusions|16";
captions[16] = "Uganda’s Future: Improving the Health of Mothers and ChildrenJotham Musinguzi, MD, MPHRegional Director Partners in Population and DevelopmentAfrica Regional OfficeJune 5, 2009Washington,  DC|17";
captions[17] = "Map of Maternal Mortality, Worldwide|18";
captions[18] = "Lost: Life, Rights, and Productivity|High rates of unmet need for family planning is an indicator that the right for an individual to determine one’s own family size is unrealized.";
captions[19] = "Ugandan Population: Large and Growing Rapidly|Jotham, Do you want MMR in here?  The term isn’t commonly understood by this group.  Could we make it more comprehensible by the lay attendee?  At least put a denominator on the slide?    I think it’s fine to leave it here as it segues to the next slide.";
captions[20] = "Uganda:  Why do pregnant women die?|Jotham,  Did you want to continue to include this in red?  This works OK for us.";
captions[21] = "Effective, Low-Cost Strategies Exist to Improve the Health of Mothers and Children|";
captions[22] = "Family Planning Reduces Maternal Death Up to 40%|This is the version with two scales, one for the MMR and one for the CPR.  You would make the point that the MMR and CPR vary inversely clearer.    ";
captions[23] = "A $1 Million Family Planning Investment Prevents:|";
captions[24] = "Uganda’s Future: Improving the Health of Mothers and Children|Uganda wants to get here.  To become more developed.  To have these things for our people…  Ideal future of Uganda";
captions[25] = "What is the message?|";
captions[26] = "Maternal & Newborn Mortality|Over the last decade, attention and resources for maternal and newborn mortality have been diverted in many countries in sub Saharan Africa.";
captions[27] = "Facts|In developing countries, a woman lifetime risk of dying due to pregnancy and childbirth is 1 in 8 in Sierra Leone and 1 in 17,400 in Sweden.  In some parts of Senegal, for every 100,000 births, 1200 women die.  1 in 100,000 in Ireland;  10 in 100.000 in the US;  Every hour of every day, at least 30 women die from complications of pregnancy. and childbirth in sub Saharan Africa-about 270,000 deaths every year. Every minute of every day 9 children under age five die in Africa-4.8 million children annually.   And for every death, 20 more suffer debilitating and painful injury from pregnancy and childbirth. Of all health indicators, maternal and newborn mortality shows the greatest disparity between rich and poor nations.";
captions[28] = "Most maternal death are due to:|The timing and causes of maternal and newborn death are well understood. Obstetric complications, including postpartum hemorrhage, Hypertensive diseases, Obstruction labor, infection and complication of abortion.   These proportions may vary by country but this is the average situation for the region. The lack of skilled care during and immediately after the delivery  is caused by lack of trained staff, poor health facilities, inaccessible services etc… Unsafe abortion is also an important contribution particularly for the younger generation.";
captions[29] = "Socio-cultural causes of maternal deaths:|In addition to the direct causes of maternal and newborn mortality and morbidity, there are a number of underlying factors at the household and community levels that also undermines the health and survival of mothers and new born. These include: insufficient access to nutritious food, early marriage, female genital mutilation, short birth spacing.   Whatever the root cause—medical or socio-cultural, most maternal and new-born deaths could be prevented with low-cost, affordable interventions. We know them. They are effective. They are affordable.";
captions[30] = "1 in 3 deaths could be avoided if women who wanted effective contraception had access to it. |Research has also shown that family planning offers a safe, affordable, and effective way to avoid maternal and child deaths. In 1 in 3 deaths could be avoided if women who wanted effective contraception had access to it. Unfortunately the uses of family planning in a country like senegal. The contraceptive prevalence is only 10%. More than 30% of women who did not want to become pregnant but do not use contrception. 21 % of women do not want more children. Unfortunately, while research were guiding programs to increase access, supply and the quality of family planning services, drastic cut happen.";
captions[31] = "The gap for reaching international maternal and child health goals in Senegal|Government around the world are focusing on combating poverty and achieving a range of health and development goals. The international community has set goals to reduce maternal mortality and child mortality by 75% by 2015.    In Senegal we are far from achieving this goal as you can see the difference in the last column.";
captions[32] = "Lack of human and infrastructure resource impacts maternal health|Achieving the international goals require a lot of investment and commitment from both the government and our partners like the US governement. Unfortunately the task is huge. As you can see by the numbers on the slide we need additional resources. (note: read one indicator, pause for audience to read slide)";
captions[33] = "8 of 10 maternal and newborn deaths are preventable|Research has shown that in 8 of 10 cases the death of the mother and baby could be avoided. The losses causes by such avoidable deaths could be stemmed by the implementation of proven, cost-effective and feasible interventions. Such interventions include improved education and care, increased number of community workers with midwifery skills for childbirth and postnatal care, an effective referral systems for the complications, the provision of better health infrastructure, remobilization of the civil society who lost engagement over the past 10 years to educate families and communities, and better coordination of efforts. High quality research need to guide and inform programs.";
captions[34] = "The Realities:|35";
captions[35] = "No woman should die giving life|36";


function create_caption_indexes()
{
	var i;
	var running_total=0;
	caption_indexes[0]=running_total;
	for(i=1; i <= captions.length; i++)
	{
		running_total = running_total + captions[i-1].length + 1;
		caption_indexes[i]=running_total;
	}
	return running_total;
}
function find_instances2(search_term) {
  var caption;
  var new_search_term;
  var regular_expression;  
  var s1='';     
  
  s1="<html><head>"; 
  s1=s1+"<link rel=\"stylesheet\" type=\"text/css\" href=\"default.css\">";
  s1=s1+"<script src=\"search.js\"></script></head>";   
  s1=s1+"<body>";
  s1=s1+"<div id=\"search\"><form name=\"form1\" onSubmit=\"find_instances2(document.form1.searchme.value);return false;\">"; 
  s1=s1+"<span style='font-family:Helvetica,Arial;font-size:11px;font-weight:bold;'>Search slide notes and transcript:</span><br/>";
  s1=s1+"<input type=\"text\" size=\"25\" name=\"searchme\" value=\"\">"; 
  s1=s1+"<a href=\"#\" onClick=\"find_instances2(document.form1.searchme.value);return false;\"><img src=\"search.gif\" border=\"0\" alt=\"Search\"></a>"; 
  s1=s1+"</form></div>";   
  s1=s1+"<span style='font-family:Helvetica,Arial;font-size:11px;font-weight:bold;'>";
  s1=s1+'<hr width="100%"/>\n';
  s1=s1+"Search results for: \"" + search_term.toUpperCase() + "\"";

  s1=s1+'<hr width="100%"/>\n';
  //CHECK THE SEARCH TERM TO MAKE SURE IT IS LEGIT--STRIP OUT FINAL *, BAD PUNCTUATION, ETC.
  if (search_term.length > 0) {
    new_search_term = filter_search_term(search_term);
    regular_expression = new RegExp(new_search_term, "gi");

    for(i = 0; i < captions.length; ++i) {
      caption = captions[i];
      if (regular_expression.test(caption)) {
        href = make_href(i, caption);
        s1=s1+href + "<br>\n";
      }
    }
  }
  //s1=s1+"<br><br>End of search results";
  s1=s1+"</span></body></html>";

parent.tabcontent.document.getElementById('search').innerHTML="";  
parent.tabcontent.document.getElementById('search').innerHTML=s1;  
  
}
function find_instances3(search_term) {
  var caption;
  var new_search_term;
  var regular_expression;  
  var s1='';     
  
  s1="<html><head>"; 
  s1=s1+"<link rel=\"stylesheet\" type=\"text/css\" href=\"default.css\">";
  s1=s1+"<script src=\"search.js\"></script></head>";   
  s1=s1+"<body><a href=\"#\" onClick=\"javascript:parent.ChangeTab('keywords','search','keywordsResults','outline');parent.TabSelected(2);return false;\"><< Back to Keywords</a><br/>";
  s1=s1+"<span style='font-family:Helvetica,Arial;font-size:11px;font-weight:bold;'>";
  s1=s1+'<hr width="100%"/>\n';
  s1=s1+"Slides containing keyword: \"" + search_term.toUpperCase() + "\"";

  s1=s1+'<hr width="100%"/>\n';
  if (search_term.length > 0) {
    new_search_term = filter_search_term(search_term);
    regular_expression = new RegExp(new_search_term, "gi");

    for(i = 0; i < captions.length; ++i) {
      caption = captions[i];
      if (regular_expression.test(caption)) {
        href = make_href2(i, caption);
        s1=s1+href + "<br>\n";
      }
    }
  }
  //s1=s1+"<br><br>End of keyword results";
  s1=s1+"</span></body></html>";
  
parent.tabcontent.document.getElementById('keywords').style.display="none";
parent.tabcontent.document.getElementById('keywordsResults').style.display="block";
parent.tabcontent.document.getElementById('keywordsResults').innerHTML="";  
parent.tabcontent.document.getElementById('keywordsResults').innerHTML=s1;  
  
}

function filter_search_term(search_term) {
  new_search_term = filter_out_bad_punctuation(search_term);
  regexp_period = /\./gi;
  regexp_asterisk = /\*/gi;
  regexp_many_asterisks = /[\*][\*]+/gi;
  regexp_final_asterisk = /(\w*)\*$/gi;
  regexp_question = /\?/gi;

  period_replace = 	 "\\\\.";
  many_asterisks_replace = "\*";
  asterisk_replace = "[A-Za-z_&\\-]*";
  question_replace = ".";

  new_search_term1 = new_search_term.replace(regexp_period,period_replace);
  new_search_term2 = new_search_term1.replace(regexp_many_asterisks,many_asterisks_replace);
  new_search_term3 = new_search_term2.replace(regexp_final_asterisk,"$1");
  new_search_term4 = new_search_term3.replace(regexp_asterisk,asterisk_replace);
  new_search_term5 = new_search_term4.replace(regexp_question,question_replace);

  filtered_search_term = new_search_term5;
  return filtered_search_term;
}

function filter_out_bad_punctuation(search_term)
{
		regexp_backslash = 	 /\\/gi;
		regexp_slash = 	         /\//gi;
		regexp_ampersand = 	 /\&/gi;
		regexp_plus = 		 /\+/gi;

		regexp_openparen = 	 /\(/gi;
		regexp_closeparen = 	 /\)/gi;
		regexp_openbracket =	 /\[/gi;
		regexp_closebracket =	 /\]/gi;
		regexp_carrot =		 /\^/gi;
		regexp_dollar = 	 /\$/gi;
		regexp_bar =		 /\|/gi;

		backslash_replace = 	 "\\\\";
		ampersand_replace = 	 "\\&";
		plus_replace =   	 "\\+";
		slash_replace =  	 "\\/";
		openbracket_replace =	 "\\[";
		closebracket_replace =	 "\\]";
		openparen_replace = 	 "\\(";
		closeparen_replace =  	 "\\)";

		carrot_replace =	"\\^";
		dollar_replace =	"\\$";
		bar_replace =		"\\|";

		search_term1  = search_term.replace(regexp_backslash,backslash_replace);
		search_term2  = search_term1.replace(regexp_slash,slash_replace);
		search_term3  = search_term2.replace(regexp_ampersand,ampersand_replace);
		search_term4  = search_term3.replace(regexp_plus,plus_replace);
		search_term5  = search_term4.replace(regexp_openparen,openparen_replace);
		search_term6  = search_term5.replace(regexp_closeparen,closeparen_replace);
		search_term7  = search_term6.replace(regexp_openbracket,openbracket_replace);
		search_term8  = search_term7.replace(regexp_closebracket,closebracket_replace);
		search_term9  = search_term8.replace(regexp_carrot,carrot_replace);
		search_term10 = search_term9.replace(regexp_dollar,dollar_replace);
		search_term11 = search_term10.replace(regexp_bar,bar_replace);

		punctuation_filtered_search_term = search_term11;

		return punctuation_filtered_search_term;
}

function make_href(caption_index, searched_caption)
{
	var caption = captions[caption_index];
	var timecode = timecodes[caption_index];
	var vid_string = get_video_string(timecode);
	var href = "\n <a href='#' OnClick='" + vid_string + ";return false;'>";
	href += searched_caption.substring(0, searched_caption.indexOf('|')) + "</a>";
	bullet_string = "Slide " + (caption_index +1) + ":  ";
	output_string = bullet_string + href;
	return output_string;
	return href;
}
function make_href2(caption_index, searched_caption)
{
	var caption = captions[caption_index];
	var timecode = timecodes[caption_index];
	var vid_string = get_video_string(timecode);
	var href = "\n <a href='#' OnClick='" + vid_string + ";return false;'>";
	href += searched_caption.substring(0, searched_caption.indexOf('|')) + "</a>";
	bullet_string = "Slide " + (caption_index +1) + ":  ";
	output_string = bullet_string + href;
	return output_string;
	return href;
}

function get_video_string(actual_timecode)
{
	var vid_string = "";
	//vid_string += "top.videoFrame.seek(" + actual_timecode + ")";
	vid_string += "parent.BuildPlayer(\"ERROR\"," + actual_timecode + ")";
	return vid_string;
}

/**********************
function search_term_is_a_digit(search_term)
{
	var test = parseInt(search_term);
	if (test >= 0 && test <= 9)
		return true;
	else
		return false;
}
**********************/