var imagesArray =[["452","382","448","447","442","443"],["459","457","456","458","455"],["XXX"],["463","460","461","462","464","466"],["465"],["006","471","470","472","473"]];
var captionsArray = [["Cuneiform tablet","The Malayer hoard of Greek coins, around 440–430 BC","Athenian drinking cup in the form of the head of a bearded Persian","Athenian red-figured plate signed by the painter Epiktetos","Limestone head of male statue of the Achaemenid period in Persian style","Stone statue of a female figure wearing"],["Gold dinar of Ardashir I, AD 224–40","Silver drachm, probably of Arsaces I, around 238–211 BC","Silver drachm of Mithradates II, around 123–88 BC","Silver tetradrachm of Artabanus II, around AD 10–38","Silver tetradrachms of Bagadates"],["XXX"],["Engraving showing a view of the ruined buildings on the terrace at Persepolis","Engraving showing delegations on the Apadana frieze","Engraving showing a view of the ruined buildings on the terrace at Persepolis","Engraving showing delegations on the Apadana frieze","Drawing of a colossal bull in the ‘Gate of All Nations’ at Persepolis, by Sir Robert Ker Porter","Sir Robert Ker Porter (1777–1842), pen and ink drawing showing part of the decoration on the tomb of Xerxes at Naqsh-i Rustam"],["Sir Robert Ker Porter (1777–1842), drawing of defeated rebels from the Bisitun relief"],["Cyrus Cylinder","Banknote of 50 Rials","Gold coin struck to commemorate 2,500 years of Persian monarchy in 1971","Sheet of postage stamps showing the Cyrus Cylinder","Commemorative gold medal"]];

var thumbArray = new Array();
var beginner = "<img src='../objects/60";
var ender = " width='60' height='60' border='0' vspace='4' />";

//this changes the main image
function ChangeStuff(page, obj) {
    var noImages = imagesArray[page].length; 
    //alert(noImages);
    var myThumb = obj;
    var v = 0;
    
    //rebuild the thumbnail list
    function MakeThumbs(n){
        thumbArray.length = n;
        for (var i=0; i<n; i++) {
           if(v < 3){ 
                if (i == myThumb){
                    thumbArray[i] = beginner+"k/cat"+imagesArray[page][i]+".jpg' alt='"+captionsArray[page][i]+"'"+ender;
                }else{
                    thumbArray[i] = "<a href='javascript:ChangeStuff("+page+","+i+")'>"+beginner+"j/cat"+imagesArray[page][i]+".jpg' alt='"+captionsArray[page][i]+"'"+ender+"</a>";
                }
            v++;
        }else{
                if (i == myThumb){
                    thumbArray[i] = beginner+"k/cat"+imagesArray[page][i]+".jpg' alt='"+captionsArray[page][i]+"'"+ender+"<br>";
                }else{
                    thumbArray[i] = "<a href='javascript:ChangeStuff("+page+","+i+")'>"+beginner+"j/cat"+imagesArray[page][i]+".jpg' alt='"+captionsArray[page][i]+"' "+ender+"</a><br>";
                }
            v=0;
            }    
        };
        
        return thumbArray        
    }
    
    //Run the make thumb nails
    MakeThumbs(noImages);
   
    //Print the new stuff
    image.innerHTML = "<a href='../objects/cat"+imagesArray[page][obj]+".html'><img src='../objects/230j/cat"+imagesArray[page][obj]+".jpg' alt='"+captionsArray[page][obj]+"' width='230' height='230' border='0' /></a>";
    //Do I need <br> in there
	var captionText = "";
	if(captionsArray[page][obj].length<=45){
		captionText = "<br>"+captionsArray[page][obj]+"<br><br>";
	}else if(captionsArray[page][obj].length>45 && captionsArray[page][obj].length<=90){
		captionText = "<br>"+captionsArray[page][obj]+"<br>";
	}else if(captionsArray[page][obj].length>90){
		captionText = captionsArray[page][obj];
	}

	caption.innerHTML = captionText;
     var otherText = "";
     for(var w=0; w<thumbArray.length;w++){
        otherText = otherText+thumbArray[w];
        //othersText = thumbArray[0]+thumbArray[1]+thumbArray[2];
        }
     

    // holder.innerHTML = otherText;
	//"<a href='grid.html'><img src='o/thumbs/all.gif' width='60' height='60' border='0' alt='object grid' vspace='4'/></a>"
    others.innerHTML = otherText;
}