/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2004-2005 SumTotal Systems, Inc. All rights reserved.
//
// The copyright to the computer software herein is proprietary and remains
// the property of SumTotal Systems, Inc. It may be used and/or copied only with
// the written consent of SumTotal Systems, Inc. or in accordance with the terms and
// conditions stipulated in the agreement/contract under which this software
// has been supplied.
//
// $Id: LMS_LearnerHome.js,v 1.23 2006/04/11 23:15:52 akim Exp $
// $Date: 2006/04/11 23:15:52 $
// $RCSfile: LMS_LearnerHome.js,v $
// $Revision: 1.23 $
//
// Abstract:
//
//    Browser class to identify browsers and operating system
//
// Revision History:
//
//    2002-02-25   Anand Arvind    Created file
//
/////////////////////////////////////////////////////////////////////////////

var g_objTaskArray = new Array();

function Content_OnLoad()
{

    //
    // Initialize page
    //
    _UTL_PageInit();

    //
    // Initialize navigation menu
    //
    _UTL_NavMenu_OnLoad();

    setTimeout("getPrefs(0," + iIndex+ ");", 1000);

    //
    // Load dashboard if visible
    //
    if ( _UTL_Verify_ObjectExistence("Content_Dashboard_Load") )
        Content_Dashboard_Load();

    //
    // Only if NT Auth, Check for popup blockers in this page and print appropriate message.
    // Else the check would have been already done in login page.
    if ( g_bIsNTAuth )
        _UTL_CheckPopupBlocker();

}

function Content_OnUnload()
{
      if ( document.getElementById("actualIFRAME") )
         document.getElementById("actualIFRAME").src =  _UTL_GetCorePagePath("experience/blank.htm");
}

function LMS_Training_Launch(nEvtID)

{
    var strURL = _UTL_GetPagePath("management/LMS_CNT_LaunchCourse.asp?UserMode=0&EventID=") + nEvtID.toString();
    window.location = strURL;
}



function getPrefs(iIndextemp,iIndex)
{
    if(iIndextemp < iIndex)
    {
        objPrefArraytemp = objPrefArray.split(",")[iIndextemp];
        arrIViewPreftemp = arrIViewPref.split(",")[iIndextemp];
        arrMaxRowstemp = arrMaxRows.split(",")[iIndextemp];
        strURL = "management/LMS_LearnerHomePageData.asp?objPrefArrayInd=" + objPrefArraytemp + "&arrIViewPrefInd=" + arrIViewPreftemp + "&arrMaxRowsInd=" + arrMaxRowstemp
            + "&iIndextemp=" + iIndextemp + "&iIndex=" + iIndex + "&UserMode=" + g_strReqUserMode ;
        document.getElementById("actualIFRAME").src =  _UTL_GetPagePath(strURL);
        
    }
}

function Schedule_Load(strData)
{
    var objA ;

    if ( document.getElementById('idHDTab0') )
    {
        objA = document.getElementById('idHDTab0').childNodes[0]; if ( objA ) objA.className = "clsHomeDataHeadingNor";
    }
    if ( document.getElementById('idHDTab1') )
    {
        objA = document.getElementById('idHDTab1').childNodes[0]; if ( objA ) objA.className = "clsHomeDataHeadingNor";
    }
    if ( document.getElementById('idHDTab2') )
    {
        objA = document.getElementById('idHDTab2').childNodes[0]; if ( objA ) objA.className = "clsHomeDataHeadingNor";
    }
    if ( document.getElementById('idHDTab3') )
    {
        objA = document.getElementById('idHDTab3').childNodes[0]; if ( objA ) objA.className = "clsHomeDataHeadingNor";
    }
    if ( document.getElementById('idHDTab4') )
    {
        objA = document.getElementById('idHDTab4').childNodes[0]; if ( objA )  objA.className = "clsHomeDataHeadingNor";
    }
    if ( document.getElementById('idHDTab5') )
    {
        objA = document.getElementById('idHDTab5').childNodes[0]; if ( objA )  objA.className = "clsHomeDataHeadingNor";
    }
	if ( document.getElementById('idHDTab6') )
    {
        objA = document.getElementById('idHDTab6').childNodes[0]; if ( objA )  objA.className = "clsHomeDataHeadingNor";
    }
    if ( strData == "training" )
    {
        objA = document.getElementById('idHDTab0').childNodes[0]; objA.className = "clsHomeDataHeadingSel";
    }
    if ( strData == "certification" )
    {
        objA = document.getElementById('idHDTab6').childNodes[0]; objA.className = "clsHomeDataHeadingSel";
    }

    if ( strData == "tasks" )
    {
        objA = document.getElementById('idHDTab1').childNodes[0]; objA.className = "clsHomeDataHeadingSel";
    }

    if ( strData == "schedule" )
    {
        objA = document.getElementById('idHDTab2').childNodes[0]; objA.className = "clsHomeDataHeadingSel";
    }

    if ( strData == "search" )
    {
        objA = document.getElementById('idHDTab3').childNodes[0]; objA.className = "clsHomeDataHeadingSel";
    }

    if ( strData == "news" )
    {
        objA = document.getElementById('idHDTab4').childNodes[0]; objA.className = "clsHomeDataHeadingSel";
    }

    if ( strData == "profile" )
    {
        objA = document.getElementById('idHDTab5').childNodes[0]; objA.className = "clsHomeDataHeadingSel";
    }

    document.getElementById("idScheduleIFrame").src = _UTL_GetPagePath( "management/LMS_LearnerHomeSchedule.asp?Mode=" + strData + "&UserMode=" + g_strReqUserMode);
}

function Schedule_SetData(strData,strMode)
{

    document.getElementById('idScheduleDiv').innerHTML = strData ;

    if ( strMode == "schedule" )
    {
        //
        // Make calendar visible
        //
        _UTL_FlatCalendarInit("idCalTable", "gfFlat");

    }
    if ( strMode == "training" )
    {
        //
        // Start loading preferences
        //
        Schedule_Tasks_GetNextTask(0)

    }
	if ( strMode == "certification" )
    {
        //
        // Start loading preferences
        //
        Schedule_Tasks_GetNextTask(0)

    }
    if ( strMode == "tasks" )
    {
        //
        // Start loading preferences
        //
        Schedule_Tasks_GetNextTask(0)

    }
    if ( strMode == "search" )
    {
        //
        // Stuff
        //
    }
    if ( strMode == "news" )
    {
        //
        // Stuff
        //
    }
    if ( strMode == "profile" )
    {
        //
        // Stuff
        //
    }
}

function Schedule_Tasks_GetNextTask(iIndex)
{

    var nView     = 0;
    var nRow      = 5;
    var objSTList = ( document.getElementById('idScheduleData').innerHTML ).split(",");

    if ( iIndex < (objSTList.length-1) )
    {
        strURL = "management/LMS_LearnerHomePageData.asp?Mode=1&objPrefArrayInd=" + objSTList[iIndex] + "&arrIViewPrefInd=" + nView + "&arrMaxRowsInd=" + nRow
            + "&iIndextemp=" + iIndex + "&iIndex=" + 0 + "&UserMode=" + g_strReqUserMode;
        // alert('schedule frame url = ' + strURL);
        document.getElementById("idScheduleTaskIFrame").src =  _UTL_GetPagePath(strURL);
    }
}


function ADM_ListActivities_HomeNew( iTaskListIndex )
{
    var objActTypes      = document.getElementById("idComboNew_" + iTaskListIndex );
    var iSelIndex        = objActTypes.selectedIndex;   
    //
    // Pass the proper set of parameters to the activity creation page
    //
     
    var iActType = objActTypes.options[ iSelIndex ].value;
    var strNavTo = g_strNewPage  + "?hidden__ActionMode=2";
    
    strNavTo += "&ActType=" + iActType + "&CallerURL=" + escape(g_strCallerURL);    
    
    _UTL_Navigate( strNavTo );
}

var fSummary;
var fDetail;
var dvProgress;
var sScrollY;

function initReports(summaryURL)
{
	fSummary = document.getElementById('ifSummary');
	fDetail = document.getElementById('ifDetail');
	dvProgress = document.getElementById('idProgressBarDiv');
	
	showProgress();
	window.ifSummary.location.replace(summaryURL);
}

function showProgress()
{
	fSummary.style.display = 'none';
	fDetail.style.display = 'none';
	dvProgress.style.display = 'block';
	dvProgress.style.visibility = 'visible';		
}


function showSummary()
{
	fSummary.style.display = 'block';
	fDetail.style.display = 'none';
	dvProgress.style.display = 'none';

	window.document.body.scrollTop = sScrollY;
}


function showDetail(detailURL)
{
	sScrollY = window.document.body.scrollTop;
	showProgress();
	window.ifDetail.location.replace(detailURL); 
}


function displayReport(ifObj)
{
	var locationURL = null;
	if (ifObj.id == 'ifSummary')
	{
		locationURL = window.ifSummary.location.href;
	}
	else
	{
		locationURL = window.ifDetail.location.href;
	}
	if (locationURL.indexOf('blank.htm') == -1)
	{
		dvProgress.style.display = 'none';
		ifObj.style.display = 'block';
		
		resizeReport(ifObj);
	}
}

function resizeReport(ifObj)
{
	ifObj.style.height = ifObj.contentWindow.document.body.scrollHeight + 5;

	var contentWidth = ifObj.contentWindow.document.body.scrollWidth;
	var containerWidth = ifObj.offsetWidth;

	if (contentWidth > containerWidth)
	{
		document.getElementById('imgGuide').style.width = contentWidth;
	}
	else if (contentWidth < containerWidth)
	{
		document.getElementById('imgGuide').style.width = '100%';
	}
}

