﻿function photogallery(f,i,l,h,k,b){gcount=(typeof gcount=="undefined")?1:gcount+1;this.gcount=gcount;this.galleryarray=f;this.cols=i;this.rows=l;var h=h||"700x";var k=k||"500px";var d=(typeof b=="object")?b:["Browse Gallery:",""];this.pagecount=Math.ceil(this.galleryarray.length/(i*l));document.write('<table class="photogallery" id="photogallery-'+gcount+'" style="width:'+h+"; height:"+k+';">');for(var a=0;a<l;a++){document.write("<tr>");for(var g=0;g<i;g++){document.write('<td valign="top"></td>')}document.write("</tr>")}document.write("</table>");document.write('<div class="photonavlinks" id="photogallerypaginate-'+gcount+'"></div>');var e=document.getElementById("photogallery-"+this.gcount);var j=document.getElementById("photogallerypaginate-"+this.gcount);e.onselectphoto=function(m,c){return true};this.showpage(e,0);this.createNav(e,j,d);e.onclick=function(c){return photogallery.defaultselectaction(c,this)};return e}photogallery.prototype.createImage=function(c){var a='<img src="'+c[0]+'" title="'+c[1]+'"/>';if(typeof c[2]!="undefined"&&c[2]!=""){var b=c[3]||"";a='<a href="'+c[2]+'" target="'+b+'">'+a+"</a>"}if(typeof c[1]!="undefined"&&c[1]!=""){a+="<br />"}return a};photogallery.prototype.showpage=function(h,c){var b=this.galleryarray.length;var g=c*(this.rows*this.cols);var f=g+(this.rows*this.cols);var d=h.getElementsByTagName("td");for(var e=g,a=0;e<f&&e<b;e++,a++){d[a].innerHTML=this.createImage(this.galleryarray[e])}while(a<d.length){d[a].innerHTML="";a++}};photogallery.prototype.createNav=function(f,b,g){var c=this;var e="";for(var a=0;a<this.pagecount;a++){e+='<a href="#navigate" rel="'+a+'">'+g[1]+(a+1)+"</a> "}b.innerHTML=g[0]+" "+e;var d=b.getElementsByTagName("a");d[0].className="current";this.previouspage=d[0];for(var a=0;a<d.length;a++){d[a].onclick=function(){c.previouspage.className="";this.className="current";c.showpage(f,this.getAttribute("rel"));c.previouspage=this;return false}}};photogallery.defaultselectaction=function(d,f){var c=d||window.event;var b=c.target||c.srcElement;if(b.tagName=="IMG"){var a=(b.parentNode.tagName=="A")?b.parentNode:null;return f.onselectphoto(b,a)}};
