	var dimension="1x1" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc

	var href_target="_new" //Enter target attribute of links, if applicable
	
	var totalslots=dimension.split("x")[0]*dimension.split("x")[1]
	
  function resize(which, max) {
  var elem = document.getElementById(which);
  if (elem == undefined || elem == null) return false;
  if (max == undefined) max = 220;
  if (elem.width > elem.height) {
    if (elem.width > max) elem.width = max;
    } else {
    if (elem.height > max) elem.height = max;
    }
   }
		
	function buildimage(i){
	
	var tempcontainer=galleryarray[i][3]!=""? '<a href="#" onClick="return Lightbox.open([[\''+galleryarray[i][3]+'\', \''+galleryarray[i][2]+'\']], 0);" title="'+galleryarray[i][2]+'">' : ""
	tempcontainer+='<img id="'+[i]+'" onload="resize('+[i]+')" src="'+galleryarray[i][0]+'" border="0" title="'+galleryarray[i][1]+'">'
	tempcontainer=galleryarray[i][3]!=""? tempcontainer+'</a>' : tempcontainer
	tempcontainer=galleryarray[i][2]!=""? tempcontainer+'<br \/>'+galleryarray[i][2] : tempcontainer
	return tempcontainer
	}
   
	function jumpto(p){
	var startpoint=(p-1)*totalslots
	var y=1;
	for (i=0; i<totalslots; i++){
	document.getElementById("slide"+i).innerHTML=(typeof galleryarray[startpoint+i]!="undefined")? buildimage(startpoint+i) : ""
	}
	while(document.getElementById("navlink"+y)!=null){
	document.getElementById("navlink"+y).className=""
	y++
	}
	document.getElementById("navlink"+p).className="current"
	}
	
	var curimage=0
	for (y=0; y<dimension.split("x")[1]; y++){
	for (x=0; x<dimension.split("x")[0]; x++){
	if (curimage<galleryarray.length)
	document.write('<div id="slide'+curimage+'" class=thumb align=center>'+buildimage(curimage)+'</div>')
	curimage++
	}
	document.write('<br style="clear: left" />')
	}

	document.write('<div id=navlinks>')

	for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
	document.write('<a id="navlink'+i+'" href="javascript:jumpto('+i+')\">'+i+'</a> ')
	document.getElementById("navlink1").className="current"
    document.write('</div>')
	


