if (doc.indexOf('gallery') != -1) {
	counter = 1;
	document.write('<table width="100%"  border="0" cellspacing="0" cellpadding="15">\n'
              +'<tr>\n'
              +'<td bordercolor="#CCCCCC"><table width="100%"  border="1" cellpadding="3" cellspacing="0" bordercolor="#E7E7E7">\n'
              +'<tr>\n'
              +'<td><img src="images/galleries/'+document.gallerydir+'/thumbs/tmb_001.gif" width="51" height="41" id="displaythumb"></td>\n'
              +'</tr>\n'
              +'</table></td>\n'
              +'</tr>\n'
              +'</table>\n'
			  +'<table  border="0" cellspacing="0" cellpadding="0">\n');
			  //image array breaks into rows of five images.  rem is the remainder for the last row.
			  //tail is the inverse.
			  rem = inventory.images.length % 5;
			  tail = 5-rem;
	          while (counter <= inventory.images.length) {
				  trhead = "<tr>\n";
				  trfoot = '</tr>\n'+'<tr><td colspan="11" height="4"><img src="tra.gif" width="4" height="4"></td></tr>\n';
				  document.write(trhead);
				  for (i=0;i<=4;i++) {
					  if (counter<inventory.images.length) {
						  document.write('<td width="7"><img src="images/tra.gif" width="7" height="1"></td>\n'+'<td width="10" bgcolor="#E7E7E7" id="gp_'+parse23(counter)+'_cell"><a href="javascript:getDisplay(\''+parse23(counter)+'\');" onMouseOver="darkbg(this.id+\'_cell\');" onMouseOut="lightbg(this.id+\'_cell\');" id="gp_'+parse23(counter)+'"><img src="images/tra.gif" width="10" height="10" id="gp_'+parse23(counter)+'_img" border="0"></a></td>\n');
						  counter++;
					  }
					  else {
						  document.write('<td width="7"><img src="images/tra.gif" width="7" height="1"></td>\n'+'<td width="10" bgcolor="#FFFFFF"><img src="images/tra.gif" width="10" height="10" border="0"></a></td>\n');
						  counter++;
					  }
				  }
				  document.write('<td width="7"><img src="images/tra.gif" width="1" height="1"></td>\n');
				  document.write(trfoot);
			  }
			  document.write('</table><br>\n');
}
