function LightboxGallery(gId){
	this.galleryId = gId;
	this.galleryEmt = null;
	this.tnMarkup = null;
	this.fullImages = null;
	this.fullAlts = null;
	this.galleryMarkup = "";
	
	this.buildGallery = function(){
		this.galleryEmt = document.getElementById(this.galleryId);
		this.tnMarkup = new Array();
		this.fullImages = new Array();
		this.fullAlts = new Array();
		var tables = this.galleryEmt.getElementsByTagName('TABLE');
		
		for(var i = 0; i < tables.length; i++){
			if(tables[i].className.indexOf("galleryImage") > -1){
				var cells = tables[i].getElementsByTagName('TD');
				
				if(cells.length >= 2){
					var images = cells[1].getElementsByTagName('IMG');
					
					if(images.length >= 1){
						this.tnMarkup.push(cells[0].innerHTML);
						this.fullImages.push(images[0].src);
						this.fullAlts.push(images[0].alt);
					}
				}
			}
		}
		
		for(var i = 0; i < this.tnMarkup.length; i++){
			var altText = (this.fullAlts[i] != '-' && this.fullAlts[i].substr(this.fullAlts[i].length - 4) != '.jpg' && this.fullAlts[i].substr(this.fullAlts[i].length  - 4) != '.gif') ? this.fullAlts[i] : ' ';
			this.galleryMarkup += "<a href=\"" + this.fullImages[i] + "\" title=\"" + altText + "\" rel=\"lightbox[gallery" + this.galleryId + "]\">" + this.tnMarkup[i] + "</a>";
		}
		
		this.galleryEmt.innerHTML = this.galleryMarkup + "<div style=\"clear: both\"></div>";
	}
}


function makeLBLinks(){
	for(var i = 0; i < galleryIds.length; i++){
		var tempGallery = new LightboxGallery(galleryIds[i]);
		tempGallery.buildGallery();
	}
}