var caption_indexes      = new Array();

var timecodes = new Array();
timecodes[0] = 0;
timecodes[1] = 525000;
timecodes[2] = 564000;
timecodes[3] = 603000;
timecodes[4] = 649000;
timecodes[5] = 701000;
timecodes[6] = 844000;
timecodes[7] = 940000;
timecodes[8] = 1141000;
timecodes[9] = 1253000;
timecodes[10] = 1447000;
timecodes[11] = 1585000;
timecodes[12] = 1666000;
timecodes[13] = 1806000;
timecodes[14] = 1914000;
timecodes[15] = 1933000;
timecodes[16] = 1943000;
timecodes[17] = 1974000;
timecodes[18] = 2013000;
timecodes[19] = 2049000;
timecodes[20] = 2080000;
timecodes[21] = 2143000;
timecodes[22] = 2231000;
timecodes[23] = 2268000;
timecodes[24] = 2299000;
timecodes[25] = 2310000;
timecodes[26] = 2341000;
timecodes[27] = 2378000;
timecodes[28] = 2432000;
timecodes[29] = 2531000;
timecodes[30] = 2592000;
timecodes[31] = 2669000;
timecodes[32] = 2709000;
timecodes[33] = 2758000;
timecodes[34] = 2776000;
timecodes[35] = 2835000;
timecodes[36] = 2951000;
timecodes[37] = 2993000;
timecodes[38] = 3022000;
timecodes[39] = 3044000;
timecodes[40] = 3105000;
timecodes[41] = 3199000;
timecodes[42] = 3239000;
timecodes[43] = 3304000;
timecodes[44] = 3326000;
timecodes[45] = 3451000;
timecodes[46] = 3522000;
timecodes[47] = 3603000;
timecodes[48] = 3635000;
timecodes[49] = 3661000;
timecodes[50] = 3709000;
timecodes[51] = 3733000;
timecodes[52] = 3743000;
timecodes[53] = 3809000;
timecodes[54] = 3879000;
timecodes[55] = 3893000;
timecodes[56] = 4660000;


var captions = new Array();
captions[0] = "Climate Change and Urban Adaptation:|";
captions[1] = "Assessing urban vulnerability to the health impacts of climate change|";
captions[2] = "Outline|";
captions[3] = "Urban centers are at risk from floods, storms, heat waves and other hazards climate change is expected to aggravate|";
captions[4] = "The challenge|";
captions[5] = "Graphical representation of urban vulnerability to climate-weather hazards|";
captions[6] = "Three components of vulnerability|";
captions[7] = "Determinants of vulnerability |";
captions[8] = "Urban vulnerability as an outcome|";
captions[9] = "Inherent urban vulnerability (1)|";
captions[10] = "Inherent urban vulnerability (2)|";
captions[11] = "Good governance (examples)|";
captions[12] = "What defines urban vulnerability? Concluding remarks|";
captions[13] = "Climate Change and Urban AdaptationJohns/Hopkins/PRB Symposium|";
captions[14] = "Outline|";
captions[15] = "The Research Team|";
captions[16] = "Temperatures Increasing Faster|";
captions[17] = "Urban Population Growth Worldwide, 1950-2025|";
captions[18] = "LDC Cities of 1 Million or More in 2000, by Region|";
captions[19] = "Distribution of LDC Urban Population by City Size|";
captions[20] = "Successful Development Strategies Are At Risk|";
captions[21] = "Theme: Link Spatial Demographic and Climate Data|";
captions[22] = "The Multiple Implications of Climate Change|";
captions[23] = "Flood Exposure (2005)|";
captions[24] = "Drought Exposure (2005)|";
captions[25] = "The Risks Facing Cities and Towns|";
captions[26] = "Health Effects of Urban Flooding and Heavy Precipitation|";
captions[27] = "Other Risks Facing Cities and Towns|";
captions[28] = "The Risks Facing the Urban Poor|";
captions[29] = "Who’s Exposed? Who’s Vulnerable? Where?|";
captions[30] = "Population Exposed in the LECZ: Medan, Indonesia|";
captions[31] = "Vulnerability and the LECZ: Proportion Poor|";
captions[32] = "Vulnerability and LECZ: Number of Poor|";
captions[33] = "Countries with the Largest LECZ Population|";
captions[34] = "Forecasts of City Population Growth in AsiaBy ecosystem, fertility, mortality; China and India not included.|";
captions[35] = "From Global to Local|";
captions[36] = "Investing in New Partnerships and Infrastructure|";
captions[37] = "Building the National and Community Data Bases|";
captions[38] = "Community Mapping and Self-AssessmentExperiences of urban poor groups provide many examples|";
captions[39] = "And For Demographers and Social Scientists|";
captions[40] = "Forecasting Spread: The Landsat Archives Open UpAccra, Ghana, in 1985 and 2000|";
captions[41] = "Tools and Approaches for Adapting to Climate Change|42";
captions[42] = "Climate Change Impacts|";
captions[43] = "What Is Vulnerability?|Vulnerability to climate change impacts is a function of exposure to climate/weather impacts, sensitivity to those impacts, and adaptive capacity of the economy. Exposure is a question of whether climate variability has any influence on an economic activity. Farming is an exposed sector. Office based service jobs generally are not. Raising flowers in a greenhouse reduces exposure. Sensitivity indicates whether an economic activity is affected by climatic changes. Again farming is climate sensitive, but some crops are more sensitive than others. Choosing a crop with a wide temperature or drought tolerance reduces sensitivity. Put another way, baseball is climate sensitive (games are stopped for rain); football is not. Playing either sport in a dome would reduce exposure. Adaptive capacity is the ability to anticipate and/or respond to climatic changes. This can be a matter of recognizing the need to plant less sensitive crops, changing zoning rules (and enforcing them) to reduce coastal vulnerability.  Adaptation is a matter of building resilience by: Reducing exposure (reducing reliance on agriculture; diversifying economy; avoiding construction in floodplains, etc.) Reducing sensitivity (selecting more robust crops, planning for disasters, increasing margin of safety in infrastructure design, etc.) Increasing adaptive capacity (education, economic diversification, information/warnings)";
captions[44] = "Assessing Exposure|In thinking about vulnerability, it’s useful to think about the development issue you are addressing and what assets are most important. Then, through discussions with community members, new reports, assessment of physical evidence (such as a waterline from past flooding), you can get a sense of exposure. Again, sources of information may be memories, maps like the one above (in this study we went on to map the extent of salt water by looking at the presence of salt tolerant plants and comparing that “salt wedge” with the locations of intakes), and models.";
captions[45] = "Assessing Sensitivity|Sensitivity is a bit different than exposure. Sensitivity is a measure of whether a climate impact will result in damages or benefits. For example, flooding will have different effects on neighboring houses if one is built on stilts and the other is built on a slab. The 3 little pigs faced the same exposure to the wolf, but the straw and wood houses were far more sensitive than the brick house.  In thinking about sensitivity, it’s useful to look at past events and their effects. Were similarly exposed assets affected differently? Why? Examples may include structural damages, crop losses, accumulation of sediments after an inland storm or coastal erosion. Can the attributes that contributed to resilience be identified? Can they be replicated?";
captions[46] = "Adaptive Capacity|Adaptive capacity addresses the ability to anticipate and respond to potential impacts. The image shows cases of Dengue fever on either side of the US-Mexico border. In 1922, there were 500,000 cases in Texas. From 1980 to 1996, there were 43 cases on the US side, but 50,000 on the Mexican side. Communities on either side are equally exposed and sensitive, but the impact is quite different. The difference is due to window screens, air conditioning, insecticide, bug repellent, and a public health service that takes Dengue and malaria very seriously.  Elements of adaptive capacity are listed in the slide, and boosting those elements are a means to building resilience.";
captions[47] = "Adapting to Climate Change and Variability|48";
captions[48] = "Coastal Adaptation Guidebook|";
captions[49] = "SERVIR: Tools to Assist Development|";
captions[50] = "Improved Use of Tools and Information: SERVIR|";
captions[51] = "Climate 1-Stop|";
captions[52] = "La Ceiba, Honduras Case Study|53";
captions[53] = "La Ceiba Adaptation Options|54";
captions[54] = "Thank You|";
captions[55] = "Fariyal Fikree|";
captions[56] = "Q & A|";


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;
}
**********************/