﻿function gallery(path, imagefile, thumbfile, caption, bdrwidth, bdrcolor, backgroundcolor, height, columns)
{

	imagefile.reverse()
	caption.reverse()
	thumbfile.reverse()
	
	document.write("<table width=\"100%\" align=\"center\" border=\"" + bdrwidth + "\" bordercolor=\"" + bdrcolor + "\" bgcolor=\"" + backgroundcolor + "\" cellpadding=\"6\">")
	var x = y = 0
	var count = 0
	var openrow = 0

	for(x=0; x< imagefile.length; x++)
	{
		count++
		
		if(openrow==0)
		{
			document.write("<tr>")
			openrow=1
		}
		
		document.write("<td align=\"center\"><div onclick=\"dhtmlHistory.add(\'location1\',{message: \'backbox\'});countdown()\"><a href=\""+ path + imagefile[x] +"\" rel=\"lightbox[slide]\" caption=\"" + caption[x] + "\"><img src=\"" + path + thumbfile[x] + "\" height=\"" + height + "\" border=\"0\" /></a></div>")
	
			document.write("</td>")
			if(count>=columns)
			{
				count=0
				document.write("</tr>")
				openrow = 0
			}	
	}
	
	if(openrow==1)
	{
		document.write("</tr>")
	}
	document.write("</table>")
}
