﻿/* lyteboxUtil.js */

/*	Call launchLytebox('blech',false,false) e.g. from Flash 
 *	to launch the lytebox named 'blech' as a photo tour.
 *	This leverages the myLytebox object created on page load 
 *	in lytebox.js -- it finds the first anchor of the named 
 *	lytebox and launches tour from it.
 *	Call launchLytebox() with no args to launch first lytebox
 *	in the page.
 */
function launchLytebox(){
/* args: tourName, doSlide, doFrame e.g. launchLytebox('facilities',false,false) */
	var matchRel = 'lytebox';
	var foundTour = false;
	var tourName = '';
	var doSlide = false;
	var doFrame = false;
	if (arguments.length > 0){
		tourName = arguments[0];
		matchRel += '[' + tourName + ']';
	}
	if (arguments.length > 1){
		doSlide = arguments[1];
	}
	if (arguments.length > 2){
		doFrame = arguments[2];
	}
	var anchors = (myLytebox.isFrame) ? window.parent.frames[window.name].document.getElementsByTagName('a') : document.getElementsByTagName('a');
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		var relAttribute = String(anchor.getAttribute('rel'));
		if (relAttribute.indexOf(matchRel) >= 0) {
			foundTour = true;
			break;
		} 
	}
	if (foundTour) {
		myLytebox.start(anchor,doSlide,doFrame);
	} else {
		alert('Virtual tour named "' + tourName + '" not found. Called by launchLytebox(' + tourName + ',' + doSlide + ',' + doFrame + ')');
	}
}

