var photoViewer=new Object();
var photoIntroTexts=new Array;

photoViewer.initialize=function()
{
	var photoImage=document.getElementById("photoImage");
	var photoIntro=document.getElementById("photoIntro");
	photoViewer.m_photoImage=photoImage;
	photoViewer.m_photoIntro=photoIntro;

	photoViewer.createIntroText(0,"The Bund, Shanghai, 1890s","Photographed by William Francis Stevenson","Collected by Peter Hodge");
	photoViewer.createIntroText(1,"Foreign staff, Chinese Imperial Maritime Customs, Tientsin, 1877 or 1878","Photographed by William Francis Stevenson","Collected by Peter Hodge");
	photoViewer.createIntroText(2,"American community, Shanghai, 1890s","Photographed by William Francis Stevenson","Collected by Peter Hodge");
	photoViewer.createIntroText(3,"The English Church (later to become Holy Trinity Cathedral), Shanghai, 1890s","Photographed by William Francis Stevenson","Collected by Peter Hodge");
	photoViewer.createIntroText(4,"The Bund, Shanghai, 1890s","Photographed by William Francis Stevenson","Collected by Peter Hodge");
	photoViewer.createIntroText(5,"Suzhou Creek, Shanghai, 1890s","Photographed by William Francis Stevenson","Collected by Peter Hodge");
	photoViewer.createIntroText(6,"Nanking Road, Shanghai, looking towards the Bund, 1890s","Photographed by William Francis Stevenson","Collected by Peter Hodge");
	photoViewer.createIntroText(7,"Chinese women raising cocoons",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(8,"Chinese farmers",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(9,"Chinese government officials in Qing Dynasty",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(10,"Chinese women in Qing Dynasty",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(11,"Chinese emperor in Qing Dynasty",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(12,"Chinese emperor in Qing Dynasty",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(13,"Chinese empress in Qing Dynasty",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(14,"Chinese senior government officials in Qing Dynasty",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(15,"Chinese woman working on silk product",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(16,"Chinese woman working on silk product",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(17,"Chinese fisherman",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(18,"Chinese handicraft worker working on linen product",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(19,"Chinese handicraft worker working on painting product",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(20,"Chinese worker working on chinaware",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(21,"Chinese worker working on ironware",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(22,"Chinese shoemaker",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(23,"Chinese tailor",null,"collected by http://www.guoxue.com");
	photoViewer.createIntroText(24,"Chinese coolie",null,"collected by http://www.guoxue.com");

	photoViewer.showPhoto();
};

photoViewer.createIntroText=function(index,title,taker,collector)
{
	var photoIntroText=document.createElement("span");
	photoIntroText.appendChild(document.createTextNode(title));
	photoIntroText.appendChild(document.createElement("br"));
	if(taker!=null)
	{
		photoIntroText.appendChild(document.createTextNode(taker));
		photoIntroText.appendChild(document.createElement("br"));
	}
	photoIntroText.appendChild(document.createTextNode(collector));
	photoIntroTexts[index]=photoIntroText;
};

photoViewer.showPhoto=function()
{
	var index=Math.floor(Math.random()*25+1);
	photoViewer.m_photoImage.src="photos/pic"+index+".jpg";
	if(photoViewer.m_photoIntro.hasChildNodes())
		photoViewer.m_photoIntro.removeChild(photoViewer.m_photoIntro.lastChild);
	photoViewer.m_photoIntro.appendChild(photoIntroTexts[index-1]);
};