/*
To Add A New Page:

General:
1. Open a current file and "save as" another name (the name should be abbreviated like: feat_fh.html"
2. All images should be jpgs and begin with the same name as the page and end with "_" and the image number (e.g., feat_fh_1.jpg)

In this Javascript File:
3. Update end of variable "imgs" with a new entry:
	an apostrophe, the filename (minus the .html), a pipe ("|"), the total number of images, and another apostrophe (e.g., 'feat_fh|4')
4. Add a new caption array variable with the name "caption_" and the filename (minus the .html), (e.g., caption_feat_fh)
5. Update the new caption array with the new captions (follow how it's done below)
6. Update the function "GetCaptionArray()" with 3 new lines as follows:
	case "feat_fh":
	  return caption_feat_fh;
	  break 

In the new html file:
7. Update the "randomImages" reference in the onload function in the body tag with the number that represents the new item's
	 index in the "imgs" array (note, the count starts with 0). (e.g., randomImages(9))

*/


//BEGIN IMAGE SWAP AND CHANGE

var imgs = new Array('home|4','feat_utfog|5','feat_bcolh|2','feat_ahvar|2','feat_voi|4','feat_bhc|3','feat_ajttme|7','feat_sbii|3','feat_tfh|3','feat_fsst|4','feat_sits|4','curr_vp|3','curr_ue|1');
var caption_feat_utfog = new Array();
caption_feat_utfog[caption_feat_utfog.length] = "The 2007 Halle Study Trip group stands inside an earth mover at the site of the Wismut Exhibition in Ronnenburg. The site served as one of the largest uranium mining sites in the world.";
caption_feat_utfog[caption_feat_utfog.length] = "A guide presents photos of the Dresden Frauenkirche after it was destroyed in the bombing of the city during World War II. After an extensive reconstruction period, the church reopened in 2005. Photo by Alma Freeman";
caption_feat_utfog[caption_feat_utfog.length] = "Participants review photos in the newsroom of Germany’s best-selling newspaper, BILD. Photo by Alma Freeman";
caption_feat_utfog[caption_feat_utfog.length] = "The Hamburg headquarters of Europe’s largest magazine publishing house Gruner + Jahr. Photo by Alma Freeman";
caption_feat_utfog[caption_feat_utfog.length] = "The group toured the old town of Meissen, home of the factory where Europe’s first porcelain was produced. Photo by Alma Freeman";
var caption_feat_bcolh = new Array();
caption_feat_bcolh[caption_feat_bcolh.length] = "Manuscript photos by Kay Hinton";
caption_feat_bcolh[caption_feat_bcolh.length] = "Steve Enniss (center) visits with author Salman Rushdie (right) and Emory Professor Ronald Schuchard during a book signing at MARBL. Photo by University Photography";
var caption_feat_ahvar = new Array();
caption_feat_ahvar[caption_feat_ahvar.length] = "Manuscript photos by Kay Hinton. TS. Eliot photo printed by permission of the Eliot Estate and Faber and Faber Ltd. © Valerie Eliot 2007";
caption_feat_ahvar[caption_feat_ahvar.length] = "Ron Schuchard sits in T.S. Eliot’s corner chair in the East Coker pub in Somerset, England, where Eliot wrote one of the Four Quartets.";
var caption_feat_voi = new Array();
caption_feat_voi[caption_feat_voi.length] = "Photo by Tanya Turan";
caption_feat_voi[caption_feat_voi.length] = "Journalism interns Robin Chanin (left) and Jean Tinkham.";
caption_feat_voi[caption_feat_voi.length] = "A group of journalism and global health students spent a month on an interdisciplinary internship program in Cape Town, South Africa.";
caption_feat_voi[caption_feat_voi.length] = "A blanket of clouds envelopes Cape Town’s Table Mountain. Photo by Tanya Turan";
var caption_feat_bhc = new Array();
caption_feat_bhc[caption_feat_bhc.length] = "Benjamin Mbakwem’s non-governmental organization assists a community in Imo State, Nigeria, with a project involving a palm oil processing mill";
caption_feat_bhc[caption_feat_bhc.length] = "HIV/AIDS mentoring session for students participating in the 2005 Scenarios from Africa contest at a secondary boys school in Imo State";
caption_feat_bhc[caption_feat_bhc.length] = "Mbakwem with Kate Winskell, the developer of the CPL program, in front of the RSPH building. Photo by Bryan Meltz";
var caption_feat_ajttme = new Array();
caption_feat_ajttme[caption_feat_ajttme.length] = "Photo by Alma Freeman";
caption_feat_ajttme[caption_feat_ajttme.length] = "Provost Earl Lewis (left) with trip participant Mark McLeod at the site of Tent of Nations, a Palestinian-run project that seeks to bring youth of various cultures together to build bridges of understanding, reconciliation, and peace. Photo by Alma Freeman";
caption_feat_ajttme[caption_feat_ajttme.length] = "Susan Henry-Crowe listens as Peter Nasser, a Christian Palestinian and Emory College alum, talks about his plans to open a Western-style restaurant in downtown Ramallah in the West Bank. Photo by Alma Freeman";
caption_feat_ajttme[caption_feat_ajttme.length] = "The Journeys group in front of the Dome of the Rock in the Old City of Jerusalem. Photo by Alma Freeman";
caption_feat_ajttme[caption_feat_ajttme.length] = "Rania Arnaout shares a story about her decision to wear a headscarf during a visit to Al-Arroub refugee camp near Hebron. Photo by Alma Freeman";
caption_feat_ajttme[caption_feat_ajttme.length] = "A child looks on during a bar mitzvah ceremony at the Western Wall in Jerusalem. Photo by Alma Freeman";
caption_feat_ajttme[caption_feat_ajttme.length] = "A boy tags along during a tour of  Al-Arroub. Photo by Alma Freeman";
var caption_feat_sbii = new Array();
caption_feat_sbii[caption_feat_sbii.length] = "Photo by Alma Freeman";
caption_feat_sbii[caption_feat_sbii.length] = "The slogan “Na, Nach, Nachma, Nachman M’Uman” is seen throughout Israel.";
caption_feat_sbii[caption_feat_sbii.length] = "Director of the Rabbi Donald A. Tam Institute for Jewish Studies Jeffrey Lesser. Photo by Jon Rou";
var caption_feat_tfh = new Array();
caption_feat_tfh[caption_feat_tfh.length] = "Photo © MedShare International";
caption_feat_tfh[caption_feat_tfh.length] = "Emory student volunteers Tuan Nguyen (left) and Evan Tiderington help organize medical equipment.";
caption_feat_tfh[caption_feat_tfh.length] = "Photo © CURE International";
var caption_feat_fsst = new Array();
caption_feat_fsst[caption_feat_fsst.length] = "Photo by Mehmet Baysan";
caption_feat_fsst[caption_feat_fsst.length] = "Halle Student Study Trip group (front row, left to right) LeTiffany Obozele, Ana Bedayo and Holly Cato (back row, left to right) Todd Brehm, Brett Zuckerman, Glen Goncharow and Laurent Stemmler";
caption_feat_fsst[caption_feat_fsst.length] = "Bedayo (front) with Goncharow and Zuckerman during a tour of the European Parliament building. ";
caption_feat_fsst[caption_feat_fsst.length] = "Located in the Grand-Place, the House of the Dukes of Brabant is made up of seven guildhouses each with a different name. ";
var caption_feat_sits = new Array();
caption_feat_sits[caption_feat_sits.length] = "Photo by Andrea Childress";
caption_feat_sits[caption_feat_sits.length] = "Students watch an outdoor shadow puppet performance accompanied by Emory’s Gamelan Ensemble, directed by Steve Everett. ";
caption_feat_sits[caption_feat_sits.length] = "Everett (right) with Javanese author and political dissident Pramoedya Ananta Toer.";
caption_feat_sits[caption_feat_sits.length] = "Javanese shadow puppets (Wayang Kulit) were used during the outdoor performance.";
var caption_curr_vp = new Array();
caption_curr_vp[caption_curr_vp.length] = "Holli Semetko (center) with The Halle Institute Student Study Trip group in Brussels";
caption_curr_vp[caption_curr_vp.length] = "Dean Susan Henry-Crowe in Jerusalem on the Journeys trip to the Middle East. Photo by Kay Hinton";
caption_curr_vp[caption_curr_vp.length] = "Germany Study Trip participant Marcia Holstad (left) and trip leader Dean Tom Lancaster (right) at a winery in the Rheingau region. Photo by Alma Freeman";
var caption_curr_ue = new Array();
caption_curr_ue[caption_curr_ue.length] = "The Carlos Museum displays 16 Tibetan thangka paintings for 'Buddha in Paradise: A Celebration in Himalayan Art,' an exhibition in honor of the visit and professorship of His Holiness the Dalai Lama.";

// delay in milliseconds between image swaps 1000 = 1 second
var delay;
var counter = 0;
var section = 0;


//Preload Images
//var home_1 = new Image(); home_1.src = "images/home_1.jpg";
for (j=0;j<=imgs.length-1;j++)
{
	var sectinfo = GetSection(j);
	var sectname = sectinfo[0];
	var totalimgs = sectinfo[1];
	for (i=0;i<=totalimgs;i++)
	{
		eval("var " + sectname + "_" + i + " = new Image(); " + sectname + "_" + i + ".src = 'images/" + sectname + "_" + i + ".jpg'");
	}
}

function preloadImgs(){
	
	
  	counter = document.getElementById("hdnimgnum").value;
}

function randomImages(sect){

section = sect; //update global section variable
if (section==0)
{
	delay = 4000;
}
else
{
	delay = 8000
}
var sectname = GetSection(sect); //get name of section and total number of images
counter = parseInt(document.getElementById("hdnimgnum").value); //get counter

  if(counter >= (sectname[1])){ //assure counter doesn't go past total number of images, if so set back to 0
    document.getElementById("hdnimgnum").value = 0;
	counter=0;
  }
  counter++;
  var newcounter = counter;
  eval( "var imgsrc = " + sectname[0] + "_" + newcounter + ".src")
  //swapImage(newcounter, "images/" + sectname[0] + "_" + newcounter + ".jpg" ); //swap the image with the next one
  swapImage(newcounter, imgsrc ); //swap the image with the next one
  
  setTimeout('randomImages(' + sect + ')', delay); //repeat after delay interval
  
}
function swapImage(imgnum,imgpath)
{
	document.getElementById('main').src = imgpath;
	document.getElementById("hdnimgnum").value = imgnum; //set current image number
	ChangeImageClick(imgnum, section, 1) //change underline on numbers
}
function GetSection(section)
{
	//returns section name and total number of images
	//from the array named "imgs"
	return imgs[section].split("|");
}
function ChangeImageClick(imgnum, sect, infunc)
{
	var sectname = GetSection(sect);//get name of section and total number of images
	
	TurnOffNums(sectname[1], sect, infunc) //turn off all numbers (remove underline)
	//turn on selected image number (add underline)
	document.getElementById("num" + imgnum).innerHTML = '<a href="javascript:void(ChangeImageClick(' + imgnum + ',' + sect +',0))" class="numon">' + imgnum + '</a>&#160;'
	if (sectname[0]!="home")
	{
	var captionarray = GetCaptionArray(sectname[0]);
	document.getElementById("spCaption").innerHTML = captionarray[imgnum-1];
	}
	//this code manually changes the image if a number has been clicked on
	//so this code should only run in that case, not if this function is called from another function
	//as it is in the swapImage function
	if (infunc==0)
	{
		eval( "var imgsrc = " + sectname[0] + "_" + imgnum + ".src")
		//document.getElementById("main").src = "images/" + sectname[0] + "_" + imgnum + ".jpg";
		document.getElementById('main').src = imgsrc;
	}
	document.getElementById("hdnimgnum").value = imgnum; //set hidden form field to new image number
}
function TurnOffNums(totalnums, sect, infunc)
{
	//turn off all numbers (remove underline by assigning new class name)
	for (i=1; i<=totalnums; i++)
	{
		document.getElementById("num" + i).innerHTML = '<a href="javascript:void(ChangeImageClick(' + i + ',' + sect +',0))" class="numoff">' + i + '</a>&#160;'
	}
}
function GetCaptionArray(sect)
{
	switch(sect)
	{
	case "feat_utfog":
	  return caption_feat_utfog;
	  break
	case "feat_bcolh":
	  return caption_feat_bcolh;
	  break 
	case "feat_ahvar":
	  return caption_feat_ahvar;
	  break 
	case "feat_voi":
	  return caption_feat_voi;
	  break 
	case "feat_bhc":
	  return caption_feat_bhc;
	  break 
	case "feat_ajttme":
	  return caption_feat_ajttme;
	  break 
	case "feat_sbii":
	  return caption_feat_sbii;
	  break 
	case "feat_tfh":
	  return caption_feat_tfh;
	  break 
	case "feat_fsst":
	  return caption_feat_fsst;
	  break 
	case "feat_sits":
	  return caption_feat_sits;
	  break 
	case "curr_vp":
	  return caption_curr_vp;
	  break 
	case "curr_ue":
	  return caption_curr_ue;
	  break 
	default:
	  return caption_feat_utfog;
	}
}
//END IMAGE SWAP AND CHANGE
function NavOpen(num)
{
	CloseAllNavs()
	document.getElementById("nav" + num).style.visibility = "visible";
	document.getElementById("nav" + num).style.display = "block";
	document.getElementById("arrow" + num).src = "images/arrow_red.gif";
	document.getElementById("navtxt" + num).className = "navon";
}
function NavClose(num)
{
	CloseAllNavs()
	document.getElementById("nav" + num).style.visibility = "hidden";
	document.getElementById("nav" + num).style.display = "none";
	document.getElementById("arrow" + num).src = "images/arrow_yellow.gif";
}
function CloseAllNavs()
{
	document.getElementById("nav1").style.visibility = "hidden";
	document.getElementById("nav1").style.display = "none";
	document.getElementById("nav2").style.visibility = "hidden";
	document.getElementById("nav2").style.display = "none";
	document.getElementById("arrow1").src = "images/arrow_yellow.gif";
	document.getElementById("arrow2").src = "images/arrow_yellow.gif";
	document.getElementById("navtxt1").className = "nav";
	document.getElementById("navtxt2").className = "nav";
}
var newpic = new Object;
newpic.closed = true;
function OpenPic(fn, newtitle, w,h)
{
	var broww = w + 20;
	var browh = h + 20;
	var screenheight = (screen.availHeight/2) - (h/2);
	var screenwidth = (screen.availWidth/2) - (w/2);
	if (!newpic.closed)
	{newpic.close();}
	newpic = window.open("", "picnew","width=" + broww + ",height=" + browh + ",scrollbars=no,menubar=no,resizable=no,toolbar=no,location=no,status=yes,left=" + screenwidth + ",top=" + screenheight + ",screenX=" + screenwidth + ",screenY=" + screenheight)
	newpic.document.write("<html><head><title>" + newtitle + "</title><style>BODY{margin:10;background-color:#ecebec;}</style></head><body><img src='" + fn + "' width='" + w + "' height='" + h + "' border='0'></body></html>");
	newpic.document.close();
	newpic.focus();
}
function OpenPF()
{
	var pfwin = window.open("","winpf");
	pfwin.document.write("<html><head><title>EMORY : in the world</title><style type='text/css'>body{margin:10px;font-family: Arial, san-serif;font-size:12px;}.title2{font-size:18px;}</style></head><body><b style='font-size:14px;'>EMORY : in the world</b><span style='position:relative;margin-left:20px;'><a href='javascript:void(PrintWin())' style='color:#777777;font-size:11px;'>[print this page]</a></span><hr color='#000000' style='height:1px;'/>" + document.getElementById("divText").innerHTML + "<script language='JavaScript'>function PrintWin(){window.print();}</script></body></html>")
	pfwin.document.close();
	pfwin.focus();
}