			var windooOpen = false;
            
            function showWindow(pTitle, pUrl, pWidth, pHeight){
				mywindoo = new Windoo({
					width: pWidth,
					height: pHeight,
					title: pTitle,
					type: 'iframe',
					shadow: false,
					container: false,
					buttons: {menu: true},
					ghost: {resize: true, move: true},
					url: pUrl
				}).show();
				mywindoo.setPosition(600, 250);
				windooOpen = true;
			}
			
			function hideWindow(){
                if (windooOpen)
				    mywindoo.hide();
			}
			
			function showImage(url){
				if ( !$("underlay") )
				{
					new Element('div').setProperty('id', 'underlay').injectInside(document.body);
					underlaySize();
					new Fx.Style('underlay', 'opacity',{duration: 400, transition: Fx.Transitions.sineInOut}).start(0,1);
				}
				
				//Make the background of the underlay to be the image, while loading the page
				urlTempImage = (url.split('.'));
				urlImage = urlTempImage[urlTempImage.length - 2]+'.jpg';
				urlTemp = urlImage.split("/");
				urlImage = urlTemp[urlTemp.length - 1];
				//Could be prettier, but it works.
				
				injectHotspots(2, urlImage);
				
				if (windooOpen) {
					$$('div.windoo').each(function(windoo) {
						windoo.remove();
					});
				}
				
				$("underlay").setStyle("background", "#fff url(images/"+urlImage+") center left no-repeat");
			}

			function injectHotspots(num, url){
				//Injects the supplied number of hotspots into the underlay
				//Remove any existing hotspots first
				$$('dl').each(function(obj){
					obj.remove();
				});
				//Add the ones for this page
				temp = url.split(".");
				suffix = temp[0];
                var horiz = Window.getScrollHeight() / 2;
				hotspots = new Element('dl').setProperty('id', 'imagemap-' + suffix);
                var tmpArray = suffix.split("-");
                var ref = tmpArray.join("");
				for (var i = 1; i <= num; i++){
					hotspots.adopt( new Element ('dt').setProperty('id', 'hotspot-' + i));
					hotspots.adopt(
						new Element('dd').setProperty('id', 'hotspot-def-' + i).setStyle('top', horiz - eval(ref + 'hotspot' + i).top).setStyle('left', eval(ref + 'hotspot' + i).left).setStyle('display', eval(ref + 'hotspot' + i).display).adopt(
						new Element('a').setProperty('href', 'images/detail-' + i + '-' + url).setProperty('class', 'smoothbox')));
    
				}
				hotspots.injectInside($('underlay'));                
                
				//Enable smoothbox on the hotspots
				TB_init();
			}
			
			function underlaySize(){
				// we have to set this to 0px before so we can reduce the size / width of the overflow onresize 
				$("underlay").setStyles({"height": '0px', "width": '0px'});
				$("underlay").setStyles({"height": window.getScrollHeight()+'px', "width": window.getScrollWidth()+'px'});
			}
			
			window.addEvent('domready', function(){
												 
				$$('a.windoo').each(function(windoo){
				
				var originalHref = windoo.href;
				
					windoo.addEvent('click', function(e) {
						showImage(originalHref);
						showWindow(windoo.title, originalHref, 400, 295);
						windooOpen = true;
					});
					
					windoo.href = "#";

				});
			});