/********************************************************************
 * FILE: PRESSCRIPT.JS
 *   Description: Javascript used to drive the presentations
 *    
 *   Copyright © 2006 Experience Builders LLC
 * LAST MODIFIED:
 *  5/30/07: If click Quit, call FindParent (new) to find outermost
 *     window.
 ********************************************************************/
var version = "text"; // for voiceovers, this should be true
var debug = true;     // If true, put up comment button

var audioTO = null;

// GOTONEWPAGE(): User selected item from pulldown menu
function GoToNewPage () {
	var menu = document.getElementById("mainmenu");
	if (!menu) {
		alert("Can't find menu");
		return;
	}
	if (menu.selectedIndex>-1)
		document.location.href = menu.options[menu.selectedIndex].value;
};

// LOADGLOBAL: User clicked Glossary or Help button, so go there
function LoadGlobal (pg) {
	if (typeof presentationmap == "undefined") {
		alert("Cannot find a presentation map, so aborting");
		return;
	}
	var url = "";
	var pgLower = pg.toLowerCase();
	var p = 0;
	while (p<presentationmap.length) {
		if (pgLower==presentationmap[p][0].toLowerCase()) {
			url = presentationmap[p][1];
			break;
		}
		p++;
	}
	if (url=="") {
		window.status = "Can't find item '"+pg+"'";
		return;
	}
	
	if (isroot) url = url.replace(/..\//,"");
	
	window.open(url.replace(/pres-/,"prespop-"),"_info","left=10,top=10,width=760,height=560,resizable,scrollbars");
};


// REPORTBUG: Submit information to EB's Issue Tracker
function ReportBug () {
	window.open("../Utilities/ExternalIssueForm.htm","BugReport","left=50,top=50,width=700,height=400,resizable,menubar=no,scrollbars=yes,titlebar=no,status");
};

// QUIT: User clicked Quit, so take back to intro section
function Quit () {
	if (confirm("Are you sure you want to quit?")) {
		var w = FindParent(window);
		w.close();
	}
};

// FINDPARENT: Get the outermost window recursively
function FindParent (w) {
	/*
	if (w.parent==null)
		return window;
	else if (w.parent == w)
		return w;
	else
		FindParent(w.parent);
	*/
	// try using top
	if (w.top==null)
		return w;
	else
		return w.top;
};

/*******************************************************************
 *  Load/Unload Functions
 *******************************************************************/

// LOADPAGE: What to do when page loads
function LoadPage () {
	// here's where you start audio
};

// UNLOADPAGE: Stop Audio
function UnloadPage () {
	StopAudio();
};

/*******************************************************************
 *  Rollover Functions
 *******************************************************************/

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr;
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
  	x.src=x.oSrc; }

function MM_preloadImages() { //v3.0
  var d=document;
  if (d.images) { 
  	if(!d.MM_p) d.MM_p=new Array();
    	var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
    	for (i=0; i<a.length; i++)
    		if (a[i].indexOf("#")!=0) {
    			d.MM_p[j]=new Image; d.MM_p[j++].src=a[i]; } } }

function MM_findObj(n, d) { //v3.0
  var p,i,x;
  if (!d) d=document;
  if ((p=n.indexOf("?"))>0 && parent.frames.length) {
    	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p); }
  if (!(x=d[n])&&d.all) x=d.all[n];
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++)
  	x=MM_findObj(n,d.layers[i].document);
  return x; }

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments;
  document.MM_sr=new Array;
  for(i=0;i<(a.length-2);i+=3)
  if ((x=MM_findObj(a[i]))!=null) {
   	document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2]; } }

// End