var LIMIT=16;
var PAGES=3;

newWindow=null;
currentImage=null;
imgPrefix="portfolio/";
thumbPrefix="portfolio/thumbs/";
imgSuffix=".jpeg";
thbSuffix=".gif";

images=new Array();
var title=null;
title=new Array();

var minim=0; 
var maxim=0;
var image=0;
var imdex=0; 		//imdex = image index
var imdex2=0;

title[imdex2++]= "";
images[imdex++]= "blank";

images[imdex++]= "bma";
images[imdex++]= "dulwich01";
images[imdex++]= "dulwich02";
images[imdex++]= "dulwich03";
images[imdex++]= "eton01";
images[imdex++]= "eton02";
images[imdex++]= "eton03";
images[imdex++]= "harrow01";
images[imdex++]= "harrow02";
images[imdex++]= "chelsea";
images[imdex++]= "kc03";
images[imdex++]= "oakhill01";
images[imdex++]= "oakhill02";
images[imdex++]= "taylor";
images[imdex++]= "rcm01";
images[imdex++]= "rcm02";
images[imdex++]= "schering02";
images[imdex++]= "schering01";
images[imdex++]= "stmary";
images[imdex++]= "stpauls";
images[imdex++]= "tiffin01";
images[imdex++]= "tiffin02";
images[imdex++]= "tiffin03";
images[imdex++]= "tiffin04";
images[imdex++]= "asl01";
images[imdex++]= "asl02";
images[imdex++]= "asldisp";
images[imdex++]= "opt01";
images[imdex++]= "opt02";
images[imdex++]= "rsm01";
images[imdex++]= "rsm02";
images[imdex++]= "rsm03";
images[imdex++]= "senate";
images[imdex++]= "univhosp";
images[imdex++]= "psi6";
images[imdex++]= "limehouse";
images[imdex++]= "blg";
images[imdex++]= "higgs";
images[imdex++]= "lincoln01";
images[imdex++]= "rb01";
images[imdex++]= "rb02";
images[imdex++]= "rb03";
images[imdex++]= "lawsoc";
//imageCounter=images.length-1;
imageCounter=imdex-1;

title[imdex2++]= "British Medical Association";
title[imdex2++]= "Dulwich College";
title[imdex2++]= "Dulwich College";
title[imdex2++]= "Dulwich College";
title[imdex2++]= "Eton College";
title[imdex2++]= "Eton College";
title[imdex2++]= "Eton College";
title[imdex2++]= "Harrow School - The Vaughan Library";
title[imdex2++]= "Harrow School";
title[imdex2++]= "Institute of the Arts London - Chelsea College of Art and Design";
title[imdex2++]= "King's College School, Wimbledon";
title[imdex2++]= "Oak Hill College";
title[imdex2++]= "Oak Hill College";
title[imdex2++]= "Oxford University - Taylor Institution";
title[imdex2++]= "Royal College of Music";
title[imdex2++]= "Royal College of Music";
title[imdex2++]= "Schering Health Care";
title[imdex2++]= "Schering Health Care";
title[imdex2++]= "St Mary’s College";
title[imdex2++]= "St Paul's School - Walker Library";
title[imdex2++]= "Tiffin School";
title[imdex2++]= "Tiffin School";
title[imdex2++]= "Tiffin School";
title[imdex2++]= "Tiffin School";
title[imdex2++]= "The American School in London";
title[imdex2++]= "The American School in London";
title[imdex2++]= "The American School in London";
title[imdex2++]= "The College of Optometrists";
title[imdex2++]= "The College of Optometrists";
title[imdex2++]= "The Royal Society of Medicine";
title[imdex2++]= "The Royal Society of Medicine";
title[imdex2++]= "The Royal Society of Medicine";
title[imdex2++]= "School of Economic Science";
title[imdex2++]= "University Hospital, Lewisham";
title[imdex2++]= "Policy Studies Institute";
title[imdex2++]= "Limehouse Library, London";
title[imdex2++]= "Barlow Lyde and Gilbert";
title[imdex2++]= "Higgs and Sons";
title[imdex2++]= "Lincoln’s Inn";
title[imdex2++]= "Reed Smith Richards Butler";
title[imdex2++]= "Reed Smith Richards Butler";
title[imdex2++]= "Reed Smith Richards Butler";
title[imdex2++]= "The Law Society";

if (location.search.length > 0)
 {
 currentImage=location.search.substring(1);
 }
for (var p=0; p<=PAGES; p++) {
  if ((currentImage>LIMIT*p) && (currentImage<=LIMIT*(p+1))) {minim=(LIMIT*p)+1; maxim=Math.min(LIMIT*(p+1),imageCounter)}
 } 

function opendoc (targetDoc, windowName, xsize, ysize, toolb)
 { 
  var windowAttrib = 
     'toolbar=' + toolb + ',location=no,directories=0,status=0,menubar=0,' + 
    'scrollbars=1,resizable=1,width=' + xsize + ',height=' + ysize; 
	 
   newWindow = window.open (targetDoc, windowName, windowAttrib); 
   if (navigator.appName.toLowerCase ().indexOf ("netscape") >= 0 && 
       parseInt (navigator.appVersion) == 2) { 
     if (navigator.appVersion.indexOf ("(X11") != -1 || 
         navigator.appVersion.indexOf ("(Mac") != -1) 
     newWindow = window.open (targetDoc, windowName, windowAttrib); 
   } 
   newWindow.focus();
 } 

function openPage(url)
 { 
 opendoc (url, 'Window1', 520, 520, 'no');  
 }  

function load(currentImage)
 {
 document.getElementById('imageviewer').src=imgPrefix+images[currentImage]+imgSuffix;
 image=currentImage
 }
 
function thumb(currentImage)
 {
 return thumbPrefix+images[currentImage]+thbSuffix;
 }

function writeCaption(currentImage)
 {
 document.write(title[currentImage])
 }

function writePrevious(image)
 {
 image--;
 if (image<minim) {image=Math.min(maxim,imageCounter)}
  document.write('<p>&lt;&nbsp;<a href="popup.htm?'+image+'">Previous</a></p>');
 }

function writeNext(image)
 {
 image++;
 if (image>Math.min(maxim,imageCounter)) {image=minim}
  document.write('<p><a href="popup.htm?'+image+'">Next</a>&nbsp;&gt;');
 }

function writeImages()
 {  
  for (var i=minim; i<=maxim; i++) {
   document.write('<a href="javascript:openPage('+"'"+'popup.htm?'+i+"'"+')"'+'><img src="'+thumb(i)+'" width=60 height=60 vspace=4 hspace=4 border=0 alt="'+title[i]+'"></a>');
   }
 }

