// common functions used throughout the toolbox.

var name = navigator.appName;
var agent = navigator.userAgent.toLowerCase();

// detect browser type
var isOpera = agent.indexOf("opera") != -1;
var isNetscape = agent.indexOf("netscape") != -1;
var isMac = agent.indexOf("mac") != -1;
var isIE = ( (name.indexOf("Microsoft") != -1) && !isOpera );

function mac_scrollbar(plusorminus) {
	if (isMac && isIE) {
		if (plusorminus == 1) {
			window.resizeBy(-1,0);
		} else {
			window.resizeBy(-1,0);
		}	
	}
}	


//popup window functions
 var newWin = null;
function popWindow(url, windowType) {
	var xPos, yPos;
	switch (windowType) {
		case 'require':
			winFeatures='height=450,width=750,scrollbars=yes'; xPos = 20; yPos = 20;
		break;
		case 'resource':
			winFeatures='height=530,width=750,resizable=no,scrollbars=yes'; xPos = 20; yPos = 20;  
		break;
		case 'tour':		// tour
			winFeatures='height=535,width=750,menubar=no,resizable=yes,scrollbars=no,toolbar=no'; xPos = 20; yPos = 20;
		break;	
		case 'interaction':		//interaction in pop up window
			winFeatures='height=535,width=720,menubar=no,resizable=yes,scrollbars=no,toolbar=no'; 
			xPos = 50; yPos = 50;
		break;	
		case 'interaction2':		//interaction in smaller pop up window
			winFeatures='height=500,width=600,menubar=no,resizable=no,scrollbars=no,toolbar=no'; xPos = 50; yPos = 10;
		break;			
		case 'interaction3':		//interaction in smaller pop up window
			winFeatures='height=360,width=550,menubar=no,resizable=no,scrollbars=no,toolbar=no'; xPos = 50; yPos = 10;
		break;		
		case 'glossary':		//glossary
			winFeatures='height=120,width=400,menubar=no,resizable=yes,scrollbars=yes,toolbar=no'; xPos = 50; yPos = 50;
		break;
		case 'glossary_with_index':		//glossary with index bar at the top
			winFeatures='height=500,width=700,menubar=no,resizable=yes,scrollbars=yes,toolbar=no'; xPos = 50; yPos = 50;
		break;
		case 'case_study':		
			winFeatures='height=400,width=400,menubar=no,resizable=yes,scrollbars=yes,toolbar=no'; 
			xPos = 200; yPos = 200;
		break;
	}
	newWin=window.open(url, windowType, winFeatures);
	newWin.focus();
	//newWin.moveTo(xPos, yPos);
}

function closeWin() {
	top.window.close();
}


// print a frame
function printFrame(fRef) {
	fRef.focus();
	fRef.print();
}

	


///////// LMS functions

// modified from "SCORM 1.2 CONTENT - Content Developer's Guide"

var nFindAPITries = 0;
var objAPI = null;
var bFinishDone = false;

function FindAPI(win) {
	while ((win.API == null) && (win.parent != null) && (win.parent != win)) {
		nFindAPITries ++;
		if (nFindAPITries > 50) {
			alert("Error in finding LMS API -- too deeply nested.");
			return null;
		}
	win = win.parent;
	}
return win.API;
}

function APIOK() {
	return ((typeof(objAPI)!= "undefined") && (objAPI != null)) 
}

function init() {

	//setTimeout(200); // update toolbox navigation frame after 1/5th second for slower machines

	objAPI = FindAPI(window);
	if ((objAPI == null) && (window.opener != null)){
		objAPI = FindAPI(window.opener);
	}
	if (!APIOK()) {
		objAPI.LMSInitialize("");
	}
}

function finish() {
	if ((APIOK()) && (bFinishDone == false)) {
		bFinishDone = (objAPI.LMSFinish("") == "true");
	}
	return (bFinishDone);
}




<!--image rollovers-----------------------------------------------
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) { //v4.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);
  if(!x && document.getElementById) x=document.getElementById(n); 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];}
}
//-->