﻿<!--
  	
  var main_window;
  var openWindowTries;
  	
  function changeClass(btn, className){
        var tmpbtn;
		tmpbtn=document.getElementById(btn);
		tmpbtn.className = className;
  }
			
  function bName() {
    // return 1 for Internet Explorer
    if (navigator.appName == "Microsoft Internet Explorer")
      return 1;

    // return 2 for Navigator
    if (navigator.appName == "Netscape")
      return 2;

    // return 0 for other browsers
    return 0;
  }

  function bVer() {
    // return version number (e.g., 4.03)
    return parseFloat(navigator.appVersion)
  }

  function PrintPage()
  {
    window.print(); 
  }
  
    function SetDialogBoxAreaVisibility(bVisible)
    {
        SetVisibility('oHTMLDialogBox', bVisible);
    }
    
    function SetVisibility(strObjectID, bVisible)
	{
        var oTemp;
        oTemp = document.getElementById(strObjectID);
        if (oTemp)
        {
            if (bVisible)
                oTemp.style.display = 'block';
            else
                oTemp.style.display = 'none';
        }
        else
            alert("Object does not exist. id=" + strObjectID);
	}

    function LoginAgain()
    {
        top.location.href = "Default.aspx";
        main_window.close();
    }
    
    function LoginAgainBranding(clientName)
    {
        //alert(clientName);
        var sLocation;
        sLocation = "Default.aspx?branding=" + clientName;
        top.location.href = sLocation;
        if(main_window){
            main_window.close();
        }
    }

    function openCandidateIconKeyWindow()
    {
        var iConKeyWindow;
		iConKeyWindow = window.open('StaticHtml/CandidateIconKey.htm', 'IconKey_window', 'width=850, height=380, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes'); 
		iConKeyWindow.focus();
    }

    function AdminLogoutConfirm( )
    {
        if (confirm("Are you sure you want to logout ?\n\nClick 'OK' to logout (this Browser Window will close) or\nclick 'Cancel' to go back."))
        {
            //alert('Close now');
            document.location.href = "CloseApplication.aspx"
        }
    }
    function RedirectToPage( strURL )
    {
        //alert('RedirectToPage(' + strURL + ')');
        document.location.href = strURL;
    }

  function openPrintWindow( strURL )
  {
		var print_window;
		print_window=window.open(strURL, 'print_window', 'width=800, height=600, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes'); 
		print_window.focus();
  }
  
  function openReportWizardWindow( strURL )
  {
		var print_window;
		ReportWizardWindow=window.open(strURL, 'ReportWizardWindow', 'width=800, height=600, status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes'); 
		ReportWizardWindow.focus();
  }
  
    function openNewPreviewWindow( strURL, bDisplayFullScreen )
	{				
        var resource_window;
        if(bDisplayFullScreen)
        {
		    var previewString;
		    previewString =  'width='  + (screen.availWidth - 10) + ', ';
		    previewString += 'height=' + (screen.availHeight - 60) + ', ';
		    previewString += 'status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, top=0, left=0';
   	        resource_window = window.open(strURL, '_blank', previewString);   	        
   	        //alert(resource_window);
        }
        else
        {
		    resource_window = window.open(strURL, '_blank', 'width=870, height=546, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes'); 
        }
		    
		resource_window.focus();		
	}
  
  	function openPreviewWindow( strURL, bDisplayFullScreen )
	{				
        var resource_window;
        if(bDisplayFullScreen)
        {
		    var previewString;
		    previewString =  'width='  + (screen.availWidth - 10) + ', ';
		    previewString += 'height=' + (screen.availHeight - 60) + ', ';
		    previewString += 'status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, top=0, left=0';
   	        resource_window = window.open(strURL, 'resource_window', previewString); 
   	        //alert(resource_window);
        }
        else
        {
		    resource_window = window.open(strURL, 'resource_window', 'width=870, height=546, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes'); 
        }
		    
		resource_window.focus();
	}
	
	function focusPreviewWindow()
	{
		resource_window = window.open('', 'resource_window', 'width=870, height=546, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes'); 
		//alert(resource_window.document.title.length);
		if(resource_window.document.title.length==0)
		{
		    resource_window.close();
		}
		else
		{
	    	resource_window.focus();
        }
    }

	// Overload #1
	
	function openReportWindow_1( strURL )
	{
		var ReportWindow_1;
		var setupString;
		setupString =  'width=1000, ';
		setupString += 'height=' + (screen.availHeight - 60) + ', ';
		setupString += 'status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, top=0';
		ReportWindow_1 = window.open(strURL, 'ReportWindow', setupString, true);
		ReportWindow_1.focus();
	}
	
	// Overload #2
	function openReportWindow_2(strReportType, strReportName, strCandidateScheduleID, strUserID)
	{
		var ReportWindow;
		var setupString;
		setupString =  'width=900, ';
		setupString += 'height=' + (screen.availHeight - 60) + ', ';
		setupString += 'status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, top=0';
		
		var strUrl = "Report.aspx?";
		strUrl +=    "ReportType=" + strReportType;
		strUrl +=    "&CS_ID=" + strReportType;
		strUrl +=    "&U_ID=" + strReportType;
		
		//alert(setupString);
		alert(strUrl);
		ReportWindow = window.open(strUrl, 'ReportWindow', setupString, true); 
		ReportWindow.focus();
	}
	
	function openCandidateReportsWindow( strURL )
	{
		var reportWindow;
		var setupString;
		
		setupString = 'width=650' ;
		setupString += 'height=' + (screen.availHeight - 50) + ',';
		setupString += 'status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, top=0';
		
		reportWindow = window.open(strURL, 'ReportWindowCandidate', setupString, true);
		reportWindow.focus();
		
	}
	
	function launchApplicationManually( strURL)
	{
	    openApplicationWindowBig( strURL )
		main_window.focus();
		
		SignIn_HideLaunchArea();
		SignIn_ShowCloseWindow();
	}
	
	

	// used to open the application when it first starts up
	function openApplicationWindowBig( strURL )
	{
		var setupString;
		//setupString =  'width=600, ';
		//setupString += 'height=600, ';
		setupString =  'width='  + (screen.availWidth - 10) + ', ';
		setupString += 'height=' + (screen.availHeight - 60) + ', ';
		setupString += 'status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, top=0, left=0';
		
	    main_window = window.open(strURL, 'main_application_window', setupString); 
		
		// if the main application does not open (is blocked) or is closed then show the Launch button
        setTimeout("checkApplicationWindowOpened()",250);
        
	}

	// used to open the the main application from a report (say when editing a Candidate from a report window)
	function openApplicationWindowFromOtherWindow( strURL )
	{
		var main_window;
		var setupString;
		setupString = 'status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, top=0, left=0';
		main_window = window.open(strURL, 'main_application_window', setupString); 
		main_window.focus();
	}

    function checkApplicationWindowOpened() 
    {
	    //alert('checkApplicationWindowOpened');
	    
        if ((main_window == undefined || main_window.closed) && openWindowTries < 9)
        {
            ++openWindowTries;
            setTimeout("checkApplicationWindowOpened()",250);
        }
        else
        {
            if ((main_window == undefined || main_window.closed))
            {
                // pop-up window was blocked
                SignIn_HideAutoLogin();
                SignIn_ShowLaunchArea();
            }
            else
            {
                // pop-up window worked
                SignIn_HideAutoLogin();
            	SignIn_HideLaunchArea();
            	SignIn_ShowCloseWindow();
            }
        }
    }

    function SignIn_HideLaunchLMS()
    {
    	document.getElementById('divLaunchLMS').style.display="none";
    }
    
    // -----------------------------------------------------------------
    
    function SignIn_HideAutoLogin()
    {
        //alert('HideAutoLogin');
    	document.getElementById('divAutoLogin').style.display="none";
    }
    
    function SignIn_ShowAutoLogin()
    {
        //alert('ShowAutoLogin');
    	document.getElementById('divAutoLogin').style.display="inline";
    }
    
    // -----------------------------------------------------------------
    
    function SignIn_HideCloseWindow()
    {
    	document.getElementById('divCloseWindow').style.display="none";
    }
    
    function SignIn_ShowCloseWindow()
    {
    	document.getElementById('divCloseWindow').style.display="inline";
    }
    
    // -----------------------------------------------------------------
    
    function SignIn_ShowLaunchArea()
    {
        document.getElementById('divLaunchLMS').style.display="inline";
    }
    
    function SignIn_HideLaunchArea()
    {
        document.getElementById('divLaunchLMS').style.display="none";
    }
    
    // -----------------------------------------------------------------
    
	function openExternalWebSitePracticeReport(strURL)
	{
		// :o)
		var preview_window;
		var setupString;
		setupString =  'width=650, ';
		setupString += 'height=' + (screen.availHeight - 80) + ', ';
		setupString += 'status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, top=0, left=0';
		preview_window=window.open(strURL, 'report_window', setupString); 
		preview_window.focus();		
	}
	
	function openExportWindow(strURL)
	{
		// :o)
		var export_window;
		var setupString;
		setupString =  'width=650, ';
		setupString += 'height=' + (screen.availHeight - 80) + ', ';
		setupString += 'status=yes, menubar=no, scrollbars=yes, toolbar=no, resizable=yes, top=0, left=0';
		export_window=window.open(strURL, 'export_window', setupString); 
		export_window.focus();
	}
	
	function showFeedback(iNum)
	{
		var oFeedback;
		var oNewWindow;
		var strInput;
			
		oFeedback = document.getElementById("oHTMLFeedback"+iNum);
		if (oFeedback)
		{
		  strInput = oFeedback.innerHTML
			while (strInput.search("&lt;") != -1) strInput=strInput.replace("&lt;", "<");
			while (strInput.search("&gt;") != -1) strInput=strInput.replace("&gt;", ">");
			while (strInput.search("&quot;") != -1) strInput=strInput.replace("&quot;", "\"");
			while (strInput.search("&amp;") != -1) strInput=strInput.replace("&amp;", "&");

			oNewWindow = window.open("",'feedback_window','left=1, top=1, width=400, height=300, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes');
			oNewWindow.document.open();
			oNewWindow.document.write("<HTML>");
			oNewWindow.document.write("<HEAD>");
			oNewWindow.document.write("<TITLE>Feedback</TITLE>");
			oNewWindow.document.write("</HEAD>");
			oNewWindow.document.write("<BODY onBLur='window.close();' leftmargin='0' topmargin='0'>");
			oNewWindow.document.write(strInput);
			oNewWindow.document.write("</BODY>");
			oNewWindow.document.write("</HTML>");
			oNewWindow.document.close();
		}
	}

  function openModelDialogWindow( strID )
  {
    var strURL 
    var dialog_window;
    strURL = "Main.aspx?function=Resource&act=Edit&type=Properties&ResourceID=" + strID;
		dialog_window=window.open(strURL, 'edit_window', 'width=800, height=600, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes'); 
  }

  function refresh()
  {
//    var sURL = unescape(window.location.pathname);
//    alert(sURL);
//    sURL = window.location.href
//    alert(sURL)
//    sURL = "Main.aspx?function=Schedule&act=new";
//		window.location.replace( sURL );
//		window.location.href =  sURL ;
//		window.location.reload( true );
  }

  function CandidateAction(strFunction, strScheduleID, strItemClicked, strParameter_1)
  {
    //alert(strItemClicked);
    /*
    if(strParameter_1=='CourseExpand'){
        if(bIsForceCourseOrder){
            if(strParameter_1=='CourseExpand'){
                if(strScheduleID != iFirstCourseScheduleID){
                    alert("You must complete all other Course above this one before you can start this course");
                    return;
                }
            }
        }
    }
    */
    strURL = "Main.aspx?function=" + strFunction + "&key=" + strScheduleID + "&itemclicked=" + strItemClicked + "&parameter_1=" + strParameter_1;
    //alert(strURL);
    location.href = strURL;
  }  

  function ShowSchedule(strScheduleID, strType)
  {
      strURL = "Main.aspx?function=Schedule&act=Summary&key=" + strScheduleID + "&type=" + strType;
      location.href = strURL;
  }
  
	// function to show a URL in a popup browser window
	function ShowURL(strURL)
	{
		var showURL_window;
		showURL_window = window.open("#", 'showURL_window', 'width=810, height=546, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes'); 
		showURL_window.location.href = strURL;
		showURL_window.focus();
	}
	
	function showLearningResource(strResourceID)
	{
		var showLRD_window;
		var strURL;
		strURL = "Show.aspx?Function=Show&Type=Resource&Id=" + strResourceID;
		showLRD_window = window.open("#", 'showLRD_window', 'width=810, height=546, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes'); 
		showLRD_window.location.href = strURL;
		showLRD_window.focus();
	}
  
	function showResource(strResourceID , strType)
	{
		//var showLRD_window;
		var strURL;
		//if (strType == 'LRD')
		//{
		//  strURL = "Show.aspx?Function=Show&Type=Resource&Id=" + strResourceID;
		//  showLRD_window = window.open("#", 'showLRD_window', 'width=800, height=600, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes'); 
		//  showLRD_window.location.href = strURL;
		//  showLRD_window.focus();
		//}
		//else
		//{
		  strURL = "Main.aspx?function=Resource&act=Summary&ResourceID=" + strResourceID + "&Type=" + strType;
		  location.href = strURL;
		//}
	}
	
	
	function DelConf (strConf, e) 
	{
	var truthBeTold = window.confirm(strConf);
		if (truthBeTold) {	
		} else  
		{
			if (bName() == 1)
			{
				window.event.returnValue = false;
				window.event.cancelBubble = true;
			}
			if (bName() == 2 && bVer() >= 5)
			{
				if (e.cancelable) e.preventDefault();
			}
		}
	}
	
	/*
	function ArchiveConfirm (strConf, e) 
	{
	var truthBeTold = window.confirm(strConf);
		if (truthBeTold) {	
		} else  
		{
			if (bName() == 1)
			{
				window.event.returnValue = false;
				window.event.cancelBubble = true;
			}
			if (bName() == 2 && bVer() >= 5)
			{
				if (e.cancelable) e.preventDefault();
			}
		}
	}	
	*/
	
	function ShowReportTree(e){
		if (bName() == 1)
		{
			window.event.returnValue = false;
			window.event.cancelBubble = true;
		}
		if (bName() == 2 && bVer() >= 5)
		{
			if (e.cancelable) e.preventDefault();
		}		
		history.back();
	}

    function CheckTotalMark(e)
    { 
	    if (document.forms(0).txtTaskTotalMark.value.length() > 0)
	    {
		    if(IsNumeric(document.forms(0).txtTaskTotalMark.value))
		    {
		    }
		    else
		    {
			    window.alert("If you want to use the result definition, the Total Mark is mandatory!");
			    if (bName() == 1)
				    {
					    window.event.returnValue = false;
					    window.event.cancelBubble = true;
				    }
			    if (bName() == 2 && bVer() >= 5)
				    {
					    if (e.cancelable) e.preventDefault();
				    }
		    }
	    }
	    else
	    {
		    window.alert("If you want to use the result definition, the Total Mark is mandatory!");
		    if (bName() == 1)
			    {
				    window.event.returnValue = false;
				    window.event.cancelBubble = true;
			    }
		    if (bName() == 2 && bVer() >= 5)
			    {
				    if (e.cancelable) e.preventDefault();
			    }
	    }
    }

    function showFeedbackPopup(inStr)
  	{
		oNewWindow = window.open("",'feedback_window','left=1, top=1, width=400, height=300, status=yes, menubar=yes, scrollbars=yes, toolbar=no, resizable=yes');
		oNewWindow.document.open();
		oNewWindow.document.write("<HTML>");
		oNewWindow.document.write("<HEAD>");
		oNewWindow.document.write("<TITLE>Feedback</TITLE>");
		oNewWindow.document.write("</HEAD>");
		oNewWindow.document.write("<BODY onBLur='window.close();' leftmargin='0' topmargin='0'>");
		oNewWindow.document.write(inStr);
		oNewWindow.document.write("</BODY>");
		oNewWindow.document.write("</HTML>");
		oNewWindow.document.close();
	}

    function LaunchQuickHelp(bChromeless, bResize, strUrl)
    {
	    var nWidth = screen.availWidth;
	    var nHeight = screen.availHeight;

	    // Get the width
	    if (nWidth > 820)
	    {
		    nWidth = 720;
		    nHeight = 540;
	    }

	    // Build the options string
	    var strOptions = "width=" + nWidth +",height=" + nHeight;
	    if (bResize)
	    {
		    strOptions += ",resizable=yes"
	    }

	    if (bChromeless)
	    {
		    strOptions += ", status=0, toolbar=0, location=0, menubar=0, scrollbars=0";
	    }
	    else
	    {
		    strOptions += ", status=1, toolbar=1, location=1, menubar=1, scrollbars=1";
	    }
	    window.open(strUrl, "OlamsQuickHelp", strOptions);
    }
    
    // --------------------------------------------------------------------------------------------

    //sets cookie name, value, expiration date
    function SetCookieValue(strName, objValue, intExpDays)
    {
        var ExpireDate = new Date ();
        ExpireDate.setTime(ExpireDate.getTime() + (intExpDays * 24 * 3600 * 1000));
        document.cookie = strName + "=" + escape(objValue) + "; expires=" + ExpireDate.toGMTString() + "; path=/";
        // path MUST BE SET to /
        // if not, then cookie will work for the page that sets the cookie ONLY!
        
        DebugAlert("SetCookieValue() - Name: >" + strName + "<, objValue: >" + objValue + "<, intExpiryDays: >" + intExpDays + "<");
    }
    
    // --------------------------------------------------------------------------------------------
    
    function GetCookieValue(strName)
    { 
	    if (document.cookie.length > 0) 
	    { 
		    begin = document.cookie.indexOf(strName+"="); 
		    if (begin != -1) 
		    { 
			    begin += strName.length+1; 
			    end = document.cookie.indexOf(";", begin);
			    if (end == -1)
			    { 
				    end = document.cookie.length;
			    }
			    return unescape(document.cookie.substring(begin, end)); 
		    } 
	    }
	    return null; 
    }
    
    // --------------------------------------------------------------------------------------------
    
    function ToggleObjectVisibility(strObjectID)
    {
        // does the object exist?
        if((document.getElementById(strObjectID) == undefined))
        {
            ExplainObjectNotFound(strObjectID, 'ToggleObjectVisibility')
        }
        else
        {
            if(document.getElementById(strObjectID).style.display == "none")
            {
                ShowObject(strObjectID);
            }
            else
            {
                HideObject(strObjectID);
            }
        }
    }
    
    // --------------------------------------------------------------------------------------------
    
    function HideObject(strObjectID)
    {
        // does the object exist?
        if((document.getElementById(strObjectID) == undefined))
        {
            ExplainObjectNotFound(strObjectID, 'HideObject')
        }
        else
        {
            //alert("HideObject(" + strObjectID + ")");
            document.getElementById(strObjectID).style.display="none";
        }
    }
    
    // --------------------------------------------------------------------------------------------
    
    function ShowObject(strObjectID)
    {
        // does the object exist?
        if((document.getElementById(strObjectID) == undefined))
        {
            ExplainObjectNotFound(strObjectID, 'ShowObject')
        }
        else
        {
            //alert("ShowObject(" + strObjectID + ")");
            document.getElementById(strObjectID).style.display="inline";
        }
    }
    
    // --------------------------------------------------------------------------------------------
    
    function ExplainObjectNotFound(strObjectID, strJavaScriptFunctionName)
    {
        alert('ERROR: Object >' + strObjectID + '< was not found in Jacascript function: ' + strJavaScriptFunctionName + '()');
    }
    
    // --------------------------------------------------------------------------------------------
    
    function DebugAlert(strText)
    {
        if(m_bDebugEnabled)
        {
            alert(strText);
        }
    }
    
    // --------------------------------------------------------------------------------------------
    
    function IsNull(object)
    {
        if(object == undefined)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    
    // ============================================================================================
    // Learner Login: Expand and Colapse Courses functions
    // ============================================================================================
      
    function ToggleCourseVisibility(strScheduleID)
    {
        var strObjectID;
        
        strObjectID = 'CourseCollapsedScheduleID_' + strScheduleID;
        ToggleObjectVisibility(strObjectID);
        
        strObjectID = 'CourseExpandedScheduleID_' + strScheduleID;
        ToggleObjectVisibility(strObjectID);
        
        // store all Course states to cookie
        StoreCourseStatesToCookie();
    }
    
    // --------------------------------------------------------------------------------------------
    
    function StoreCourseStatesToCookie()
    {
        var strCookieValue = "";
        
        var iIndex = 0;
        while(iIndex < arrCourses_ScheduleID.length)
        {
            var strScheduleID = arrCourses_ScheduleID[iIndex];
            var strCourseExpansionState;
            var strObjectID = 'CourseExpandedScheduleID_' + strScheduleID;
            
            // is it visible?
            if(document.getElementById(strObjectID).style.display == "inline")
            {
                strCourseExpansionState = "expanded";
            }
            else
            {
                strCourseExpansionState = "collapsed";
            }
            
            strCookieValue = strCookieValue + strScheduleID + ":" + strCourseExpansionState + ",";
                       
            iIndex ++;
        }
        
        SetCourseStatesCookie(strCookieValue);
    }
    
    // --------------------------------------------------------------------------------------------
    
    function SetCourseStatesCookie(strValue)
    {
        var strName;
        strName = m_Cookie_AframeSkillsOptimiserCourseStates + m_iUserID;
        
        DebugAlert("Getting cookie name >" + strName + "< with value of >" + strValue + "<");
        
        var CookieExpiresDays = 7;
        SetCookieValue(strName, strValue, CookieExpiresDays);
    }
    
    // --------------------------------------------------------------------------------------------
    
    function GetCourseStatesCookie()
    {
        var strName;
        strName = m_Cookie_AframeSkillsOptimiserCourseStates + m_iUserID;
        
        DebugAlert("Getting cookie name >" + strName + "<");
        
        var retVal = GetCookieValue(strName);
        return retVal;
    }
    
    // --------------------------------------------------------------------------------------------
    
    function InitialiseCourseStates()
    {
        // ---------------
        // Read the cookie
        // ---------------
        var strCookieValue = GetCourseStatesCookie()

        if( ! IsNull(strCookieValue))
        {
            DebugAlert("InitialiseCourseStates() - Cookie found: >" + strCookieValue + "<");
            
            // ---------------------------------
            // load course states into the array
            // ---------------------------------
            var iPos = 0;
            while(iPos <= strCookieValue.length)
            {
                // get the value pair (which amlways looks like "nnn:expanded" or "nnn:collapsed")
                var strValuePair;
                
                //alert("A: iPos = " + iPos);
                //alert("B: = " + strCookieValue);
                
                // search for a comma
                var iFoundPos = strCookieValue.indexOf(",", iPos);
                
                //alert("C: iFoundPos = " + iFoundPos);
                
                if(iFoundPos < 0)
                {
                    // no more value pairs to process
                    break;
                }
                else
                {
                    strValuePair = strCookieValue.substring(iPos, iFoundPos);
                    //alert(strValuePair);
                    
                    // ----------------------
                    // process the value pair 
                    // ----------------------
                    
                    // first split it into scheduleID and ExpansionState)
                    var iColonPos = strValuePair.indexOf(":", 0);
                    //alert("D: iColonPos = " + iColonPos);
                    
                    var iScheduleID = strValuePair.substring(0, iColonPos);
                    //alert("E: iScheduleID = " + iScheduleID);
                    
                    var strCourseExpansionState = strValuePair.substring(iColonPos +1);
                    //alert("F: strCourseExpansionState=" + strCourseExpansionState);
                    
                    // store to the arrCourses_IsExpanded[] array
                    SetCourseArrayExpandedState(iScheduleID, strCourseExpansionState);

                    iPos = iFoundPos + 1;
                }
            }            
        }
        else
        {
            DebugAlert("Cookie not found.");
        }
 
        // ------------------------------------------------------------
        // Set the display state of all of the courses (from the array)
        // ------------------------------------------------------------
        
        DebugAlert("Starting to process arrCourses_IsExpanded[] (expanding and collapsing courses from array settings).");
        var iIndex = 0;
        while(iIndex < arrCourses_ScheduleID.length)
        {
            var strScheduleID = arrCourses_ScheduleID[iIndex];
            var bMakeCourseExpanded = arrCourses_IsExpanded[iIndex];
            
            SetCourseDisplayState(strScheduleID, bMakeCourseExpanded);
          
            iIndex ++;
        }
    }
    
    // --------------------------------------------------------------------------------------------
    
    function SetCourseArrayExpandedState(iScheduleID, strCourseExpansionState)
    {
        var iIndex = 0;
        while(iIndex < arrCourses_ScheduleID.length)
        {
            if(iScheduleID == arrCourses_ScheduleID[iIndex])
            {
                var bExpanded;
                if (strCourseExpansionState == "expanded")
                {
                    bExpanded = 1;
                }
                else
                {
                    bExpanded = 0;
                }
                
                arrCourses_IsExpanded[iIndex] = bExpanded;
                
                DebugAlert("SetCourseArrayExpandedState() ScheduleID = " + iScheduleID + ":" + bExpanded + " (arrCourses_IsExpanded[" + iIndex + "])");
                
                break;
            }            
               
            iIndex ++;
        }
    }
    
    // --------------------------------------------------------------------------------------------
  
    function SetCourseDisplayState(strScheduleID, bMakeCourseExpanded)
    {
        if(bMakeCourseExpanded)
        {
            SetCourseDisplayExpanded(strScheduleID);
        }
        else
        {
            SetCourseDisplayCollapsed(strScheduleID);
        }
    }
    
    // --------------------------------------------------------------------------------------------
    
    function SetCourseDisplayCollapsed(strScheduleID)
    {
        var strObjectID;
        strObjectID = "CourseCollapsedScheduleID_" + strScheduleID;
    
        // does the object exist?
        if((document.getElementById(strObjectID) == undefined))
        {
            ExplainObjectNotFound(strObjectID, 'SetCourseDisplayCollapsed');
        }
        else
        {
            ShowObject(strObjectID);
        }

        strObjectID = "CourseExpandedScheduleID_" + strScheduleID;
    
        // does the object exist?
        if((document.getElementById(strObjectID) == undefined))
        {
            ExplainObjectNotFound(strObjectID, 'SetCourseDisplayCollapsed');
        }
        else
        {
            HideObject(strObjectID);
        }
    }
    
    // --------------------------------------------------------------------------------------------
    
    function SetCourseDisplayExpanded(strScheduleID)
    {
        var strObjectID;
        strObjectID = "CourseCollapsedScheduleID_" + strScheduleID;
    
        // does the object exist?
        if((document.getElementById(strObjectID) == undefined))
        {
            ExplainObjectNotFound(strObjectID, 'SetCourseDisplayCollapsed');
        }
        else
        {
            HideObject(strObjectID);
        }

        strObjectID = "CourseExpandedScheduleID_" + strScheduleID;
    
        // does the object exist?
        if((document.getElementById(strObjectID) == undefined))
        {
            ExplainObjectNotFound(strObjectID, 'SetCourseDisplayCollapsed');
        }
        else
        {
            ShowObject(strObjectID);
        }
    }
    
    
    function confimAssesmentDuration(evt, source, ignoreValue) {    
        if (source.options[source.selectedIndex].value != ignoreValue) {                     
            var prompt = "WARNING: You are specifying the maximum number of attempts for this\nAssessment. It is highly recommended that you leave this set to 'Unlimited'.\n\n";
            prompt = prompt + "Changing this to something other than Unlimited is NOT recommended because\nonce a learner has used all of the allowed attempts, a Trainer cannot give the\nlearner more attempts.\n\n";
            prompt = prompt + "";
            prompt = prompt + "When the number of attempts is set to Unlimited, the system will highlight\nLearners who have used 3 or more ";
            prompt = prompt + "attempts but have still not reached\nthe target score. ";

            alert(prompt);        
        }
    }
    
    function confimAssesmentAtemptMethod(evt, source, returnFocusTo) {    
        var prompt = "WARNING: This option should only be selected for use with surveys or evaluations.\n\r\nClick \'OK\' to change it or \'Cancel\' not to change it.";
        var result = confirm(prompt);
        if (result) {
            evt.returnValue = true;
        } else {
            document.getElementById(returnFocusTo).checked=true;
            evt.returnValue = false;
        }        
    }
    
    // --------------------------------------------------------------------------------------------
    
    // ============================================================================================

    function confirmDeletion(sNodeText, sGroupDescription){
        var sprompt;
        sprompt = 'Are you sure you want to delete the '+ sGroupDescription + ': ' + sNodeText + ' ? \r\nClick \'OK\' to delete it or \'Cancel\' to keep it.';
        var result = confirm(sprompt);
        if(result){
            return true;
         }else{
            return false;
        }
    }
    
    function disableButtonObject(objectIn){
		 //alert(objectIn);
	     objectIn.disabled = true;
	}
	
	
        ///<summary>
        ///Code used to determine width of the client area.
        ///Added by Derek Baird 11 Aug 2008
        ///</summary>
        function getClientWidth() {
            var x;

            if (self.innerHeight) // all except Explorer
            {
                x = self.innerWidth;
            }

            else if (document.documentElement && document.documentElement.clientHeight)
                // Explorer 6 & 7 Strict Mode
            {
                x = document.documentElement.clientWidth;
            }
            else if (document.body) // other Explorers
            {
                x = document.body.clientWidth;
            }
            return x;
        }

        ///<summary>
        ///Code used to determine height of the client area.
        ///Added by Derek Baird 11 Aug 2008
        ///</summary>
        function getClientHeight() {
            var y;
            if (self.innerHeight) // all except Explorer
            {
                y = self.innerHeight;
            }

            else if (document.documentElement && document.documentElement.clientHeight)
                // Explorer 6 & 7 Strict Mode
            {
                y = document.documentElement.clientHeight;
            }
            else if (document.body) // other Explorers
            {
                y = document.body.clientHeight;
            }

            return y;
        }
   
   
   
        
function QueryString() {
	// PROPERTIES
	this.arg = new Array;
	this.status = false;
	
	// METHODS
	this.clear = Clear;
	this.get = Get;
	this.getAll = GetAll;
	this.getStatus = GetStatus;
	this.read = Read;
	
	// FUNCTIONS
	
	// Clears the array, this.arg, of all query string data
	function Clear()
	{	this.arg = new Array;
	}
	
	// Returns a named value from the query string
	function Get(sName)
	{	return this.arg[sName];
	}
	
	// Return all data as an associative array
	function GetAll()
	{	return this.arg;
	}
	
	function GetStatus()
	{	return this.status;
	}
	
	// Reads the query string into an array named this.arg
	function Read(sUrl) 
	{	var aArgsTemp, aTemp, sQuery;
		// You can pass in a URL query string
		if(sUrl)
		{	sQuery = sUrl.substr(sUrl.lastIndexOf("?")+1, sUrl.length);
		}
		// Or read it from the browser location
		else
		{	sQuery = window.location.search.substr(1, window.location.search.length);
		}
		// Check that query string exists and contains data
		// If not (length < 1) then return
		if(sQuery.length < 1) {return;}
		// Else set this.status to true and proceed
		else {this.status = true;}
		//
		aArgsTemp = sQuery.split("&");	
		for (var i=0 ; i<aArgsTemp.length; i++)
		{	aTemp = aArgsTemp[i].split("=");
			this.arg[aTemp[0]] = aTemp[1];
		}
	}
}


Array.prototype.exists = function ( value ) 
{
    ///<summary>Determines if a value exists in and array.</summary>
    for (var i = 0; i < this.length; i++) {
        if (this[i] == value) return true;
    }
    return false;
}


Array.prototype.indexOfValue = function ( value ) 
{
    ///<summary>Returns the index of the value in the array.</summary>
    for (var i = 0; i < this.length; i++) {
        if (this[i] == value) return i;
    }
    return -1;
}

Array.prototype.removeElement = function( value ) {
    ///<summary>Removes the value from the array.</summary>
    var index = this.indexOfValue( value );
    if(index!=-1 && index <this.length) {
            this.splice(index, 1)
    }
}   
            	
//-->

function findControlPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent)
        while (1) {
        curleft += obj.offsetLeft;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function findControlPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent)
        while (1) {
        curtop += obj.offsetTop;
        if (!obj.offsetParent)
            break;
        obj = obj.offsetParent;
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}

function provideFileForDownload(url) {
    window.open(url, '_blank', 'height=100,width=100,resizable=no');
    return false;
}

