var isIe4=false, isDom=false, isMac=false, isNs4=false, isWin=false, isLoaded=false, isIe=false;
var textStr, slideShow=true, curImg, curProject, theShow, showPaused=false, imgNums;
var birminghamText=new Array(), edinburghText=new Array(), pinderfieldsText=new Array(), blackburnText=new Array();
var uhndText=new Array(), uhnd2Text=new Array(), hopeText=new Array(), uclhText=new Array(), infirmaryText=new Array(), fifeText=new Array();

function init()
{
	if (isDom)
	{
		isLoaded=true;
	}
}

birminghamText[1]="3D impression of the new Birmingham hospital";
birminghamText[2]="The south east view of the new hospital";
birminghamText[3]="An impression of the  modular design from the air";
edinburghText[1]="The entrance to the Royal Infirmary of Edinburgh";
edinburghText[2]="Inside the mall";
edinburghText[3]="Royal Infirmary of Edinburgh Accident and Emergency entrance";
pinderfieldsText[1]="An impression of how Pinderfields Hospital might look";
pinderfieldsText[2]="An impression of how Pinderfields Hospital might look";
blackburnText[1]="The new Queens Park Hospital at an early design stage";
blackburnText[2]="Queens Park Hospital nears completion";
blackburnText[3]="The new hospital takes shape";
uhndText[1]="University Hospital North Durham main entrance";
uhndText[2]="UHND from the air";
uhndText[3]="The approach to UHND";
uhnd2Text[1]="Salsa in Ward";
uhnd2Text[2]="Belly dancer in Reception";
uclhText[1]="UCLH";
uclhText[2]="The UCLH tower ";
uclhText[3]="A view of UCLH from Euston Road";
infirmaryText[1]="Takahiro Iwasaki's <em>Rain of Text</em>";
infirmaryText[2]="Melanie Perkin's <em>DNA</em>";
hopeText[1]="Hope Hospital, Eccles Old Road entrance";
hopeText[2]="Hope Hospital Concourse";
hopeText[3]="Hope Hospital Concourse entrance";
fifeText[1]="Fife Hospital Overview 1";
fifeText[2]="Fife Hospital Overview 2";

function showPop(project,img)
{
	temp = eval(project+"Text");
	textStr = temp[img];
	imgNums=temp.length;
	imgStr='<img src="/resources/i/gallery/'+project+"_"+img+'.jpg" width="418" height="372" />';	
positionMe('popUp',180,111);
	writeMe('mainPic',imgStr);
	writeMe('title',textStr);
	if (slideShow)
	{
		writeMe('title',textStr);
		curImg = img;
		curProject = project;
		theShow = setTimeout("nextImg()", 5000);
	}
	showMe('popUp');
}

function nextImg()
{
	if (curImg==(imgNums-1)) curImg=0;
	curImg++;
	clearTimeout(theShow);
	showPop(curProject,curImg);
}
function prevImg()
{
	if (curImg==1) curImg=imgNums;
	curImg--;
	showPop(curProject,curImg);
}

function hidePop()
{
	hideMe('popUp');
	document.getElementById('popUp').style.display="none";
	clearTimeout(theShow);
	resetVals();
}
function left()
{
	clearTimeout(theShow);
	slideShow=false;
	prevImg();
	writeMe('playPause','<img src=\"/resources/i/pop_up/play.gif\" height=\"27\" width=\"27\" alt=\"play\" border=\"0\" />');
	showPaused = true;
}
function right()
{
	clearTimeout(theShow);
	slideShow=false;
	nextImg();
	writeMe('playPause','<img src=\"/resources/i/pop_up/play.gif\" height=\"27\" width=\"27\" alt=\"play\" border=\"0\" />');
	showPaused = true;
}
function pause()
{
	if (!showPaused)
	{
		clearTimeout(theShow);
		writeMe('title',textStr);
		writeMe('playPause','<img src=\"/resources/i/pop_up/play.gif\" height=\"27\" width=\"27\" alt=\"play\" border=\"0\" />');
		showPaused = true;
	}
	else
	{
		showPaused = false;
		slideShow = true;
		writeMe('playPause','<img src=\"/resources/i/pop_up/pause.gif\" height=\"27\" width=\"27\" alt=\"pause\" border=\"0\" />');
		showPop(curProject,curImg);
	}
}
function stop()
{
	clearTimeout(theShow);
	slideShow = false;
	showPaused = true;
	writeMe('playPause','<img src=\"/resources/i/pop_up/play.gif\" height=\"27\" width=\"27\" alt=\"play\" border=\"0\" />');
	writeMe('title',textStr);
}
function resetVals()
{
	curImg=0;
	project=0;
	textStr="";
	slideShow=true;
	showPaused = false;
}

function showMe(divID)
{
	if (isLoaded) document.getElementById(divID).style.visibility='visible';
}

function hideMe(divID)
{
	if (isLoaded) document.getElementById(divID).style.visibility='hidden';
}

function writeMe(divID,divText)
{
	if (isLoaded)
	{
		document.getElementById(divID).innerHTML=divText;
	}
	if (isNs4)
	{
		document.layers[divID].document.open()
		document.layers[divID].document.write(divtext)
		document.layers[divID].document.close()
	}
}

function positionMe(divID,l,t)
{
	if (isLoaded)
	{
		document.getElementById(divID).style.display="block";
		document.getElementById(divID).style.position="absolute";
		document.getElementById(divID).style.top=t+"px";
		document.getElementById(divID).style.left=l+"px";
	}
}



isMac=(navigator.platform=="MacPPC")? true:false;
isWin=(navigator.appVersion.indexOf("Win")!=-1)? true:false;
isIe=(navigator.appName=="Microsoft Internet Explorer")? true:false;
isIe4=(document.all)? true:false;
isDom=(document.getElementById)? true:false;
if ((parseInt(navigator.appVersion)==4) && (navigator.appName=="Netscape"))
{
	isNs4 = true;
	isImg = true;
}
window.onload=init;