/*
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_dclotp|3','feat_tfty|4','feat_cgbvil|2','feat_troe|4','feat_aesb|3','feat_tsbt|5','feat_asis|3','feat_sagc|2','feat_emwisoeos|3','feat_coayn|3','curr_vp|4');
var caption_feat_dclotp = new Array();
caption_feat_dclotp[caption_feat_dclotp.length] = "Dr. Lien waves to the hundreds of faculty and students that gathered to hear him speak.";
caption_feat_dclotp[caption_feat_dclotp.length] = "Faculty and students with Dr. and Mrs. Lien.";
caption_feat_dclotp[caption_feat_dclotp.length] = "Dr. Lien presents Emory’s President Wagner with a modern work of art.";
var caption_feat_tfty = new Array();
caption_feat_tfty[caption_feat_tfty.length] = "Scenes from Siena Italy";
caption_feat_tfty[caption_feat_tfty.length] = "President Wagner and Siena’s Vice Rector Professor Vittorio Santoro signing the interuniversity agreement";
caption_feat_tfty[caption_feat_tfty.length] = "Emory students at the University of Siena during a study abroad trip";
caption_feat_tfty[caption_feat_tfty.length] = "Scenes from Siena Italy";
var caption_feat_cgbvil = new Array();
caption_feat_cgbvil[caption_feat_cgbvil.length] = "In Monrovia, Liberia, billboards such as this one are part of a public campaign to end violence against women.";
caption_feat_cgbvil[caption_feat_cgbvil.length] = "Sita Ranchod-Nilsson, IDN director, and Casey Dunning, IDN administrative coordinator, with the National Traditional Women’s Council of Liberia.";
var caption_feat_troe = new Array();
caption_feat_troe[caption_feat_troe.length] = "";
caption_feat_troe[caption_feat_troe.length] = "";
caption_feat_troe[caption_feat_troe.length] = "(Left) An artists depiction of The Château of Lusignan, destroyed during the religious wars of the sixteenth century; (Right) From left to right: Jean-Jacques Vincensini of Université de Corse, Emory University’s Matthew Morris, Michel Zink of Collège de France, Claudio Galderisi, Directeur, Centre d’Etudes Supérieures de Civilisation Médievale, at the Ruins of the Château de Lusignan.";
caption_feat_troe[caption_feat_troe.length] = "";
var caption_feat_aesb = new Array();
caption_feat_aesb[caption_feat_aesb.length] = "";
caption_feat_aesb[caption_feat_aesb.length] = "President of the European Parliament, Hans-Gert Pöttering, seated with Professor Tom Lancaster and Evan Goldberg, talks with Emory students.";
caption_feat_aesb[caption_feat_aesb.length] = "Dr. Walther Leisler Kiep and Dr. Beate Lindemann from Atlantik-Brücke, cosponsor of the trip.";
var caption_feat_tsbt = new Array();
caption_feat_tsbt[caption_feat_tsbt.length] = "British photographer, Harry Burton, took more than fourteen hundred photos of the excavation over ten years. Photo by Harry Burton (British, 1879-1940). ©Griffith Institute, Ashmolean Museum, University of Oxford.";
caption_feat_tsbt[caption_feat_tsbt.length] = "(Left) Funerary Mask of Psusennes I: The golden mask lay over the head, chest and part of the shoulders of the mummy of Psusennes, as a layer of protection. The royal headdress with ureaus cobra and the divine false beard he wears attested to his royal and godly status. The use of gold, considered the flesh of the gods, reaffirmed his divinity in the afterlife. (Right) Collar of Neferuptah: Found on the body of Neferuptah, daughter of Amenemhat III, this collar might have been worn in life and was included in the tomb for her use in the afterlife. © Sandro Vannini";
caption_feat_tsbt[caption_feat_tsbt.length] = "(Left) Tutankhamun Shabti: The only such figure found in the Antechamber, it is one of the largest of the servant statuettes.The inscription records the shabti spell from the Book of the Dead, ensuring that the king would do no forced labor in the afterlife. Tutankhamun’s Golden Sandals: These golden sandals have engraved decoration that replicates woven reeds. Created specifically for the afterlife, they still covered the feet of Tutankhamun when Howard Carter unwrapped the mummy. © Sandro Vannini";
caption_feat_tsbt[caption_feat_tsbt.length] = "(Left) A CT scan of King Tut contradicted the long-held theory that a blow to the head killed the boy pharaoh; (Right) Head of Amenhotep III in the Blue Crown: From the Karnak Temple Cachette, this rather unusual statue was modeled in unbaked clay with the features of King Amenhotep III, in particular those seen near the end of his reign. © Sandro Vannini";
caption_feat_tsbt[caption_feat_tsbt.length] = "(Left) The Valley of the Kings, where for a period of nearly 500 years  tombs were constructed for the kings and powerful nobles of the New Kingdom; (Right) Howard Carter, (right) the renowned archaeologist who discovered the tomb of King Tut; Photos by Harry Burton (British, 1879-1940). ©Griffith Institute, Ashmolean Museum, University of Oxford.";
var caption_feat_asis = new Array();
caption_feat_asis[caption_feat_asis.length] = "";
caption_feat_asis[caption_feat_asis.length] = "Dr. Holladay with Yonsei students in Seoul.";
caption_feat_asis[caption_feat_asis.length] = "RThe oldest university in Korea, Yonsei is set on 250 wooded acres in western Seoul on the former site of a Yi Dynasty royal palace.";
var caption_feat_sagc = new Array();
caption_feat_sagc[caption_feat_sagc.length] = "";
caption_feat_sagc[caption_feat_sagc.length] = "Dr. Jeffrey Koplan, Director of the Emory Global Health Institute, with Nozizwe Madlala-Routledge during her visit to Emory as an Institute Distinguished Visiting Fellow.";
var caption_feat_emwisoeos = new Array();
caption_feat_emwisoeos[caption_feat_emwisoeos.length] = "";
caption_feat_emwisoeos[caption_feat_emwisoeos.length] = "Charles Raison and Geshe Lobsang photographed with H.H. the Dalai Lama on a trip to Dharmasala in 2006.";
caption_feat_emwisoeos[caption_feat_emwisoeos.length] = "";
var caption_feat_coayn = new Array();
caption_feat_coayn[caption_feat_coayn.length] = "";
caption_feat_coayn[caption_feat_coayn.length] = "";
caption_feat_coayn[caption_feat_coayn.length] = "“When interviewers ask me how I write a novel, I usually cut them short and say, ‘From left to right.’” - Umberto Eco";
var caption_curr_vp = new Array();
caption_curr_vp[caption_curr_vp.length] = "In the Grand Salon of the Hôtel de Ville, Jean Plantu (right) and Mike Luckovich (left) entertain some 800 guests with cartoons of political leaders.";
caption_curr_vp[caption_curr_vp.length] = "Jean Plantu, Holli Semetko and Mike Luckovich before the backdrop of the winning cartoon by Benjamin Ilunga Yumba from the Democratic Republic of Congo, a dramatic drawing of an African boy peering through a wire fence his large blue eyes sparkling with bright yellow stars of the EU flag.";
caption_curr_vp[caption_curr_vp.length] = "Guests view more than 150 new cartoons on display in a new exhibition “Cartooning for Peace: Perspectives of Europe from around the World” curated by Le Monde’s Jean Plantu.";
caption_curr_vp[caption_curr_vp.length] = "Hôtel de Ville, the splendid City Hall of Paris, was rebuilt in 1882 after many of the city’s treasures and archives were destroyed by fire in the 1871 revolt of the Paris Commune. The building officially has two purposes: to serve as the seat of city government and as a place for public and voluntary associations to hold receptions."

// 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_dclotp":
	  return caption_feat_dclotp;
	  break 
	case "feat_tfty":
	  return caption_feat_tfty;
	  break
	case "feat_cgbvil":
	  return caption_feat_cgbvil;
	  break 
	case "feat_troe":
	  return caption_feat_troe;
	  break 
	case "feat_aesb":
	  return caption_feat_aesb;
	  break 
	case "feat_tsbt":
	  return caption_feat_tsbt;
	  break 
	case "feat_asis":
	  return caption_feat_asis;
	  break 
	case "feat_sagc":
	  return caption_feat_sagc;
	  break 
	case "feat_emwisoeos":
	  return caption_feat_emwisoeos;
	  break 
	case "feat_coayn":
	  return caption_feat_coayn;
	  break 
	case "curr_vp":
	  return caption_curr_vp;
	  break 
	default:
	  return caption_feat_dclotp;
	}
}
//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();
}