/* 
COPYRIGHT MASTERS OF SCIENCE IN AGRONOMY PROGRAM 2007 - 2010

FILE HISTORY:
2.00 SGS 9/15/03 New Look Structure
2.50 DTM 4/05/04 Dynamic Creation Update
3.00 BM & TLS 5/2007 NEW LOOK, FEEL, FUNCTIONALITY, DTD XHTML 1.0 Transitional

USE JS SHRINKER YUI Compressor 2.4.2 AT: http://compressorrater.thruhere.net/
TO COMPRESS THIS FILE.  IT WILL COMPRESS THE FILE ALMOST 65% OF 
ITS ORIGINAL SIZE
*/
/**************************************************************************
VARIABLES THAT ADMIN CAN CHANGE
**************************************************************************/
//User Change Variables
var checkWinHeight = "off";						// 'on' or 'off' turns off auto height adjustment for windows
var popWinSize = new Array('900','600');		// width/height of popup win that open most windows
var glossWinSize = new Array('500', '200');		// width/height of popup win for glossary


/**************************************************************************
VARIABLES FOR MS AGRONOMY COURSES
**************************************************************************/
/* computer info */
var screenWidth = screen.availWidth; //width of display minus taskbar
var screenHeight = screen.availHeight; // height of display minus minus taskbar

//browers info
var version;

//xhtml
var xhtmlDefinition = "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>" +
    "<html xmlns='http://www.w3.org/1999/xhtml' >" +
    "<head>" +
    "<meta http-equiv='content-type' content='text/html; charset=UTF-8' />";

/* VARIABLES FOR XML LOADING AND PARSING */
var xmlDocument; 
var xml;
var courseMap;
var lessonMap;
var sectionMap;
var pageMap;
var professor;
var proURL;
var sectionURL;
var lastNode;
var strLinks = '';
var classLinks = '';
var level = 0;
var befLevChange = new Array();
befLevChange[0] = 0;
var skip = 0;
var lessonHead;
var imageSmall;
var imageLarge;



/**
var changeXmlPath Added PR:10.06.08 added to accomdate the security policy by firefox that 
prohibits local files from accessing xml files not in the same directory
*/
var changeXmlPath; 

/**
added 10.08 TS due to FF change in local or CD (have to change the path by 3 levels)
*/
var FFPathChange = (changeXmlPath==true)?(FFPathChange = "../../../") : (FFPathChange = path);

/* HTML VARIABLES */
var objArray = new Array();
var bannerHTML;
var linkMap;
var toolbarPicture='toolbar-nonactive.jpg';
var title;
var navDiv;

//styles
var cssString;
var dropOpen = false; //variable to hold drop nav info
var clsBtnVisible = false; // if close button for every window is visible or not

//paths
var barpath; //sets root of course level



/**************************************************************************
BROWSER CHECK SETTINGS
**************************************************************************/

/**
DETERMINES IF YOU ARE USING INTERNET EXPLORER OR FIREFOX BROWSER 
*/
function browserDetermine()
{
	var versionSearch;
	var searchLength;
	var searchString;
	
    if (document.implementation && document.implementation.createDocument)
		{  
			searchString = navigator.userAgent;
			if (searchString.indexOf('Firefox', 0) != -1) version = 'Firefox';
			else if (searchString.indexOf('Safari',0) != -1) version = 'Safari';
			
			if (window.location.href.indexOf('file://', 0) != -1) changeXmlPath = true;
		}
	if (window.ActiveXObject)
		{ 
			versionSearch = 'MSIE'
			searchLength = 8;
			searchString = navigator.userAgent;
			version = searchString.substring(searchString.indexOf(versionSearch, 0), searchString.indexOf(versionSearch, 0) + searchLength);
		}
		
		cssString = '<link rel="stylesheet" href="' + path + 'theme/' + theme + '/' + version + '.css" type="text/css" />';
		return cssString;
}

/** 
WRITES SCRIPT LINKS INTO PAGE HEADER BASED ON PATH TO ROOT SHARED FOLDER
ROOT PATHS TO SHARED FOLDER ARE CONVERTED TO PATHS TO COURSE ROOT FOLDER
FOR IMAGES SPECIFICALLY FOR THE COURSE
*/
function writeJS(path)
{
	if(path == "../../../../../")	{barpath = "../../../"}
	else if(path == "../../../../")	{barpath = "../../"}
	else if(path == "../../../")	{barpath = "../"}
	else if(path == "../../")		{barpath = ""};
	
	var searchpath = barpath;	//
	var jspath = path;			//
	var glbpath = path;  		//global path - path to shared folder from item
	
	var jsStr = '<head>' +
				'<script src="' + barpath + 'jsCourse.js"></script>' + 			//course variables
				'<script src="' + path + 'shared/shortcuts_min.js"></script>'; 	//keyboard shortcuts
	
	document.write(jsStr);

}

function writeJS2(path)
{
	/**
	LINKS EVERYPAGE TO APPROPRIATE STYLE SHEETS
	This function is called from importXML() due to load order
	and time required for loading the theme variable from 
	jsCourse.js.  Theme var is required to show theme elements
	images, css
	*/
	var jsStr1 ='<link rel="stylesheet" href="' + path + 'shared/print.css" type="text/css" media="print" />' +
		'<link rel="stylesheet" href="' + path + 'theme/' + theme + '/theme_styles.css" type="text/css" />' +
		'<script language="JavaScript">window.name = "mainWin";</script>' +
		browserDetermine(); //returns a string that links to css depending on browswer
	
	document.write(jsStr1);	
}


/** 
SPECIFIC FUNCTIONS TO LOAD WHEN WINDOW FINISHES LOADING - THESE WILL ONLY HAPPEN
WHEN ALL ITEMS HAVE BEEN INTERPRETED BY THE BROWSER 
*/

/* FUNCTIONS TO RUN ON WINDOW - LOAD */
window.onload = function(){

	/** 
	this function had checks for both main pages and popup pages, but 
	now the popup pages run functions checkNav() on body.onload within the page
	and setLinks() is run from within the checkNav function.
	
	for some reason, it doesn't run this function in popup windows, but does in study question 
	windows. 
	*/

	// check to see if page is course index or not. If course index, don't processNavXML
	if(lessonNumber == "x")
	{
		checkNav();			//checks to see popup has study icons, if not, collapses left div
	}
	else
	{
		setLinks();			//creates javascript onclick action for class links
		processNavXML(); 	//processes navigation
		activityIcon();		//sets icons for activities automatically; needs to happen after proccessNavXML in order
							//for the function to know how much space the left nav will take up
	}
	
}

/* OPEN WINDOW FUNCTIONS - THESE OPEN WINDOWS BASED ON THE CLASS NAME IN THE LINK */
//goes through link classes on page, and assigns an open function for each based on class
var newreview=null; newdetail=null; newfyi=null; newglossary=null; newtry=null; newdiscuss=null; newimage = null; newassign = null; newredirect = null; newstudy = null;

var winAttributes = "toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=" + popWinSize[0] + ", height=" + popWinSize[1];
var glossWinAtt = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=" + glossWinSize[0] + ", height=" + glossWinSize[1];

var picWid;
var picHei;

function setLinks()
{
	var links = document.getElementsByTagName("a");
	var areas = document.getElementsByTagName("area");
	
	var cTitles = new Array('fyi', 'try' ,'study', 'detail', 'review', 'glosary', 'discuss', 'assign', 'redirect');
	var lTitles = new Array('FYI : ', 'TRY THIS! : ', 'STUDY QUESTION : ', 'IN DETAIL : ', 'REVIEW : ', 
							'GLOSSARY TERM : ', 'DISCUSSION : ', 'ASSIGNMENT : ', 'REDIRECT : ');
	
	//write information automatically onlinks 
	function writeLinkInfo(cTitle, lTitle, varName, winAtVar)
	{
		if(!titleAt) {links[l].title = lTitle + links[l].innerHTML;}
		else{links[l].title = lTitle + links[l].title; }
		
		links[l].onclick = function()
		{
			if (varName != null && varName.open) varName.close();
				varName = window.open(this.href, varName, winAtVar);
				varName.focus();
			return false;
		}
	}
	
	//loop through links and check for classes, then apply popup rules based on class
	for(var l=0; l < links.length; l++)
	{
		//if link has no title attribute, use innerHTML as title
		var titleAt = links[l].getAttribute("title"); 
		var cName = links[l].className;
		
		// opens image from images folder and dynamically writes caption
		if(cName == 'pic')
		{
			links[l].onclick = function()
			{
				var generator = window.open(this.href,'name','width=700, height=600, scrollbars=yes, resizable=yes');
				generator.focus();
				generator.document.write(xhtmlDefinition + '<head><title>' + this.title + '</title>');
				generator.document.write('<link rel="stylesheet" href="' + path + 'theme/' + theme + '/theme_styles.css">');
				generator.document.write('</head><body style="background-color:#ffffff" ><br />');		
				generator.document.write('<center><div style="padding: 15px 0px 15px 0px; border: 1px; background-color: #ffffff"><img class="popupPic" id="picture" src="' + this.href + '" alt="' + this.title + '" />');
				
				generator.document.write('<p style= font-size:.9em; line-height: 1.4em; font-weight: bold; padding-bottom:20px; >' + this.title + '</p></div></center>');
				generator.document.write(clswin);
				
				generator.document.write('</body></html>');
				generator.document.write('<\script type=\"text\/javascript\">');
				generator.document.write('window.onload = function(){resizeTo((document.getElementById("picture").width + 80), (document.getElementById("picture").height + 225));}');
				
				generator.document.write('</\script>');
				generator.document.close();
				return false;
				generator.document.focus(); 
			}
		}
					
		if(cName == "fyi")
		{
			writeLinkInfo(cTitles[0], lTitles[0], newfyi, winAttributes);
		}
		else if(cName == "try")
		{
			writeLinkInfo(cTitles[1], lTitles[1], newtry, winAttributes);
		}
		else if(cName == "study")
		{
			writeLinkInfo(cTitles[2], lTitles[2], newstudy, winAttributes);
		}
		else if(cName == "detail")
		{
			writeLinkInfo(cTitles[3], lTitles[3], newdetail, winAttributes);
		}
		else if(cName == "review")
		{
			writeLinkInfo(cTitles[4], lTitles[4], newreview, winAttributes);
		}
		else if(cName == "glossary")
		{
			writeLinkInfo(cTitles[5], lTitles[5], newglossary, glossWinAtt);
		}
		else if(cName == "discuss")
		{
			writeLinkInfo(cTitles[6], lTitles[6], newdiscuss, winAttributes);
		}
		else if(cName == "assign")
		{
			writeLinkInfo(cTitles[7], lTitles[7], newassign, winAttributes);
		}
		else if(cName == "redirect")
		{
			writeLinkInfo(cTitles[8], lTitles[8], newredirect, winAttributes);
		}
	}
	
	//finding linked areas within photos based on class, assign title
	function writeAreaInfo(cTitle, lTitle, varName, winAtVar)
	{
		if(!titleAt){ areas[v].title = lTitle + areas[v].title; }
		else{ areas[v].title = lTitle + areas[v].title; }
		
		areas[v].onclick = function()
		{
			if (varName != null && varName.open) varName.close();
				varName = window.open(this.href, varName, winAtVar);
				varName.focus();
			return false;
		}
	}
	
	//loop through links and check for classes, then apply popup rules based on class
	for(var v=0; v < areas.length; v++)
	{
		var cNameArea = areas[v].className;

		//check for glossary class
		if(cNameArea == "glossary")
		{	
			writeAreaInfo(cTitles[5], lTitles[5], newglossary, glossWinAtt);
		}
		//check for detail class
		if(cNameArea == "detail")
		{
			writeAreaInfo(cTitles[3], lTitles[3], newdetail, winAttributes);
		}
		//check for try class
		if(cNameArea == "try")
		{
			writeAreaInfo(cTitles[1], lTitles[1], newdetail, winAttributes);
		}
		
		//check for glossary class
		if(cNameArea == "pic")
		{
			if(!titleAt){ areas[v].title = "OPEN IMAGE"; }
			else{ /*areas[v].title = "OPEN IMAGE : " + links[v].title; */}
			
			areas[v].onclick = function()
			{
				var winAtt = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes";
				if (newimage != null && newimage.open) newimage.close();
					newimage = window.open(this.href, "newimage", winAtt);
					newimage.focus();
				return false;
			}
		}
		
		
	}
}

/**************************************************************************
START PAGE DISPLAY FUNCTIONS
**************************************************************************/

/** 
WRITE SEARCH BOX 
*/
function writeSearch()
{
	var SearchStr = '<br /><form name="queryform" action="' + barpath + 
	'search/search.html" target="_self">' +
	'<input type="text" value="search" name="keys" size="10" class="study">' + 
	'<input style="width: 30px;" type="submit"  value="GO" class="button">' +
	'</form><br />';

	return SearchStr;
}

/** 
WRITE THE CURRENT YEAR 
*/
function currentYear()
{
    var currentDate = new Date();
    var currentYear = currentDate.getFullYear();
    return currentYear;
}

/** 
WRITE TITLE IN BROWSER HEADER 
*/
function writeTitleHead(pagetitle) { document.title = pagetitle; }

/** 
WRITE GREEN H2 TITLE IN PAGE BODY 
*/
function writeTitleBody(name)
{
//special print issues if summary or into in 502
if(course == "502" && lessonNumber == "Soil Basics Summary" ||
   course == "502" && lessonNumber == "Soil Chemistry Introduction" ||
   course == "502" && lessonNumber == "Soil Chemistry Summary" ||
   course == "502" && lessonNumber == "Soil Physics Introduction" ||
   course == "502" && lessonNumber == "Soil Physics Summary" ||
   course == "502" && lessonNumber == "Soil Biology Introduction" ||
   course == "502" && lessonNumber == "Soil Biology Summary" ||
   course == "502" && lessonNumber == "Case Study and Summary"
   )
	{
		document.write("<h3 id='printLessNum'>Agronomy " + course + " : " + 
				   lessonNumber + " </h3>" + "<h2>" + title + "</h2>");
	}
else
	{
		if (title)
		{
			document.write("<h3 id='printLessNum'>Agronomy " + course + " : " + maincat + " " + 
							lessonNumber + " </h3>" + "<h2>" + title + "</h2>");
		}
		else
		{
			document.write("<h2>" + name + "</h2>");
		}
	}
}

/* 
WRITE BLACK H3 TITLE IN PAGE BODY 
*/
function writePageTitle(pgtitle){ document.write("<h3 style='z-index:-1'>" + pgtitle + "</h3>"); }

/** 
GOBACK IN HISTORY 1 PAGE 
*/
function goBack(){ window.history.back() }

/**
AUTOMATICALLY ADJUST HEIGHT FOR POPUP WINDOWS
*/
function setWindowHeight()
	{
		var xh = document.getElementById('page').offsetHeight;
		var xw = document.getElementById('page').offsetWidth;
		var sh = screen.height;
		var hei;
										
		var wid = xw + 31;
		
		if(xh >= sh){ hei = (sh - 100); }
		else
		{				
			hei = xh + 100;
		}
		window.resizeTo(wid,hei);
	}

/**
CHECKS THE WINDOW SIZE OF THE POPUP WINDOW BASED ON PAGE DIV WIDTH & HEIGHT
THEN SETS THE PAGE SIZE ACCORDING TO THE PAGE DIV
*/
function checkWinSize()
{
	var gh = document.getElementById('page').offsetHeight;
	var gw = document.getElementById('page').offsetWidth;
	if(type == 'activity'  || type == 'fyi' || type == 'detail')
	{
		setWindowHeight();
	}
	//setWindowHeight();
}


/**
CREATES FOOTER AND COPYRIGHT INFORMATION 
*/
function writeFooter(NextPage){
document.write("<div id='footer'>" + writeFooterNav(NextPage) +
               "<div class='copyright' style='margin-left: 10px; float:left'>" + 
			   		"Copyright " + currentYear() + " - <a style='color: #666666;' " + 
			   		"href='http://www.agron.iastate.edu' target='_blank'>Department of Agronomy</a>, " + 
			   		"<a href='http://www.iastate.edu' style='color: #666666;' target='_blank'>Iowa State University" + 
			   		"</a> - All Rights Reserved" + 
				"</div>" + 
				"<div class='copyright' id='feedback' style='float:right; padding-right:10px;'>" + 
					"<a href='http://masters.agron.iastate.edu/students/feedback.aspx?url=" + location.href + 
					"' target='_blank' title='Go to coursepage feedback form'>Send Feedback</a>" + 
				"</div>" +
			"</div>" +  //closes footer div
		"</div>" +  //closes wrapper div
	"</div>"  //closes page div
					
	//GOOGLE ANALYTICS FUNCTION CALL 					
	/*"<script type='text/javascript'>" + "_uacct = 'UA-2490634-1';" + 
	"urchinTracker(); </script>"*/
	);  
			
	//window.document.onload = function()
	//{
	 if(lessonNumber == "x"){ // x is lessonNumber on all popup windows //
		 if(checkWinHeight == "on"){
			 checkWinSize();
		 }
	 }
	//}			 	
}

/**
WRITE FOOTER NAV ON EACH CLASS PAGE WITH ARROWS AND 
LINK TO THE NEXT PAGE
*/
function writeFooterNav(NextPage)
{
	var footerNav =''
	if(lessonNumber != 'x')
	{ 
	footerNav = ("<div id='footerNav' class='footerNavStyle'>" + 
					"<a href='#top' title='Go to Page Top' >" +
					"<img style='float:left; border: 0;' alt='' src='" + path + "theme/" + theme + "/images/top.jpg' /></a>" +    
					"<map id='changePage' name='changePage'>" +
						"<area alt='' shape='rect' href='javascript:window.history.back()' " + 
						"title='Previous Page' coords='0 0, 29 19' />" +
						"<area alt='' shape='rect' href='" +NextPage+ "' coords='30 0, 60 19' title='Next Page' />" +
					"</map>" +
				   "<img style='border:none;float:right;' alt='' usemap='#changePage' src='" + path + 
				   "theme/" + theme + "/images/page_nav.jpg' />" + 
				 "</div>"); 
	}
	return footerNav;
}

/**
WRITE LEFT NAV TITLE AND STYLES
*/
function writeNavTitle(strNavTitle, yellowTitle)
{
	var indexCase;
	//var indexCase = (lessonNumber == 'index' || lessonNumber == 'Intro') ? (indexCase = "") : (indexCase = "LESSON ");
	
	if(!yellowTitle)
	{
		if(lessonNumber == 'index' || lessonNumber == 'Intro'){ indexCase = "" } 
		else { indexCase = maincat.toUpperCase() + " " }
		
		var navTitle = "<div class='nTitle'>" + indexCase + strNavTitle + "</div>" + 
					   "<div class='nPic'>" +
							"<img  alt='' src='" + path + "theme/" + theme + "/images/navBar.jpg' />" +
					   "</div>"; 
	}		
	else
	{
		var navTitle = "<div class='nTitle'>" + yellowTitle + "</div>" + 
				   	   "<div class='nPic'>" + 
					   "<img  alt='' src='" + path + "/images/navBar.jpg' />" + 
					   "</div>"; 
	}
	document.write(navTitle);
}

/* 
WRITE FOOTER AND SOFTWARE ICONS ON INDEX PAGE 
*/
function writeIndexFooter(path){
	document.write(
	"<div id='indexFooter'>" +
		"<span class='h1' style='margin-top:0px;width:300px;'><b>Software Required</b>&nbsp;&nbsp;" + 
			"<a href='http://masters.agron.iastate.edu/redirect/software/ie.html' title='Get Internet Explorer' >" + 
			"<img src='" + path + "theme/" + theme + "/images/softwareIcons/get_explorer.jpg' alt='Get Internet Explorer' style='border:none' />" + 
			"</a>&nbsp;&nbsp;" + 
			"<a href='http://masters.agron.iastate.edu/redirect/software/flash.html' title='Get Adobe Flash Player' >" + 
			"<img src='" + path + "theme/" + theme + "/images/softwareIcons/get_flash.jpg' alt='Get Flash Player' style='border:none'/>" + 
			"</a>&nbsp;&nbsp;" +
			"<a href='http://masters.agron.iastate.edu/redirect/software/quicktime.html' title='Get Apple Quicktime Player' >" + 
			"<img src='" + path + "theme/" + theme + "/images/softwareIcons/get_quicktime.jpg' alt='Get Quicktime Player' style='border:none'/>" + 
			"</a>&nbsp;&nbsp;" +
			"<a href='http://masters.agron.iastate.edu/redirect/software/acrobat.html' title='Get Adobe Acrobat Reader' >" + 
			"<img src='" + path + "theme/" + theme + "/images/softwareIcons/get_acrobat.jpg' alt='Get Adobe Acrobat Reader' style='border:none'/>" + 
			"</a>&nbsp;&nbsp;" +
			"<a href='http://masters.agron.iastate.edu/redirect/software/realplayer.html' title='Get RealPlayer' >" + 
			"<img src='" + path + "theme/" + theme + "/images/softwareIcons/get_real.jpg' alt='Get Real Player' style='border:none'/>" + 
			"</a>&nbsp;&nbsp;" +
			"<a href='http://masters.agron.iastate.edu/redirect/software/msoffice.html' title='Get Microsoft Office' >" + 
			"<img src='" + path + "theme/" + theme + "/images/softwareIcons/get_office.jpg' alt='Get Microsoft Office (education discount)' style='border:none'/>" + 
			"</a>&nbsp;&nbsp;" +
		"</span><br />" + 
        "<span class='copyright'>Copyright " + currentYear() + 
		" - Agronomy Department, Iowa State University - All Rights Reserved</span>" +
    "</div>" +  //closes footer div
  "</div>" +  //closes wrapper div
"</div>");  //closes page div
}

/**
WRITE CLOSE WINDOW BUTTON
*/
function writeClosewindow()
{
	document.write('<p>' + clswin + '</p>');
}
var clswin = '<div style="float:right;">' + 
			 '<table style="text-align:center; border:1px solid #666666; ' + 
			 'background-color:#efefef; width:100px;">' + 
			 '<tr><td><a href="javascript:window.close()" class="caption" ' + 
			 'style="font-size:10px; font-weight:bold; text-decoration: none;">' + 
			 'Close Window</a></td></tr></table></div>';

/** 
WRITE MAIN COURSE BANNER, TOOLBAR, AND IMAGE MAP 
*/
function writeBanner(NextPage)
{   
	var toolsIndex = 'visible'; 
    if(lessonNumber == 'index'){toolsIndex = 'hidden';}

    bannerHTML = 
	"<div id='page'>" + 
     	"<div id='wrapper'>" +
       		"<div id='header'>" + 
				"<a name='top' id='top'></a>" + //page top anchor
					"<div id='banner'>" +
					
					// write course title in shell
					"<div id='courseName' " + 
						"style='background-image:url(\"" + path + "transparentcourseNum.gif\"); '" +  
						"onclick='window.location = \"" + barpath + "index.html\"'>" + 
						"<span id='courseNum'>AGRONOMY " + course + "</span><br />" +
						"<span id='ctitle'><b>" + courseTitle + "</b></span></div>" + 

					//write logo in to course shell
					"<div id='clogo'>" +
						"<img src='" + barpath + "images/" + imageLarge +"' alt='' " + 
						"style='position: relative; border:0px; top: -1px; padding: 0px 0px 0px 0px;' usemap='#Map' />" + 
					"</div>" +	
					
					//write black and white logo in print outs but not on regular pages
					//normally hidden
					"<div id='printLogo' >" +
						"<img src='" + path + 	"theme/" + theme + "/images/headbar1bw.jpg' alt='' " + 
						"style='border:0px; padding: 0px 0px 0px 0px;' />" +
					"</div>" +
					
					//write course name, number and tagline at top right of page
					"<map id='Map' name='Map'>" +                 
						"<area alt='' shape='rect' coords='0 0, 325 100' href='http://www.masters.agron.iastate.edu' />" +
						"<area alt='' shape='rect' coords='580 0 , 797 50' " + 
						"href='" + barpath + "index.html' title='Click for course index' />" +
						//"<area alt='' shape='rect' coords='712 60, 727 77' href='' onclick='collapseAll();'/>" +
					"</map>" + 
						
						"<div id='toolbar' style='visibility:" + toolsIndex + 
							"' onmouseout='image1.src=\"" + path + "theme/" + theme + "/images/toolbar-nonactive.jpg\";' class='toolBar' >" +
						
							"<img usemap='#toolMap' name='image1' style='border:0px;' src='" +
							path + "theme/" + theme + "/images/" + toolbarPicture +"' alt='' />" +
															
							"<map  name='toolMap'>" +
								"<area alt='' shape='rect' coords='0 0, 85 20'  " + 
								"onmouseover='image1.src=\"" + path + "theme/" + theme + "/images/toolbar-course.jpg\";' " + 
								"onmouseout='setTimeout(\"menuCollapse()\", 500)' onclick='menuPopup(\"course\");'  />" +  
								
								"<area alt='' shape='rect' coords='85 0, 195 20' " + 
								"onmouseover='image1.src=\"" + path + "theme/" + theme + "/images/toolbar-interactions.jpg\";' " + 
								"onmouseout='setTimeout(\"menuCollapse()\", 500)' onclick='menuPopup(\"interactions\");'  />" + 
								
								"<area alt='' shape='rect' coords='195 0, 270 20' " + 
								"onmouseover='image1.src=\"" + path + "theme/" + theme + "/images/toolbar-tools.jpg\";' " + 
								"onmouseout='setTimeout(\"menuCollapse()\", 500)' onclick='menuPopup(\"tools\");'  />"+   
								"<area alt='' shape='rect' coords='270 0, 310 20' " + 
								"onclick='opengenerictools(\"toolbar.html\",\"tools\", 400, 150)' />" +
							"</map>" +
						
								"<div id='courseMenu' onmouseover='dropOpen = true' onmouseout='dropOpen = false; " + 
									"setTimeout(\"menuCollapse()\", 500);' class='dropDownMenusCourse' >" + 
									"<img alt='' src='" + path + "theme/" + theme + "/images/course_dropdown.jpg' " +
									"style='border: 0;' usemap='#courseImage'/>" +
									
									"<map id='courseImage' name='courseImage'>" +
									"<area alt='' shape='rect' coords='0 0, 66 57' href='" + barpath + "intro/index.html' />" +
									"<area alt='' shape='rect' coords='67 0, 146 57' href='" + barpath + "index.html' />" +
									"<area alt='' shape='rect' coords='147 0, 221 57' onclick='returnCourseMenu();' />" + 
									"</map>" + 
								"</div>" +
									   
								"<div id='interactionsMenu' onmouseover='dropOpen = true' onmouseout='dropOpen = false; " + 
									"setTimeout(\"menuCollapse()\", 500);' class='dropDownMenusInt'  >" + 
									"<img alt='' src='" + path + "theme/" + theme + "/images/interactions_dropdown.jpg' " + 
									"style='border: 0;' usemap='#intImage'/>" +
									
									"<map id='intImage' name='intImage'>" +
									"<area alt='' shape='rect' coords='12 07, 65 60' " +
									"href='mailto:"+ professor + " " + proURL + "' />" +
									"</map>" +
								"</div>" +                       	          
																	
							"<div id='toolsMenu' onmouseover='dropOpen = true' onmouseout='dropOpen = false; " + 
								"setTimeout(\"menuCollapse()\", 500);' class='dropDownMenusTools' >" + 
								
								"<img alt='' src='" + path + "theme/" + theme + "/images/tools_dropdown.jpg' " + 
								"style='border: 0;' usemap='#toolsImage'/>" +
								"<map id='toolsImage' name='toolsImage'>" +
								"<area alt='' shape='rect' coords='25 10, 94 60' onclick='openconv();' />" +
								"<area alt='' shape='rect' coords='108 10, 153 60' onclick='openglossnav();' />" +
								"<area alt='' shape='rect' coords='167 10, 205 60' onclick='opensearch();' />" + 
								"<area alt='' shape='rect' coords='227 10, 277 60' onclick='opensns();' />" +
								"<area alt='' shape='rect' coords='294 10, 334 60' onclick='printTools();' />" +
								"</map>" +  
											 
							"<div id='topArrows' style='background-image:url(\""+ path + "theme/" + theme + "/images/topArrows.gif\"; x-repeat:none'>" + 
								"<img usemap='#topArrowMap' src='" + path + "theme/" + theme + "/images/topArrows.gif' alt='' " +
								"style='visibility:" + toolsIndex + "; cursor: pointer; " + 
								"position: relative; z-index: 2; left: 320px; top: -74px; " + 
								"border: 0px; padding: 0px 0px 0px 0px;' />" +
								
								"<map id='topArrowMap' name='topArrowMap'>" + 
								"<area alt='' shape='rect' coords='0 0, 28 17' " + 
								"href='javascript:window.history.back()' title='Previous Page'/>" +
								"<area alt='' shape='rect' coords='32 0, 65 17' href='" + NextPage + "' title='Next Page' />" +
								"</map>" +
								
							"</div>" +                                                                                 
						"</div>" + //end toolbar                                               	                	        
				  "</div>" + //end banner
			  "</div>";  //end header

	 document.write(bannerHTML); 
	 
	 	 /**
	 KEYBOARD SHORTCUT FUNCTIONS
	 added at end of headbar load
	 http://www.openjs.com/scripts/events/keyboard_shortcuts/
	 */
	shortcut.add("Ctrl+Shift+Right", function(){ 	//to next page
	window.location=NextPage;
	});
	
	shortcut.add("Ctrl+Shift+Left", function(){		//back a page
	goBack();
	});
	
/*	shortcut.add("Shift+d", function(){		//back a page
	returnClassMenu();
	});
	
	shortcut.add("Shift+s", function(){		//back a page
	opensns();
	});
	
	shortcut.add("Shift+c", function(){		//back a page
	openconv();
	});
	
	shortcut.add("Shift+g", function(){		//back a page
	openglossnav();
	});*/
	
	shortcut.add("Ctrl+Shift+f", function(){		//back a page
	opensearch();
	});
	
	shortcut.add("Ctrl+Shift+a", function(){		//back a page
	window.location=barpath + "index.html";
	});
}

/** 
WRITES BANNER INFORMATION ON POPUP WINDOWS
*/
function writePopupBanner(Title, type)
{
	var pageWrapper;
	var popBannerHTML;
	var Hphoto;
	
	if(type == "detail")
	{ 
		pageWrapper = "<div id='wrapper' style='width:800px;'><div id='popupName'>" + 
					  "<h2>IN DETAIL : " + Title + "</h2></div>"; 
		Hphoto = path + "theme/" + theme + "/images/detail_header.jpg"; 
		popBannerHTML = "<div id='banner' class='popupBannerStyle' " + 
						"style='background-image:url(" + Hphoto + "); background-repeat:repeat-x;>" +
						"<div id='innerbanner' style=' height:55px; border:1px;  margin-bottom:20px;'>" +
						"<h3 class='popupInnerBannerStyle'>" + Title + "</h3></div>";
	}
	else if(type == "fyi")
	{ 
		pageWrapper = "<div id='wrapper' style='width:800px;'><div id='popupName'>" + 
					  "<h2>FYI : " + Title + "</h2></div>"; 
		Hphoto = path + "theme/" + theme + "/images/fyi_header.jpg"; 
		popBannerHTML = "<div id='banner' class='popupBannerStyle' " + 
						"style='background-image:url(" + Hphoto + "); background-repeat:repeat-x; >" +
						"<div id='innerbanner' style=' height:55px; border:1px;  margin-bottom:20px;'>" +
						"<h3 class='popupInnerBannerStyle'>" + Title + "</h3></div>";	
	}
	else if(type == "activity")
	{ 
		pageWrapper = "<div id='wrapper' style='width:800px;'><div id='popupName'>" + 
					  "<h2>ACTIVITY : " + Title + "</h2></div>"; 
		Hphoto = path + "theme/" + theme + "/images/activity_header.jpg"; 
		popBannerHTML = "<div id='banner' class='popupBannerStyle' " + 
						"style='background-image:url(" + Hphoto + "); background-repeat:repeat-x; >" +
						"<div id='innerbanner' style=' height:55px; border:1px; margin-bottom:20px;'>" +
						"<h3 class='popupInnerBannerStyle'>" + Title + "</h3></div>";		
	}
	else if(type == "blankpage")
	{
		pageWrapper = "<div id='wrapper'>"; 
		popBannerHTML = "";
	}
	
	var mainPages = "<div id='page'>" + pageWrapper + "<div id='header'>";

	var endBanner = "</div>" + //end banner
					"</div>";  //end header;

	document.write(mainPages + popBannerHTML + endBanner);
}

/** 
POPS UP A CERTAIN MENU BASED ON WHICH MENU IS IN THE FUNCTION'S ARGUMENT
*/
function menuPopup(menuType)
{  
    var menuName = menuType + "Menu";
	
    var toolMenu = document.getElementById(menuName);
    toolMenu.style.visibility = 'visible'  
	toolMenu.style.zIndex = 500;
	
 	var courseMenu = document.getElementById(menuName);
    courseMenu.style.visibility = 'visible'  

	courseMenu.style.zIndex = 500; 
}

/** 
HIDES A CERTAIN MENU BASED ON WHICH MENU IS IN THE FUNCTION'S ARGUMENT
*/
function menuCollapse()
{
    if(dropOpen)
    {
        dropOpen = true;
    }
    else{
		var hiddenMenu;
		hiddenMenu = document.getElementById("toolsMenu");
		hiddenMenu.style.visibility = 'hidden'; 
	
		var toolMenu = document.getElementById('interactionsMenu');
		toolMenu.style.visibility = 'hidden'
		dropOpen=false;
		
		var toolMenu = document.getElementById('courseMenu');
		toolMenu.style.visibility = 'hidden'
		dropOpen=false;
    }
} 

/** 
PRINT BUTTON FUNCTIONALITY FOR DROP DOWN TOOLS MENU 
*/
function printTools()
{ 
	window.print();
}

/**************************************************************************
START LEFT NAV, AUTO ICONS, AND COURSE MAP & END PAGE DISPLAY FUNCTIONS
**************************************************************************/

/**
Creates the XML document and defines variables
*/


function importXML()
{
    //check if browser is not internet explorer
	if ((version.indexOf('Firefox') != -1) || (version.indexOf('Safari') != -1))
	{   
	    xml = document.implementation.createDocument("", "", null);
	    xml.async = false;
		if (changeXmlPath) { //Firefox security policy for local files
			xml.load(course +"Map.xml");
		} else {
			xml.load(barpath + course +"Map.xml");
		}
		xmlDocument = xml;
	}
	//check if browser is internet explorer
	else if (version.indexOf('MSIE') != -1)
	{
        xml = document.createElement('xml');
        xml.async = false;
        xml.load(barpath + course +"Map.xml");
		xmlDocument = xml;
 	}
	else
	{
		alert("For best results, please use IE or FireFox.  Please make sure you have Javascript turned on.  If you do, please contact MS Agron Office.");
		return;
	}

	 courseMap = xmlDocument.getElementsByTagName('course');
	 lessonMap = courseMap[0].getElementsByTagName('lesson');
	 
	 var courseTitleAtt = courseMap[0].getAttribute('title');	 	
	 professor= courseMap[0].getAttribute('instructor');
     proURL = courseMap[0].getAttribute('email');
	 
	 for(var i=0; i <= lessonMap.length - 1; i++)
	 {
		 if(lessonNumber == lessonMap[i].getAttribute('id'))
		 {
			 sectionMap = lessonMap[i].getElementsByTagName('section');
			 
			 /**
			 large image and small image for lesson.  URL to small image is included in XML.
			 Large image URL can be found by taking a substring of the small image URL.
			 i.e. lesson01_small.jpg equals lesson01.jpg.  If image attribute is not defined, imageSmall is nothing
			 and imageLarge defaults to 'index.jpg' which will happen on every course index page
			 */
			 imageSmall = (lessonMap[i].getAttribute('image')) ? 
			 (imageSmall = lessonMap[i].getAttribute('image')) 
			:(imageSmall = ''); 
																
			 imageLarge = (lessonMap[i].getAttribute('image')) ? 
			 (imageLarge = imageSmall.substr(0, imageSmall.indexOf('_small')) + ".jpg")
			 :(imageLarge = course + 'index.jpg');
																
			 
			 //lessonNumberTitle is used instead of title attribute if it exists
			 title = (lessonMap[i].getAttribute('lessonNumberTitle')) ? 
			 (title = lessonMap[i].getAttribute('lessonNumberTitle')) 
			:(title = lessonMap[i].getAttribute('title'));
			
			//provides the header for the title
			lessonHead = (lessonMap[i].getAttribute('lessonNumberTitle')) ? 
			(lessonHead = '') 
			:(lessonHead = maincat + " " + lessonNumber + ": ");
			
			 sectionURL =lessonMap[i].getAttribute('url');
			 if(lessonMap[i].childNodes.length != 0){sectionCrawl(lessonMap[i], 'section');}
		 }
	 }

}

/**
CHECKNAV FUNCTION IS INSERTED INTO THE ONLOAD EVENT OF THE BODY TAG FOR POPUPS
THIS CHECKS TO SEE IF THE POPUP PAGE HAS ACTIVITIES ON IT.  IF SO, THE LEFT
NAV AREA WILL REMAIN, OTHERWISE, THE LEFT NAV ICON AREA WILL COLLAPSE 
*/
function checkNav()
{
	/**
	run setLinks() here becuase body.onload makes the window.onload function not work
	*/
	setLinks(); 
	
    var popupDivs = document.getElementsByTagName('div');
    navDiv = document.getElementById('tryThisLeftNav');
    var leftColumn = document.getElementById('side-a');
	var midColumn = document.getElementById('popupcontent');
		
    var flag = false;
    for(var i=0; i <= popupDivs.length - 1; i++)
    {  
        if(popupDivs[i].className == 'activity' || popupDivs[i].className == 'activityNoBorder')
        {
            flag = true;
        }
    } 
    if(flag == false)
    {
        leftColumn.style.width = '0px';
		midColumn.style.paddingLeft = '30px';
		midColumn.style.paddingRight = '30px';
		midColumn.style.width = '740px';
    }
    else
    {   
        activityIcon(); 
    }
}

/**
goes through course XML based on browser 
*/
function sectionCrawl(xmlMap, tag)
{
	/**
	Internet Explorer section
	*/
	if(version.indexOf('MSIE') != -1)
	{
		var levelMap = xmlMap.childNodes;
		for(var i = 0; i <= levelMap.length -1; i++)
		{
			var coursMapURL = levelMap[i].childNodes[0].getAttribute('url');
			writeCourseNav(levelMap, i, 'section', coursMapURL, level);
			level++;
			if(levelMap[i].hasChildNodes())
			{
				pageCrawlIE(levelMap[i].childNodes);
			}
			level--;
		}
	}
	/**
	FireFox section
	*/
	else
	{
		var levelMap = xmlMap.getElementsByTagName('section');
		for(var i = 0; i <= levelMap.length - 1; i++)
		{
			var courseMapURL = levelMap[i].getElementsByTagName('page'); 
			courseMapURL
			= courseMapURL[0].getAttribute('url'); 
			writeCourseNav(levelMap, i, 'section', courseMapURL, level);
			level++;
			befLevChange.push(0);
			if(levelMap[i].hasChildNodes())
			{
				pageCrawlFF(levelMap[i].getElementsByTagName('page'));
			}
			level--;
			befLevChange.splice(0, befLevChange.length - 1);
		}
	}
		
	var header = "<div style='font-size: 14px; 	margin-left: 15px; margin-bottom: -5px;'>" +
			  "<a style='padding-bottom: 15px; font-weight : Bold;' href='javascript:openerLocal(\""+ FFPathChange + "" + 
				courseMap[0].getAttribute('url') +"\")' >" + courseMap[0].getAttribute('title') +"</a></div>" + 
                "<div><table class='courseMapStyle'><tr><td><img src='" + FFPathChange + "../../../theme/" + theme + "/images/lmenu/ftv2lastnode.gif' alt='' /></td><td>" +  
                "<a style='padding-bottom: 15px; font-weight : Bold; class='coursePadding'" + 
				"href='javascript:openerLocal(\""+ FFPathChange + "" + 
				sectionURL +"\")' >" +  
				lessonHead + 
				title + "</a></td></td></table></div>";
	strLinks = header + strLinks;
}

/**
function pageCrawlIE for IE
CRAWLS THROUGH THE XML USING RELATIVE NODE PROPERTIES, I.E. .CHILDNODES
*/
function pageCrawlIE(xmlMap)
{	
	var levelMap = xmlMap;
	for(var i = 0; i <= levelMap.length -1; i++)
	{
		var courseMapURL = levelMap[i].getAttribute('url');
		if(!(level == 1 && i == 0))
		{
			writeCourseNav(levelMap, i, 'page', courseMapURL, level);
		}
		if(levelMap[i].hasChildNodes())
		{
			level++;
			pageCrawlIE(levelMap[i].childNodes);
			level--;
		}
	}
}

/**
function pageCrawlFF for Firefox
CRAWLS THROUGH THE XML WITHOUT USING RELATIVE NODE PROPERTIES, I.E. .CHILDNODES

PROPERTY getElementsByTagName TAKES ALL XML NODES AT A LEVEL AND THEIR CHILD NODES.
befLevChange AND skip VARIABLES ARE USED TO ONLY INCLUDE THE NODES AT THE APPROPRIATE LEVEL
OTHER WISE A CHILD NODE WILL BE WRITTEN AS A PART OF ITS SPECIFIC LEVEL AND AS A PART OF ANY 
LEVELS PRECEEDING THAT CHILD NODE
*/
function pageCrawlFF(xmlMap)
{
	var levelMap = xmlMap;
	for(var i = 0; i <= levelMap.length -1; i = i)
	{
		var courseMapURL = levelMap[i].getAttribute('url');
		if(!(level == 1 && i == 0))
		{
			writeCourseNav(levelMap, i, 'page', courseMapURL, level);
		}
		befLevChange[level]++;
		if(levelMap[i].hasChildNodes())
		{
			level++;
			befLevChange.push(0);
			pageCrawlFF(levelMap[i].getElementsByTagName('page'));
			skip = 0;
			for(var i = level - 1; i < befLevChange.length; i++){skip += befLevChange[i];}
			i = skip;
			level--;
		}
		else{i++;}		
	}
}

function writeClassNav()
{
	classLinks = "<div style='font-size: 14px; 	margin-left: 15px; margin-bottom: -5px;'>" +
			  "<a style='padding-bottom: 15px; font-weight : Bold;' href='javascript:openerLocal(\""+ path + "" + 
				courseMap[0].getAttribute('url') +"\")' >" + courseMap[0].getAttribute('title') +"</a></div>";

	for(var i=1; i <= lessonMap.length - 1; i++)
	 {
		sectionMap = lessonMap[i].getElementsByTagName('section');
		title = (lessonMap[i].getAttribute('lessonNumberTitle')) ? (title = lessonMap[i].getAttribute('lessonNumberTitle')): (title = lessonMap[i].getAttribute('title'));
		
		lessonHead = (lessonMap[i].getAttribute('lessonNumberTitle')) ? (lessonHead = '') : (lessonHead = maincat + " " + lessonMap[i].getAttribute('id') + ": ");
		
		sectionURL =lessonMap[i].getAttribute('url');
		classLinks += "<div><table class='courseMapStyle'><tr><td><img src='../../../theme/" + theme + "/images/lmenu/ftv2lastnode.gif' alt='' /></td><td>" +  
                "<a style='padding-bottom: 15px; font-weight : Bold; class='coursePadding'" + 
				"href='javascript:openerLocal(\""+ path + "" + 
				sectionURL +"\")' >" +  
				lessonHead + 
				title + "</a></td></td></table></div>";
				
		if(lessonMap[i].childNodes.length != 0){sectionCrawl(lessonMap[i], 'section');}
	 }
}

/**
Writes course navigation in lesson map popup window
*/
function writeCourseNav(levelMap, i, tag, url, Level )
{		
	var cssLeftNav; 
	
	/**
	lastNode variable will insert one of two pictures on the course map depending if the node being written
	is the last node at its level in the xml's node tree
	*/
	
	// CD run in Firefox
	if (changeXmlPath) 
	{
		lastNode = (i == levelMap.length - 1 || (tag != 'section' && levelMap[i].hasChildNodes())) ? 
			(lastNode = "&nbsp;&nbsp;&nbsp;<img src='" + FFPathChange + "theme/" + theme + "/images/lmenu/ftv2lastnode.gif' alt='' />") : 
			(lastNode = "&nbsp;&nbsp;&nbsp;<img src='" + FFPathChange + "theme/" + theme + "/images/lmenu/ftv2node.gif' alt='' />");
			
	/**
	leftIcon variable will insert a picture along the left side of 
	the course map.  It will either be the value of variable lastNode or a vertical line
	*/
	var leftIcon = (tag == 'section') ? (leftIcon = lastNode) : 
				   (leftIcon = "&nbsp;&nbsp;&nbsp;<img src='theme/" + theme + "/images/lmenu/ftv2vertline.gif' alt='' />");
	}
	// CD run in IE
	else
	{
		lastNode = (i == levelMap.length - 1 || (tag != 'section' && levelMap[i].hasChildNodes())) ? 
			(lastNode = "&nbsp;&nbsp;&nbsp;<img src='../../../theme/" + theme + "/images/lmenu/ftv2lastnode.gif' alt='' />") : 
			(lastNode = "&nbsp;&nbsp;&nbsp;<img src='../../../theme/" + theme + "/images/lmenu/ftv2node.gif' alt='' />");
			
	/**
	leftIcon variable will insert a picture along the left side of the course map.  It will either be the 
	value of variable lastNode or a vertical line
	*/
	var leftIcon = (tag == 'section') ? (leftIcon = lastNode) : 
				   (leftIcon = "&nbsp;&nbsp;&nbsp;<img src='../../../theme/" + theme + "/images/lmenu/ftv2vertline.gif' alt='' />");
	}

	/**
	cssLeftNav will style the links in the course map.  If the xml node is a section node that
	does not have a cssDisplay attribute there is no stylings.  If the xml node isn't a section
	node than the cssLeftNav will be set equal to the cssDisplay attribute of the node which contains
	the appropriate class name in the stylings sheet
	*/
	if(tag == 'section' && levelMap[i].getAttribute('cssDisplay') == 'none')
	{ 
		if(levelMap[i].getElementsByTagName('page')) //if the section has a child page
		{
			var firstPage = levelMap[i].getElementsByTagName('page')[0];
			
			if(firstPage != undefined) //this will probably never be undefined
			{
				var childCssAttribute = firstPage.getAttribute('cssDisplay');
				if( childCssAttribute != 'none')
					cssLeftNav = childCssAttribute;
				else
					cssLeftNav = '';
			}
		}
	}
	else if(tag == 'section' && levelMap[i].getAttribute('cssDisplay') != 'none')
	{ var cssLeftNav = levelMap[i].getAttribute('cssDisplay'); }
	
	/**
	causes pages that have no class to be have the same style as other leftNavLinks. 
	Assume that "extra" pages will never have more than one page or if they do, 
	they will have a named class.
	*/
	else if(tag == 'page' && levelMap[i].getAttribute('cssDisplay') == null)
	{ 
		cssLeftNav = 'LeftNavText';
	}
	else if(tag == 'page' && levelMap[i].getAttribute('cssDisplay') != 'none')
	{ 
		var cssLeftNav = levelMap[i].getAttribute('cssDisplay');
	};
			 
	/**
	rightIcon variable will insert a picture to the right of the picture on the 
	left side of the course map and some spacing
	*/				 
	var rightIcon = (tag == 'page') ? (rightIcon = lastNode) : (rightIcon = '');
	
	/**
	spacing variable will add space between the leftIcon and rightIcon values with respect to the level
	*/
	var spacing = new Array(Level).join('&nbsp;&nbsp;');
	
	/**
	two different function are used to open pages: openerLocal and openActivity.  
	A page node with a cssDisplay attribute will indicate there is an activity's 
	information in the page node.  The ternary operator will insert one of two 
	opening functions depending on the what kind of information is in the page node
	*/
	var strFunction = (tag == 'page' && levelMap[i].getAttribute('cssDisplay')) ? 
					  (strFunction = 'openActivity') : (strFunction = 'openerLocal');
	
	/**
	added 10.08 TS due to FF change in local or CD (have to change the path by 3 levels)
	*/
	//var FFPathChange = (changeXmlPath)?(FFPathChange = "") : (FFPathChange = path);
	
	strLinks += "<div class='courseMapStyle'><table style='margin-bottom: -9px; font-size: 14px;'><tr>"+
				"<td>" + leftIcon + "</td><td>" + spacing + "</td><td>" + rightIcon + "</td><td>" +
				"<a style='padding-bottom: 15px; font-weight : bold;' class='" +
				cssLeftNav + "' href='javascript:" + strFunction + "(\""+ FFPathChange + "" + 
				url +"\")' >" + 
				levelMap[i].getAttribute('title') + "</a></td></tr></table></div>";
	
	classLinks += "<div class='courseMapStyle'><table style='margin-bottom: -9px; font-size: 14px;'><tr>"+
				"<td>" + leftIcon + "</td><td>" + spacing + "</td><td>" + rightIcon + "</td><td>" +
				"<a style='padding-bottom: 15px; font-weight : bold;' class='" +
				cssLeftNav + "' href='javascript:" + strFunction + "(\""+ path + "" + 
				url +"\")' >" + 
				levelMap[i].getAttribute('title') + "</a></td></tr></table></div>";
}

/**
PROCESSES AND PARSES THE XML NAVIGATION FILE 
*/
function processNavXML()
{
    var navXMLPath = path;
	var navText = '';
	
    navDiv = document.getElementById('leftNav');

	for(var j=0; j <= sectionMap.length - 1; j++)
	{
	
		pageMap = sectionMap[j].getElementsByTagName('page');
		
		//allows relative and absolute urls to be written from XML
		var absRelURL = (pageMap[0].getAttribute('url').indexOf('http') == -1) ? (absRelURL = path) : (absRelURL = '');
						 
		//leftNav content created here
	   //*******************************************************************************************
		if(sectionMap[j].getAttribute('cssDisplay') != 'none')
		{   

			//left nav highlight current link
			//url strings from current page in browser
			var start, end, subStringLenth;
			start = window.location.pathname.lastIndexOf('/') - 2;
			end =  window.location.pathname.lastIndexOf('html') - 1;
			//end =  window.location.pathname.length;
			var subStringLength = end - start;
			
			//url strings from xml
			var start1, end1, subStringLength1;
			start1 = pageMap[0].getAttribute('url').lastIndexOf('/') - 2;
			end1 = pageMap[0].getAttribute('url').lastIndexOf('html') - 1;
			//end1 = pageMap[0].getAttribute('url').length;
			subStringLength1 = end1 - start1;
							
			var currentURL = window.location.pathname.substr(start, subStringLength);
			var boldNav = pageMap[0].getAttribute('url').substr(start1, subStringLength1);
			var listHighlight = pageMap[0].getAttribute('highlight');

			//ternary operator will ensure the correct section is highlighted despite the page within the section you are in;
		//left hand navigation links will not be bolded when active
		/* var boldNavCSS = (currentURL.indexOf(boldNav) != -1) ? 
				(boldNavCSS = 'font-weight:bold; color:#333333;') : 
				(boldNavCSS = 'font-weight:normal; color:#999999;');*/
//alert(currentURL);
		var boldNavCSS;

			if(listHighlight == 'none')
			{
				boldNavCSS = 'font-weight:normal; color:#999999;';
			}
			else if(currentURL.indexOf(boldNav) != -1)
			{
				boldNavCSS = 'font-weight:bold; color:#333333;';
			}
			else
			{
				boldNavCSS = 'font-weight:normal; color:#999999';
			}
			
			navText += "<a style='" + boldNavCSS + ";' class='" + 
			sectionMap[j].getAttribute('cssDisplay') + "' href='" + absRelURL + "" + 
			pageMap[0].getAttribute('url') + "'>" + sectionMap[j].getAttribute('title') + "</a><br /><br/>";  
		}
	}
		
navDiv.innerHTML = navText + writeSearch();  	//write the html into the left navigation div 
}
    

/**
SETS ACTIVITY ICONS AT THE CORRECT SPOT (NEXT TO THEIR RESPECTIVE ACTIVITY) WITHIN A PAGE 
*/
function activityIcon()
{
    var flag=false;
        
    var interactiveElements = new Array('tryThis', 'studyQuestion', 'inDetail', 'assignment', 'discuss', 'fyi', 'reflect');
    var interactiveElementsPicture = new Array(
											   path + 'theme/' + theme + '/images/icon-activity.jpg', 
											   path + 'theme/' + theme + '/images/icon-activity.jpg', 
											   path + 'theme/' + theme + '/images/icon-indetail.jpg', 
											   path + 'theme/' + theme + '/images/icon-assignment.jpg', 
											   path + 'theme/' + theme + '/images/icon-discuss.jpg', 
											   path + 'theme/' + theme + '/images/icon-fyi.jpg', 
											   path + 'theme/' + theme + '/images/icon-reflect.jpg');
	var count = 0;  
	var bin = 0;
	var leftNavIcons = 0;
		
	for(var i=0; i<= interactiveElements.length; i++)
	{ 
		 count = 1;
		
		 while(document.getElementById(interactiveElements[i] + count) != null)
		 {
			//navDiv needs to be set each iteration in order for .offsetHeight function to work, the 
			//ternary statement below determines if the leftnav if from a page or popup
			
			navDiv = (document.getElementById('leftNav') == navDiv) ? 
				(navDiv = document.getElementById('leftNav')): 
				(navDiv = document.getElementById('tryThisLeftNav'));
			
			var element = document.getElementById(interactiveElements[i] + count);
			
			var tryThisObj = (element.offsetTop <= navDiv.offsetTop + navDiv.offsetHeight) ? 
				(tryThisObj = navDiv.offsetTop + navDiv.offsetHeight + 10 + (50 * leftNavIcons++)) : 
				(tryThisObj = element.offsetTop);

			var elementObj = new pageObject(interactiveElements[i] + count, interactiveElements[i] + count + "T", 0);
			
			var rightCol = document.getElementById('side-a');              
							
			objArray[bin] = elementObj;     
						   
			//writes html that positions activity icons next to their activities and tells what to do if icon is clicked    
			rightCol.innerHTML += "<div id='"+ (elementObj.IconDiv) +
			"'class='adjustIconStyle' style='top:" +  //** event commented out since no collapse function
			(tryThisObj) + "px' /><img title='' alt='' src='" + //** event commented out since no collapse function 
			interactiveElementsPicture[i] + "' /></div>";
			
			count++; bin++;   
		 }        
	}
}

/** 
CREATES AN OBJECT THAT CONTAINS THE ID OF THE ACTIVITY DIV, THE ID OF THE DIV 
CONTAINING THE ACTIVITY ICON, THE HTML CONTAINED IN EACH ACTIVITY DIV, AND THE 
NUMBER OF TIMES AN ICON IS CLICKED IN ORDER TO EXPAND OR COLLAPSE IT
ON EVERY OTHER CLICK 
*/
function pageObject(activityDiv, iconDiv, height)
{
    this.ActivityDiv = activityDiv;
    this.IconDiv = iconDiv;
	this.Height = height;
}

function openerLocal(openerLocation)
{
  	  opener.location = openerLocation;  
}

/**
The below two functions now include code to open pdfs in a new 
window and also to open redirect links that int he xml file.
//NOTE: redirect links should contain http:// in the url
//09.15.2008 PR
*/
function returnClassMenu()
{
	writeClassNav();
    var coursemapPage = window.open('','open_window', 'width=550, height = 450, scrollbars= yes, focus = yes');
	
	coursemapPage.document.write("<html><head>" +
								 "<title>Lesson Map</title> " +
								 cssString +
								 "<link rel='stylesheet' href='../../../theme/" + theme + "/theme_styles.css' type='text/css' />"  + 
								 "<style type='text/css' >body{background-color: #FEF7F1; word-wrap: break-word;}</style></head><body>" + 
								 "<script type='text/javascript'>" +
								 "var winAttributes =" +
								 "'toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=830, height=600';" + 
								 "lessonNumber='x';" +
								 "function openerLocal(openerLocation) {if (openerLocation.indexOf('.pdf', 0) != -1) window.open(openerLocation, \"_blank\"); else opener.location = openerLocation; window.opener.focus();}" +
								 "function openActivity(url){var web_index = url.indexOf('http://', 0); if(web_index != -1) { var web_url= url.substring(web_index, url.length); url = web_url;} var openAct = window.open(url, 'newActivity', winAttributes);}</script>" + 
								 classLinks + " <br /> " + clswin + "</body></html>");
	coursemapPage.document.close();
	coursemapPage.focus()
}

/**
writes code to open lesson navigation popup window
*/
function returnCourseMenu()
{
    var coursemapPage = window.open('','open_window', 'width=550, height = 450, scrollbars= yes, focus = yes, resizable=1');
	coursemapPage.document.write("<html><head>" +
								 "<title>Lesson Map</title> " +
								 cssString);

if (changeXmlPath){//if running FF3 from CD
		coursemapPage.document.write("<link rel='stylesheet' href='" + FFPathChange + "theme/" + theme + "/theme_styles.css' type='text/css' />");
	}else{
		coursemapPage.document.write("<link rel='stylesheet' href='../../../theme/" + theme + "/theme_styles.css' type='text/css' />");
	}
		
	coursemapPage.document.write("<style type='text/css' >body{background-color: #FEF7F1; word-wrap: break-word;}</style></head><body>" + 
								 "<script type='text/javascript'>" +
								 "var winAttributes =" +
								 "'toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=830, height=600';" + 
								 "lessonNumber='x';" +
								 "function openerLocal(openerLocation) {if (openerLocation.indexOf('.pdf', 0) != -1) window.open(openerLocation, \"_blank\"); else opener.location = openerLocation; window.opener.focus();}" +
								 "function openActivity(url){var web_index = url.indexOf('http://', 0); if(web_index != -1) { var web_url= url.substring(web_index, url.length); url = web_url;} var openAct = window.open(url, 'newActivity', winAttributes);}</script>" + 
								 strLinks + " <br /> " + clswin + "</body></html>");
	coursemapPage.document.close();
	coursemapPage.focus()
}

/* 
WRITES LINKS FROM THE COURSE XML TO THE INDEX PAGE OF THE COURSE
*/
var linkBlockHeight = "<span style='display:block; height:10px;'></span>";

function lessonIndexList()
{   
    var indexListLeft = "<div class='indexColumnStyle' style='float: left; '>";
	var indexListRight = "<div class='indexColumnStyle' style='float: right;'>";
	
	//this variable is used to divide the xml into two inorder to have two columns of links on index page,
	//it takes lessonMap.length - 1 to not include course index lesson and rounded up in the case of an odd length
	var leftSection = Math.ceil((lessonMap.length - 1) / 2);

	for(var i= 1; i <= lessonMap.length - 1; i++)
	{
		if(i <= leftSection)
		{
			indexListLeft += "<table><tr><td style='vertical-align:top;'>" +
			"<img src='images/" + lessonMap[i].getAttribute('image') + "' class='vertMiddle' />&nbsp;&nbsp;</td>" +
			"<td><a class='index' href='../../" + lessonMap[i].getAttribute('url') + 
			"' title='" + lessonMap[i].getAttribute('title') + "'>";
	
			if(lessonMap[i].getAttribute('lessonNumberTitle'))
			{ indexListLeft += lessonMap[i].getAttribute('lessonNumberTitle')  + "</td></tr></table>"; }
			else
			{ 
			indexListLeft += "" + lessonMap[i].getAttribute('id') + ": " + lessonMap[i].getAttribute('title')  + "</td></tr></table>"; 								
			}
			
			indexListLeft += "</a>" + linkBlockHeight;
		}
		else
		{
			indexListRight += "<table><tr><td style='vertical-align:top;'>" +
			"<img src='images/" + lessonMap[i].getAttribute('image') + "' class='vertMiddle' />&nbsp;&nbsp;</td>" +
			"<td style='text-align: left;'><a class='index' href='../../" + lessonMap[i].getAttribute('url') + 
			"' title='" + lessonMap[i].getAttribute('title') + "'>";
	
			if(lessonMap[i].getAttribute('lessonNumberTitle'))
			{ indexListRight += lessonMap[i].getAttribute('lessonNumberTitle') + "</td></tr></table>"; }
			else
			{ 
			indexListRight += "" + lessonMap[i].getAttribute('id') + ": " + lessonMap[i].getAttribute('title') + "</td></tr></table>"; }
			
			indexListRight += "</a>" + linkBlockHeight;
		}
	}	
    document.write(indexListLeft + "</div>" + indexListRight + "</div>");
}
/************************************************************************** 
END MENU FUNCTIONS & START REDIRECT FUNCTIONS 
**************************************************************************/

/* previous ms redirect function */
<!-- -------------This adjusts width & height of new windows for IE-->
var newredirect = null;
function openredirect(url)
	{
var winl = (screenWidth - 700) / 2;
var wint = ((screenHeight - 450) - 80) / 2;
  if (newredirect != null && newredirect.open) newredirect.close();
  newredirect = window.open("","cto","toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=600,top=" + wint + ",left=" + winl);

     	newredirect.document.write('<html><head><title>Loading</title>' +
	'<link rel="stylesheet" href="' + glbpath + 'shared/cssGlobal.css" type="text/css">' +
	'<link rel="stylesheet" href="' + glbpath + 'shared/cssCourse.css" type="text/css"></head>')

if(lesson=="IN")

{	newredirect.document.write('<script>function redirect(){window.location="http://masters.agron.iastate.edu/redirect/' + course + '/intro/' + url + '"}</script>');
}
else
{
	newredirect.document.write('<script>function redirect(){window.location="http://masters.agron.iastate.edu/redirect/' + course + '/' + maincat + lesson + '/' + url + '"}</script>');
//alert(lesson);
}
	newredirect.document.write('<body class="white" onLoad="redirect();">' +
	'<p class="mainHdg3">LOADING...' +
	'<p>You are being redirected to a website on the Internet, however, you must be online to access this site. If you are not redirected within 5 seconds, please click <a>here</a>.<p>' +
	clswin +
	'</body></html>');

     newredirect.document.close();
	}
/* end previous redirect function */




/************************************************************************** 
START CONTENT MANIPULATION FUNCTIONS
**************************************************************************/

//*********************old functions Test section***********************//
//test section variables
var browser_name = navigator.appName;
var browser_version = navigator.appVersion;
var version_number = parseFloat(browser_version);
var styleStr, adjWidth, adjHeight, adjVertCntr;

{	if ((browser_name == 'Netscape') && (version_number < 5))
	{
		styleStr =  "webstyle_net4.css";
		adjWidth =  0;
		adjHeight =  26;
		adjVertCntr =  80;
	}
	else if ((browser_name == 'Netscape') && (version_number >= 5))
	{
		styleStr =  "webstyle_5brwsr.css";
		adjWidth =  4;
		adjHeight = 26;
		adjVertCntr =  80;
	}
	else if ((browser_name == 'Microsoft Internet Explorer') && (version_number >= 4))
	{
		styleStr =  "webstyle_5brwsr.css";
		adjWidth =  0;
		adjHeight =  0;
		adjVertCntr =  106;
	}
	else
	{
		styleStr =  "webstyle_5brwsr.css";
		adjWidth =  0;
		adjHeight =  0;
		adjVertCntr =  80;
	}
}
 
/* OPENS UP GLOSSARY FROM DROPDOWN MENU */
var newglossnav = null;
function openglossnav()
	{
var winl = (screen.availWidth - 600) / 2;
var wint = ((screen.availHeight - 350) - 80) / 2;
  newglossnav = window.open("../../../tools/glossary/index.html","Glossary","toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=350,top=" + wint + ",left=" + winl);
	}

//functions to combine or alter *********************************

	
var newconv = null;
function openconv()
	{
var winl = (screen.availWidth - 610) / 2;
var wint = ((screen.availHeight - 410) - 80) / 2;
  if (newconv != null && newconv.open) newconv.close();
  newconv = window.open("../../../tools/conversions/conversions.html","convert","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=820,height=440,top=" + wint + ",left=" + winl);
	}
	
var newimage = null;
function openimage(url,name,w,h,title,caption)
	{
var neww = (adjWidth - (-w));
var newh = (adjHeight - (-h));
var winl = (screen.availWidth - neww) / 2;
var wint = ((screen.availHeight - newh) - 80) / 2;
  if (newimage != null && newimage.open) newimage.close();
  newimage = window.open("",name ,"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + neww + ",height=" + newh + ",top=" + wint + ",left=" + winl);

imageStr = '<html>' +
	'<head>' +
	'<title>' + title + '</title>' +
	/*'<script src="' + glbpath + 'shared/writeShell.js"></script>' +*/
	'<link rel="stylesheet" href="' + path + 'theme/' + theme + '/theme_styles.css" type="text/css">' +
	'</head><body style="background:#fff;">' +
	'<br><center><img src="' + url + '"></center>' +
	'<p class="imageCaption">' + caption + '</p>' +
	clswin +
	'<p></body></html>';
     	newimage.document.write(imageStr);
     	newimage.document.close(); 
	}

//***********************************
// FUNCTIONS THAT MAY NOT BE NEEDED
//***********************************

function writeStyleLink(path)
{
document.write('<LINK rel="stylesheet" href="' + path + styleStr + '" type="text/css">');
}

function statusMsg(msg) { window.status = 'New Window: '+msg; }
function statusMsgRoot(location) { window.status = 'New Window: http://masters.agron.iastate.edu/'+location; }
function statusOut() { window.status = ''; }
	
var newstudy = null;
function openstudy(url,name,w,h)
	{
var neww = (adjWidth - (-w));
var newh = (adjHeight - (-h));
var winl = (screen.availWidth - neww) / 2;
var wint = ((screen.availHeight - newh) - 80) / 2;
  if (newstudy != null && newstudy.open) newstudy.close();
  newstudy = window.open(url,name ,"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + neww + ",height=" + newh + ",top=" + wint + ",left=" + winl);
	}

var newdetail = null;
function opendetail(url,name,w,h)
	{
var neww = (adjWidth - (-w));
var newh = (adjHeight - (-h));
var winl = (screen.availWidth - neww) / 2;
var wint = ((screen.availHeight - newh) - 80) / 2;
  if (newdetail != null && newdetail.open) newdetail.close();
  newdetail = window.open(url,name ,"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + neww + ",height=" + newh + ",top=" + wint + ",left=" + winl);
	}

var newsearch = null;
function opensearch()
	{
		window.location = barpath + "search/search.html"
	}
	
function opengenericnotools(url,name,w,h)
	{
var neww = (adjWidth - (-w));
var newh = (adjHeight - (-h));
var winl = (screen.availWidth - neww) / 2;
var wint = ((screen.availHeight - newh) - adjVertCntr) / 2;
  if (newgeneric != null && newgeneric.open) newgeneric.close();
  newgeneric = window.open(url,name ,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=" + neww + ",height=" + newh + ",top=" + wint + ",left=" + winl);
	}

function openAll(URL,Type, w, h, att1, value1, att2, value2, att3, value3, att4, value4, att5, value5, att6, value6, att7, value7)
{   
    var neww = (adjWidth - (-w));
    var newh = (adjHeight - (-h));
    var winl = (screen.availWidth - neww) / 2;
    var wint = ((screen.availHeight - newh) - 80) / 2;
    if (Type != null && Type.open) Type.close();
	Type = window.open(URL, Type,"height=" + newh + ", width=" + neww + ", " + att1 + "=" + value1 + ", " + att2 + "=" + value2 + ", " + att3 + "=" + value3 + ", " + att4 + "=" + value4 + ", " + att5 + "=" + value5 + ", " + att6 + "=" + value6 + ", " + att7 + "=" + value7); 
}
var newtry = null;
function opentry(url,name,w,h)
	{
var neww = (adjWidth - (-w));
var newh = (adjHeight - (-h));
var winl = (screen.availWidth - neww) / 2;
var wint = ((screen.availHeight - newh) - 80) / 2;
  if (newtry != null && newtry.open) newtry.close();
  newtry = window.open(url,name ,"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + neww + ",height=" + newh + ",top=" + wint + ",left=" + winl);
	}
	var newsns = null;
function opensns()
	{
  if (newsns != null && newsns.open) newsns.close();
  newtry = window.open("http://masters.agron.iastate.edu/redirect/gotowebct.html","sns" ,"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=820,height=600");
	}

/* autoclose - closes open windows */
function autoclose()
	{
  if (newframes != null && newframes.open) newframes.close();
  if (newdetail != null && newdetail.open) newdetail.close();
  if (newfyi != null && newfyi.open) newfyi.close();
  if (newgeneric != null && newgeneric.open) newgeneric.close();
  if (newglossterm != null && newglossterm.open) newglossterm.close();
  if (newglossnav != null && newglossnav.open) newglossnav.close();
  if (newimage != null && newimage.open) newimage.close();
  if (newmedia != null && newmedia.open) newmedia.close();
  if (newredirect != null && newredirect.open) newredirect.close();
  if (newreview != null && newreview.open) newreview.close();
  if (newstudy != null && newstudy.open) newstudy.close();
  if (newtry != null && newtry.open) newtry.close();
  if (newVideo != null && newVideo.open) newVideo.close();
  else {return null};
	}
	
	var newgeneric = null;
function opengeneric(url,name,w,h)
	{
var neww = (adjWidth - (-w));
var newh = (adjHeight - (-h));
var winl = (screen.availWidth - neww) / 2;
var wint = ((screen.availHeight - newh) - 80) / 2;
  if (newgeneric != null && newgeneric.open) newgeneric.close();
  newgeneric = window.open(url,name ,"toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + neww + ",height=" + newh + ",top=" + wint + ",left=" + winl);
	}