

/**
 *  HeroSlideshow
 *  Non-Silverlight slideshow for MS Learning landing page.
 *  Pulls core content strings and image SRCs from designated XML file.
 *  @configure	Various filepaths and other properties are defined in HeroSlideshow.util.init() method.
 */

/**
 * Augment native Object properties and methods.
 */ 
Object.augment = function(oDestination, oSource) {
	for (var property in oSource) {
		if (typeof oDestination[property] == 'undefined') {
			oDestination[property] = oSource[property];
		}
	}
	return oDestination;
};

Object.augment(String.prototype, {
	contains: function(re, str) {
		if (str.search(re) != -1) { return true; } 
		else { return false; }
	}
});

Object.augment(Array.prototype, {
	push: function(item) { 
		this[this.length] = item;
		return this.length;
	},
	indexOf: function (obj, si) {
		if (si == null) {
			si = 0;
		} else if (si < 0) {
			si = Math.max(0, this.length + si);
		}
		for (var i=si; i < this.length; i++) {
			if (this[i] === obj) { return i; }
		}
		return -1;
	},
	contains: function (obj) {
		return this.indexOf(obj) != -1;
	}
});
/* END Object.augments */





/**
 *  HeroSlideshow
 *  Create required xmlDoc global object, and instantiate the main slideshow object.
 */

if (typeof window.HeroSlideshow == "undefined") {
	var HeroSlideshow = new Object();
};


/**
 *  HeroSlideshow.dom
 *  Helper methods for DOM scripting.
 */
HeroSlideshow.dom = {
	addClass: function(node, cls) {
		var c = node.className.split(' ');
		(!c.contains(cls)) ? c.push(cls) : true ;
		node.className = c.join(' ');
	}
}; // end HeroSlideshow.dom



/**
 *  HeroSlideshow.event
 *  Event handlers, including non-destructive "addEvent"-type attacher.
 */

HeroSlideshow.event = {
	add: function(obj, evType, fn){
		if (obj.addEventListener){
			obj.addEventListener(evType, fn, true);
			return true;
		} else if (obj.attachEvent){
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		} else {
			return false;
		};
	},
	stop: function(e) {
		if (e) {
			if (e.preventDefault) {	/* W3C */
				e.preventDefault();
				e.stopPropagation();
			} else {				/* IE */
				e.returnValue = false;
				e.cancelBubble = true;
			};
		} else {
		};
		return false;
	}
}; 	// END HeroSlideshow.event



/**
 *  HeroSlideshow.rollovers
 *  All rollover scripts (buttons), plus helper methods.
 *  @todo		Nix duplicate code.
 *  @requires	HeroSlideshow.util	Numerous properties and methods.
 */

HeroSlideshow.rollovers = {
	
	/* Slideshow nav buttons --- */
	onMouseOver: function() { 
		var newBg = HeroSlideshow.rollovers.getRolloverImageUrl(this.id) || false;
		if (newBg) {
			HeroSlideshow.rollovers.setImage(this.id, newBg);  
		}
	},
	onMouseOut: function() { 
		var check=0;
		for (var i=0; i < HeroSlideshow.util.slideCount; i++) { 
			if((this.id) !=(HeroSlideshow.util.btnIdPrefix + i)) { 
				var isSelected = HeroSlideshow.rollovers.isButtonSelected(HeroSlideshow.util.btnIdPrefix + i) || false;
				if (isSelected !== true) { 
					check++;
				}
			}
		} // end for
		if (check>0) { 
			HeroSlideshow.rollovers.buttonNormal(this.id);
		} else { 
			/* probably overkill, but otherwise btn states may be wonky */
			if (this.id == HeroSlideshow.util.btnPrevId) {
				HeroSlideshow.rollovers.prevButtonNormal();
			} else if (this.id == HeroSlideshow.util.btnNextId) {
				HeroSlideshow.rollovers.nextButtonNormal();
			} else if (this.id == (HeroSlideshow.util.btnIdPrefix + HeroSlideshow.util.visibleIndex)) {
				/* this is a Selected button - preserve Here state */
				var newBg = 'url('+ HeroSlideshow.util.buttonImages['item'].selected +')';
				HeroSlideshow.rollovers.setImage(this.id, newBg);
			} else {
				/* failsafe */
				HeroSlideshow.rollovers.buttonNormal(this.id);
			}
		}
	},
	/* --- end slideshow buttons */

	
	/* Helper methods, albeit repetitive --- */
	setImage: function(buttonId, sImgSrc) {
		if (!buttonId || !sImgSrc) { return false; }
		var tmp = document.getElementById(buttonId);
		if (tmp) { 
			tmp.style.backgroundImage = sImgSrc;
		}
	},
	getRolloverImageUrl: function(sId){
		var out = false;
		if (sId == HeroSlideshow.util.btnPrevId) { 
			out = 'url(' + HeroSlideshow.util.buttonImages['prev'].rollover +')';
		} else if (sId == HeroSlideshow.util.btnNextId) { 
			out = 'url(' + HeroSlideshow.util.buttonImages['next'].rollover +')';
		} else { 
			out = 'url(' + HeroSlideshow.util.buttonImages['item'].rollover +')';
		}
		return out;
	},
	setSelected: function(buttonId) { 
		if (HeroSlideshow.util.prevSelected != null) { 
			HeroSlideshow.rollovers.buttonNormal(HeroSlideshow.util.prevSelected);
		}
		var newImage = 'url('+ HeroSlideshow.util.buttonImages['item'].selected +')';
		HeroSlideshow.rollovers.setImage(buttonId, newImage);
	},
	
	/* hard "normal" reset for Previous button */
	prevButtonNormal: function() { 
		var newBg = 'url(' + HeroSlideshow.util.buttonImages['prev'].normal +')';
		HeroSlideshow.rollovers.setImage(HeroSlideshow.util.btnPrevId, newBg); 
	},
	/* hard "normal" reset for Next button */
	nextButtonNormal: function() { 
		var newBg = 'url(' + HeroSlideshow.util.buttonImages['next'].normal +')';
		HeroSlideshow.rollovers.setImage(HeroSlideshow.util.btnNextId, newBg); 
	},
	buttonNormal: function(buttonId) { 
		var newBg = false;
		if (buttonId == HeroSlideshow.util.btnPrevId) {
			newBg = 'url('+ HeroSlideshow.util.buttonImages['prev'].normal +')';
		} else if (buttonId == HeroSlideshow.util.btnNextId) { 
			newBg = 'url('+ HeroSlideshow.util.buttonImages['next'].normal +')';
		} else { 
			newBg = 'url('+ HeroSlideshow.util.buttonImages['item'].normal +' )';
		}
		if (newBg) {
			HeroSlideshow.rollovers.setImage(buttonId,newBg); 
		}
	},
	
	
	isButtonSelected: function(buttonId) { 
		var newImage = 'url('+ HeroSlideshow.util.buttonImages['item'].normal +')';
		if (document.getElementById(buttonId).style.backgroundImage == newImage) { 
			return true;
		} else { 
		 	return false;
		}
	},
	
	buttonselected: function(buttonId) { 
        if(HeroSlideshow.util.prevSelected != null) { 
         	this.buttonNormal(HeroSlideshow.util.prevSelected);
        }
		var newBg = 'url(' + HeroSlideshow.util.buttonImages['item'].selected +' )';
		HeroSlideshow.rollovers.setImage(buttonId,newBg);
	}
	
	
	
};	// END HeroSlideshow.rollovers







/**
 *  HeroSlideshow.actions
 *  Slideshow nav button onclick handlers.
 *  @requires	HeroSlideshow.util		Numerous properties and methods.
 *  @requires	HeroSlideshow.rollovers
 */
HeroSlideshow.actions = {

	scrollSlide: function(iSetIndex, iClearIndex) {
		var thisContentNode = HeroSlideshow.util.MainContentNodes[iSetIndex];		
		var newSlide = HeroSlideshow.util.outputTemplate(thisContentNode);
		HeroSlideshow.util.setHeroContent(newSlide);
        HeroSlideshow.rollovers.buttonNormal(HeroSlideshow.util.btnIdPrefix + iClearIndex);
        HeroSlideshow.rollovers.buttonselected(HeroSlideshow.util.btnIdPrefix + iSetIndex);
        HeroSlideshow.util.visibleIndex = iSetIndex;
	},
	
	btnOnclick: function(sId) { 
		clearTimeout ( HeroSlideshow.util.timer );
		var thisThing = parseInt(sId.substring(HeroSlideshow.util.btnIdPrefix.length));
		this.scrollSlide(thisThing, HeroSlideshow.util.visibleIndex);		
	},
	
	btnOnPrev: function() { 
		clearTimeout ( HeroSlideshow.util.timer );
		var nowVisibleIndex = HeroSlideshow.util.visibleIndex;
		var prevIndex = 0;
		if (nowVisibleIndex === 0) {
			prevIndex = HeroSlideshow.util.slideCount;
		} else {
			prevIndex = nowVisibleIndex - 1;
		}
		this.scrollSlide(prevIndex, nowVisibleIndex);
	},
	
	btnOnNext: function() { 
		clearTimeout ( HeroSlideshow.util.timer );
		var nowVisibleIndex = HeroSlideshow.util.visibleIndex;
		var nextIndex = 0;
		if (nowVisibleIndex === HeroSlideshow.util.slideCount) {
			nextIndex = 0;
		} else {
			nextIndex = nowVisibleIndex + 1;
		}
		this.scrollSlide(nextIndex, nowVisibleIndex);
	}
	
}; 	// END HeroSlideshow.actions



/**
 *  HeroSlideshow.util
 *  Core slideshow script.
 *  Set defaults for filepaths, CSS classes, and IDs in INIT method.
 */
HeroSlideshow.util = {

	setHeroContent: function(nStuff) {
		if (!nStuff || !this.slideshowHolderId) { return false; }
		var holder = document.getElementById(this.slideshowHolderId);
		if (holder) {
			holder.innerHTML = '';
			holder.appendChild(nStuff);
		}
	},
	
	/**
	 * makeButton
	 * Generate nav button.  Add onclick inline, after invoking this method (i.e. outside this method).
	 */
	makeButton: function(aParams) {
		if (!aParams) { return false; }
		var id 		= aParams['id'] || false;
		var css 	= aParams['class'] || '';
		var title 	= aParams['title'] || '';
		
		if (!id) {  /* failsafe: make random ID if need be */
			id = HeroSlideshow.util.btnIdPrefix + Math.floor(Math.random()*11);
		}
		var newButton = document.createElement('button');
		newButton.id 		= id;
		newButton.className = css;
		newButton.title 	= title;
		newButton.onmouseover	= HeroSlideshow.rollovers.onMouseOver;
		newButton.onmouseout 	= HeroSlideshow.rollovers.onMouseOut;
		return newButton;
	},
	
	addButtons: function() {
		var buttonsHolder = document.getElementById(this.slideshowButtonsId);
		if (!buttonsHolder) { alert('Slideshow error: buttons holder not found.'); return false; }
		
		var form = document.createElement('form');
			form.id = this.btnFormId;
		var fieldset = document.createElement('fieldset');

		var prevBtn =  this.makeButton({
			'id':		this.btnPrevId,
			'class':	'previous',
			'title':	'< Previous'
		});
		prevBtn.onclick = function(e){ 
			HeroSlideshow.actions.btnOnPrev();
			return HeroSlideshow.event.stop(e);
		};	
		fieldset.appendChild(prevBtn);
		
		for (var i=0; i<=this.slideCount; i++) {    
			var btn = this.makeButton({
				'id':		this.btnIdPrefix + i,
				'class':	'button',
				'title':	'Case Study '+ (i+1)
			});
			btn.onclick = function(e){ 
				HeroSlideshow.actions.btnOnclick(this.id);
				return HeroSlideshow.event.stop(e);
			};
			fieldset.appendChild(btn);
		} // end for
      
		var nextBtn = this.makeButton({
			'id':		this.btnNextId,
			'class':	'next',
			'title':	'Next >'
		});
		nextBtn.onclick = function(e){ 
			HeroSlideshow.actions.btnOnNext();
			return HeroSlideshow.event.stop(e);
		};
		fieldset.appendChild(nextBtn);
		
		form.appendChild(fieldset);
		buttonsHolder.appendChild(form);
		
		/* set tacit button images (only after insertion into document) */
        HeroSlideshow.rollovers.buttonNormal(this.btnPrevId);
        HeroSlideshow.rollovers.buttonNormal(this.btnNextId);
        for (var i=0; i<=this.slideCount; i++) { 
            HeroSlideshow.rollovers.buttonNormal(this.btnIdPrefix + i);
        }
		
	},
	
	getNodeInfo: function(oNode, sTagname) {
		if (!oNode || !sTagname || sTagname == '') { return false; }
		
		/* scrub input against accepted node names */
		var tagname = false;
		for (x in this.acceptedNodeNames) {
			if (sTagname === this.acceptedNodeNames[x]) {
				tagname = this.acceptedNodeNames[x];
				break;
			}
		}
		if (!tagname) { return false; }
		var tmpNode = oNode.getElementsByTagName(tagname)[0].childNodes[0];
		
		if ( tmpNode == null ) { return false;  }
		else { var tmp = tmpNode.nodeValue; }
		
		if (tmp && tmp != '') {
			var out = oNode.getElementsByTagName(tagname)[0].childNodes[0].nodeValue;
		}
		return out || false;
	},
	
	makeRandomNumber: function() {
		var n = 999;
		return ( Math.floor ( Math.random ( ) * n + 1 ) );
	},
	

	addButtonsCss: function(){
		if (!this.btnCssFilePath) { return false; }
		var headElem = document.getElementsByTagName("head")[0];
		if (!headElem) { return false; }
		var cssNode = document.createElement('link');
		if (cssNode) {
			cssNode.type = 'text/css';
			cssNode.rel = 'stylesheet';
			cssNode.href = this.btnCssFilePath;
			cssNode.media = 'screen';
			headElem.appendChild(cssNode);
		}
	},


	getXmlNode: function(oContentNode, sNodeName) {
		if (!oContentNode || !sNodeName) { return false; }
		var tmp = oContentNode.getElementsByTagName(sNodeName);
		return tmp || false;
	},
	
	isSafari: function(){
		var ret = false;
		var userAgent = navigator.userAgent.toLowerCase();
		if (userAgent.indexOf('applewebkit') != -1) {
			ret = true;
		}
		return ret;
	},
	
	/**
	 *  xhrOnReady
	 *  Callback in lieu of onload when XML loaded via XmlHttpRequest. (Required by Safari, which has no XML dom parser.)
	 *  @param	oReq {Object}	An XHR request object.
	*/
	xhrOnReady: function(oReq){
		if (typeof oReq != 'object') { return false; }
		/* Yes, must explicitly pass the XML contents to the global xmlDoc Object. */
		window.xmlDoc = oReq.responseXML || false; 
		if (window.xmlDoc) {
			/* perform the 'onload' */
			this.displayXml();
		}
	},
	
	/**
	 *  displayXml
	 *  Parse xmlDoc object, generate/reset dynamic content, and set timeout for next iteration.
	 *  Called by Method this.launch as xmlDoc onload event at specified intervals.
	 *  @require 	xmlDoc	{Object}	Loaded XML document object in Global space (instantiated in method this.launch).
	 *  @note	Mind your namespaces! Due to unresolved scoping quirks, this method requires explicit Object references. 
	 */
	displayXml: function() {
		
		if (typeof window.xmlDoc == 'undefined' || window.xmlDoc === false) { 
			alert('Slideshow error: No XML object'); 
			return false; 
		}
		
		var thisDoc = xmlDoc.getElementsByTagName('Content');
		if (!thisDoc) { alert('Slideshow error: XML content not found'); return false; }
		
		this.setDefaults(thisDoc);
		if (!this.MainContent) { return false; }
		
		if (this.firstTime === true || this.visibleIndex === this.slideCount) { 
			this.visibleIndex = 0;
		} else { 
			this.visibleIndex++;
		}
		
		/*	var thisContentNode = this.MainContentNodes[this.visibleIndex]; */
		var newSlide = this.outputTemplate( this.MainContentNodes[this.visibleIndex] );
		if (!newSlide) { return false; }
		this.setHeroContent(newSlide);
		
		if (this.firstTime === true) {
			this.addButtonsCss();
			this.addButtons();
		 	this.firstTime = false;
		}
		
		var this_visibleId = this.btnIdPrefix + this.visibleIndex;
		HeroSlideshow.rollovers.buttonselected( this_visibleId );
		this.prevSelected = this_visibleId;
		this_visibleId = null;
		
		this.timer = setTimeout("HeroSlideshow.util.launch()", this.interval);
	
	},
	
	pause: function(){
		window.clearTimeout(this.timer);
	},
	resume: function(){
		this.timer = setTimeout("HeroSlideshow.util.launch()", this.interval);
	},
	
	
	/**
	 *  launch
	 *  Instantiates global xmlDoc object, reads file, and attaches an onload.
	 *  @requires	xmlDoc	{Object}	Global var/object.
	 */
	launch: function() {
		if (!this.xmlFile) { return false;  }
		if (window.ActiveXObject) {
			/* IE */
		    xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
		    xmlDoc.async = false;
		    xmlDoc.load(this.xmlFile);
		    this.displayXml();
		} else if (this.isSafari) {
			/* Safari - no native XML DOM parser, use XHR instead */
			if (window.XMLHttpRequest) {
				var xhr = new XMLHttpRequest();
				xhr.open("GET", this.xmlFile, false);
				xhr.onload = function(){ HeroSlideshow.util.xhrOnReady(xhr); }
				xhr.send(null);
			} // close window.XHR test
		} else if (document.implementation.createDocument) {
			/* Mozilla */
		    xmlDoc = document.implementation.createDocument('', '', null);
		    xmlDoc.load(this.xmlFile);
		    xmlDoc.onload = this.displayXml;
		} else {
		    // Browser doesn't support XML DOM manipulation
			return false;
		}
	},
	
	/**
	 * setDefaults
	 * Triggered by successful onload of XML file. 
	 * @param 	oContentNode	{Object}	Root content node of the XML file.
	 */
	setDefaults: function(oContentNode){
		if (!oContentNode) { alert('No XML node: cannot set defaults'); return false; }
				
		var docNode 		= oContentNode[0];
		//	this.GlobalPaths 	= this.getXmlNode(docNode, 'GlobalPath');
		//	this.JSpath = this.getXmlNode(this.GlobalPaths[0], 'JavaScript');
		//	this.slidesDirectory	= this.JSpath[0].firstChild.nodeValue;
		
		this.MainContent 		= this.getXmlNode(docNode, 'Slides'); 
		this.MainContentNodes 	= this.getXmlNode(this.MainContent[0], 'Item'); 
		this.slideCount 		= this.MainContentNodes.length -1;
	
	},
	
	outputTemplate: function(oNode){
		if (!oNode || typeof oNode != 'object' ) { return false; }
		
		var quote 			= this.getNodeInfo(oNode, 'quote');
		var name 			= this.getNodeInfo(oNode, 'name');
		var name_slugline 	= this.getNodeInfo(oNode, 'name_slugline');
		var logo_img_src 	= this.getNodeInfo(oNode, 'logo_img_src');
		var logo_img_alt 	= this.getNodeInfo(oNode, 'logo_img_alt');
		var logo_img_width 	= this.getNodeInfo(oNode, 'logo_img_width');
		var logo_img_height	= this.getNodeInfo(oNode, 'logo_img_height');
		var logo_img_linkhref	= this.getNodeInfo(oNode, 'logo_img_link-href');
		var link_text		= this.getNodeInfo(oNode, 'link_text');
		var link_href		= this.getNodeInfo(oNode, 'link_href');
		var link_onclick	= this.getNodeInfo(oNode, 'link_onclick');
		
		if (quote) {
			var quoteDiv = document.createElement('div');
				quoteDiv.className = 'quote';
				quoteDiv.innerHTML = quote;
		}
		if (name) {
			var nameDiv =  document.createElement('div');
				nameDiv.className = 'name';
				nameDiv.innerHTML = name;
		}
		if (name_slugline && name_slugline != '') {
			var titleDiv =  document.createElement('div');
				titleDiv.className = 'title';
				titleDiv.innerHTML = name_slugline;
		}
		if (logo_img_src && logo_img_src != '') {
			var logoImg = document.createElement('img');
				logoImg.src = logo_img_src;
				if (logo_img_alt) { logoImg.alt = logo_img_alt; }
				if (logo_img_width) { logoImg.width = logo_img_width; }
				if (logo_img_height) { logoImg.height = logo_img_height; }
		}
		if (logoImg && logo_img_linkhref && logo_img_linkhref != '') {
			var logoLink = document.createElement('a');
				logoLink.href = logo_img_linkhref;
				logoLink.target = '_blank';
			logoLink.appendChild(logoImg);
		}
		if (logoImg || logoLink) {
			var logoDiv =  document.createElement('div');
				logoDiv.className = 'logo';
			if (logoLink) { logoDiv.appendChild(logoLink); }
			else { logoDiv.appendChild(logoImg); }
		}
		if (link_href) {
			var linkDiv = document.createElement('div');
				linkDiv.className = 'link';
				var newLink = document.createElement('a');
					newLink.href = link_href;
					newLink.innerHTML = link_text;
				linkDiv.appendChild(newLink);
		}
		var newSlide = document.createElement('div');
			if (quoteDiv) 	{ newSlide.appendChild(quoteDiv); }
			if (nameDiv) 	{ newSlide.appendChild(nameDiv); }
			if (titleDiv) 	{ newSlide.appendChild(titleDiv); }
			if (logoDiv) 	{ newSlide.appendChild(logoDiv); }
			if (linkDiv)	{ newSlide.appendChild(linkDiv); }
		
		return newSlide;
	},
	
	init: function(aParams) {
	
		/* Presets */
		this.jsAssetsDirectory 	= '/online/scripts/hero'; /* no trailing slash */
		this.buttonsDirectory	= this.jsAssetsDirectory +'/_img';  /* no trailing slash */
		this.btnCssFilePath 	= this.jsAssetsDirectory +'/slideshow_nav.css';
		
		this.xmlDomain 	= 'http://'+ window.location.hostname;
		this.xmlPath	= '/online/scripts/hero/';
		if (aParams) { 
			if (aParams['xml'] && aParams['xml'] != '') {
				if (aParams['xml'].indexOf('/')===0) {
					var xmlSrc = this.xmlDomain + aParams['xml'];
				} else {
					var xmlSrc = this.xmlDomain + this.xmlPath + aParams['xml'];
				}
			}
		}
		this.xmlFile = (xmlSrc) 
			? xmlSrc
			: this.xmlDomain + this.xmlPath + 'casestudies.xml';
		
		this.interval			= 6000; 	/* milliseconds */
		if (aParams) { 
			if (aParams['interval'] && parseInt(aParams['interval'])) {
				this.interval = aParams['interval'];
			}
		}
		
		this.btnIdPrefix 		= 'btn';
		this.btnPrevId			= 'prevBtn';
		this.btnNextId			= 'nextBtn';
		
		this.heroImage 			= document.getElementById('MSL_jsHeroImg') || false;
		this.heroLink			= document.getElementById('MSL_jsHeroLink') || false;
		//	this.bottomImageHolder 	= document.getElementById('MSL_jsHighlights') || false;
		
		this.slideshowHolderId 	= 'headerCaseStudyContent';
		this.slideshowButtonsId	= 'headerCaseStudyButtons';
		this.btnFormId			= 'MSO_jsSlideshowForm'; /* id attached to dynamically-inserted FORM holding the buttons */
		
		/* all valid nodes in the XML */
		this.acceptedNodeNames = [
			'quote',
			'name',
			'name_slugline',
			'logo_img_src',
			'logo_img_alt',
			'logo_img_width',
			'logo_img_height',
			'logo_img_link-href',
			'link_text',
			'link_href'
		];
		
		this.buttonImages = {
			'item': {
				'normal':	this.buttonsDirectory + '/button.gif',
				'rollover': this.buttonsDirectory + '/button-hot.gif',
				'selected': this.buttonsDirectory + '/button-hot.gif'
			},
			'prev': {
				'normal':	this.buttonsDirectory + '/arrow-left.gif',
				'rollover': this.buttonsDirectory + '/arrow-left-hot.gif',
				'selected': this.buttonsDirectory + '/arrow-left.gif'
			},
			'next': {
				'normal':	this.buttonsDirectory + '/arrow-right.gif',
				'rollover': this.buttonsDirectory + '/arrow-right-hot.gif',
				'selected': this.buttonsDirectory + '/arrow-right.gif'
			}
		};
		
		
		/* make sure we have our targets */
		this.holder = document.getElementById(this.slideshowHolderId);
		if (!this.holder) { return false; }
		if (!document.getElementById(this.slideshowButtonsId)) { return false; }
		

		/* required defaults */
		this.timer 			= false;
		this.visibleIndex 	= 0;
		this.prevSelected	= false;
		this.firstTime 		= true;
		this.userAgent 		= navigator.userAgent.toLowerCase() || false;
		
		/* launch the slideshow */
		this.launch();
	}
	
	
};	// END HeroSlideshow.util




/**
 *  Launch the slideshow.
 *  Attach slideshow init as an onload.
 *  INIT INVOCATION MOVED TO PAGE.
*/

/*
	if (typeof window.HeroSlideshow != 'undefined') {
		HeroSlideshow.event.add( window, 'load', function() { 
			var xmlDoc;
			HeroSlideshow.util.init({
				'xml': 'casestudies.xml'
			});
		});
	}
*/

/**
 *  END HeroSlideshow
 * ----------------------------------------------------------------------------------
 */


