// JavaScript Document

// region array generates region to highlight on page reload
var regArray = new Array();

regArray[0] = "americas";
regArray[1] = "africa";
regArray[2] = "europe";
regArray[3] = "middleEast";
regArray[4] = "asia";
regArray[5] = "oceania";

var numRegs=regArray.length;
var randNum = Math.floor(Math.random() * numRegs);

// switches active region of map on homepage
// controls what content and colors appear for each region
// change 'titleMsg' string (inside double-quotes) to update profile title
// change 'introMsg' string (inside double-quotes) to update profile byline
function switchRegion(regionName)
{
	if (regionName == 'americas') 
	{
		titleMsg = "Latin American Initiatives";
		titleBgColor = "#4e9293";
		introMsg = "Adjunct Professor Alejandro M. Garro promotes Latin American Initiatives at the Law School. <a href=\"programs-projects/profile-americas.html\">Read more</a>";
		introBgColor = "#bdd1d2";
	}
	else if (regionName == 'africa') 
	{
		titleMsg = "Mombasa, Kenya";
		titleBgColor = "#559e35";
		introMsg = "Andrew Eisenberg is writing a soundful ethnography of community and citizenship among Kenya's “Swahili”. <a href=\"programs-projects/profile-africa.html\">Read more</a>";
		introBgColor = "#b9d1af";
	}
	else if (regionName == 'europe') 
	{
		titleMsg = "Bourbonnais, France";
		titleBgColor = "#89a115";
		introMsg = "Columbia’s art historians document the Middle Ages through an intensive study of local architectural monuments.  <a href=\"programs-projects/profile-europe.html\">Read more</a>";
		introBgColor = "#cfd6ac";
	}
	else if (regionName == 'middleEast') 
	{
		titleMsg = "Istanbul, Turkey";
		titleBgColor = "#b39137";
		introMsg = "Lamont-Doherty marine geologists and seismologists are working to more accurately forecast near-shore earthquakes.  <a href=\"programs-projects/profile-middleEast.html\">Read more</a>";
		introBgColor = "#dcd0b6";
	}
	else if (regionName == 'asia') 
	{
		titleMsg = "Singapore";
		titleBgColor = "#bc763a";
		introMsg = "A teacher exchange with Singapore initiated by the Summer Research Program for Science Teachers. <a href=\"programs-projects/profile-asia.html\">Read more</a>";
		introBgColor = "#dec9b8";
	}
	else if (regionName == 'oceania') 
	{
		titleMsg = "Papua New Guinea";
		titleBgColor = "#717099";
		introMsg = "Coffee, Gold, and Souls: Commodity Chains and Environmental Change in Papua New Guinea <a href=\"programs-projects/profile-oceania.html\">Read more</a>";
		introBgColor = "#c7c7d5";
	}
	else if (regionName == 'oceans') 
	{
		titleMsg = "Mapmaker of the Ocean Floor";
		titleBgColor = "#587ec3";
		introMsg = "A pioneer of modern oceanography, Marie Tharp was the first to map the unseen topography of the ocean floor on a global scale. <a href=\"programs-projects/profile-oceans.html\">Read more</a>";
		introBgColor = "#bdcadd";
	}
	else 
	{
		titleMsg = "Error.";
		introMsg = "Make sure you have JavaScript enabled on your browser; contact the Vice Provost's office if you feel you have received this message in error.";
	}
	// revert all region tabs to 'off' state
	eval("document.getElementById('nav-americas').src = 'images/index-map/ttl-americas.gif'");
	eval("document.getElementById('nav-africa').src = 'images/index-map/ttl-africa.gif'");
	eval("document.getElementById('nav-europe').src = 'images/index-map/ttl-europe.gif'");
	eval("document.getElementById('nav-middleEast').src = 'images/index-map/ttl-middleEast.gif'");
	eval("document.getElementById('nav-asia').src = 'images/index-map/ttl-asia.gif'");
	eval("document.getElementById('nav-oceania').src = 'images/index-map/ttl-oceania.gif'");
	eval("document.getElementById('nav-oceans').src = 'images/index-map/ttl-oceans.gif'");
	// swap active region tab to 'on' state
	eval("document.getElementById('nav-' + regionName).src = 'images/index-map/ttl-' + regionName + '-on.gif'");
	// swap map graphic to active region
	eval("document.images.map.src = 'images/index-map/map-' + regionName + '.gif'"); 
	// write text for title of profile
	eval("document.getElementById('profileTitle').innerHTML = titleMsg");
	// change background color for title of profile
	eval("document.getElementById('profileTitle').style.backgroundColor = titleBgColor");
	// write profile byline
	eval("document.getElementById('profileText').innerHTML = introMsg"); 
	// change byline background color
	eval("document.getElementById('profileText').style.backgroundColor = introBgColor");
	// swap in photo for active profile
	eval("document.images.profileImage.src = 'images/index-map/profile-' + regionName + '.jpg'");
	
}
