			//constants
			var CONST_IMG_PREFIX = "img";
			var CONST_IMG_WIDTH = 157;
			var CONST_IMG_HEIGHT = 89;
			var CONST_SPACE = 2;
			var DIR_LEFT  = "left";
			var DIR_RIGHT = "right";
			var EVENT_OVER = "over";
			var EVENT_OUT = "out";
			var CATEGORY_EXTERIOR = "ext";
			var CATEGORY_INTERIOR = "int";
			var OMNITURE_EXTERIOR = "Exterior Photos: ";
			var OMNITURE_INTERIOR = "Interior Photos: ";
			
			//regular expressions:
			var _REPLACE_SRC = new RegExp(/_REPLACE_SRC/);
			var _REPLACE_ID = new RegExp(/_REPLACE_ID/g);
			var _REPLACE_STYLE_LEFT = new RegExp(/_REPLACE_STYLE_LEFT/);
			var _REPLACE_HEIGHT = new RegExp(/_REPLACE_HEIGHT/);
			var _REPLACE_WIDTH = new RegExp(/_REPLACE_WIDTH/);
			
			//(future) element references:
			var ssEngine = null;
			var ssCaboose = null;
			var displayArea = null;
			
			//omniture-related
			var clicksforExternal;
			var clicksforInternal;
			
			//misc
			var currentCategoryDisplay;
			var exteriorSlides;
			var exteriorSlidesMarkedUp;
			var interiorSlides;
			var interiorSlidesMarkup;
			var wrapperReferences = new Object();
			var categoryReferences = new Object();
			var isSliding = false;
			var _interval = null;
			var slideIncrement = 5;
			if(navigator.userAgent.indexOf("Safari") != -1) slideIncrement = 15; //Safari is slow
			var slideMarkup;
			var existentialWidth = 0; //will be rewritten, dynamically
			
			
			function getTemplate() {
				var template = "<div style='position:absolute; top:0px; left:_REPLACE_STYLE_LEFTpx; width:_REPLACE_WIDTHpx; height:_REPLACE_HEIGHTpx;'><a href='javascript:displayMega(\"_REPLACE_ID\")'><img src='_REPLACE_SRC' onmouseover='slideEvent(this, \"_REPLACE_ID\", EVENT_OVER)' onmouseout='slideEvent(this, \"_REPLACE_ID\", EVENT_OUT)' border='0'/></a></div>";
				return template;
			}
			
			function slideShowUnit(indexer, path, rolloverPath, megaPath) {
				
				this.cardinality = indexer;
				this.id = indexer;
				this.path = path;
				this.rollover = rolloverPath;
				this.mega = megaPath;
				this.slideMarkup = "";
				
				//set the reference for ease of lookup later:
				wrapperReferences[this.id] = this;
				
				//preload the rollover:
				var temp = new Image();
				temp.src = this.rollover;
			}
			
			function slideCategoryUnit(id, associatedImageId, path, rolloverPath, selectedPath) {
				this.id = id;
				this.imageReference = document.getElementById(associatedImageId);
				this.path = path;
				this.rollover = rolloverPath;
				this.selected = selectedPath;
				
				//set the reference for lookup:
				categoryReferences[this.id] = this;
			}
			
			function embedInMarkup(arrSrc, arrMarkup) {
			/*
				@arrSrc is passed in by reference, and will be modified by this function
			*/
			
			
			//retrieve the template	
			var tmpl = getTemplate();
			
			for(var i=0; i < arrSrc.length; i++) {
					//grab the reference to the wrapper object:
					var wrapper = arrSrc[i];
					//overwrite src
					var temp = tmpl.replace(_REPLACE_SRC, wrapper.path);
					//id
					temp = temp.replace(_REPLACE_ID, wrapper.id);
					//left pos
					var left = i == 0 ? 0 : (i * CONST_IMG_WIDTH );
					temp = temp.replace(_REPLACE_STYLE_LEFT, left);
					//width:
					temp = temp.replace(_REPLACE_WIDTH, CONST_IMG_WIDTH);
					//height:
					temp = temp.replace(_REPLACE_HEIGHT, CONST_IMG_HEIGHT);
					//alert(temp);
					arrMarkup[i] = temp;
				}
			
			}
			
			function slide(dir){
				if(dir == DIR_LEFT) {
					//if the engine has not passed all of the way off of the screen, decrement it
					//otherwise set its left equal to its overall width
					if ( parseInt(ssEngine.style.left) > (existentialWidth * (-1)) ) {
						ssEngine.style.left = parseInt(ssEngine.style.left)- slideIncrement + "px";
					}
					else {
						ssEngine.style.left = parseInt(ssCaboose.style.left) + existentialWidth - slideIncrement + "px";
						
					}
					
					if ( parseInt(ssCaboose.style.left) > (existentialWidth * (-1) ) ) {
						ssCaboose.style.left = parseInt(ssCaboose.style.left) - slideIncrement + "px";	
					}
					else {
						ssCaboose.style.left = parseInt(ssEngine.style.left) + existentialWidth  + "px";
						
					}
				}
				else if(dir == DIR_RIGHT) {
					if ( parseInt(ssEngine.style.left) < (existentialWidth) ) {
						ssEngine.style.left = parseInt(ssEngine.style.left)+ slideIncrement + "px";
					}
					else {
						ssEngine.style.left = parseInt(ssCaboose.style.left) - existentialWidth + slideIncrement  + "px";
						
					}
					
					if ( parseInt(ssCaboose.style.left) < (existentialWidth ) ) {
						ssCaboose.style.left = parseInt(ssCaboose.style.left)+ slideIncrement + "px";	
					}
					else {
						ssCaboose.style.left = parseInt(ssEngine.style.left) - existentialWidth  + "px";
						
					}
				}

				
			}
			
			
			function moveSlides(dir) {
				if(! isSliding) {
					isSliding = true;
					var funcSignature = "slide('" + dir + "')";
					_interval = setInterval(funcSignature,30);
				}
				
			}
			
			function clear() {
				clearInterval(_interval);
				isSliding = false;
			}
			
			function stopSlides() {
				clear();
			}
			
			function retrieveWrapper(id) {
				return wrapperReferences[id];
			}
			
			//displays the large or "mega"-sized image:
			function displayMega(key) {
				var wrap = retrieveWrapper(key);
				
				if(wrap != null) {
					displayArea.style.visibility = "hidden";
					var preLoader = new Image();
					preLoader.src = wrap.mega;
					displayArea.innerHTML = "<img src='" + preLoader.src + "' border='0'/>";
					displayArea.style.visibility = "visible";
					//omniture-related:
					registerMegaClick();
				}
				
			}
			
			function registerMegaClick() {
				if(currentCategoryDisplay == CATEGORY_EXTERIOR) {
					clicksforExternal += 1;
					bubbleSequentialEvent(" var variables = [ {name: 'events', value: 'event6'} ]");
				}
				else if(currentCategoryDisplay = CATEGORY_INTERIOR) {
					clicksforInternal += 1;
					bubbleSequentialEvent(" var variables = [ {name: 'events', value: 'event7'} ]");
				}
				
			}
			
			function slideEvent(imageRef, key, eventType) {
				//get the wrapper:
				var wrap = retrieveWrapper(key);
				
				//if we've got a wrapper, determine the event type:
				if(wrap != null) {
					if(eventType == EVENT_OVER) {
						imageRef.src = wrap.rollover;
					}
					else if(eventType == EVENT_OUT) {
						imageRef.src = wrap.path;
					}
				}
				
			}
			
			function buildAndToggleCategories(type) {
					//build the requested structure:
					buildSlideStructure(type);
					//toggle the category images:
					for(catField in categoryReferences) {
						var catWrapper = categoryReferences[catField];
						//for the wrapper that matches the type to display, set the image to selected
						//otherwise set it to deselected (default)
						if(catField == type) {
							catWrapper.imageReference.src = catWrapper.selected;
						}
						else {
							catWrapper.imageReference.src = catWrapper.path;
						}
					}
					if (arguments.length < 2) { //Prevent granularize on load
						granularizeUrl(type);
					}
					
			}
			
			function selectDisplay(dispType) {
				
				//if the currently selected display type is different than dispType,
				//then we can change them out
				if(arguments.length == 2) { //overloaded for initialization purposes
					buildAndToggleCategories(dispType, true);
				}
				 else if(currentCategoryDisplay != dispType) {
					 buildAndToggleCategories(dispType);
					 //omniture event here:
					 if(pcode) {
						//have to clear s.pageName temporarily; will be reset
						s.pageName = '';
						bubbleSequentialEvent(" var variables = [ {name: 'pageName', value: '" + (pcode + " - " + dispType + "Tab") + "'} ]");
					}
				}
			}
			
			function granularizeUrl(hashExt) {
				var curUrl = document.location.toString();
				if(curUrl.indexOf("#") != -1) {
					curUrl = curUrl.substr(0, curUrl.indexOf('#')) + "#" + hashExt;
					if (curUrl != document.location.toString()) {
						document.location = curUrl;
					}
				} 
				else {
					document.location = curUrl + "#" + hashExt;
				}
			}
			
			function displayMouseActivity(eventType, refImage, dispType) {
				//if the currently selected category != dispType, then allow
				if(currentCategoryDisplay != dispType) {
					//get the reference to the category wrapper:
					var catWrap = categoryReferences[dispType];
					//mouseover:
					if(EVENT_OVER == eventType) {
						refImage.src = catWrap.rollover;
					}
					//mouseout:
					else if(EVENT_OUT == eventType) {
						refImage.src = catWrap.path;
					}
				}
			}
			
			
			function buildSlideStructure(whichStructure) {
				var markup;
				var lengthCoefficient;
				var firstImageID;
				
				if(CATEGORY_EXTERIOR == whichStructure) {
					markup = exteriorSlidesMarkedUp.join(" ");
					lengthCoefficient = exteriorSlides.length;
					firstImageID = exteriorSlides[0].id;
					currentCategoryDisplay = CATEGORY_EXTERIOR;
				}
				else if(CATEGORY_INTERIOR == whichStructure) {
					markup = interiorSlidesMarkup.join(" ");
					lengthCoefficient = interiorSlides.length;
					firstImageID = interiorSlides[0].id;
					currentCategoryDisplay = CATEGORY_INTERIOR;
				}
				
				ssEngine.innerHTML = markup;
				ssCaboose.innerHTML = markup;
				
				//the actual ("existenial") width
				existentialWidth = lengthCoefficient * CONST_IMG_WIDTH;
				
				//set the left styles programatically:    
				ssEngine.style.width = existentialWidth + "px";
				ssCaboose.style.width = existentialWidth + "px";
				ssEngine.style.left = "0px";
				ssCaboose.style.left = parseInt(ssEngine.style.left) + existentialWidth;
				
				//display the first large image:
				displayMega(firstImageID);
				
			}
			
			function setOnUnload() {
				window.onunload = omnitureOnUnload;
			}
			
			function slidesInit() {
				//set, or add to, the onunload event (omniture)
				//addToOnload(setOnUnload);
				
				//initialize omniture variables:
				clicksforExternal = 0;
				clicksforInternal = 0;
				
				//set references:
				ssEngine = document.getElementById("exteriorSlideshowEngine");
				ssCaboose = document.getElementById("exteriorSlideshowCaboose");
				displayArea = document.getElementById("displayArea");
				
				
				//construct both the exterior and interior slides' markup:
				exteriorSlidesMarkedUp = new Array();
				embedInMarkup(exteriorSlides, exteriorSlidesMarkedUp);
				interiorSlidesMarkup = new Array();
				embedInMarkup(interiorSlides, interiorSlidesMarkup);
				
				//in case the page has been bookmarked:
				var location = document.location.toString();
				var cat = CATEGORY_EXTERIOR; // default val
				if(location.indexOf("#") != -1) {
					var temp = location.substr(location.indexOf("#") + 1);
					//grab what's after the hash mark:
					if(temp == CATEGORY_EXTERIOR || temp == CATEGORY_INTERIOR) {
						//default	
						cat = temp;
					}
				}
				
				//build the slide structure - overload call to herald this being the first time in:
				selectDisplay(cat, true);
			}
			
			function omnitureOnUnload() {
				//alert("External Images selected: " + clicksforExternal + "; Internal: " + clicksforInternal);
			}
