

/**
 *  MSLslideshow
 *  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 MSLslideshow.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 */





/**
 *  MSLslideshow
 *  Create required xmlDoc global object, and instantiate the main slideshow object.
 */

if (typeof window.MSLslideshow == "undefined") {
	var MSLslideshow = new Object();
};


/**
 *  MSLslideshow.dom
 *  Helper methods for DOM scripting.
 */
MSLslideshow.dom = {

	addClass: function(node, cls) {
		var c = node.className.split(' ');
		(!c.contains(cls)) ? c.push(cls) : true ;
		node.className = c.join(' ');
	}
	
}; // end MSLslideshow.dom



/**
 *  MSLslideshow.event
 *  Event handlers, including non-destructive "addEvent"-type attacher.
 */

MSLslideshow.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 MSLslideshow.event



/**
 *  MSLslideshow.rollovers
 *  All rollover scripts (buttons and callouts), plus helper methods.
 *  @requires	MSLslideshow.util	Numerous properties and methods.
 */

MSLslideshow.rollovers = {
	
	calloutsMouseOver: function(){
		if (!this.src) { return false; } /* must be an img */
		if (!this.className) { return false; } 
		
		var newBg = false;
		var ref = this.className; /* noid: don't want to accidentally overwrite the actual class */
		var thisIndex = parseInt( ref.substr((ref.length -1), ref.length) );
		
		var temp = MSLslideshow.util.SubContentNodes[thisIndex];
		var newBg = MSLslideshow.util.getNodeInfo(temp, 'RolloverImage');
		if (newBg && newBg !='') {
			this.src = newBg;
		}
	},
	calloutsMouseOut: function(){
		
		if (!this.src) { return false; } /* must be an img */
		if (!this.className) { return false; }
		
		var newBg = false;		
		var ref = this.className; /* noid: don't want to accidentally overwrite the actual class */
		var thisIndex = parseInt( ref.substr((ref.length -1), ref.length) );
		
		var temp = MSLslideshow.util.SubContentNodes[thisIndex];
		var newBg = MSLslideshow.util.getNodeInfo(temp, 'ImageSource');
		if (newBg && newBg !='') {
			this.src = newBg;
		}
	},
	
	
	/* Slideshow nav buttons --- */
	onMouseOver: function() { 
		var newBg = MSLslideshow.rollovers.getRolloverImageUrl(this.id) || false;
		if (newBg) {
			MSLslideshow.rollovers.setImage(this.id, newBg);  
		}
	},
	onMouseOut: function() { 
		var check=0;
		for (var i=0; i < MSLslideshow.util.slideCount; i++) { 
			if((this.id) !=(MSLslideshow.util.btnIdPrefix + i)) { 
				var isSelected = MSLslideshow.rollovers.isButtonSelected(MSLslideshow.util.btnIdPrefix + i) || false;
				if (isSelected !== true) { 
					check++;
				}
			}
		} // end for
		if (check>0) { 
			MSLslideshow.rollovers.buttonNormal(this.id);
		} else { 
			/* probably overkill, but otherwise btn states may be wonky */
			if (this.id == MSLslideshow.util.btnPrevId) {
				MSLslideshow.rollovers.prevButtonNormal();
			} else if (this.id == MSLslideshow.util.btnNextId) {
				MSLslideshow.rollovers.nextButtonNormal();
			} else if (this.id == (MSLslideshow.util.btnIdPrefix + MSLslideshow.util.visibleIndex)) {
				/* this is a Selected button - preserve Here state */
				var newBg = 'url('+ MSLslideshow.util.buttonImages['item'].selected +')';
				MSLslideshow.rollovers.setImage(this.id, newBg);
			} else {
				/* failsafe */
				MSLslideshow.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 == MSLslideshow.util.btnPrevId) { 
			out = 'url(' + MSLslideshow.util.buttonImages['prev'].rollover +')';
		} else if (sId == MSLslideshow.util.btnNextId) { 
			out = 'url(' + MSLslideshow.util.buttonImages['next'].rollover +')';
		} else { 
			out = 'url(' + MSLslideshow.util.buttonImages['item'].rollover +')';
		}
		return out;
	},
	setSelected: function(buttonId) { 
		if (MSLslideshow.util.prevSelected != null) { 
			MSLslideshow.rollovers.buttonNormal(MSLslideshow.util.prevSelected);
		}
		var newImage = 'url('+ MSLslideshow.util.buttonImages['item'].selected +')';
		MSLslideshow.rollovers.setImage(buttonId, newImage);
	},
	
	/* hard "normal" reset for Previous button */
	prevButtonNormal: function() { 
		var newBg = 'url(' + MSLslideshow.util.buttonImages['prev'].normal +')';
		MSLslideshow.rollovers.setImage(MSLslideshow.util.btnPrevId, newBg); 
	},
	/* hard "normal" reset for Next button */
	nextButtonNormal: function() { 
		var newBg = 'url(' + MSLslideshow.util.buttonImages['next'].normal +')';
		MSLslideshow.rollovers.setImage(MSLslideshow.util.btnNextId, newBg); 
	},
	buttonNormal: function(buttonId) { 
		var newBg = false;
		if (buttonId == MSLslideshow.util.btnPrevId) {
			newBg = 'url('+ MSLslideshow.util.buttonImages['prev'].normal +')';
		} else if (buttonId == MSLslideshow.util.btnNextId) { 
			newBg = 'url('+ MSLslideshow.util.buttonImages['next'].normal +')';
		} else { 
			newBg = 'url('+ MSLslideshow.util.buttonImages['item'].normal +' )';
		}
		if (newBg) {
			MSLslideshow.rollovers.setImage(buttonId,newBg); 
		}
	},
	
	
	isButtonSelected: function(buttonId) { 
		var newImage = 'url('+ MSLslideshow.util.buttonImages['item'].normal +')';
		if (document.getElementById(buttonId).style.backgroundImage == newImage) { 
			return true;
		} else { 
		 	return false;
		}
	},
	
	buttonselected: function(buttonId) { 
        if(MSLslideshow.util.prevSelected != null) { 
         	this.buttonNormal(MSLslideshow.util.prevSelected);
        }
		var newBg = 'url(' + MSLslideshow.util.buttonImages['item'].selected +' )';
		MSLslideshow.rollovers.setImage(buttonId,newBg);
	}
	
	
};	// END MSLslideshow.rollovers







/**
 *  MSLslideshow.actions
 *  onclick handlers for Slideshow nav buttons.
 *  @requires	MSLslideshow.util		Numerous properties and methods.
 *  @requires	MSLslideshow.rollovers
 */
MSLslideshow.actions = {

	scrollSlide: function(iSetIndex, iClearIndex) {
		var thisContentNode = MSLslideshow.util.MainContentNodes[iSetIndex];
		var img = MSLslideshow.util.getNodeInfo(thisContentNode, 'ImageSource')
		if (img) {
			MSLslideshow.util.setHeroImage(img);
		}
        MSLslideshow.rollovers.buttonNormal(MSLslideshow.util.btnIdPrefix + iClearIndex);
        MSLslideshow.rollovers.buttonselected(MSLslideshow.util.btnIdPrefix + iSetIndex);
        MSLslideshow.util.visibleIndex = iSetIndex;
	},

	btnOnclick: function(sId) { 
		clearTimeout ( MSLslideshow.util.timer );
		var thisThing = parseInt(sId.substring(3));
		this.scrollSlide(thisThing, MSLslideshow.util.visibleIndex);		
	},
	
	btnOnPrev: function() { 
		clearTimeout ( MSLslideshow.util.timer );
		var nowVisibleIndex = MSLslideshow.util.visibleIndex;
		var prevIndex = 0;
		if (nowVisibleIndex === 0) {
			prevIndex = MSLslideshow.util.slideCount;
		} else {
			prevIndex = nowVisibleIndex - 1;
		}
		this.scrollSlide(prevIndex, nowVisibleIndex);
	},
	
	btnOnNext: function() { 
		clearTimeout ( MSLslideshow.util.timer );
		var nowVisibleIndex = MSLslideshow.util.visibleIndex;
		var nextIndex = 0;
		if (nowVisibleIndex === MSLslideshow.util.slideCount) {
			nextIndex = 0;
		} else {
			nextIndex = nowVisibleIndex + 1;
		}
		this.scrollSlide(nextIndex, nowVisibleIndex);
	}
	
}; 	// END MSLslideshow.actions



/**
 *  MSLslideshow.util
 *  Core slideshow script.
 *  Set defaults for filepaths, CSS classes, and IDs in INIT method.
 */
MSLslideshow.util = {

	setHeroImage: function(nImg) {
		if (!this.heroImage || !nImg) { return false; }
		this.heroImage.src = nImg;
	},
	
	makeButton: function(aParams) {
		if (!aParams) { return false; }
		
		var id 		= aParams['id'] || false;
		var css 	= aParams['class'] || '';
		var title 	= aParams['title'] || '';
		// add onclick inline, after creating new Button
		
		if (!id) { 
			id = 'btn'+ Math.floor(Math.random()*11);
		};
		var newButton = document.createElement('button');
		newButton.id 		= id;
		newButton.className = css;
		newButton.title 	= title;
				
		newButton.onmouseover	= MSLslideshow.rollovers.onMouseOver;
		newButton.onmouseout 	= MSLslideshow.rollovers.onMouseOut;
		
		return newButton;

	},
	
	addButtons: function() {
		var heroTable = document.getElementById(this.slideshowHolderId);
		if (!heroTable) { alert('Slideshow error: holder not found.'); return false; }
		var newRow = heroTable.insertRow(1);
		var tr = document.createElement("tr");
		var td = document.createElement("td");
		var form = document.createElement("form");
			form.id = this.btnHolderId;
		var fieldset = document.createElement("fieldset");

		var prevBtn =  MSLslideshow.util.makeButton({
			'id':		this.btnPrevId,
			'class':	'previous',
			'title':	'< Previous'
		});
		prevBtn.onclick = function(e){ 
			MSLslideshow.actions.btnOnPrev();
			return MSLslideshow.event.stop(e);
		};
		fieldset.appendChild(prevBtn);
		
		for (var i=0; i<=this.slideCount; i++) {    
			var btn = MSLslideshow.util.makeButton({
				'id':		this.btnIdPrefix + i,
				'class':	'button',
				'title':	'Slide '+ (i+1)
			});
			btn.onclick = function(e){ 
				MSLslideshow.actions.btnOnclick(this.id);
				return MSLslideshow.event.stop(e);
			};
			fieldset.appendChild(btn);
		} // end for
      
		var nextBtn = MSLslideshow.util.makeButton({
			'id':		this.btnNextId,
			'class':	'next',
			'title':	'Next >'
		});
		nextBtn.onclick = function(e){ 
			MSLslideshow.actions.btnOnNext();
			return MSLslideshow.event.stop(e);
		};
		fieldset.appendChild(nextBtn);
		
		form.appendChild(fieldset);
		td.appendChild(form)
	   	newRow.appendChild(td); 
		
        for (var i=0; i<=this.slideCount; i++) { 
            MSLslideshow.rollovers.buttonNormal(this.btnIdPrefix + i);
        }
		/* First view: hard-set Next's state to normal */
        MSLslideshow.rollovers.nextButtonNormal(this.btnNextId);
		
	},
	
	getNodeInfo: function(oNode, sTagname) {
		if (!oNode || !sTagname || sTagname == '') { return false; }
		var tagname = false;
		switch (sTagname){
			case 'ImageSource':
				tagname = 'ImageSource';
				break;
			case 'RolloverImage':
				tagname = 'RolloverImage';
				break;
			case 'ImageLink':
				tagname = 'ImageLink';
				break;
			case 'ImageText':
				tagname = 'ImageText';
				break;
			default:
				// do nothing
		}
		
		if (tagname) {
			var tmp = oNode.getElementsByTagName(tagname)[0].childNodes[0].nodeValue;
			if (tmp) {
				var out = oNode.getElementsByTagName(tagname)[0].childNodes[0].nodeValue;
			}
		}
		if ((out && out != '') && (tagname == 'ImageSource' || tagname == 'RolloverImage')) {
			out = this.slidesDirectory + out;
		}
		
		return out || false;
	},
	
	makeRandomNumber: function() {
		var n = 999;
		return ( Math.floor ( Math.random ( ) * n + 1 ) );
	},
	
	/**
	 * makeCalloutBoxes
	 * Creates the "bottomTable", with the 3-5 highlights w/ icon images, below the slideshow
	 */
	makeCalloutBoxes: function(sId) { 
		if (typeof sId != 'string') { var sId = false; }
		
		var Subcontent = this.SubContentNodes;
		if (!Subcontent) {
			return false;
		}
		
		var bgImageCount = Subcontent.length;
		
		if (this.calloutBackgrounds) {
			var bgImg = false;
			switch (bgImageCount) {
				case 5:
					bgImg = 'url('+ this.calloutBackgrounds[5] +')';
					break;
				case 4:
					bgImg = 'url('+ this.calloutBackgrounds[4] +')';
					break;
				default:
					bgImg = 'url('+ this.calloutBackgrounds['default'] +')';
			}
		}  // end calloutBackgrounds
		
		var newTable = document.createElement('table');
		newTable.id = sId || this.calloutsTableId;
		newTable.cellSpacing = 0;
		if (bgImg) {
			newTable.style.backgroundImage = bgImg;
		}
		MSLslideshow.dom.addClass(newTable, 'colspan'+bgImageCount );
		
		var newRow1 = newTable.insertRow(0);
			MSLslideshow.dom.addClass(newRow1, 'row1');
			MSLslideshow.dom.addClass(newRow1, 'colspan'+bgImageCount );
			
		var newRow2 = newTable.insertRow(1);
			MSLslideshow.dom.addClass(newRow2, 'row2');
			MSLslideshow.dom.addClass(newRow2, 'colspan'+bgImageCount );
		
		for (var i = 0; i < bgImageCount; i++) { 
			var imgText 		= this.getNodeInfo(Subcontent[i], 'ImageText');
			var imgSource 		= this.getNodeInfo(Subcontent[i], 'ImageSource');
			var imgLink 		= this.getNodeInfo(Subcontent[i], 'ImageLink');

			/* add text cell to row 1 */
			var newThTxt = document.createElement('th');
			newThTxt.scope = 'col';
			
			var currenttext = document.createTextNode(imgText);
			/* wrap txt in span for CSS flexibility */
			var span = document.createElement('span');
			span.appendChild(currenttext);
			newThTxt.appendChild(span);
			newRow1.appendChild(newThTxt);
			
			/* add image cell to row 2 */
			var img = document.createElement('img');
			img.src = imgSource;
			img.alt = imgText; /* alt = XHTML required: at least create an empty one, plz */
			
			var className = this.calloutImgClassPrefix + i.toString();
			img.className	= className;
			img.onmouseover	= MSLslideshow.rollovers.calloutsMouseOver;
			img.onmouseout	= MSLslideshow.rollovers.calloutsMouseOut;
			
			/* wrap img in span for CSS flexibility */
			var imgSpan = document.createElement('span');
			imgSpan.appendChild(img);
			
			//	tr.row2 td a span img
			
			/* link the span & image */
			var tagA = document.createElement('a');
			tagA.href 		= imgLink;
			
			tagA.appendChild(imgSpan);
			
			var newTd = document.createElement('td');
			newTd.appendChild(tagA);
			newRow2.appendChild(newTd);
		}
		
		this.bottomImageHolder.appendChild(newTable);
		
	},
	
	getXmlNode: function(oContentNode, sNodeName) {
		if (!oContentNode || !sNodeName) { return false; }
		var tmp = oContentNode.getElementsByTagName(sNodeName);
		return tmp || false;
	},
	
	checkVitals: function() {
		var out = false;
		if (typeof window.xmlDoc == 'undefined') {
			// no xmlDoc object
		}
		if (typeof window.MSLslideshow.rollover == 'undefined') {
			// no rollover namespace
		}
		if (typeof window.MSLslideshow.event == 'undefined') {
			// no event namespace
		}
		if (typeof window.MSLslideshow.actions == 'undefined') {
			// no actions namespace (onclick methods)
		}
		
	},
	
	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 3 and earlier: 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' */
			MSLslideshow.util.displayXml();
		}
	},
	
	testSilverlight: function (){
		var runningSilverlight = false; 
	    try {
	        var ctrl = null;
	        try { 
				/* test ala Moz first, else weird errors can sometimes occur */
				var plugin = navigator.plugins["Silverlight Plug-In"];
				if ( plugin ) { 
					runningSilverlight = true; 
	            	plugin = null;
	            }
				
	        } 
			catch(e) { 
				ctrl = new ActiveXObject('AgControl.AgControl');
	            runningSilverlight = true;
	            ctrl = null;
	        }
	    }
	    catch(e) {
	        runningSilverlight = false;
	    };
	    return runningSilverlight;
	},
		

	/**
	 *  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; }
		
		MSLslideshow.util.setDefaults(thisDoc);
		if (!this.MainContent || ! this.SubContent ) {
			return false;
		}
		
		if (
			MSLslideshow.util.firstTime === true 
			|| MSLslideshow.util.visibleIndex === MSLslideshow.util.slideCount
		) { 
			MSLslideshow.util.visibleIndex = 0;
		} else { 
			MSLslideshow.util.visibleIndex++;
		}
		
		var thisContentNode = MSLslideshow.util.MainContentNodes[MSLslideshow.util.visibleIndex];
		
		var img 		= MSLslideshow.util.getNodeInfo(thisContentNode, 'ImageSource');
		var linkHref 	= MSLslideshow.util.getNodeInfo(thisContentNode, 'ImageLink');
		
		if (img) { MSLslideshow.util.setHeroImage(img); }
		if (MSLslideshow.util.heroLink && linkHref !== false) {
			MSLslideshow.util.heroLink.href = linkHref;
		}
		
		if (MSLslideshow.util.firstTime === true) {
			MSLslideshow.util.addButtons();
		 	MSLslideshow.util.makeCalloutBoxes(MSLslideshow.util.calloutsTableId);
			MSLslideshow.util.firstTime = false;
		}
		
		var this_visibleId = MSLslideshow.util.btnIdPrefix + MSLslideshow.util.visibleIndex;
		MSLslideshow.rollovers.buttonselected( this_visibleId );
		MSLslideshow.util.prevSelected = this_visibleId;
		this_visibleId = null;
		
		MSLslideshow.util.timer = setTimeout("MSLslideshow.util.launch()", MSLslideshow.util.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);
		    MSLslideshow.util.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(){ MSLslideshow.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 = MSLslideshow.util.displayXml;
		} else {
		    // Browser doesn't support XML DOM manipulation
		}
		
	},
	
	/**
	 * 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.buttonsDirectory 	= this.jsAssetsDirectory || this.slidesDirectory;

		this.MainContent 		= this.getXmlNode(docNode, 'MainContent'); 
		this.MainContentNodes 	= this.getXmlNode(this.MainContent[0], 'Item');
		this.slideCount 		= this.MainContentNodes.length -1;

		this.SubContent 		= this.getXmlNode(docNode, 'SubContent');
		this.SubContentNodes 	= this.getXmlNode(this.SubContent[0], 'Item');
							   /* Set SubContentNodes's accepted node names in MSLslideshow.util.getNodeInfo() */
							   /* ImageText, ImageSource, RolloverImage, ImageLink */
	
	},
	

	/**
	 * init
	 * Customize and initialize presets and required properties.
	 * Note - Set accepted XML content node names in:
	 *	 MSLslideshow.util.setDefault() - top level nodes
	 *	 MSLslideshow.util.getNodeInfo() - child node names in <SubContent />
	*/
	init: function() {

		this.silverlightTestId	= 'test_NonSilverlight';
		this.userAgent 		= navigator.userAgent.toLowerCase() || false;
	
		/* Silverlight detection - Safari mileage may vary.
		------------------------------------------------------------ */		
			/* First, test ala Moz */
			if (!this.isSafari() && this.testSilverlight()) { return false; } 
			/* All others test for div nested in SL's Object tag. */
			var slTest = document.getElementById(this.silverlightTestId);
			if (!slTest) { return false; }
			
			/* SL not running.  Make sure our target is present, and make it visible */
			this.NonSilverlightContentHolder = document.getElementById('MSL_jsSlideshow') || false; 
			if (!this.NonSilverlightContentHolder) { return false; }
			this.NonSilverlightContentHolder.style.position	= 'absolute';
			this.NonSilverlightContentHolder.style.display 	= 'block';
		/* ------------------------------------------------------------
			END Silverlight detection   ...Proceed: */
		
		
		/* PRESETS */
		this.jsAssetsDirectory 	= '/learning/components/homeHero/jsassets/'; /* include trailing slash */
		this.buttonsDirectory	= false;  	/* Optional: set custom img buttons dir (defaults to this.jsAssetsDirectory) */
		this.xmlFile 			= 'http://'+ window.location.hostname +'/learning/default-input.xml';
		
		this.interval			= 5000; 	/* milliseconds */
		//	this.interval			= 3000; 	/* dev tmp */
		
		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 	= 'MSL_jsSlideshowTable';
		this.btnHolderId		= 'MSL_jsSlideshowForm'; /* id attached to dynamically-inserted FORM holding the buttons */

		this.calloutsTableId 		= 'MSL_jsCalloutsTable';
		this.calloutImgClassPrefix 	= 'callout';
		this.calloutBackgrounds 	= {
			'default':	this.jsAssetsDirectory + 'bkgd-callout-panel-3.jpg',
		/* no. of TDs	Bg img src */
			4:			this.jsAssetsDirectory + 'bkgd-callout-panel-4.jpg',
			5:			this.jsAssetsDirectory + 'bkgd-callout-panel-5.jpg'
		};
		
		
		
		/* Button Images */
		this.buttonImages = {
			'item': {
				'normal':	this.jsAssetsDirectory + 'bttn-heronav-item-normal.gif',
				'rollover': this.jsAssetsDirectory + 'bttn-heronav-item-rollover.gif',
				'selected': this.jsAssetsDirectory + 'bttn-heronav-item-selected.gif'
			},
			'prev': {
				'normal':	this.jsAssetsDirectory + 'bttn-heronav-prev-normal.gif',
				'rollover': this.jsAssetsDirectory + 'bttn-heronav-prev-rollover.gif',
				'selected': this.jsAssetsDirectory + 'bttn-heronav-prev-selected.gif'
			},
			'next': {
				'normal':	this.jsAssetsDirectory + 'bttn-heronav-next-normal.gif',
				'rollover': this.jsAssetsDirectory + 'bttn-heronav-next-rollover.gif',
				'selected': this.jsAssetsDirectory + 'bttn-heronav-next-selected.gif'
			}
		};
		
		
		/* No edit - required defaults: */
		this.timer 			= false;
		this.visibleIndex 	= 0;
		this.prevSelected	= false;
		this.firstTime 		= true;
		
		/* Launch the slideshow. */
		this.launch();
		
	} /* end init() */
	
	
};	// END MSLslideshow.util




/**
 *  Launch the slideshow.
 *  Attach slideshow init as an onload.
 */
if (typeof window.MSLslideshow != 'undefined') {
	MSLslideshow.event.add( window, 'load', function() { 
		var xmlDoc;
		MSLslideshow.util.init();
	});
}


/**
 *  END MSLslideshow
 * ----------------------------------------------------------------------------------
 */


