/*******************************************************************************************************************************
Javascript functions for multiple layered static HTML pages
*******************************************************************************************************************************/
	var gblVisibleDiv = 1; // The id of the Div that is currently visible
	
	// Makes a content Div visibile while setting the other content Divs to hidden.
	// Conventions: - Main wrapper div is called MainContentDiv --> REMOVED 07/25/2002 GKC
	//              - Content divs are named ContentDiv1, ContentDiv2, ContentDiv3, ...
	function ShowContentDiv(intDiv) {
		var strVisibility = "visible";
		
		// Loop through each ContentDiv.. if it exists, then set its visibility attribute
		for (var i=1; i<10; i++) {
			// Determine the value for the visibility attribute
			if (i == intDiv) {
				strVisibility = "visible";
				gblVisibleDiv = i; // Remember that this div is curently visible
			} else {
				strVisibility = "hidden";
			}
		
			if (document.layers) { // NS4
//				if (eval("window.document.MainContentDiv.document.ContentDiv" + i)) { // If the div exists
//					eval("window.document.MainContentDiv.document.ContentDiv" + i).visibility = strVisibility;
//				}
				if (eval("window.document.ContentDiv" + i)) { // If the div exists
					eval("window.document.ContentDiv" + i).visibility = strVisibility;
				}
			} else {
			
			
				if (document.all) { // IE
					if (eval("document.all.ContentDiv" + i)) { // If the div exists
						eval("document.all.ContentDiv" + i).style.visibility = strVisibility;
					}
				} else { // Assume NS6
					if (document.getElementById("ContentDiv" + i)) { // If the div exists
						document.getElementById("ContentDiv" + i).style.visibility = strVisibility;
					}
				}
			}
		}
	}
	
	// Special version of the classic image swapping function generated by ImageReady.  This version is compatible with Netscape 4 and its
	// implementation of layers.
	function chgImgDiv() {
		if (document.images) {
			if (document.layers) { // NS4 - will have to determine the current layer we are working with in order to swap the images
				for (var i=0; i<chgImgDiv.arguments.length; i+=2) {
//					objDoc = eval("window.document.MainContentDiv.document.ContentDiv" + gblVisibleDiv + ".document");
					objDoc = eval("window.document.ContentDiv" + gblVisibleDiv + ".document");
					if (objDoc[chgImgDiv.arguments[i]]) { // If we've successfully referenced the correct div, try to image swap
						objDoc[chgImgDiv.arguments[i]].src = chgImgDiv.arguments[i+1];
					}
				}
			} else { // IE4+ and NS6
				for (var i=0; i<chgImgDiv.arguments.length; i+=2) {
					document[chgImgDiv.arguments[i]].src = chgImgDiv.arguments[i+1];
				}
			}
		}
	}	


	// Makes a Rollover Div visibile while setting the other Rollover Divs to hidden.
	// Conventions: - Rollover divs are named Rollover1, Rollover2, Rollover3, ...
	// This function is useful for Netscape 4 compatibility issues.  What was happening with NS4 was that in pages with multiple layered content, the
	// rollovers weren't working.  As far as I could tell, the image objects are being referenced correctly and the src attributes are changing, but
	// to no effect.  Also, the content being multi-layered caused the slider to not function properly - it has something to do with writing the content
	// to the layer.  Most rollovers are simple image swapping for buttons.  The lack of these rollovers is no big deal.  However, some content 
	// requires the rollover effect in order to uncover some of the content.  That is what this function is for.  The content will be placed into its
	// own layer and made visible when the time is right.
	function ShowRollover(intDiv) {
		var strVisibility = "visible";
		// Loop through each Rollover.. if it exists, then set its visibility attribute
		for (var i=1; i<10; i++) {
			// Determine the value for the visibility attribute
			if (i == intDiv) {
				strVisibility = "visible";
				gblVisibleDiv = i; // Remember that this div is curently visible
			} else {
				strVisibility = "hidden";
			}
		
			if (document.layers) { // NS4
//				if (eval("window.document.MainContentDiv.document.ContentDiv" + i)) { // If the div exists
//					eval("window.document.MainContentDiv.document.ContentDiv" + i).visibility = strVisibility;
//				}
				if (eval("window.document.Rollover" + i)) { // If the div exists
					eval("window.document.Rollover" + i).visibility = strVisibility;
				}
			} else {
			
			
				if (document.all) { // IE
					if (eval("document.all.Rollover" + i)) { // If the div exists
						eval("document.all.Rollover" + i).style.visibility = strVisibility;
					}
				} else { // Assume NS6
					if (document.getElementById("Rollover" + i)) { // If the div exists
						document.getElementById("Rollover" + i).style.visibility = strVisibility;
					}
				}
			}
		}
	}
	


/*******************************************************************************************************************************
Javascript functions for navigation
*******************************************************************************************************************************/
	// Navigates to the previous page
	// Assumes that boolCoursePlus has already been defined
	function NavPrev() {
		var objC = gblArrayCatByID[GblCurrentLOID];
		var intStepNo = objC.StepNo;
		// If we're at step 1, then exit because there is no previous page
		if (intStepNo <= 1) {
			return;
		}
		
		// Determine the previous StepNo
		intStepNo = objC.StepNo - 1;
		
		// Same StepNo as current page.  Exit.
		if (intStepNo == gblArrayCatByID[GblCurrentLOID].StepNo) {
			return;
		}
		
		window.document.location = "Page" + intStepNo + ".htm";
	}
	
	// Navigates to the next page
	// Assumes that boolCoursePlus has already been defined
	function NavNext() {
		var objC = gblArrayCatByID[GblCurrentLOID];
		var intStepNo = objC.StepNo;

		// Determine the next StepNo
		intStepNo = objC.StepNo + 1;
		
		if (intStepNo > 2) {
			alert("Sorry, the page you have requested is not a part of this demo.");
			return;
		}
		
		// StepNo greater than max StepNo -> exit.
		if (intStepNo > gblArrayCat[gblArrayCat.length-1].StepNo) {
			return;
		}

		
		window.document.location = "Page" + intStepNo + ".htm";
	}

/*******************************************************************************************************************************
Javascript functions for writing out HTML for navigation section
*******************************************************************************************************************************/
	// This nav section lists all of the course pages one on top of another in a gray background.
	function GetNavSectionHTML() {
		var strHTML = "";
		
		// Start with header text
		strHTML += GblNavHeaderHTML;
		
		strHTML += "<table border=0 cellpadding=0 cellspacing=0 width=259 hXeight=147 bgcolor='#DCDCDC'>";
		
		for (var i=0; i<gblArrayCat.length; i++) {
			objC = gblArrayCat[i];
			
			
			if (objC.ID == GblCurrentLOID) { // This page is the one currently selected
				strHTML += "<tr bgcolor='#BBBBBB'>";
				strHTML += "<td width=13 height=17><IMG SRC='" + GblImagesDir + "/ArrowUpRightSmallOrange.gif' WIDTH='13' HEIGHT='13' ALT=''></td>";

				strHTML += "<td width=13><span class='topLeftNavNumbers'>&nbsp;" + objC.StepNo + "</span></td>";

				strHTML += "<td><a class='topLeftNavLink' href='#'>" + objC.Name + "</a></td>";
//				strHTML += "<b>" + objC.Name + "</b>";
				strHTML += "</tr>";
			} else { // Not selected - most of the others
				strHTML += "<tr>";
				strHTML += "<td width=13 height=17><IMG SRC='" + GblImagesDir + "/spacer.gif' WIDTH='13' HEIGHT='13' ALT=''></td>";
				strHTML += "<td width=13><span class='topLeftNavNumbers'>&nbsp;" + objC.StepNo + "</span></td>";
				strHTML += "<td><a class='topLeftNavLink' href='javascript:void LoadProductPage(" + (objC.StepNo - 1) + ")'>" + objC.Name + "</a></td>";
				strHTML += "</tr>";
			}
			
			// Write out a thin white line
				strHTML += "<tr><td colspan=3 bgcolor='#FFFFFF'><IMG SRC='" + GblImagesDir + "/spacer.gif' WIDTH='147' HEIGHT='2' ALT=''></td></tr>";

		}
		
		strHTML += "</table>";
		
		// Add footer text
		strHTML += GblNavFooterHTML;
		
		return strHTML;
	}







	
	// This nav section is simply a back and next bar that should exist at the bottom of the main content area.
	function GetBottomNavSectionHTML() {
		var strHTML = "";
		var objCat = gblArrayCatByID[GblCurrentLOID];
		var intStepNo = objCat.StepNo;
		var strNextPageTitle = "";
		
		strHTML += "<table cellpadding=0 cellspacing=0 border=0 width='100%'>";
		strHTML += "<tr>";
			// Previous link
			strHTML += "<td align='left'>";
			if (intStepNo > 1) { // Not first page, so let's show the Previous link.
				strHTML += "<a href='javascript:void NavPrev();' class='SessionContentLink'>< Previous</a>";
			}
			strHTML += "</td>";
		
			// Next link
			strHTML += "<td align='right'>";
			if (intStepNo < gblArrayCat[gblArrayCat.length-1].StepNo) { // Not last page, so let's show the Next link

				// Get the object for the next page.
				var objCNext;
				for (var i=0; i<gblArrayCat.length; i++) {
					objC = gblArrayCat[i];			
					if (objC.ID == GblCurrentLOID) { // This page is the one currently selected
						if ((i+1)<gblArrayCat.length) {
							objCNext = gblArrayCat[i+1];
							if (objCNext) {
								strNextPageTitle = objCNext.Name;
							}
						}
					}
				}
				strHTML += "<a href='javascript:void NavNext();' class='SessionContentLink'>Next: " + strNextPageTitle + " ></a>";
			}
			strHTML += "</td>";
		strHTML += "</tr>";
		strHTML += "</table>";
		
		return strHTML;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
/*******************************************************************************************************************************
Misc Javascript functions
*******************************************************************************************************************************/
	
	function openParent(strURL)
	{
		if (window.opener && !window.opener.closed)
			window.opener.location=strURL;
		else
			window.opener=window.open(strURL,'winNewParent');
		window.opener.focus();

	}
	function openVideo(strURL)
	{
		window.open(strURL,'winVideo','height=300 width=340');

	}
	function openHelp(strURL)
	{
		window.open(strURL,'winHelp','height=570 width=470 scrollbars=yes');

	}
	
