var imagesArray =[["021","040","306","471"],["088","398","319","326","298","300"],["034","040","044","045","047","048","088"],["009","005","103","140","141","142","143","144","145"]];
var captionsArray = [["Fragment of stone corner block with relief decoration","Stone relief showing a figure in Median dress","Cuneiform tablet detailing litigation","Banknote of 50 Rials"],["Cast of a statue of Darius I","Cylinder seal","Gold daric, around 520-500 BC","Silver siglos, around 375-340 BC","Pyramidal weight in diorite","Pyramidal weight in polished diorite"],["Fragment of stone relief showing a figure carrying an elephant tusk","Stone relief showing a figure in Median dress","Stone relief showing gift-bearers with a vase","Stone relief showing possibly a Sogdian gift-bearer carrying a jar","Stone relief showing a priest or servant in Median dress","Fragment of stone relief showing a figure facing left","Cast of a statue of Darius I"],["Massive bell-shaped column base","Large stone slab with the ‘Daiva’ text of Xerxes","Silver bowl","Alabaster vessel (alabastron)","Fragment of alabaster vessel (alabastron)","Calcite alabastron fragment","Clacite alabastron fragment","Fragment of alabaster vessel (alabastron)","Alabaster vessel (alabastron) fragment"]];

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<=53){
		captionText = "<br>"+captionsArray[page][obj]+"<br><br>";
	}else if(captionsArray[page][obj].length>53 && captionsArray[page][obj].length<90){
		captionText = "<br>"+captionsArray[page][obj]+"<br>";
	}else{
		captionText = captionsArray[page][obj];
	}
	caption.innerHTML = captionText;
     var otherText = "";
     for(var w=0; w<thumbArray.length;w++){
        otherText = otherText+thumbArray[w];
        }
	//+"<a href='grid.html'><img src='../i/all.gif' width='60' height='60' border='0' alt='object grid' vspace='4'/></a>"
    others.innerHTML = otherText;
}