			var gallery_full_img;
			var gallery_full_a;
			var gallery_title;
			var gallery_caption;
			var gallery_description;
			var gallery_caption_container;
			
			function addGalleryEvent(el,event,listener){
				if (el.addEventListener){
				  el.addEventListener(event, listener, false); 
				} else if (el.attachEvent){
				  el.attachEvent('on' + event, listener);
				}	
			}
			
			function init_gallery_temp(){
				//this is not doing anything at the moment,
				//since I now have something equivalent running on the server
			
				//first, see if we have more than one image.  if we do, rebuild this page as a gallery
				var project = document.getElementById('project');
				var entries = project.getElementsByClassName('entry');
				
				if (entries.length !=1)
					return;

				var entry = entries[0];
				var images = entry.getElementsByTagName('IMG');
				if (images.length>1) {

					//build gallery
					var gallery = document.createElement('div');
					gallery.id = 'gallery';
					entry.insertBefore(gallery,entry.firstChild);					
					
					var children = entry.childNodes;
					for (var i = 1; i < children.length; i++) {
						if (children[i].tagName == 'P' || children[i].tagName == 'DIV') {
							var movingChild = entry.removeChild(children[i]);
							gallery.appendChild(movingChild);
							i--;
						}
					}
					
					setup_gallery(gallery);
				}
			}

			function init_gallery(gallery){
				var gallery = document.getElementById('gallery');

				if (gallery) {

					gallery_full_a = document.getElementById('gallery_full_a');
					if (gallery_full_a == null) {
						//set up captions
						gallery_title = document.createElement('span');
						gallery_title.id = 'gallery_title';
						gallery_caption = document.createElement('span');
						gallery_caption.id = 'gallery_caption';
						gallery_description = document.createElement('span');
						gallery_description.id = 'gallery_description';
						gallery_caption_container = document.createElement('span');
						gallery_caption_container.id = 'gallery_caption_container';

						gallery_full_a = document.createElement('a');
						gallery_full_a.id = 'gallery_full_a';
	
						gallery_full_img = document.createElement('img');
						gallery_full_img.id = 'gallery_full_img';	
						
						gallery_full_a.appendChild(gallery_full_img);
	
						gallery.insertBefore(gallery_caption_container,gallery.firstChild);
						gallery_caption_container.appendChild(gallery_title);
						gallery_caption_container.appendChild(gallery_caption);
						gallery_caption_container.appendChild(gallery_description);

						gallery.insertBefore(gallery_full_a,gallery.firstChild);
					} else {
						gallery_full_img = document.getElementById('gallery_full_img');
						gallery_caption_container = document.getElementById('gallery_caption_container');
						gallery_title = document.getElementById('gallery_title');
						gallery_caption = document.getElementById('gallery_caption');
						gallery_description = document.getElementById('gallery_description');
					}

					var children = gallery.childNodes;
					var initialized = false;
					for (var i = 0; i < children.length; i++) {
						if (children[i].tagName == 'P' || children[i].tagName == 'DIV') {
							if (!initialized) {  //only do it the first time
								update_gallery(children[i]);
								initialized = true;
							}
							addGalleryEvent(children[i],'mouseover',update_gallery);
						}
					}

					//update Lightbox
					if (Lightbox) {
						Lightbox.prototype.updateImageList();
					}
				}
			}
			
			function update_gallery(element) {
				var p = element;
				var caption = '';
				var description = '';
				var title;

				//if (Element.prototype.isPrototypeOf(this)) {
				if (this.getElementsByTagName) {
					//alert('using this');
					p = this;
				} else {
					//alert('using element');
					p = element;
				}

				//update link for lightbox
				var links = p.getElementsByTagName('a');
				if (gallery_full_a != undefined && links.length>0) {
					gallery_full_a.href = links[0].href;
					gallery_full_a.rel = links[0].rel; //so lightbox works
				}

				//update image source
				var images = p.getElementsByTagName('img');
				if (gallery_full_img != undefined && images.length>0) {
					gallery_full_img.src = images[0].src;
					title = images[0].title;
					if (title == '')
						title = images[0].alt;
				}
				
				//update captions
				if (gallery_caption_container != undefined) {
					var spans = p.getElementsByTagName('p');
					for (i=0; i<spans.length;i++) {
					
						if (spans[i].className == 'wp-caption-text') {
							caption = spans[i].innerHTML;
						} else if (spans[i].className == 'wp-description-text') {
							description = spans[i].innerHTML;
						}
					}
					
					if (title =='no title') {
						title = ''; //this is so costume pics don't show
						description='';
						caption='';
					}

					gallery_title.innerHTML = title;
					gallery_caption.innerHTML = caption;
					gallery_description.innerHTML = description;
					if (caption == '' && description=='' && title=='') {
						//gallery_caption_container.style.display = 'none';
					} else {
						//gallery_caption_container.style.display = 'block';
					}
				}
				
				//update Lightbox
				if (Lightbox) {
					Lightbox.prototype.updateImageList();
				}
			}
			
			addGalleryEvent(window,'load',init_gallery);