function photogallery(garray,cols,rows,twidth,theight,paginatetext){gcount=(typeof gcount=="undefined")?1:gcount+1
this.gcount=gcount
this.galleryarray=garray
this.cols=cols
this.rows=rows
var twidth=twidth||"700x"
var theight=theight||"500px"
var ptext=(typeof paginatetext=="object")?paginatetext:["Browse Games:",""]
this.pagecount=Math.ceil(this.galleryarray.length/(cols*rows))
document.write('<table class="photogallery" id="photogallery-'+gcount+'" style="width:'+twidth+'; height:'+theight+';">')
for(var r=0;r<rows;r++){document.write('<tr>')
for(var c=0;c<cols;c++)
document.write('<td valign="top"></td>')
document.write('</tr>')}
document.write('</table>')
document.write('<div class="photonavlinks" id="photogallerypaginate-'+gcount+'"></div>')
var gdiv=document.getElementById("photogallery-"+this.gcount)
var pdiv=document.getElementById("photogallerypaginate-"+this.gcount)
gdiv.onselectphoto=function(imgobj,linkobj){return true}
this.showpage(gdiv,0)
this.createNav(gdiv,pdiv,ptext)
gdiv.onclick=function(e){return photogallery.defaultselectaction(e,this)}
return gdiv}
photogallery.prototype.createImage=function(imgparts){var imageHTML='<img src="'+imgparts[0]+'" title="'+imgparts[1]+'"/>'
if(typeof imgparts[2]!="undefined"&&imgparts[2]!=""){var linktarget=imgparts[3]||""
imageHTML='<a href="'+imgparts[2]+'" target="'+linktarget+'">'+imageHTML+'</a>'}
if(typeof imgparts[1]!="undefined"&&imgparts[1]!="")
imageHTML+='<br />'+imgparts[1]
return imageHTML}
photogallery.prototype.showpage=function(gdiv,pagenumber){var totalitems=this.galleryarray.length
var showstartindex=pagenumber*(this.rows*this.cols)
var showendindex=showstartindex+(this.rows*this.cols)
var tablecells=gdiv.getElementsByTagName("td")
for(var i=showstartindex,currentcell=0;i<showendindex&&i<totalitems;i++,currentcell++)
tablecells[currentcell].innerHTML=this.createImage(this.galleryarray[i])
while(currentcell<tablecells.length){tablecells[currentcell].innerHTML=""
currentcell++}}
photogallery.prototype.createNav=function(gdiv,pdiv,ptext){var instanceOfGallery=this
var navHTML=""
for(var i=0;i<this.pagecount;i++)
navHTML+='<a href="#navigate" rel="'+i+'">'+ptext[1]+(i+1)+'</a> '
pdiv.innerHTML=ptext[0]+' '+navHTML
var navlinks=pdiv.getElementsByTagName("a")
navlinks[0].className="current"
this.previouspage=navlinks[0]
for(var i=0;i<navlinks.length;i++){navlinks[i].onclick=function(){instanceOfGallery.previouspage.className=""
this.className="current"
instanceOfGallery.showpage(gdiv,this.getAttribute("rel"))
instanceOfGallery.previouspage=this
return false}}}
photogallery.defaultselectaction=function(e,gdiv){var evtobj=e||window.event
var clickedobj=evtobj.target||evtobj.srcElement
if(clickedobj.tagName=="IMG"){var linkobj=(clickedobj.parentNode.tagName=="A")?clickedobj.parentNode:null
return gdiv.onselectphoto(clickedobj,linkobj)}}