/*
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_fh|4','feat_cmdt|8','feat_mag|3','feat_gise|2','feat_itsotgg|3','feat_eghi|5','feat_ethm|2','feat_etsci|2','curr_ian|4','curr_ie|5','curr_vp|1','curr_ue|1');
var caption_feat_fh = new Array();
caption_feat_fh[caption_feat_fh.length] = "Built on the site of the Old Fort, one of South Africa's most notorious prisons in which thousands of people were jailed, including Mahatma Gandhi and Nelson Mandela. The new Constitutional Court building was designed to reflect the values of the new constitutional democracy. The Court's permanent home, above, was inaugurated by President Thabo Mbeki on Human Rights Day 2004. Photo by Corinne A. Kratz";
caption_feat_fh[caption_feat_fh.length] = "The main entrance door of the Court is made up of wooden panels each representing a theme from the Bill of Rights, presented in the 11 languages recognized by the Constitution, including sign language. Photo by Corinne A. Kratz";
caption_feat_fh[caption_feat_fh.length] = "Displayed throughout the building is Justice Albie Sachs' collection of over 200 tapestries, engravings, sculptures and paintings created by local artists. Right:  A metal sculpture with punctured screens allows for transparency in the building while protecting the wall surrounding the Court. Photo by Corinne A. Kratz";
caption_feat_fh[caption_feat_fh.length] = "(left to right) Justice Sachs, Emory's Center for the Study of Public Scholarship Co-Director Corinne Kratz, and Emory President James Wagner. Photo by Mehmet Baysan";
var caption_feat_cmdt = new Array();
caption_feat_cmdt[caption_feat_cmdt.length] = "The &quot;Cradle of Christianity&quot; exhibition displays one of the most important of the Dead Sea Scrolls, the Temple Scroll. The Israel Museum, Jerusalem";
caption_feat_cmdt[caption_feat_cmdt.length] = "Ossuary of &quot;Joseph son of Caiaphas&quot; from 1st-century Jerusalem, will be one of the highlights at the &quot;Cradle of Christianity&quot; exhibition. Photo by Avraham Hay";
caption_feat_cmdt[caption_feat_cmdt.length] = "5th-century menorah with depressions for oil lamps discovered at the Synagogue at Hammat Tiberias, Sea of Galilee. The Israel Museum, Jerusalem. Photo by David Harris";
caption_feat_cmdt[caption_feat_cmdt.length] = "1st century fragmentary Greek inscription forbidding foreigners from entry to the Temple prescient discovered in the Temple Mount area. Israel Antiquities Authority, Jerusalem. Photo by Avraham Hay";
caption_feat_cmdt[caption_feat_cmdt.length] = "&quot;Fabled Beasts in a Landscape&quot; from 1720 is one of the Indian miniature paintings displayed at the recent &quot;Domains of Wonder&quot; exhibition at the Carlos Museum. &copy; San Diego Museum of Art";
caption_feat_cmdt[caption_feat_cmdt.length] = "A visitor views a piece in the Egyptian galleries of the Carlos Museum. Photo by Holly Sasnett.";
caption_feat_cmdt[caption_feat_cmdt.length] = "The Museum's galleries of Greek and Roman Art. Photo by Holly Sasnett ";
caption_feat_cmdt[caption_feat_cmdt.length] = "Carlos Museum Director Bonnie Speed in the galleries of Greek and Roman Art. Photo by University Photo";
var caption_feat_mag = new Array();
caption_feat_mag[caption_feat_mag.length] = "";
caption_feat_mag[caption_feat_mag.length] = "";
caption_feat_mag[caption_feat_mag.length] = "Laura Emiko Soltis with former President Jimmy Carter and his wife, Rosalynn, taken during Soltis' internship at The Carter Center in fall 2005. Photo by A. Poyo ";
var caption_feat_gise = new Array();
caption_feat_gise[caption_feat_gise.length] = "Emory students participate in the summer study abroad program in Siena, Italy. ";
caption_feat_gise[caption_feat_gise.length] = "Emory students participate in the summer study abroad program in Siena, Italy. ";
var caption_feat_itsotgg = new Array();
caption_feat_itsotgg[caption_feat_itsotgg.length] = "Pilgrims to Samothrace came from cities across the Mediterranean to be initiated into the Mysteries of the Great Gods.  Their first opportunity to gather as a group was in the Theatrical Circle on the Eastern Hill pictured here";
caption_feat_itsotgg[caption_feat_itsotgg.length] = "Wescoat (left) and Emory art history graduate student Rachel Foulk measure a several-ton threshold building block from the Sanctuary site. ";
caption_feat_itsotgg[caption_feat_itsotgg.length] = "The most famous discovery from the island, the Winged Victory of Samothrace found in 1863, now stands at the top of the grand staircase in the Louvre museum in Paris.";
var caption_feat_eghi = new Array();
caption_feat_eghi[caption_feat_eghi.length] = "Photo by: Go Tanaka-Bangladesh";
caption_feat_eghi[caption_feat_eghi.length] = "Photo by: Bentley Brown-Chad";
caption_feat_eghi[caption_feat_eghi.length] = "Photo by: Juli Powers-Bolivia";
caption_feat_eghi[caption_feat_eghi.length] = "Photo by: Jie Liu-China";
caption_feat_eghi[caption_feat_eghi.length] = "Left photo by: Maya Ravani-Kenya. Right photo by: Kinnery Naik-India";
var caption_feat_ethm = new Array();
caption_feat_ethm[caption_feat_ethm.length] = "Photo by Emory Creative Group";
caption_feat_ethm[caption_feat_ethm.length] = "(left to right) The Dalai Lama signs the documents accepting his Presidential Distinguished Professorship at Emory, presented by Vice Provost for International Affairs Holli Semetko and Director of the of the Emory-Tibet Partnership Geshe Lobsang Tenzin.";
var caption_feat_etsci = new Array();
caption_feat_etsci[caption_feat_etsci.length] = "An Emory delegation recently traveled to Dharamsala, India to visit the Dalai Lama and to hear his ideas for the Emory-Tibet Science Initiative. Those present included (left to right) Geshe Lhakdor, director of the Library of Tibetan Works and Archives; Preetha Ram, assistant dean for science; His Holiness the Dalai Lama; Charles Raison,  assistant professor in Emory's School of Medicine's Mind Body Program; and Geshe Lobsang Tenzin, director of the Emory-Tibet Partnership.";
caption_feat_etsci[caption_feat_etsci.length] = "";
var caption_curr_ian = new Array();
caption_curr_ian[caption_curr_ian.length] = "Provost Earl Lewis (right) presents this year's Creekmore Award to Carlos del Rio, professor of medicine and chief of the Emory medical service at Grady Hospital. Photo by Wilford Harewood";
caption_curr_ian[caption_curr_ian.length] = "(left to right) Emory President James Wagner, Carlos del Rio, Marion Creekmore, and Dean of Emory's School of Medicine Thomas Lawley.  Photo by Wilford Harewood";
caption_curr_ian[caption_curr_ian.length] = "left: Sheth Award winner Shariffa Al-Jabri. right: Al-Jabri's sister-in-law Zakia Amour Al-Suqri (left) and sister Zakia Saif Al-Jabri traveled from Oman for the ceremony.";
caption_curr_ian[caption_curr_ian.length] = "(left to right) School of Nursing Dean Marla Salmon, Professor Jagdish Sheth, Shariffa Al-Jabri, Madhu Sheth, President Wagner, and Vice Provost for International Affairs Holli Semetko";
var caption_curr_ie = new Array();
caption_curr_ie[caption_curr_ie.length] = "(left to right) Amanda Sue Niskar 95PH, Jackie Bitensky 90C, Ben Brewer 05C, Julie Nemirovsky 06B, Lauren Skiba 06C, and Richard Kanton 68C";
caption_curr_ie[caption_curr_ie.length] = "Speakers at the panel included: (left to right) Hungarian Ambassador to the United States Andras Simonyi; Vice Provost for International Affairs Holli Semetko; Gyula Kodol&aacute;nyi; Ferenc M&aacute;dl; and Academy-Award-winning cinematographer Vilmos Zsigmond, who showed details from his 1962 film Hungary in Revolt.";
caption_curr_ie[caption_curr_ie.length] = "Award-winning journalist Charlayne Hunter-Gault. Photo by Alma Freeman";
caption_curr_ie[caption_curr_ie.length] = "Emory's Distinguished Writer in Residence Salman Rushdie. Photo by Ann Borden";
caption_curr_ie[caption_curr_ie.length] = "Geshe Thupten Jinpa at Emory. Photo by Craig Semetko";
var caption_curr_vp = new Array();
caption_curr_vp[caption_curr_vp.length] = "Vice Provost for International Affairs Holli Semetko meets with His Holiness the Dalai Lama in Bangalore, India.";
var caption_curr_ue = new Array();
caption_curr_ue[caption_curr_ue.length] = "Monks of Drepung Loseling Monastery construct a sand mandala at the Carlos Museum during Emory's annual Tibet Week. Photo by Tony Benner";

// 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>'
	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>'
	}
}
function GetCaptionArray(sect)
{
	switch(sect)
	{
	case "feat_fh":
	  return caption_feat_fh;
	  break
	case "feat_cmdt":
	  return caption_feat_cmdt;
	  break 
	case "feat_mag":
	  return caption_feat_mag;
	  break 
	case "feat_gise":
	  return caption_feat_gise;
	  break 
	case "feat_itsotgg":
	  return caption_feat_itsotgg;
	  break 
	case "feat_eghi":
	  return caption_feat_eghi;
	  break 
	case "feat_ethm":
	  return caption_feat_ethm;
	  break 
	case "feat_etsci":
	  return caption_feat_etsci;
	  break 
	case "curr_ian":
	  return caption_curr_ian;
	  break 
	case "curr_ie":
	  return caption_curr_ie;
	  break 
	case "curr_vp":
	  return caption_curr_vp;
	  break 
	case "curr_ue":
	  return caption_curr_ue;
	  break 
	default:
	  return caption_feat_fh;
	}
}
//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();
}