//*********************************************************************************************************
// String translation catalog functions
// Insert the Course Player Strings JavaScript library

var szParentReload = false;
var mItemIndex = -1;
var nFirstHrefIndex = 0;
var nLastHrefIndex = 0;

function getPlayerStr() {
/* oVeRLoRDz commented out Sep 20 2004
	var StringsLibrary = new StringsCatalog();
	var strClass = getPlayerStr.arguments[0].toUpperCase();
	var strProperty = getPlayerStr.arguments[1].toUpperCase();
	if (eval("StringsLibrary." + strClass + "Strings") && eval("StringsLibrary." + strClass + "Strings." + strProperty)) {
		var strTranslation = eval("StringsLibrary." + strClass + "Strings." + strProperty);
		var iArg = 2;
		while (strTranslation.indexOf("%s") > -1) {
			rExp = /%s/;
			strTranslation = strTranslation.replace(rExp,((getPlayerStr.arguments[iArg])?getPlayerStr.arguments[iArg]:"---"));
			iArg++;
		}		
		return strTranslation;
	}
	else return "";
*/
	return "";
}

//*******************************************************************
// Define a Strings Catalog, containing individual Strings libraries
function StringsCatalog() {

	this.DOCStrings = new DOCStrings();
	this.MSGStrings = new MSGStrings();
	this.LBLStrings = new LBLStrings();
	this.ALTStrings = new ALTStrings();
	this.STATUSStrings = new STATUSStrings();
	this.DISCONNECTIONStrings = new DISCONNECTIONStrings();
}


//*********************************************************************************************************
//verify if the imsmanifest xml file is loaded
function verify(){
  // 0 Object is not initialized
  // 1 Loading object is loading data
  // 2 Loaded object has loaded data
  // 3 Data from object can be worked with
  // 4 Object completely initialized
  if (xmlDoc.readyState != 4){
      return false;
  }
}

function addItemLevel(itemID, parentID)
{
	//this function returns the tree level of item in the Course
	
	var nItemLevel, szTmp;
	if (parentID.toString() == "0")	{
		nItemLevel = nMaxTreeLevel;
		szItemLevel = szItemLevel + itemID + ":" + nItemLevel.toString() + "_;_";
	}	
	else {
		var nItemLevel = szItemLevel.split("_;_");
		for (var nItem=0; nItem<nItemLevel.length; nItem++)
		{
			nPos = nItemLevel[nItem].indexOf(parentID);
			if (nPos != -1) {
				szTmp = nItemLevel[nItem].split(":");
				nItemLevel = parseInt(szTmp[1]) - 1;
				szItemLevel = szItemLevel + itemID + ":" + nItemLevel.toString() + "_;_";
			}
		}
	}
	return nItemLevel;
}

//************************************************************************
function addParentChildItem(parentID, itemID)
{
	var szparentID = parentID + "***";		
	var nIndex = szParentChildItem.indexOf(szparentID);
	var nPos;
	if(nIndex == -1)
	{
		// not found parentID 		
		szParentChildItem = szParentChildItem + szparentID + itemID + "_;_";
	}
	else {
		//found parentID
		var nLength, szHead, szTail;
		nLength = szParentChildItem.length;
		szHead = szParentChildItem.substr(0,nIndex + szparentID.length);		
		szTail = szParentChildItem.substr(nIndex + szparentID.length);
		szParentChildItem = szHead + itemID + "&&" + szTail;
	}
}

//************************************************************************
function openLearningItem(itemindex, itemID,imgObj, nOpenType)
{
	var nIndex;
	var nItem = szParentChildItem.split("_;_");
	var szitemID = itemID + "***";
	var openType = "";

	if (nOpenType==0) {
		//default open or close by click on items
		if (imgObj.src.indexOf("right.jpg") != -1) {
			maniOpenedItems(itemindex, itemID, 1);
			openType = "block";
			imgObj.src = "common/images/down.jpg";
		}	
		else { 
			maniOpenedItems(itemindex, itemID, 0);
			openType = "none";
			imgObj.src = "common/images/right.jpg";
		}	
	}
	else {
		// always open item
		openType = "block";
	}	
	
	if (openType == "block") {
		// open all direct child items
		
		var strChildItems = rootObj.children[itemindex].szChildrenIndex;
		var ChildItemID, imgChildObj;
		var arrItem = strChildItems.split("_:_");
		//alert(itemindex);
		if (arrItem.length > 2) {
			for (var j=0; j<arrItem.length; j++) {
				if (arrItem[j] != "") {
					if (rootObj.children[parseInt(arrItem[j])].itemType != "Question Pool") {
						// if not question pool then display on course outline
						ChildItemID = rootObj.children[parseInt(arrItem[j])].itemID;
						imgChildObj = eval("document.frames(\"ifrCourseContent\").document.all(\"img"+ChildItemID+"\")")
						document.frames("ifrCourseContent").viewitem(imgChildObj,ChildItemID,imgObj,openType,0);
					}	
				}	
			}
		}
		else {
			ChildItemID = rootObj.children[itemindex].itemID;
			if ( (imgChildObj) && (typeof(imgChildObj) != "undefined" ) ) {
				imgChildObj = eval("document.frames(\"ifrCourseContent\").document.all(\"img"+ChildItemID+"\")");
				imgChildObj.src="common/images/down.jpg";
				//alert(ChildItemID+":"+imgChildObj.src);
			}
		}	
	}
	else {
		// close all child items of this item index		
		var strAllChildItems = rootObj.children[itemindex].szAllChildrenIndex;
		var ChildItemID, imgChildObj;
		var arrItem = strAllChildItems.split("_:_");
		for (var j=0; j<arrItem.length; j++) {
			if (arrItem[j] != "") {
				if (rootObj.children[parseInt(arrItem[j])].itemType != "Question Pool") {
					// if not question pool then display on course outline			
					ChildItemID = rootObj.children[parseInt(arrItem[j])].itemID;
					imgChildObj = eval("document.frames(\"ifrCourseContent\").document.all(\"img"+ChildItemID+"\")");
					maniOpenedItems(arrItem[j], rootObj.children[parseInt(arrItem[j])].itemID, 0);				
					document.frames("ifrCourseContent").viewitem(imgChildObj,ChildItemID,imgObj,openType,0);
				}	
			}	
		}
	}	
	
}

//*******************************************************************
//Load manifest file
function loadManifest(){
	var organizationObj, i;

	xmlDoc.async="false"; 
 	xmlDoc.onreadystatechange=verify;
 	//xmlDoc.load(urlCourseHref + "/imsmanifest.xml"); 	
 	xmlDoc.load(urlCourseHref + "imsmanifest.xml"); 	
	xmlObj=xmlDoc.documentElement; 

	for (i=0; i<xmlObj.childNodes.length; i++){
		switch (xmlObj.childNodes(i).tagName){
			case "organizations":
				organizationObj = xmlObj.childNodes(i).firstChild;
				break;
			case "resources":
				resourcesObj = xmlObj.childNodes(i);								
				break;
			default:
				break;
		}
	}

	numOfItem = 0;
	//get course name		
	var strCourseName = organizationObj.firstChild.text;
	//get course info
	rootObj = new learningItemObject(0, strCourseName, 0, 0, 0, 0, 0, "", -1, -1, null);
	
	//Build ItemInfo List, Skip the first Item which should be <title> tag
	for (i=1; i<organizationObj.childNodes.length; i++){	
		getItemInfo(organizationObj.childNodes(i), 0, rootObj); 		
	}			
}

//*********************************************************************************************************
function getItemInfo(xmlItem, parentIndex, parentObj){
	var itemID, itemTitle, itemStatus, masteryTime, rawScore, maxScore, resourceref, href, parentID;
	var itemObj, i, j, k, h, itemType, itemIndex;
	var manifestObj, recordObj, educationalObj, learningresourcetypeObj, langstringObj;
	
	if (xmlItem.tagName == "item"){		
		itemID = xmlItem.getAttribute("identifier");
		resourceref = xmlItem.getAttribute("resourceref");
		itemTitle = xmlItem.firstChild.text;
		parentID = parentObj.itemID;
		//getting href
		href = "";
		for (j=0; j<resourcesObj.childNodes.length; j++){
			if (resourcesObj.childNodes(j).getAttribute("identifier") == resourceref){
				manifestObj = resourcesObj.childNodes(j).firstChild;
				recordObj = manifestObj.firstChild;
				for (h=0;h<recordObj.childNodes.length;h++){
					if (recordObj.childNodes(h).tagName == "educational"){
						educationalObj = recordObj.childNodes(h);		
						break;
					}
				}
				learningresourcetypeObj = educationalObj.firstChild;
				langstringObj = learningresourcetypeObj.firstChild			
				itemType = langstringObj.text;								
				for (k=0; k<resourcesObj.childNodes(j).childNodes.length; k++){
					if (resourcesObj.childNodes(j).childNodes(k).tagName == "file"){						
						if (href==""){
							href = resourcesObj.childNodes(j).childNodes(k).getAttribute("href");	
						}
						else{
							href = href + "_:_" + resourcesObj.childNodes(j).childNodes(k).getAttribute("href");
						}
					}
					if (resourcesObj.childNodes(j).childNodes(k).tagName == "MaxScore"){ 						
						maxScore = resourcesObj.childNodes(j).childNodes(k).text;	
					}
				}
				break;
			}
		}
		// Mr TNT _ Mar 30, 2006
		if (maxScore == undefined)
		{
			maxScore = 0;
		}
		//----------------------
		
		itemObj = new learningItemObject(itemID, itemTitle, itemType, 1, 0, 0, maxScore, href, parentID, parentIndex, parentObj);
		
		insItem(rootObj, itemObj);
		
		if (xmlItem.hasChildNodes){
			itemIndex = parseInt(rootObj.nChildren) - 1;
			for (i=1; i<xmlItem.childNodes.length; i++){								
				getItemInfo(xmlItem.childNodes(i), itemIndex, itemObj);				
				//rootObj.children[itemIndex].szChildrenIndex = rootObj.children[itemIndex].szChildrenIndex + (parseInt(rootObj.nChildren) - 1) + "_:_";				
			}
		}
	}
}

//**********************************************************************
function GetAllChildItems(nParentIndex, szItemsIndex)
{
	var arrItems, m, arrItems, szItemsTemp;	
	if (szItemsIndex.length > 3) {
		arrItems = szItemsIndex.split("_:_");				
		for (m=0; m<arrItems.length; m++)
		{										
			if (arrItems[m] != "") {								
				if (rootObj.children[parseInt(arrItems[m])].szChildrenIndex.length > 3) {
					szItemsTemp = rootObj.children[nParentIndex].szAllChildrenIndex;
					szItemsTemp = szItemsTemp.substr(0,szItemsTemp.length-3);
					
					rootObj.children[nParentIndex].szAllChildrenIndex = szItemsTemp + rootObj.children[parseInt(arrItems[m])].szChildrenIndex;
					//alert(rootObj.children[nParentIndex].itemID+";nParentIndex=" + rootObj.children[nParentIndex].szAllChildrenIndex);
				}									
				GetAllChildItems(nParentIndex, rootObj.children[parseInt(arrItems[m])].szChildrenIndex,arrItems[m]);
			}	
		}		
	}
	
	mItemIndex++;	
	while (mItemIndex < rootObj.nChildren)	
	{
		rootObj.children[mItemIndex].szAllChildrenIndex = rootObj.children[mItemIndex].szChildrenIndex;
		GetAllChildItems(mItemIndex, rootObj.children[mItemIndex].szChildrenIndex);
	}	
}

//**********************************************************************
//Update Data Values from SuspendData which was set in OnEndLMSInteraction() in file LMSInteraction
function updateSuspendData(nIndex)
{
	var nfirst, nlast;
	var strSuspendTmp;
	var strItemIDs = top.frames.DisplayFrame.rootObj.children[nIndex].itemID + "*";

	if (typeof(EnrollmentID)!="undefined" && EnrollmentID && EnrollmentID!="sal") {
		nfirst = SuspendData.indexOf(strItemIDs);
		
		if (nfirst != -1) {
		
			var strHead, strTail, arrItemObj;
			strSuspendTmp = SuspendData.substr(nfirst);
			nlast = strSuspendTmp.indexOf("-");
			if (nlast != -1) 
				strHead = strSuspendTmp.substring(0,nlast);
			else
				strHead = strSuspendTmp;
	
			arrItemObj = strHead.split("*");
			top.frames.DisplayFrame.rootObj.children[nIndex].itemStatus = arrItemObj[2];
			// Convert from milisecond to second
			top.frames.DisplayFrame.rootObj.children[nIndex].masteryTime = Math.round(parseInt(arrItemObj[1])/1000);
			top.frames.DisplayFrame.rootObj.children[nIndex].rawScore = arrItemObj[3];
			
			switch (top.frames.DisplayFrame.rootObj.children[nIndex].itemType){
				case "Question Pool":
					top.frames.DisplayFrame.rootObj.children[nIndex].maxScore = arrItemObj[4];
					break;
				case "Topic":
					top.frames.DisplayFrame.rootObj.children[nIndex].maxScore = 0;
					break;
				case "Sub Topic":
					top.frames.DisplayFrame.rootObj.children[nIndex].maxScore = 0;
					break;
				case "Chapter":
					top.frames.DisplayFrame.rootObj.children[nIndex].maxScore = 0;
					//alert(rootObj.children[nIndex].rawScore)
					break;
				default:
					break;
			}
		}	
	}//if (typeof(EnrollmentID)!="undefined" && EnrollmentID && EnrollmentID!="sal")
	else 	{
		top.frames.DisplayFrame.rootObj.children[nIndex].itemStatus = 1;
		top.frames.DisplayFrame.rootObj.children[nIndex].masteryTime = 0;
		top.frames.DisplayFrame.rootObj.children[nIndex].rawScore = 0;
		switch (top.frames.DisplayFrame.rootObj.children[nIndex].itemType){
			case "Question Pool":
				top.frames.DisplayFrame.rootObj.children[nIndex].maxScore = 0;
				break;
			case "Topic":
				top.frames.DisplayFrame.rootObj.children[nIndex].maxScore = 0;
				break;
			case "Sub Topic":
				top.frames.DisplayFrame.rootObj.children[nIndex].maxScore = 0;
				break;
			case "Chapter":
				top.frames.DisplayFrame.rootObj.children[nIndex].maxScore = 0;
				break;
			default:
				break;
		}
		
		// TNT _ Sep 12th, 2005
		// Search And Play : prevent student to access Quiz, Middle Term, Final Exam
		// ----- begin adding: version 3.3.5
		if (EnrollmentID == "sal")
		{
			switch (top.frames.DisplayFrame.rootObj.children[nIndex].itemType){
				case "Graded Quiz":
					top.frames.DisplayFrame.rootObj.children[nIndex].itemStatus = 3;
					break;
				case "Middle Term":
					top.frames.DisplayFrame.rootObj.children[nIndex].itemStatus = 3;
					break;
				case "Exam":
					top.frames.DisplayFrame.rootObj.children[nIndex].itemStatus = 3;
					break;
				default:
					break;
			}
		}
		// ----- end adding
		
	}//if (EnrollmentID!="sal")
}

//*********************************************************************************************************
//constructor of learning object item
function learningItemObject(itemID, itemTitle, itemType, itemStatus, masteryTime, rawScore, maxScore, href, parentID, parentIndex, childObj){
	//alert("itemID = " + itemID + ", itemTitle = " + itemTitle + ", itemType = " + itemType + ", itemStatus = " + itemStatus + ", masteryTime = " + masteryTime + ", rawScore = " + rawScore + ", maxScore = " + maxScore + ", href = " + href + ", parentID = " + parentID);
	//alert(parentIndex);
	this.itemID = itemID;
	this.itemTitle = itemTitle;
	this.itemType = itemType; 
	this.itemStatus = itemStatus;
	this.masteryTime = masteryTime;
	this.sessionTime = 0;
	if (typeof(href) == "undefined") this.itemHref = "";
	else this.itemHref = href;
	this.rawScore = rawScore;
	this.maxScore = maxScore;
	this.parentID = parentID;	
	this.parentIndex = parentIndex;
	this.children = new Array(); 
	this.nChildren = 0;
	this.szChildrenIndex = "_:_"; 	
	this.szAllChildrenIndex = "_:_";
	this.addChild = addChild;
	this.dirtyFlag = 0;
}

//**********************************************************************
function addChild(childNode) 
{ 
  	this.children[this.nChildren] = childNode 		
  	this.nChildren++ 
  	return childNode 
} 

//**********************************************************************
function insItem(parentFolder, childFolder) 
{ 
	return parentFolder.addChild(childFolder) 
} 

//*********************************************************************************************************
function BuildCourseLayer(nflag)	
{
	var nLevel = 0;
	var imgStatus, strDisplayType, mParentIndex;
	var isFirstHref = false;
	var pendingStr, itemType, itemIndex, itemName, parentItemType;
	mParentIndex = 0;

	szHTMLStr = "<table width='100%' border='0' cellspacing='0' align='center'>\n";

	for (var k=0; k<top.frames.DisplayFrame.rootObj.nChildren; k++)
	{
		if ( mParentIndex != top.frames.DisplayFrame.rootObj.children[k].parentIndex)
		{			
			mParentIndex = top.frames.DisplayFrame.rootObj.children[k].parentIndex;
		}
					
		if ( (k!=0) && (top.frames.DisplayFrame.rootObj.children[mParentIndex].itemID == top.frames.DisplayFrame.rootObj.children[k].parentID) ) {							
			top.frames.DisplayFrame.rootObj.children[mParentIndex].szChildrenIndex = top.frames.DisplayFrame.rootObj.children[mParentIndex].szChildrenIndex + k + "_:_";
		}			
		
		//*******************************************
		// Update data from SuspendData *************
		if (nflag == 0){ updateSuspendData(k); }
		
// Agu 13, 2004 : VuNa, comment out, this is no need
/*		if (top.frames.DisplayFrame.rootObj.children[k].itemStatus == 2){
			
		 	imgStatus = "half.jpg";			

		 }
		else if (top.frames.DisplayFrame.rootObj.children[k].itemStatus == 3) imgStatus = "select.jpg";
		else imgStatus = "blank.jpg";
		

		if (top.frames.DisplayFrame.rootObj.children[k].parentID == 0) {
			strDisplayType = "block";
		}
		else {
			strDisplayType = "none";
		}
*/
// End of comment
	
		//addParentChildItem(rootObj.children[k].parentID, rootObj.children[k].itemID);
		//******** Get First and Last Href ********//
		/*
			if (top.frames.DisplayFrame.rootObj.children[k].itemHref != "") {
				if (!isFirstHref) {
					nFirstHrefIndex = k;
					isFirstHref = true;
				}
				nLastHrefIndex = k;
			}
		*/
		//****************************************//
		
		nLevel = addItemLevel(top.frames.DisplayFrame.rootObj.children[k].itemID, top.frames.DisplayFrame.rootObj.children[k].parentID);
		nLevel = nMaxTreeLevel - nLevel;
		//alert(rootObj.children[k].itemHref);

/* Agu 13, 2004 : Vuna comment				
//		szHTMLStr = szHTMLStr + "<tr style=\"display:"+strDisplayType+"\" id=\""+top.frames.DisplayFrame.rootObj.children[k].itemID+"\">\n";

//		szHTMLStr = szHTMLStr + "<td valign='top'><table border='0' cellspacing='5' align='center'><tr>\n";

		if (top.frames.DisplayFrame.rootObj.children[k].parentID != 0)
			
			for (var j=0; j<nLevel; j++) {
				szHTMLStr = szHTMLStr + "<td width='21'><img border='0' src='common/images/spacer.gif' width='21' height='20'></td>\n";
			}
				
		szHTMLStr = szHTMLStr + "<td width='21'><a target='_self' style=\"cursor:hand\"><img id=\"img"+top.frames.DisplayFrame.rootObj.children[k].itemID+"\" onclick=\"javascript:window.top.frames.DisplayFrame.openLearningItem("+k+",'"+rootObj.children[k].itemID+"',this,0)\" src='common/images/right.jpg' name='btn_right' border='0'></a></td>\n";					
		szHTMLStr = szHTMLStr + "<td width='21'><img src='common/images/skins/" + skinCollections[SkinID][5] +"/"+imgStatus+"'></td>\n";
		
/* no use for szHTMLStr
		if ( (top.frames.DisplayFrame.rootObj.children[k].itemStatus == 3) &&
			 ( (top.frames.DisplayFrame.rootObj.children[k].itemType == "Middle Term") ||
			   (top.frames.DisplayFrame.rootObj.children[k].itemType == "Exam") ||
			   (top.frames.DisplayFrame.rootObj.children[k].itemType == "Ungraded Quiz") ||
			   (top.frames.DisplayFrame.rootObj.children[k].itemType == "Graded Quiz") ) ) {
			szHTMLStr = szHTMLStr + "<td width=95% colspan=\""+nLevel+"\" align='left'><font size='3' face='Arial'><b>"+top.frames.DisplayFrame.rootObj.children[k].itemTitle+"</b></font></td>\n";
		}
		else {
			szHTMLStr = szHTMLStr + "<td width=95% colspan=\""+nLevel+"\" align='left'><font size='3' face='Arial'><b><a href=\"javascript:window.top.frames.DisplayFrame.goItem('"+rootObj.children[k].itemID+"',"+k+");\">"+top.frames.DisplayFrame.rootObj.children[k].itemTitle+"</a></b></font></td>\n";
		}			

		szHTMLStr = szHTMLStr + "</tr></table>\n";
		szHTMLStr = szHTMLStr + "</td></tr>\n";
*/

//Getting itemType and itemIndex
//  Aug 13, 2004
//	there is something wrong when k is 12 or 16, at that time 
// itemID = 'AT17_SessionStart'	and 'AT20_sessionStart'
			
		if (top.frames.DisplayFrame.rootObj.children[k].itemID == PendingItemID){
			if ( k == 12 && k == 16){
			itemType = top.frames.DisplayFrame.rootObj.children[k].itemType;
			itemName = top.frames.DisplayFrame.rootObj.children[k].itemTitle;
			itemIndex = k;			
			}
		} 	

	
	}	

	//Hunter added Jan 11, 2004 for showing pending item		
	/*if (PendingItemID!=""){
		switch (itemType){
			case "Chapter":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\">" + getPlayerStr("MSG","ResumeAtTxt","<b>"+itemName+"</b>") + "</a></font></td></tr>";
				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Topic":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\">" + getPlayerStr("MSG","ResumeAtTxt","<b>"+itemName+"</b>") + "</a></font></td></tr>";
				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Sub Topic":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\">" + getPlayerStr("MSG","ResumeAtTxt","<b>"+itemName+"</b>") + "</a></font></td></tr>";
				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Exercise":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\">" + getPlayerStr("MSG","ResumeAtTxt","<b>"+itemName+"</b>") + "</a></font></td></tr>";
				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Question Pool":
				hideMenu();
				parentItemType = rootObj.children[rootObj.children[itemIndex].parentIndex].itemType;
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><i>" + getPlayerStr("MSG","PendingPoolPrompt",parentItemType) + "</i></font></td></tr>";
				pendingStr = pendingStr + "<tr><td valign='top' align='middle'><font size='2' face='Arial'><i>" + getPlayerStr("MSG","PendingPoolAsk",parentItemType) + "</i></font></td></tr>";
				pendingStr = pendingStr + "<tr height='15'><td valign='top' align='middle'></td></tr>"
				pendingStr = pendingStr + "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\"><img src=\"common/images/b_ok.gif\" border='0'></a>&nbsp;<a href=\"javascript:window.top.frames.DisplayFrame.close();\"><img src=\"common/images/" + LanguageID + "/b_cancel.gif\" border='0'></a></font></td></tr>";
				//szHTMLStr = szHTMLStr + pendingStr + "</table>";
				szHTMLStr = "<table width='100%' border='0' cellspacing='0' align='center'>" + pendingStr + "</table>";
				break;				
		}
	}
		*/
	
	if (LMSMissingQuestion != null && LMSMissingQuestion != "" && LMSMissingQuestion != 0){
		//alert("Missing" + LMSMissingQuestion);
	
		bMissingQuestion = true;
		
		JumptoPendingQuestion();

		/*szHTMLStr = "<table width='100%' border='0' cellspacing='0' align='center'>\n";		
		//alert(itemType)
		switch (itemType){
			case "Chapter":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.JumptoPendingQuestion();\">" + getPlayerStr("MSG","PENDINGPOOLPROMPT","<b>"+itemName+"</b>") + "</a></font></td></tr>";
				szHTMLStr = szHTMLStr + pendingStr + "</table>";				
				break;
			case "Topic":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.JumptoPendingQuestion();\">" + getPlayerStr("MSG","PENDINGPOOLPROMPT","<b>"+itemName+"</b>") + "</a></font></td></tr>";
				szHTMLStr = szHTMLStr + pendingStr + "</table>";				
				break;
			case "Sub Topic":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.JumptoPendingQuestion();\">" + getPlayerStr("MSG","PENDINGPOOLPROMPT","<b>"+itemName+"</b>") + "</a></font></td></tr>";
				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Exercise":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.JumptoPendingQuestion();\">" + getPlayerStr("MSG","PENDINGPOOLPROMPT","<b>"+itemName+"</b>") + "</a></font></td></tr>";
				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Question Pool":
				hideMenu();
				parentItemType = rootObj.children[rootObj.children[itemIndex].parentIndex].itemType;
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><i>" + getPlayerStr("MSG","PendingPoolPrompt",parentItemType) + "</i></font></td></tr>";
				pendingStr = pendingStr + "<tr><td valign='top' align='middle'><font size='2' face='Arial'><i>" + getPlayerStr("MSG","PendingPoolAsk",parentItemType) + "</i></font></td></tr>";
				pendingStr = pendingStr + "<tr height='15'><td valign='top' align='middle'></td></tr>"
				pendingStr = pendingStr + "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.JumptoPendingQuestion();\"><img src=\"common/images/b_ok.gif\" border='0'></a>&nbsp;<a href=\"javascript:window.top.frames.DisplayFrame.close();\"><img src=\"common/images/" + LanguageID + "/b_cancel.gif\" border='0'></a></font></td></tr>";
				//szHTMLStr = szHTMLStr + pendingStr + "</table>";
				szHTMLStr = "<table width='100%' border='0' cellspacing='0' align='center'>" + pendingStr + "</table>";
				break;				
		}*/
	}else 
	if(PendingItemID!=""){
		//alert("Pending:" + PendingItemID);
		//Vuna Comment szHTMLStr , not used for this course
		
		switch (itemType){
			case "Chapter":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\">" + getPlayerStr("MSG","ResumeAtTxt","<b>"+itemName+"</b>") + "</a></font></td></tr>";
//				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Topic":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\">" + getPlayerStr("MSG","ResumeAtTxt","<b>"+itemName+"</b>") + "</a></font></td></tr>";				
//				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Sub Topic":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\">" + getPlayerStr("MSG","ResumeAtTxt","<b>"+itemName+"</b>") + "</a></font></td></tr>";
//				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Exercise":
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\">" + getPlayerStr("MSG","ResumeAtTxt","<b>"+itemName+"</b>") + "</a></font></td></tr>";
//				szHTMLStr = szHTMLStr + pendingStr + "</table>";
				break;
			case "Question Pool":
				hideMenu();
				parentItemType = top.frames.DisplayFrame.rootObj.children[top.frames.DisplayFrame.rootObj.children[itemIndex].parentIndex].itemType;
				pendingStr = "<tr><td valign='top' align='middle'><font size='2' face='Arial'><i>" + getPlayerStr("MSG","PendingPoolPrompt",parentItemType) + "</i></font></td></tr>";
				pendingStr = pendingStr + "<tr><td valign='top' align='middle'><font size='2' face='Arial'><i>" + getPlayerStr("MSG","PendingPoolAsk",parentItemType) + "</i></font></td></tr>";
				pendingStr = pendingStr + "<tr height='15'><td valign='top' align='middle'></td></tr>"
				pendingStr = pendingStr + "<tr><td valign='top' align='middle'><font size='2' face='Arial'><a href=\"javascript:window.top.frames.DisplayFrame.goItem('" + PendingItemID + "'," + itemIndex + ");\"><img src=\"common/images/b_ok.gif\" border='0'></a>&nbsp;<a href=\"javascript:window.top.frames.DisplayFrame.close();\"><img src=\"common/images/" + LanguageID + "/b_cancel.gif\" border='0'></a></font></td></tr>";
				//szHTMLStr = szHTMLStr + pendingStr + "</table>";
//				szHTMLStr = "<table width='100%' border='0' cellspacing='0' align='center'>" + pendingStr + "</table>";
				break;				
		}
	}
	//Hunter added Jan 11, 2004 for showing text while exiting

/* VunA comment Aug 13 2004
	if (exiting == 1){		
		szHTMLStr = "<table width='100%' border='0' cellspacing='0' align='center'><tr><td><font face='arial' size='2'>" + getPlayerStr("MSG","ExitingPleaseWait") + "</font><td><tr></table>";	
	}
*/
	//alert(szHTMLStr);	
	//document.frames("ifrCourseContent").document.all("divCourseContent").innerHTML=szHTMLStr;	
		
	// Thuan added Dec 26, 2003, for demo only
	/*
	szContent = escape('Help content 1.<br>Help content 2<br>help content 3<br>Help content 4.<br>Help content 5<br>help content 6!');
	szHTMLStr = szHTMLStr + "<br><a href=javascript:window.top.frames.DisplayFrame.showHelp('help','" + szContent + "');>Help 1</a>";
	szContent = escape('Click anywhere.<br>Scroll down<br>Here we go');
	szHTMLStr = szHTMLStr + "<br><a href=javascript:window.top.frames.DisplayFrame.showHelp('tip','" + szContent + "');>Help 2</a>";
	*/
	// Thuan added Dec 26, 2003 ends
		
//Vu Na comment
// 	loadCourseContent();
//	
	GetAllChildItems(0, "");

	//Hunter added Jan 11, 2004 for hiding navigation bar in case of pending exam or exiting

/* VuNA comment
	if (exiting == 1){
		hideNavigationBar();
	}
	else{
		if (itemType == "Question Pool"){
			showNavigationBar("none", "none", "none", "");
		}
	}	
*/
	//Hunter added Jan 14, 2004 for update percent completed, assessment

//VUna Comment	
	//UpdatePercentComplete();		

	//BuildAssessment();	
	//UpdateAssessment(strAssess);
//End of Comment
	return true;
}

//**********************************************************************
//**********BUILD LEFT MENU*********************************************
function BuildLeftMenu()
{
	if(typeof(rootObj) != "undefined" && rootObj != null ){
		for (var k=0; k<rootObj.nChildren-1; k++)
		{		
			if (rootObj.children[k].parentID == 0) 
				strLeftMenu += "" + rootObj.children[k].itemTitle + ";" + rootObj.children[k].itemID + ";" + k + ";"
		}		
		strLeftMenu = strLeftMenu.substring(0,strLeftMenu.length-1)
	}
	return true;
}

//**********************************************************************
function showNavigationBar(homeButton, backButton, nextButton, exitButton)
{
	var buttonHome, buttonBack, buttonNext, buttonExit;
	buttonHome = "";
	buttonBack = "";
	buttonNext = "";
	buttonExit = "";
	
	if (homeButton == "none") buttonHome = "none";
	else if (homeButton == "show") buttonHome = "inline";
		
	if (backButton == "none") buttonBack = "none";
	else if (backButton == "show") buttonBack = "inline";
	
	if (nextButton == "none") buttonNext = "none";
	else if(nextButton == "show") buttonNext = "inline";
		
	if (exitButton == "none") buttonExit = "none";
	else if (exitButton == "show") buttonExit = "inline";

	if (document.all("divHome"))
	if (buttonHome != "") {
		document.all("divHome").style.display=buttonHome;		
	}	
	if (document.all("divBack"))
	if (buttonBack != "") {
		document.all("divBack").style.display=buttonBack;		
	}
	if (document.all("divForward"))
	if (buttonNext != "") {
		document.all("divForward").style.display=buttonNext;
	}	
}

//**********************************************************************
function hideNavigationBar()
{
	showNavigationBar("none", "none", "none", "none");
}

//**********************************************************************
function checkBackNextNavigationBar(nCurrHref, nFirstHref, nLastHref)
{
	if (exiting == 1) hideNavigationBar();
	else if (nCurrHref==0) showNavigationBar("none","none","","");
	else if (nCurrHref <= nFirstHref) showNavigationBar("show", "none", "", "");
	else if (nCurrHref > nLastHref) showNavigationBar("show", "show", "none", "");
	else showNavigationBar("show", "show", "show", "");	
}

//**********************************************************************
function jumpToTopic(itemID, nIndex){
/*
	var itemType, arrChildren, arrHref;
	var i;
	//alert("itemiD="+itemID + "index=" + nIndex)
	
	//for the first time szCurrentItemID = ""
	if (szCurrentItemID != ""){ 
		szPrevItemID = szCurrentItemID;
		switch (rootObj.children[nCurrentIndex].itemType) {
			case "Chapter":
				break;
			case "Topic":				
				updateTopicInfo(szCurrentItemID);	
				break;
			case "Sub Topic":
				updateTopicInfo(szCurrentItemID);
				break;
		}		
	}
	startTimer(); 	
	
	itemType = rootObj.children[nIndex].itemType;
	//alert("itemID=" + itemID +",nIndex="+nIndex + ",itemType=" + itemType);	

	showNavigationBar("show","show","show","");	
	switch (itemType){
		case "Chapter":			
			for (i=nIndex; i<rootObj.nChildren; i++) {
				if (rootObj.children[i].itemHref != "") {
					szCurrentItemID = rootObj.children[i].itemID;
					szCurrentHref = rootObj.children[i].itemHref;
					nCurrentIndex = i;
					document.all("ifrCourseContent").src = urlCourseHref + "/" + szCurrentHref;
					checkBackNextNavigationBar(nCurrentIndex, nFirstHrefIndex, nLastHrefIndex);
					openMenu();
			
					if (LMSUpdateMode == 0) {
					UpdatePercentComplete();
					}

					break;
				}				
			}		
			break;
		case "Topic":
			for (i=nIndex; i<rootObj.nChildren; i++) {
				if (rootObj.children[i].itemHref != "") {
					szCurrentItemID = rootObj.children[i].itemID;
					szCurrentHref = rootObj.children[i].itemHref;
					nCurrentIndex = i;
					document.all("ifrCourseContent").src = urlCourseHref + "/" + szCurrentHref;
					checkBackNextNavigationBar(nCurrentIndex, nFirstHrefIndex, nLastHrefIndex);
					openMenu();
					break;
				}				
			}
			if (LMSUpdateMode == 0) {
				UpdatePercentComplete();
			}

			break;
		case "Sub Topic":
			szCurrentItemID = rootObj.children[nIndex].itemID;
			szCurrentHref = rootObj.children[nIndex].itemHref;
			nCurrentIndex = nIndex;
			document.all("ifrCourseContent").src = urlCourseHref + "/" + szCurrentHref;
			checkBackNextNavigationBar(nCurrentIndex, nFirstHrefIndex, nLastHrefIndex);			
			openMenu();
			if (LMSUpdateMode == 0) {
				UpdatePercentComplete();
			}

			break;
		case "Exercise":
			//same to SubTopic
			//alert("Exercise");
			szCurrentItemID = rootObj.children[nIndex].itemID;
			szCurrentHref = rootObj.children[nIndex].itemHref;
			nCurrentIndex = nIndex;
			document.all("ifrCourseContent").src = urlCourseHref + "/" + szCurrentHref;
			checkBackNextNavigationBar(nCurrentIndex, nFirstHrefIndex, nLastHrefIndex);			
			break;
		case "Graded Quiz":
			//alert("Graded Quiz");
			//<thi>
			i=nIndex;
			if (rootObj.children[i].itemStatus==3)
			{
				i++;
				while (i<rootObj.nChildren)
				{
					if (rootObj.children[i].itemType != "Question Pool")
					{
						jumpToTopic(rootObj.children[i].itemID, i);
						break; 
					}
					i++;
				}
				if (i==rootObj.nChildren)
				{
					rootObj.children[nCurrentIndex].itemStatus = 3;
					updateParentStatus(rootObj.children[nCurrentIndex].parentID);
					PendingItemID = "";
					goHome();
				}
			}
			else
			//</thi> 
			{
				arrChildren = rootObj.children[nIndex].szChildrenIndex.split("_:_");
				jumpToTopic(arrChildren[1], nIndex + 1);
			}
			break;
		case "Ungraded Quiz":
			//alert("Ungraded Quiz");	
			//<thi>
			i=nIndex;
			if (rootObj.children[i].itemStatus==3)
			{
				i++;
				while (i<rootObj.nChildren)
				{
					if (rootObj.children[i].itemType != "Question Pool")
					{
						jumpToTopic(rootObj.children[i].itemID, i);
						break; 
					}
					i++;
				}
				if (i==rootObj.nChildren)
				{
					rootObj.children[nCurrentIndex].itemStatus = 3;
					updateParentStatus(rootObj.children[nCurrentIndex].parentID);
					PendingItemID = "";
					goHome();
				}
			}
			else
			//</thi> 
			{
				arrChildren = rootObj.children[nIndex].szChildrenIndex.split("_:_");
				jumpToTopic(arrChildren[1], nIndex + 1);
			}
			break;
		case "Middle Term":			
			//alert("Middle Term");	
			//<thi>
			i=nIndex;
			if (rootObj.children[i].itemStatus==3)
			{
				i++;
				while (i<rootObj.nChildren)
				{
					if (rootObj.children[i].itemType != "Question Pool")
					{
						jumpToTopic(rootObj.children[i].itemID, i);
						break; 
					}
					i++;
				}
				if (i==rootObj.nChildren)
				{
					rootObj.children[nCurrentIndex].itemStatus = 3;
					updateParentStatus(rootObj.children[nCurrentIndex].parentID);
					PendingItemID = "";
					goHome();
				}
			}
			else
			//</thi> 
			{
				arrChildren = rootObj.children[nIndex].szChildrenIndex.split("_:_");
//				alert(arrChildren[1])
				jumpToTopic(arrChildren[1], nIndex + 1);
			}
			break;
		case "Exam":
			//0. if (object.itemStatus == 3) => khong cho vao
			//alert("Exam");
			//<thi>
			i=nIndex;
			if (rootObj.children[i].itemStatus==3)
			{
				i++;
				while (i<rootObj.nChildren)
				{
					if (rootObj.children[i].itemType != "Question Pool")
					{
						jumpToTopic(rootObj.children[i].itemID, i);
						break; 
					}
					i++;
				}
				if (i==rootObj.nChildren)
				{
					rootObj.children[nCurrentIndex].itemStatus = 3;
					updateParentStatus(rootObj.children[nCurrentIndex].parentID);
					PendingItemID = "";
					goHome();
				}
			}
			else
			//</thi> 
			{
				arrChildren = rootObj.children[nIndex].szChildrenIndex.split("_:_");
				jumpToTopic(arrChildren[1], nIndex + 1);
			}
			break;				
		case "Question Pool":
			//alert("Question Pool");
			
			//1. arrHref = rootObj.children[nIndex].itemHref.split("_:_");
			//2. ranNum = parseINt(random Math.random()*arrHref.length);
			//3. Bo Home, Back button, Next thi duoc
			hideMenu();
			//alert("hide back home button");
			
			if (rootObj.children[nIndex].itemHref.indexOf("_:_") != -1) {
				arrHref = rootObj.children[nIndex].itemHref.split("_:_");
				var ranNum = parseInt(Math.random()* (arrHref.length-1));
				szCurrentHref = arrHref[ranNum];
			}
			else {
				szCurrentHref = rootObj.children[nIndex].itemHref;
			}
						
			szCurrentItemID = rootObj.children[nIndex].itemID;			
			nCurrentIndex = nIndex;
			//alert(urlCourseHref + "/" + szCurrentHref)
			document.all("ifrCourseContent").src = urlCourseHref + "/" + szCurrentHref;
			checkBackNextNavigationBar(nCurrentIndex, nFirstHrefIndex, nLastHrefIndex);			
			// Check next button
			

			break;
	}	

	// GEt Topic name and topic title
	strTopicName = ""
	strTopicTitle= "";
	//VyTTT changed on 15 May 2004_starts
	if(bMissingQuestion==true){
		strTopicName = rootObj.children[rootObj.children[nIndex].parentIndex].itemTitle;
		strTopicTitle= rootObj.children[nCurrentIndex].itemTitle
		//alert(rootObj.children[rootObj.children[nIndex].parentIndex].itemID)
	}else{		
		for(i=0;i<nCurrentIndex; i++){						
		//if(rootObj.children[i].parentID==0 && rootObj.children[i].itemID == rootObj.children[nCurrentIndex].parentID ){						
			if (rootObj.children[i].parentID==0){
				if (rootObj.children[i].szAllChildrenIndex.indexOf("_:_" + nCurrentIndex + "_:_")!=-1){
					strTopicName = rootObj.children[i].itemTitle;
					strTopicTitle= rootObj.children[nCurrentIndex].itemTitle									
					break;
				}
			}
		}
	}	
	//alert(strTopicName)
	//VyTTT changed on 15 May 2004_ends
	setTopicName(strTopicName);
	setPageTitle(strTopicTitle);
*/
}

//**********************************************************************
function goNext()
{	
	var nIndex = 0;
	var szItemID, szItemHref, nItemIndex;
	var itemID;

	//is checking connection	
	if (isChecking) {
		if (objErrWindow) {
			objErrWindow.focus();
			return;
		}
		else {
			Sleep(1000);
			if (isChecking) {
				alert(getPlayerStr('DISCONNECTION','NAVWAITING'));
				return;
			}
		}
	}
	
    	if (bMissingQuestion==false ){
		if (szCurrentItemID == "") {
			nIndex = 0;
			itemID = rootObj.children[nIndex].itemID;
			jumpToTopic(itemID, nIndex);
		}
		else { 
			rootObj.children[nCurrentIndex].itemStatus = 3;
			updateParentStatus(rootObj.children[nCurrentIndex].parentID);
			//if (nCurrentIndex < rootObj.nChildren) nIndex = nCurrentIndex + 1;
			if (nCurrentIndex < nLastHrefIndex) {
				nIndex = nCurrentIndex + 1;
				itemID = rootObj.children[nIndex].itemID;
				jumpToTopic(itemID, nIndex);
			}
			else { 
				//itemID = -1;	
				//nIndex = -1;						
				//goHome();			
				//nIndex = 0;
				//itemID = rootObj.children[nIndex].itemID;	
				//jumpToTopic(itemID, nIndex);
				//alert(nCurrentIndex);						
				PendingItemID = "";
				//alert("go home");
				goHome();
			}
		}		
	}else{//VyTTT added on May 14 2004
		pos = LMSMissingQuestion.indexOf("_:_");
		if(pos != -1 ){
			LMSMissingQuestion = LMSMissingQuestion.substr(pos+3);
			JumptoPendingQuestion();
		}else{
			if(LMSMissingQuestion.length > 0 )
				LMSMissingQuestion = 0;
			bMissingQuestion = false;	
			PendingItemID = ""
			goHome()		
		}	
	}	
}

//**********************************************************************
function goBack()
{	
	var nIndex = 0;
	var nIndexDenied = 0;	
	var szItemID, szItemHref, nItemIndex;
	//is checking connection	
	if (isChecking) {
		if (objErrWindow) {
			objErrWindow.focus();
			return;
		}
		else {
			Sleep(1000);
			if (isChecking) {
				alert(getPlayerStr('DISCONNECTION','NAVWAITING'));
				return;
			}
		}
	}

	if (szCurrentItemID == "") nIndex = 0;
	else nIndex = nCurrentIndex;

	for (var i=nIndex; i>=0; i--)
	{
		if ( (rootObj.children[i].itemHref != "") && (i<nIndex) ) {		
			//alert(rootObj.children[i].itemType);
			if ( (rootObj.children[i].itemStatus == 3) && 
				( (rootObj.children[i].itemType == "Graded Quiz") ||
				  (rootObj.children[i].itemType == "Ungraded Quiz") ||
				  (rootObj.children[i].itemType == "Middle Term") ||
				  (rootObj.children[i].itemType == "Exam") ) )	
			{
				nIndexDenied = i;	
				//alert("denied="+rootObj.children[i].itemType+";"+rootObj.children[i].itemID+";index="+nIndexDenied);
			}
			else if (rootObj.children[i].itemType == "Question Pool") {
				if (rootObj.children[i].itemStatus !=3) {
					nItemIndex = rootObj.children[i].parentIndex;
					szItemID = rootObj.children[nItemIndex].itemID;
					szItemHref = rootObj.children[nItemIndex].itemHref;
					break;
				}
			}	
			else {    		
				szItemID = rootObj.children[i].itemID;
				szItemHref = rootObj.children[i].itemHref;
				nItemIndex = i;						
				break;
			}	
		}					
	}		
	jumpToTopic(szItemID, nItemIndex);
}

//**********************************************************************
function goItem(itemID,nIndex)
{
	//viewType = 0:view current; 1: moveback; 2: movenext	
	var szItemID, szItemHref, nItemIndex;
	//alert(nIndex);
	for (var i=nIndex; i<rootObj.nChildren; i++)
	{	
		//alert("href="+rootObj.children[i].itemHref);
		if ( (rootObj.children[i].itemID == itemID) && (rootObj.children[i].itemHref != "") )
		{
			szItemID = rootObj.children[i].itemID;
			szItemHref = rootObj.children[i].itemHref;
			nItemIndex = i;
			break;				
		}
		else if ( (rootObj.children[i].itemHref != "") && (i > nIndex) ) {			
				szItemID = rootObj.children[i].itemID;
				szItemHref = rootObj.children[i].itemHref;
				nItemIndex = i;								
				break;																
		}						
	}
	jumpToTopic(szItemID, nItemIndex);
	//szCurrentItemID = szItemID;
	//szCurrentHref = szItemHref;
	//nCurrentIndex = nItemIndex;
	//alert(nCurrentIndex);
	//var szfile = "?f=";
	//var nHrefPos = szCurrentHref.indexOf(szfile);
	//var szItemHref = szCurrentHref.substr(nHrefPos + szfile.length);	
	//document.all("ifrCourseContent").src = szItemHref;
	//document.all("ifrCourseContent").src = szCurrentHref;
	//checkBackNextNavigationBar(nCurrentIndex, nFirstHrefIndex, nLastHrefIndex);	
					
}

//**********************************************************************
function goHome()
{
	//alert(rootObj.children[1].itemStatus + ":" + rootObj.children[2].itemStatus);

	//Hunter add this code for tracking item learning object
	//alert(szCurrentItemID);	
	
	//is checking connection	
	if (isChecking) {
		if (objErrWindow) {
			objErrWindow.focus();
			return;
		}
		else {
			Sleep(1000);
			if (isChecking) {
				alert(getPlayerStr('DISCONNECTION','NAVWAITING'));
				return;
			}
		}
	}

	if (szCurrentItemID != ""){ 
		szPrevItemID = szCurrentItemID;
		//alert(szPrevItemID);
		switch (rootObj.children[nCurrentIndex].itemType){
			case "Chapter":
				break;
			case "Topic":				
				updateTopicInfo(szCurrentItemID);	
				break;
			case "Sub Topic":
				updateTopicInfo(szCurrentItemID);
				break;
		}		
	}
	szCurrentItemID = "";	
	setTopicName("");
	setPageTitle("");	

	//PendingItemID = "";

	//rootObj.children[1].itemStatus = 2;
	//alert(document.frames("ifrCourseContent").window.location.href);
	document.all("ifrCourseContent").src = "Home.htm";
	//document.frames("ifrCourseContent").document.all("divCourseContent").innerHTML = "<font face='arial' size='2'>" + getPlayerStr("MSG","PleaseWait") + "</font>";
	//window.location.href="Index.htm";	
	resetCourseContents();
	BuildCourseLayer(1);
	oTimeInterval = window.setInterval(loadCourseContent,1000);
	
	//document.frames("ifrCourseContent").document.all("divCourseContent").innerHTML=szHTMLStr;	
	
}

//**********************************************************************
function resetCourseContents()
{	
	//szOpenItem="_;_"; //szOpenItem=item1_;_item2_;_....
	szParentChildItem = "_;_"; //*parentID1***ItemID1&&ItemID2&&ItemID3_;_...
	szItemLevel = ""; //itemID:level_;_itemID:level
	nTreeLevel = 0;
	nMaxTreeLevel = 50;	
	szCurrentItemID = "";
	nCurrentIndex = 0;
	szCurrentHref = "";
	//szPrevItemID = "";
	szPrevHref = "";
	//PendingItemID = "";
}

//**********************************************************************
function loadCourseContent()
{
	//alert("test");
	var frameCouseObj = document.frames("ifrCourseContent").document.all("divCourseContent");
	//alert('we are here');
	
	var mitemID;
	if( (frameCouseObj) && (typeof(frameCouseObj) == "object") )
	{		
		window.clearInterval(oTimeInterval);		
		frameCouseObj.innerHTML=szHTMLStr;
		//alert("szOpenItemIndex="+szOpenItemIndex);
		var arrOpenedItem = szOpenItemIndex.split("_;_");	
		var imageObj;
		for (var m=0; m<arrOpenedItem.length; m++)
		{
			//alert(arrOpenedItem[m]);
			if (arrOpenedItem[m] != "") {
				//alert(arrOpenedItem[m]);	
				mitemID = rootObj.children[parseInt(arrOpenedItem[m])].itemID;
				imageObj = eval("document.frames(\"ifrCourseContent\").document.all(\"img"+mitemID+"\")");								
				if (typeof(imageObj) == "object")
					openLearningItem(arrOpenedItem[m], mitemID,imageObj,1);
			}
			checkBackNextNavigationBar(nCurrentIndex, nFirstHrefIndex, nLastHrefIndex);	
		}	
	}
}

//**********************************************************************
function maniOpenedItems(itemindex, itemID, ntype)
{
	//ntype = 0: remove; 1: add;
	var stritemindex = "_;_" + itemindex + "_;_";
	var mPos = szOpenItemIndex.indexOf(stritemindex);
	if (mPos == -1) {
		if (ntype == 1) szOpenItemIndex = szOpenItemIndex + itemindex + "_;_";
	}
	else {
		if (ntype == 0) {
			var szItemHead, szItemTail;			
			szItemHead = szOpenItemIndex.substr(0,mPos+3);
			szItemTail = szOpenItemIndex.substr(mPos + stritemindex.length);			
			//alert("szItemHead=" + szItemHead);
			//alert("szItemTail=" + szItemTail);
			szOpenItemIndex = szItemHead + szItemTail;			
		}
	}	
	//alert("szOpenItemIndex=" + szOpenItemIndex);
}

//**********************************************************************
function setTopicName(szTopicName)
{
	document.all("idTopicName").innerHTML = szTopicName
}

//**********************************************************************
function setPageTitle(szTopicTitle)
{	
	document.all("idTopicTitle").innerHTML = szTopicTitle
}

//**********************************************************************
function showHelp(title, content) {
	document.all("helpTitle").innerHTML = title;
	document.all("helpContent").innerHTML = content;
	hideHelp();
	if (lastNote != '') { hideHelp(); }

	helpArea.className = 'notevisible';
	lastNote = 'helpArea';
	showLayer('arrowAsssistant','','show');
	var pathAsistente = 'common/images/skins/' + skinCollections[SkinID][5] + '/ayuda.gif';
	MM_swapImage('asistente','',pathAsistente,1);
}

//**********************************************************************
function hideHelp() {
	helpArea.className = 'notehidden';
	lastNote = '';
	showLayer('arrowAsssistant','','hide');
	MM_swapImage('asssistant','','common/images/skins/' + skinCollections[SkinID][5] + '/assistant.gif',1);
}

//**********************************************************************
function buildSkinParam()
{
	// build parameter string to pass to skin() function
	for (i=0;i<skinCollections.length;i++)
	{
		skinParamStr += "'" + skinCollections[i][1] + "','javascript:changeSkin(" + skinCollections[i][0] + ")'";
		if (i<skinCollections.length-1)
		{
			skinParamStr += ",";
		}
	}
}

//**********************************************************************
function loadDefaultSkin()
{
	var logoPath = "common/images/skins/" + skinCollections[SkinID][2];
	var tituloPath = "common/images/skins/" + skinCollections[SkinID][3];
	var statusPath = "common/images/skins/" + skinCollections[SkinID][4];
	
	skin_logo.src = logoPath;
	skin_titulo.src = tituloPath;
	skin_status.src = statusPath;
}

//**********************************************************************
function changeSkin(skinId)
{
	var logoPath = "common/images/skins/" + skinCollections[skinId][2];
	var tituloPath = "common/images/skins/" + skinCollections[skinId][3];
	var statusPath = "common/images/skins/" + skinCollections[skinId][4];
	
	skin_logo.src = logoPath;
	skin_titulo.src = tituloPath;
	skin_status.src = statusPath;
}

//**********************************************************************
function BuildAssessment(){
	var strCurrParentTitle="";
	var strCurrParentID="";	
	var SumRowExam = 0;
	var SumMaxExam = 0; 
	var SumRowQuiz = 0
	var SumMaxQuiz = 0
	var SumRowUQuiz = 0
	var SumMaxUQuiz = 0
	var SumRowMidd = 0
	var SumMaxMidd = 0
	var ItemType ;
	var blExam  = false;
	var blQuiz  = false;
	var blUQuiz = false;
	var blMidd	= false; 		
	var maxScore,rawScore		;
	strAssess ="110;"		
	if(typeof(rootObj) != "undefined" && rootObj != null){	
		for(i=0;i<rootObj.nChildren; i++){			
			ItemType = rootObj.children[rootObj.children[i].parentIndex].itemType											
			if(typeof(rootObj.children[i].rawScore) != "undefined")
				rawScore = parseInt(rootObj.children[i].rawScore)			
			else
				rawScore = 0
			if(typeof(rootObj.children[i].maxScore) != "undefined")
				maxScore = parseInt(rootObj.children[i].maxScore)			
			else
				maxScore = 0		
			if(ItemType=='Exam'){
				if(rootObj.children[i].itemStatus==3){
					SumRowExam += rawScore;
					SumMaxExam += maxScore;//parseInt(rootObj.children[i].maxScore);		
				}
				blExam 		= true;
					//alert("row " +SumRowExam) 
			}else if(ItemType=='Graded Quiz'){
				if(rootObj.children[i].itemStatus==3){
					SumRowQuiz += rawScore;//parseInt(rootObj.children[i].rawScore)
					SumMaxQuiz += maxScore;//parseInt(rootObj.children[i].maxScore)
				}	
				blQuiz 		= true;		
			}else if(ItemType=='Ungraded Quiz'){
				if(rootObj.children[i].itemStatus==3){
					SumRowUQuiz += rawScore;//parseInt(rootObj.children[i].rawScore)
					SumMaxUQuiz += maxScore;//parseInt(rootObj.children[i].maxScore)
				}
				blUQuiz 	 = true;
			}else if(ItemType=='Middle Term'){
				if(rootObj.children[i].itemStatus==3){
					SumRowMidd += rawScore;//parseInt(rootObj.children[i].rawScore
					SumMaxMidd += maxScore;//rootObj.children[i].maxScore		
				}	
				blMidd 		= true;
			}			
		}
		if(blExam)
			strAssess +=getPlayerStr("LBL","Exam")+";" +SumRowExam + ";" + SumMaxExam + ";"
		if(blQuiz)	
			strAssess +=getPlayerStr("LBL","GradedQuiz")+";" +SumRowQuiz + ";" + SumMaxQuiz + ";"
		if(blUQuiz)	
			strAssess +=getPlayerStr("LBL","UnGradedQuiz")+";" +SumRowUQuiz + ";" + SumMaxUQuiz + ";"
		if(blMidd)	
			strAssess +=getPlayerStr("LBL","MidTerm")+";" +SumRowMidd + ";" + SumMaxMidd + ";"		
		strAssess = strAssess.substring(0,strAssess.length-1)
	}	
	UpdatePercentComplete();
	return true
}

//**********************************************************************
//Phil modified June 6, 2004: remove hard-coded skin selection
function UpdateAssessment(){
	var graphFirst, graphLast, graphMiddle,strTable ;
	var strTmp	 = UpdateAssessment.arguments[0];
	var args 	 = strTmp.split(";")
	var strTable = "";

	if(args.length > 2){
		strTable = "<center><table width=196 border=0 align='left' cellPadding=0 cellSpacing=0 class=SkinAssessmentBackground>"			
		strTable 	+= "<tr><td colSpan=6 class=SkinAssessmentBackground><img src='common/images/spacer.gif' width=196 height=1></td></tr>"
		strTable 	+= "<tr><td><img src=common/images/spacer.gif width=1></td><td colSpan=4 class=SkinAssessmentForeground><img src='common/images/spacer.gif' width=194 height=2></td><td><img src='common/images/spacer.gif' width='1'></td></tr>";
		gwidth=args[0];
		for (i=1; i<(args.length-2); i+=3)	{
			nombre=args[i]; g=args[i+1]; //total=args[i+2];		
			total =(isNaN(args[i+2]))?0: args[i+2]; 
			calpercentage=(isNaN(Math.round(g*100/total)))? 0 : Math.round(g*100/total)
			calwidth=Math.round(gwidth*(calpercentage/100));	
			if ((calpercentage==0) && (calpercentage<=20))	{
				graphFirst="common/images/calRedFirst.gif";
				graphLast="common/images/calRedLast.gif";
				graphMiddle="common/images/calRedMiddle.gif"; } else
			if ((calpercentage>20) && (calpercentage<=40))	{
				graphFirst="common/images/calOrangeFirst.gif";
				graphLast="common/images/calOrangeLast.gif";
				graphMiddle="common/images/calOrangeMiddle.gif"; } else
			if ((calpercentage>40) && (calpercentage<=60))	{
				graphFirst="common/images/calYellowFirst.gif";
				graphLast="common/images/calYellowLast.gif";
				graphMiddle="common/images/calYellowMiddle.gif"; } else
			if ((calpercentage>60) && (calpercentage<=80))	{
				graphFirst="common/images/calGreenFirst.gif";
				graphLast="common/images/calGreenLast.gif";
				graphMiddle="common/images/calGreenMiddle.gif"; } else
			if ((calpercentage>80) && (calpercentage<=100))	{
				graphFirst="common/images/calBlueFirst.gif";
				graphLast="common/images/calBlueLast.gif";
				graphMiddle="common/images/calBlueMiddle.gif"; 
			}
			
			strTable  +="<tr><td><img src='common/images/spacer.gif' width=1></td><td class=SkinAssessmentForeground><img src='common/images/spacer.gif' width='2'></td>";
			strTable  += "<td valign='bottom' class='excercise' colSpan='2' width='190'>&nbsp;"+nombre+"</td>";
			strTable  += "<td class=SkinAssessmentForeground><img src='common/images/spacer.gif' width=2></td><td><img src='common/images/spacer.gif' width='1'></td></tr>";
			
			strTable  += "<tr><td><img src='common/images/spacer.gif' width='1'></td><td class=SkinAssessmentForeground><img src='common/images/spacer.gif' width='2'></td>";
			strTable  += "<td colSpan='2'><img src='common/images/spacer.gif' height='2' width='190'></td>";
			strTable  += "<td class=SkinAssessmentForeground><img src='common/images/spacer.gif' width='2'></td><td><img src='common/images/spacer.gif' width='1'></td></tr>";
			
			strTable  += "<tr><td><img src='common/images/spacer.gif' width=1></td><td class=SkinAssessmentForeground><img src=common/images/spacer.gif width='2'></td>";		
			strTable  += "<td valign='middle' align='right' class='assessment' width=40>"+g+"/"+total+"&nbsp;</td><td class='assessment' valign='bottom' width=150><img src='"+graphFirst+"'><img src='"+graphMiddle+"' width="+calwidth+" height=14><img src='"+graphLast+"' >&nbsp;"+calpercentage+"%</td>";
			strTable  += "<td class=SkinAssessmentForeground><img src='common/images/spacer.gif' width=2></td><td><img src='common/images/spacer.gif' width=1></td></tr>";
			
			strTable  += "<tr><td><img src='common/images/spacer.gif' width=1></td><td class=SkinAssessmentForeground><img src='common/images/spacer.gif' width=2></td>";
			strTable  += "<td colSpan=2><img src='common/images/spacer.gif' height=2></td>";
			strTable  += "<td class=SkinAssessmentForeground><img src='common/images/spacer.gif' width='2'></td><td><img src='common/images/spacer.gif' width=1></td></tr>";
			}
		strTable += "<tr><td><img src='common/images/spacer.gif' width='1'></td><td colSpan=4 class=SkinAssessmentForeground><img src='common/images/spacer.gif' width=194 height=2></td><td><img src='common/images/spacer.gif' width=1></td></tr><tr><td colSpan=6 class=SkinAssessmentBackground><img src='common/images/spacer.gif' width=196 height=1></td></tr>";
		strTable +="</table></center>";		
		
	}
	// oVeRLoRDz commented out July 25 2004: don't know what it does
	//document.all("MapSpan").innerHTML = strTable;
	UpdatePercentComplete();
} 

//**********************************************************************
function UpdatePercentComplete()
{
	var TotalTopics;
	var TopicsCompletedNumber;
	var MaxScoreExam;
	var ProgressScoreExam;
	var MaxScoreQuiz;
	var ProgressScoreQuiz;
	var ParentItem; 
	var result; 

	//doesn't show percent complete in offline mode
	//if (top.frames.DisplayFrame.LMSUpdateMode == 0) return;

	TotalTopics =0;
	TopicsCompletedNumber = 0;
	MaxScoreExam= 0;
	ProgressScoreExam = 0;
	MaxScoreQuiz = 0;
	ProgressScoreQuiz = 0;

	if ((typeof(rootObj)=='undefined')||(rootObj ==  null ))
		return; 
	for (var k=0; k<rootObj.nChildren; k++)
	{
		if (rootObj.children[k].itemType == 'Topic') //is topic
		{
			TotalTopics++;
			if (rootObj.children[k].itemStatus ==3)
				TopicsCompletedNumber++;
		}
	if (((ParentItem.itemType=='Exam')||(ParentItem.itemType=='Middle Term')) && (!isNaN(rootObj.children[k].maxScore)))
	{
			MaxScoreExam += parseInt(rootObj.children[k].maxScore);
	}	
/*		if (rootObj.children[k].itemType == 'Exam') //is Exam
		{
			MaxScoreExam += parseInt(rootObj.children[k].maxScore);
			//alert(rootObj.children[k].itemID + ":" + rootObj.children[k].maxScore);
		}
		if (rootObj.children[k].itemType == 'Middle Term') //is MidTerm
		
		{
			MaxScoreExam += parseInt(rootObj.children[k].maxScore);
			//alert(rootObj.children[k].itemID + ":" + rootObj.children[k].maxScore);
		}
*/
	
		if ((ParentItem.itemType=='Graded Quiz') && (!isNaN(rootObj.children[k].maxScore)))
		{
			MaxScoreQuiz += parseInt(rootObj.children[k].maxScore);
		}

		if (rootObj.children[k].itemType == 'Question Pool') //is Question Pool
		{
			if (rootObj.children[k].itemStatus ==3)
			{
				ParentItem =rootObj.children[rootObj.children[k].parentIndex];
				if ((ParentItem.itemType=='Exam')||(ParentItem.itemType=='Middle Term'))
					ProgressScoreExam += parseInt(rootObj.children[k].maxScore);
				if (ParentItem.itemType=='Graded Quiz')
					ProgressScoreQuiz += parseInt(rootObj.children[k].maxScore);
			}
		}
	}
	result= 0;
	if (TotalTopics == 0)
	{
		if ((MaxScoreExam == 0)&&(MaxScoreQuiz != 0))
			result = ProgressScoreQuiz/MaxScoreQuiz;
		else
			if ((MaxScoreExam != 0)&&(MaxScoreQuiz != 0))
				result = (ProgressScoreQuiz/MaxScoreQuiz) * 0.99 + (ProgressScoreExam/MaxScoreExam)*0.01;
			else
				if ((MaxScoreExam != 0)&&(MaxScoreQuiz == 0))
					result = ProgressScoreExam/MaxScoreExam;
	}	
	else
	{
		if ((MaxScoreExam == 0)&&(MaxScoreQuiz != 0))
			result = (TopicsCompletedNumber/TotalTopics)*0.5 + (ProgressScoreQuiz/MaxScoreQuiz)*0.5;
		else
			if ((MaxScoreExam != 0)&&(MaxScoreQuiz != 0))
		{
				result = (TopicsCompletedNumber/TotalTopics)*0.495 + (ProgressScoreQuiz/MaxScoreQuiz)*0.495 + (ProgressScoreExam/MaxScoreExam)*0.01;
		}
			else
			if ((MaxScoreExam != 0)&&(MaxScoreQuiz == 0))
				result = (TopicsCompletedNumber/TotalTopics)*0.99 + (ProgressScoreExam/MaxScoreExam)*0.01;
			else
			if ((MaxScoreExam == 0)&&(MaxScoreQuiz == 0))
				result = (TopicsCompletedNumber/TotalTopics)
	}
	result = result * 100; 
	UpdateProgressBar(result,100,136);		
}

//**********************************************************************
function UpdateProgressBar(g,total,gwidth)
{
	var graphimage="common/images/skins/" + skinCollections[SkinID][5] + "/graphMiddle.gif";
	var oDiv;
	oDiv = window.top.frames.DisplayFrame.document.all("ProgressBar");
	output='<center><table border="0" cellspacing="0" cellpadding="0"><tr><td align="center" colSpan="2" class="progress"><strong>' + getPlayerStr("LBL","Progress") + ':</strong></td></tr>';
	calpercentage=Math.floor(g*100/total);
	calwidth=Math.round(gwidth*(calpercentage/100));
	output+='<tr><td><img src="common/images/skins/' + skinCollections[SkinID][5] + '/graphFirst.gif"><img src="'+graphimage+'" width="'+calwidth+'" height="18"><img src="common/images/skins/' + skinCollections[SkinID][5] + '/graphFirst.gif"></td>'+'<td valign="middle" align="center" class="progress">&nbsp;'+calpercentage+'%</td></tr>';
	output+='</table></center>';
	oDiv.innerHTML= output; 
}

//**********************************************************************
function hideMenu(){	
//	var body = MM_findObj("menuSpan");
//	body.className = 'notehidden';
//	showLayer('menuSpan','','hide');
}
function enabledMenu(){
//	var body = MM_findObj("menuSpan");
//	body.className = 'minorspan';	
//	showLayer('menuSpan','','hide');	
} 
function showMenu(){
//	var body = MM_findObj("menuSpan");
//	body.className = 'minorspan';
//	showLayer('menuSpan','','show');	
} 
function openMenu(){	
	if(blCheckMenu==true)
		showMenu();
	else
		enabledMenu();
		
}

function ExitCourse(){
	//test for check connection feature
	//is checking connection
	if (confirm("Do you really want to exit this course?")){
		window.parent.close();
	}
	//if (confirm("Do you really want to exit this course?"))
	//{	
	//	szParentReload = true;
	//	window.parent.close();
	//}
	//else
	//{
	//	return false;
	//}
}

// Thuan added new function window_onunload
function window_onunload() {
	if (szParentReload == true)
		window.parent.opener.location.reload(true);	
}

//**********************************************************************
function jumpToExitPage(){
	//ExitURL = "http://gsbeta.ttnkvn.com/EN/User/CourseParticipation/ExitingUNCCourseNew.asp";
	//EnrollmentID = "32110";		
	/*
	SuspendData = getSuspendData();		
	ExitURL = ExitURL + "?EnrollmentID=" + EnrollmentID;
	if ((PendingItemID!=originalPendingItemID) && (PendingItemID!="")){
		ExitURL = ExitURL + "&PendingItem=" + PendingItemID;
	}
	ExitURL = ExitURL + "&SuspendData=" + SuspendData;
	window.location.href = ExitURL;
	*/

	//UnloadCoursePlayer();
	alert("here");
	window.close();
}

//**********************************************************************
function getSuspendData(){
	var i, SuspendData;
	SuspendData = "";	
	for (i=0; i<rootObj.nChildren; i++){
		//SuspendData = <ItemID1>*<MasteryTime>*<Status>*<RawScore>*<MaxScore>-<ItemID2>*<MasteryTime>*<Status>*<RawScore>*<MaxScore>
		if (rootObj.children[i].dirtyFlag==1){
			SuspendData = SuspendData + "-" + rootObj.children[i].itemID + "*";	
			// substitute sessionTime for masteryTime to send to LMS
			//SuspendData = SuspendData + rootObj.children[i].masteryTime + "*";	
			SuspendData = SuspendData + rootObj.children[i].sessionTime + "*";
			SuspendData = SuspendData + rootObj.children[i].itemStatus + "*";				
			if (rootObj.children[i].itemType == "Question Pool"){
				//alert("Question Pool");
				SuspendData = SuspendData + rootObj.children[i].rawScore + "*";	
				SuspendData = SuspendData + rootObj.children[i].maxScore;			
			}
			else{
				SuspendData = SuspendData + "0*0";	
			}
		}
	}
	if (SuspendData.length>0) SuspendData = SuspendData.substring(1, SuspendData.length);
	return SuspendData;
}

//**********************************************************************
function JumptoPendingQuestion(){
	if(bMissingQuestion==false)			
		goHome();

	arrItemID = LMSMissingQuestion.split("_:_");

	for(i=0;i<rootObj.children.length;i++){ 
		if(rootObj.children[i].itemID == arrItemID[0]){
			//alert("ID="+arrItemID[0]+"index="+i)		
			jumpToTopic(arrItemID[0],i)
			showNavigationBar("none", "none", "none", "");			
			break;
		}	
	}
}

/************************************************************************************************
**Parse querystring arguments into course variables (i.e., during course launch)
************************************************************************************************/
function InitializeCourseVars() {
	var ourURL, myParams, i
	ourURL = top.document.location + "";    // go figure, gotta coerce it to a string
	myParams = "";

	// loop through the parameters and populate the CourseVars array
	if ( ourURL.indexOf( "?" ) != -1 )
	{
	    myParams = ourURL.substring( ourURL.indexOf( "?" ) + 1 );
	    if (myParams.indexOf("%26")!=-1)
			myParams = unescape(myParams);
	    
	    ArgsArray = myParams.split( "&" );
	    for( i=0; i < ArgsArray.length; i++ )
	    {
		var tag = "";
		var val = "";
		if ( ArgsArray[i].indexOf( "=" ) != -1 )
		{
		    tag = ArgsArray[i].substring( 0, ArgsArray[i].indexOf( "=" ) );
		    val = ArgsArray[i].substring( ArgsArray[i].indexOf( "=" ) + 1 );
		}
		else
		    tag = ArgsArray[i]; // val will be "" still
		
		CourseVars[tag.toUpperCase()] = val;
	    }
	}

}

//**********************************************************************
//Read config.xml file to get config params
function getXMLConfigVars(){
	var i;

	//alert("NTC getXMLConfigVars");
	
	xmlDoc.async="false"; 
 	xmlDoc.onreadystatechange=verify;
	xmlDoc.load(urlCourseHref + "/config.xml"); 			
	xmlObj=xmlDoc.documentElement;
	
	if (!xmlObj) //config.xml is not found
	{
		MaxQueueSize = 10;
		return;
	}

	for (i=0; i<xmlObj.childNodes.length; i++){
		switch (xmlObj.childNodes(i).tagName){
			case "LMSInteractionMode":
				LMSInteractionMode = parseInt(xmlObj.childNodes(i).firstChild.text);
				break;
			case "LMSUpdateMode":
				top.frames.DisplayFrame.LMSUpdateMode = parseInt(xmlObj.childNodes(i).firstChild.text);
				break;
			case "MaxQueueSize":
				MaxQueueSize = parseInt(xmlObj.childNodes(i).firstChild.text);
				break;
			case "MaxQueueLength":
				MaxQueueLength = parseInt(xmlObj.childNodes(i).firstChild.text);
				break;
			case "QueueTime":
				QueueTime = parseInt(xmlObj.childNodes(i).firstChild.text);
				break;
			case "ConnectionCheckTime":
				checkConnectionTime = parseInt(xmlObj.childNodes(i).firstChild.text);
				break;
			case "ConnectionLostTime":
				checkLossConnectionTime = parseInt(xmlObj.childNodes(i).firstChild.text);
				break;
			case "TotalOfCheck":
				totalOfCheck = parseInt(xmlObj.childNodes(i).firstChild.text);
				break; 
			case "API":
				api = xmlObj.childNodes(i).firstChild.text; 
				break;
			case "LanguageID":
				LanguageID = xmlObj.childNodes(i).firstChild.text;
				break;
			case "LMSserverURL":
				//alert("NTC getXMLConfigVars _ LMSserverURL");
				
				serverURL = xmlObj.childNodes(i).firstChild.text;
				break;
			//case "LMSserverURLConnection":
			//	serverURLConnection = xmlObj.childNodes(i).firstChild.text;
			//	break;
			case "LostConnectionUpdateURL":
				updateURL = xmlObj.childNodes(i).firstChild.text;
				break;
			case "LostConnectionUpdateEmail":
				mailAddress = xmlObj.childNodes(i).firstChild.text;
				break;
			case "RemoteCourseAddress":
				szRemoteCourseAddress = xmlObj.childNodes(i).firstChild.text;
				if (szRemoteCourseAddress) {
					var ourParams = "";
					var szRemoteCourseAddress, ourURL;

					ourURL = document.location + "";    // go figure, gotta coerce it to a string
					if ( ourURL.indexOf( "?" ) != -1 ) ourParams = ourURL.substring( ourURL.indexOf( "?" ) + 1 );

					//alert(szRemoteCourseAddress + "main.htm?" + ourParams);

					open(szRemoteCourseAddress + "main.htm?" + ourParams, "_self");
				}
				break;
			case "SkinID":
				SkinID = xmlObj.childNodes(i).firstChild.text;
			default:
				break;
		}
	}	
}

//**********************************************************************
function openPopup(strLink)
{
	var child=window.open(strLink,"_blank","toolbar=yes,location=0,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=1,width=700,height=450");
	return false;
}