/////////////////////////////////////////////////////////////////////////////
//
// 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.
//

//
// Abstract:
//
//    Browser class to identify browsers and operating system
//
// Revision History:
//
//    2002-02-25   Anand Arvind    Created file
//
/////////////////////////////////////////////////////////////////////////////

//
// Common objects
//
var g_objPopupWindow  = null ;
var g_objButton       = new Array();
var g_objBrowser      = new _ObjBrowser();
g_objBrowser.Init();
var g_strAuthCookie   = 'IPrep';
// Added the flag to get the status of Modal window in Firefox
var g_blnModalFlag =    false;

//
// Logging code
//
var g_UTL_DebugFlag   = false ;
var g_UTL_DebugWindow = null ;

//
// For Manager mode employee selection
var g_nUserMode;

//
//   This function is to check if the event is pressing Enter/Return key
//
function _UTL_EnterPressed(evt)
{

    evt = SYS_Browser_GetEventObject(evt);

    if ( SYS_Browser_GetEventKeyCode(evt) == 13)
        return true ;
    else
        return false ;
}

function _UTL_Trim(strValue)
{

    //
    // Remove leading and trailing spaces
    //
    var str1 = strValue.replace(/^\s*/,"");
    var str2 = str1.replace(/\s*$/,"");

    return str2 ;

}
//
//This function is used to persist state of a checkbox even if checkbox is disabled
//Use this function just before submititng the form
//
function _UTL_PersistCheckBoxState(objField)
{
    if(objField.disabled=true)
        objField.disabled = false;
}


function _UTL_TrimLeadingZeros(strValue)
{
    //
    // Remove leading zeros
    //

    str1 = strValue;
    if (strValue != "0")
        str1 = strValue.replace(/^0*/,"");
    return str1;
}


function _UTL_Chop(strValue, nSize)
{
    var nMaxLength = (arguments.length == 2) ? nSize : 64;

    return (strValue.length > nMaxLength) ? strValue.substring(0,nMaxLength-1) : strValue;
}


function _UTL_CleanForJSVar(strValue)
{

    var str1 = null ;
    var str2 = "" ;
    var strR = "";

    if ( strValue == null )
        return "";

    if ( typeof strValue != "string" )
        strValue = String(strValue);

    //
    // Replace tags
    //
    var str1 = strValue.replace(/\'/g,"\\\'");
    var str2 = str1.replace(/\"/g,"\\\"");
    var str3 = str2.replace(/\r\n/g,"");

    return str3 ;

}

function _UTL_PageInit()
{

    //
    // Right click
    //
    // TBD document.onmousedown   = _UTL_BlockRightClick ;

    //
    // Context menu
    //
    document.oncontextmenu = _UTL_BlockContextMenu ;

    SYS_Browser_OuterHTML_Init() ;
    SYS_Browser_InnerText_Init() ;
    
    if ( g_UTL_DebugFlag )
        _UTL_InitDebugWindow();

    //
    // If export is not enabled hide the icons
    //
    if ( typeof(EXPORT_ENABLED) != "undefined" )
    {
        //
        // Find all instances of export button and hide them
        //
        if ( EXPORT_ENABLED == false )
        {
            if ( document.images )
            {
                for ( var i = 0 ; i < document.images.length ; i++ )
                {
                    if ( String(document.images[i].src).indexOf("icon_export.gif") >= 0 )
                    {
                        document.images[i].style.display = "none";
                    }
                }
            }

        }

    }

}

function _UTL_BlockContextMenu(evt)
{
    evt = (evt) ? evt : event ;
    
    //
    // If CTRL pressed show context menu
    //
    if ( evt.ctrlKey == true )
        return true ;

    //
    // Enable right click on hyperlinks and form fields: text-area and single line inputs
    //
    var eTarget = SYS_Browser_GetEventTarget(evt) ;
    
    if(eTarget)
        if ( eTarget.tagName == "TEXTAREA" ||
             eTarget.tagName == "INPUT"    ||
             eTarget.tagName == "A"        ||
             eTarget.tagName == "IMG"      ||
             eTarget.tagName == "IMAGE"    )
        {
            return true ;
        }
        else
        {
            SYS_Browser_StopEventPropagation(evt);
            return false ;
        };

    return true ;
}

function _UTL_BlockRightClick(evt)
{

    //
    // Debug message
    //
    // window.status = '_UTL_BlockRightClick = ' + event.srcElement.tagName + ' button ' + event.button + event.ctrlKey ;
    //

    //
    // Disable right mouse click
    //
    if ( window.Event )
    {

        if ( evt.modifiers & Event.CONTROL_MASK && ( evt.which == 2 || evt.which == 3 ) )
            return true ;

        if ( evt.which == 2 || evt.which == 3 )
            return false ;

    }
    else
    {

        //
        // If CTRL pressed show context menu
        //
        if ( event.ctrlKey == true && event.button > 1 )
            return true ;

        if ( event.srcElement.tagName == "TEXTAREA" ||
             event.srcElement.tagName == "INPUT"    )
        {

        }
        else
        {

            if ( event.button > 1 )
            {
                event.cancelBubble = true ;
                event.returnValue  = false ;
                return false ;

            }
        }
    }

    return true ;

}

function _UTL_CheckPopupBlocker()
{

    //
    // For IE and Netscape  
    //
    if ( (g_objBrowser.IsIE() && g_objBrowser.Version() >= 500) | (g_objBrowser.IsNetscape() && g_objBrowser.Version() >= 500) )
    {

        //
        // Due to a timing issue, if an earlier window exists, kill it and call this function again
        //
        if ( g_objPopupWindow != null && typeof(g_objPopupWindow) == "object" )
        {
            g_objPopupWindow.close();
            g_objPopupWindow = null;
            setTimeout("_UTL_CheckPopupBlocker()",100);
            return;
        }

        g_objPopupWindow = window.open(STRING_SITE_PREFIX + "/blank.htm#abc", "popup_name", "notoolbars,resizable=no,scrollbars=yes,width=5,height=5,left=4000,top=4000");

        //
        // Give 500 ms for opening window on the machine
        //
        setTimeout("_UTL_CheckPopupExists()",500);

    }

}

function _UTL_CheckPopupExists(objWindow)
{

    if ( (g_objBrowser.IsIE() && g_objBrowser.Version() >= 500) | (g_objBrowser.IsNetscape() && g_objBrowser.Version() >= 500) )
    {
        //
        // Can open popups
        //
        if ( g_objPopupWindow == null || (typeof(g_objPopupWindow)=="undefined") || (typeof(g_objPopupWindow.location.hash)!="string") )
        {
            //
            // Something happened or a false positive of a popup blocker
            //
            if ( typeof(L_Info_PopupBlockerOn) != "undefined" )
            {
                alert(L_Info_PopupBlockerOn);
            }
        }
        else
        {
            g_objPopupWindow.close();
            g_objPopupWindow = null;
        }

        g_objPopupWindow = null;
    }
}

function _UTL_OpenWindow(strURL, strWindowName, nLaunchWidth, nLaunchHeight, strLaunchFeatures)
{

    var nScreenWidth      = 800 ;
    var nScreenHeight     = 600 ;
    nLaunchWidth      = nLaunchWidth || 800 ;
    nLaunchHeight     = nLaunchHeight || 600 ;

    if ( arguments.length < 5 )
    {
        strLaunchFeatures = "notoolbars,resizable=no,scrollbars=yes,";
    }
    else
    {
        if ( strLaunchFeatures.length > 0 )
            strLaunchFeatures += ",";
    };

    if (window.screen)
    {
        nScreenWidth  = screen.availWidth  - 30;
        nScreenHeight = screen.availHeight - 40;
        nLaunchWidth  = Math.min(nLaunchWidth, nScreenWidth);
        nLaunchHeight = Math.min(nLaunchHeight, nScreenHeight);

        //
        // NS/IE switch
        //
        if (window.Event)
        {
            strLaunchFeatures += 'screenX=' + (nScreenWidth - nLaunchWidth)/2 + ',screenY=' + (nScreenHeight - nLaunchHeight)/2 + ',';
        }
        else
        {
            strLaunchFeatures += 'left=' + (nScreenWidth - nLaunchWidth)/2 + ',top=' + (nScreenHeight - nLaunchHeight)/2 + ',';
        }

    }

    strLaunchFeatures += 'width=' + nLaunchWidth + ',height=' + nLaunchHeight;

    window.open(strURL, strWindowName, strLaunchFeatures);


}

function _UTL_OpenModalWindow(strURL, strWindowName, nLaunchWidth, nLaunchHeight, strLchFeatures, strDlgArgs)
{
    var startURL            = strURL.indexOf("Path")
    var strLaunchFeatures   ;
    var nScreenWidth        = 800 ;
    var nScreenHeight       = 600 ;


    if( typeof(strLchFeatures) == "undefined")
        strLaunchFeatures   = "center:yes; help:no; status:no;"
    else
        strLaunchFeatures = strLchFeatures;

 
    if ( arguments.length < 3 )
    {
        nLaunchWidth      = 800 ;
        nLaunchHeight     = 600 ;
    };

    if (window.screen)  // Netscape
    {
        nScreenWidth  = screen.availWidth  - 30;
        nScreenHeight = screen.availHeight - 15;
        nLaunchWidth  = Math.min(nLaunchWidth, nScreenWidth);
        nLaunchHeight = Math.min(nLaunchHeight, nScreenHeight);
    }
    
    if( typeof(nLaunchWidth) != "undefined")
    {
        strLaunchFeatures = "dialogWidth:" + nLaunchWidth + "px;" + strLaunchFeatures;
    }

    if( typeof(nLaunchHeight) != "undefined")
    {
       strLaunchFeatures = "dialogHeight:" + nLaunchHeight + "px;" + strLaunchFeatures;
    }
        
    // TO DO, change to object detection
    if ( g_objBrowser.IsNetscape() )
    {
        return _UTL_OpenModalWindowInNS(strURL,nLaunchWidth,nLaunchHeight, "return()", "win",strDlgArgs);
    }
    else
    {
        if( typeof( strDlgArgs ) == 'undefined' )
            return window.showModalDialog(strURL, self, strLaunchFeatures);
        else
            return window.showModalDialog(strURL, strDlgArgs, strLaunchFeatures);
    }
}

function _UTL_OpenCBModalWindow(strURL, strWindowName, nLaunchWidth, nLaunchHeight, strLchFeatures, strDlgArgs, strReturnFunc)
{
    var startURL            = strURL.indexOf("Path")
    var strLaunchFeatures   ;
    var nScreenWidth        = 800 ;
    var nScreenHeight       = 600 ;
   // var strReturnValue      ; //1-20-06 MinJie made strReturnValue to be wider scoped so it can be passed into the SEC
   //Functioncall wrapper and still properly execute.  

    if( typeof(strLchFeatures) == "undefined")
        strLaunchFeatures   = "center:yes; help:no; status:no;"
    else
        strLaunchFeatures = strLchFeatures;

 
    if ( arguments.length < 3 || nLaunchWidth == "" || nLaunchHeight == "")
    {   
        nLaunchWidth      = 800 ;
        nLaunchHeight     = 600 ;
    };

    if (window.screen)  // Netscape
    {
        nScreenWidth  = screen.availWidth  - 30;
        nScreenHeight = screen.availHeight - 15;
        nLaunchWidth  = Math.min(nLaunchWidth, nScreenWidth);
        nLaunchHeight = Math.min(nLaunchHeight, nScreenHeight);
    }
    
    if( typeof(nLaunchWidth) != "undefined")
    {
        strLaunchFeatures = "dialogWidth:" + nLaunchWidth + "px;" + strLaunchFeatures;
    }

    if( typeof(nLaunchHeight) != "undefined")
    {
       strLaunchFeatures = "dialogHeight:" + nLaunchHeight + "px;" + strLaunchFeatures;
    }
        
    // TO DO, change to object detection
    if ( g_objBrowser.IsNetscape() )
    {                    
        return _UTL_OpenModalWindowInNS(strURL,nLaunchWidth,nLaunchHeight, strReturnFunc , "win" , strDlgArgs);
    }
    else
    {
        if( typeof( strDlgArgs ) == 'undefined' )
            strDlgArgs = self;

        if(strReturnFunc == "" || typeof(strReturnFunc) == "undefined")
            return  window.showModalDialog(strURL, strDlgArgs, strLaunchFeatures);
        else
        {
            strReturnValue =  window.showModalDialog(strURL, strDlgArgs, strLaunchFeatures);
            //1-20-06 MinJie replaced eval with wrapper call.
            SYS_SEC_EvalFunctionCall( strReturnFunc + "( strReturnValue )" );
        }
    }
}

function _UTL_OpenYesNoWindow(szTitle, szMessage, iWidth, iHeight)
{
    if ( arguments.length < 3 )
    {
        iWidth      = 400 ;
        iHeight     = 150 ;
    }

    if ( arguments.length < 4 )
    {
        iHeight     = 150 ;
    }

    return _UTL_OpenModalWindow(_UTL_GetPagePath("common/dialogs/SYS_YesNoDialog.asp?Title=" + encodeURIComponent(szTitle) + "&Message=" + encodeURIComponent(szMessage)), szTitle, iWidth, iHeight);
}

function _UTL_OpenYesNoCancelWindow(szTitle, szMessage, iWidth, iHeight, szYesCaption, szNoCaption, szReturnFunc)
{
    if( typeof(szYesCaption) == "undefined")
         szYesCaption = "";

    if( typeof(szNoCaption) == "undefined")
         szNoCaption = "";

    if( typeof(szReturnFunc) == "undefined")
         szReturnFunc = "";


    if ( arguments.length < 3 )
    {
        iWidth      = 400 ;
    }

    if ( arguments.length < 4 )
    {
        iHeight     = 150 ;
    }

    return _UTL_OpenCBModalWindow(_UTL_GetPagePath("common/dialogs/SYS_YesNoCancelDialog.asp?Title=" + encodeURIComponent(szTitle) + "&Message=" + encodeURIComponent(szMessage) + "&szYesCaption=" + encodeURIComponent(szYesCaption) + "&szNoCaption=" + encodeURIComponent(szNoCaption) ), szTitle, iWidth, iHeight, "", "", szReturnFunc);
}

function _UTL_OpenOKWindow(szTitle, szMessage, iWidth, iHeight)
{
    if ( arguments.length < 3 )
    {
        iWidth      = 400 ;
        iHeight     = 150 ;
    }

    if ( arguments.length < 4 )
    {
        iHeight     = 150 ;
    }

    return _UTL_OpenModalWindow(_UTL_GetPagePath("common/dialogs/SYS_OKDialog.asp?Title=" + encodeURIComponent(szTitle) + "&Message=" + encodeURIComponent(szMessage)), szTitle, iWidth, iHeight);
}

function _UTL_OpenOKCancelWindow(szTitle, szMessage, iWidth, iHeight, szYesCaption, szReturnFunc)
{
    if( typeof(szYesCaption) == "undefined")
         szYesCaption = "";

    if( typeof(szReturnFunc) == "undefined")
         szReturnFunc = "";

    
    if ( arguments.length < 3 )
    {
        iWidth      = 400 ;
        iHeight     = 150 ;
    }

    if ( arguments.length < 4 )
    {
        iHeight     = 150 ;
    }

    return _UTL_OpenCBModalWindow(_UTL_GetPagePath("common/dialogs/SYS_OKCancelDialog.asp?Title=" + encodeURIComponent(szTitle) + "&Message=" + encodeURIComponent(szMessage) + "&szYesCaption=" + encodeURIComponent(szYesCaption) ), szTitle, iWidth, iHeight, "", "", szReturnFunc);
}

function _UTL_OpenHelpWindow(strContext)
{

    var strDirName = STRING_SITE_PREFIX + "/" + STRING_LANG_PATH + "help/";

    switch ( String(strContext) )
    {
    case "learner" :
        strDirName += "Learner/_AspenLearner.htm";
        break ;
    case "manager" :
        strDirName += "Manager/_AspenManager.htm";
        break ;
    case "admin" :
        strDirName += "Admin/_AspenAdmin.htm";
        break ;
    case "author" :
        strDirName += "Author/_AspenAuthor.htm";
        break ;
    case "cmgr" :
        strDirName += "ContMgr/_AspenContMgr.htm";
        break ;
    case "acp" :
        strDirName += "PersDeliv/_AspenPersDeliv.htm";
        break ;
    case "scormplayer" :
        strDirName += "Player/_AspenSCORMPlayer.htm";
        break ;
    case "avc" :
        strDirName += "VirClass/_AspenVirClass.htm";
        break ;
    default :
        strDirName += "Learner/_AspenLearner.htm";
    }

    _UTL_OpenWindow(strDirName, "AspenHelp", 750, 550, "notoolbars,resizable=yes,scrollbars=yes")

}

function _UTL_OpenHelpSearch()
{

    var strDirName = STRING_SITE_PREFIX + "/" + STRING_LANG_PATH + "help/Learner/Search/Abt_srch_ftr.htm";

    _UTL_OpenWindow(strDirName, "AspenSearchHelp", 750, 550, "notoolbars,resizable=yes,scrollbars=yes")

}

function _UTL_OpenHelpUsersGuide(strContext)
{

    var strDirName = STRING_SITE_PREFIX + "/" + STRING_LANG_PATH + "help/";

    switch ( String(strContext) )
    {
    case "learner" :
        strDirName += "Learner/learner_users_guide.pdf";
        break ;
    case "manager" :
        strDirName += "Manager/manager_users_guide.pdf";
        break ;
    case "admin" :
        strDirName += "Admin/admin_users_guide.pdf";
        break ;
    default :
        strDirName += "Learner/learner_users_guide.pdf";
    }

    _UTL_OpenWindow(strDirName, "AspenUsersGuide", 750, 550, "notoolbars,resizable=yes,scrollbars=yes")

}

function _UTL_Verify_ObjectExistence(strValue)
{
    var bValue    = true ;
    var objValues = strValue.split(".");
    var strCheck  = "";

    if ( objValues.length > 1 )
    {
        strCheck = objValues[0] ;
        for ( var i = 1 ; i < objValues.length ; i++ )
        {
            strCheck += "." + objValues[i] ;
            bValue = SYS_SEC_EvalHtmlCodeBlock("! ( typeof(" + strCheck + ") == \"undefined\" )");
            if ( bValue == false )
                break ;
        }
    }
    else
        bValue = SYS_SEC_EvalHtmlCodeBlock("! ( typeof(" + strValue + ") == \"undefined\" )");

    return bValue ;

}

function _UTL_Log(strMsg)
{

    if ( g_UTL_DebugWindow )
        g_UTL_DebugWindow.document.all.idDebug.innerHTML += strMsg + "<br>";

}

function _UTL_InitDebugWindow()
{

    //
    // Launch debug window
    //
    if ( g_UTL_DebugFlag )
    {
        g_UTL_DebugWindow  = window.open(null,"_DebugTrace_",
                                          "width=750,height=600,left=1,top=1,scrollbars=yes,resizable=yes,resizeable=yes");

        g_UTL_DebugWindow.document.open();
        g_UTL_DebugWindow.document.write("<html><body><div id='idDebug'><b>Debug Window</b><br><br></div></body></html>");
        g_UTL_DebugWindow.document.close();
    }

}

function _UTL_Button_Text_MoveOver(objButton)
{

    objButton.className = "clsTextButtonMoveOver"

}

function _UTL_Button_Text_MoveAway(objButton)
{

    objButton.className = "clsTextButtonMoveOut"

}

function _UTL_CloseWindow()
{

    var current = self;

    while (current != current.parent && current.parent != null)
    {
        current = current.parent;
        current.close();
        return;
    }

    if (current != null && current.opener != null && !current.opener.closed) {
        current.opener.close();
    }

}

function _UTL_Printf(str)
{

    //
    // TODO make this more efficient
    //
    var nIndex    = 0 ;
    var nCount    = 1 ;
    var nLength   = 0 ;
    var strResult = str ;

    if ( arguments.length > 1 )
    {
        nIndex = strResult.indexOf("%s");
        while ( nIndex >= 0 && nCount <= arguments.length )
        {
            nLength   = strResult.length ;
            strResult = strResult.substring(0,nIndex) + String(arguments[nCount++]) + strResult.substring(nIndex+2,nLength);
            nIndex    = strResult.indexOf("%s");
        }
    };

    return strResult ;

}


/////////////////////////////////////////////////////////////////////////////
//
// Function Name : _UTL_PrintfEx
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////
function _UTL_PrintfEx(str)
{

    var nIndex    = 0 ;
    var nCount    = 1 ;
    var nLength   = 0 ;
    var strResult = str ;

    if ( arguments.length > 1 )
    {

        while ( nCount <= arguments.length - 1 )
        {
            nLength   = strResult.length ;
            strResult = strResult.replace("%" + nCount , String(arguments[nCount++]));

        }
    };

    return strResult ;

}

function _UTL_GetPagePrefix()
{

    return ( STRING_SITE_PREFIX + "/" + STRING_LANG_PATH );


}

function _UTL_GetPagePath(strPage)
{

    return ( STRING_SITE_PREFIX + "/" + STRING_LANG_PATH + strPage );

}

function _UTL_GetPagePath_Authoring(strPage)
{

    return ( "/" + STRING_ROOT_PREFIX + "/" + STRING_LANG_PATH + strPage );

}

function _UTL_GetCorePagePath(strPage)
{

    return ( STRING_SITE_PREFIX + "/core/" + strPage );

}

function _UTL_GetImagePrefix()
{

    return STRING_IMAGE_PREFIX ;

}

function _UTL_GetImagePath(strImage)
{

    return STRING_IMAGE_PREFIX + strImage ;

}

function _UTL_GetLangPath()
{

 return STRING_LANG_PATH + "/";

}


function _UTL_GetLangCode()
{

    return g_strUserLangCode ;

}


function _UTL_Navigate(strURL)
{
if (g_blnModalFlag != true)
{
    window.location = strURL ;
}

}


function _UTL_NavigatePage(strURL)
{

    window.location = _UTL_GetPagePath(strURL) ;

}

function _UTL_NavigatePageNoLoc(strURL)
{

    window.location = STRING_SITE_PREFIX + "/core/" + strURL ;

}

function _UTL_NotImplemented()
{
    alert("This feature has not been implemented");
}

function _UTL_NoOp()
{
    return;
}

function _UTL_PreLoadImage(imgObj,imgSrc)
{
    if (document.images)
    {
        SYS_SEC_EvalHtmlCodeBlock(imgObj + "=new Image()");
        SYS_SEC_EvalStringOnly(imgObj).src = imgSrc;
    }
}


/////////////////////////////////////////////////////////////////////////////
//
// Function Name :
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
//   Manager mode employee selection
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_Manager_SelectEmployee(nUserMode)
{

    var strRetVal = null ;
    g_nUserMode = nUserMode;
    _UTL_OpenCBModalWindow(_UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(_UTL_GetPagePath("management/LMS_EmpSelect.asp") + "?UserMode=" + nUserMode),
                                     "SkillInfo","","","","","_UTL_Manager_SelectEmployee_AfterModal");
}

function _UTL_Manager_SelectEmployee_AfterModal(strRetVal)
{
    //
    // Reload page
    //
    if ( strRetVal != "" && String(strRetVal) != "undefined")
        window.location = _UTL_GetPagePath("management/LMS_LearnerHome.asp?UserMode="+g_nUserMode) ;


}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name :
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
//   Author mode project selection
//
/////////////////////////////////////////////////////////////////////////////
function _UTL_Author_SelectProject(nUserMode)
{

    var strRetVal     = "";
    var guidProjectID = "";
    var strRefUrl     = "";
    var rgList        = null;

    strRetVal = _UTL_OpenModalWindow(_UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(_UTL_GetPagePath("authoring/CDS_ProjectSelect.asp") + "?Persist=yes&UserMode=" + nUserMode),"ProjectInfo");

    //
    // Reload page
    //
    if ( strRetVal != "" && String(strRetVal) != "undefined")
    {
        rgList = strRetVal.split(",");
        window.location = _UTL_GetCorePagePath("authoring/admin/projects/select_project.asp")
                            + "?txtProjectID=" + rgList[0] + "&refURL=" + escape(rgList[1]);

        rgList = null;
    }



}
/////////////////////////////////////////////////////////////////////////////
//
// Function Name :
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
//   Author mode learning object selection
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_Author_RefreshTree()
{
    top.location = top.location;
}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : ObjHtmlTable support client side functions
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////



function _UTL_HtmlTable_RowTouched(evt)
{
    var objElement  = SYS_Browser_GetEventTarget(evt);
    
    if( objElement )
    {
        if( objElement.parentNode && objElement.parentNode.parentNode )
            var objTableRow = objElement.parentNode.parentNode;    
    
        if ( objElement.type == "radio" )
                    _UTL_HtmlTable_RowUnTouchAll(evt);
        
        if ( objElement.checked )
        {
            if(objTableRow)
                if ( objTableRow.className == "clsTableRowOdd" )
                    objTableRow.className = "clsTableRowSelectedOdd";
                else if ( objTableRow.className == "clsTableRowEven" )
                    objTableRow.className = "clsTableRowSelectedEven";
        }
        else
        {
            if(objTableRow)
                if ( objTableRow.className == "clsTableRowSelectedOdd" )
                    objTableRow.className = "clsTableRowOdd";
                else if ( objTableRow.className == "clsTableRowSelectedEven" )
                    objTableRow.className = "clsTableRowEven";
        }
    }

    //cart operation
    if ( typeof(bIsCartPresent) != "undefined" )
    {
        if(objTableRow)
            var strRowId = objTableRow.id;

        var iIndex = 0;
        if(strRowId)
            if (strRowId.indexOf("_") == -1)
            {
                iIndex = Math.round (strRowId.substring(3));
            }
            else
            {
                iIndex = Math.round(strRowId.substring(strRowId.indexOf("Row") + 3, strRowId.indexOf("_")));
            }

        Cart_CheckClick( objElement, iIndex );
    }
    //end cart operation
}



function _UTL_HtmlTable_RowUnTouchAll(evt)
{
    var objEvtTarget  = SYS_Browser_GetEventTarget(evt);    
    var objTable      = objEvtTarget.parentNode.parentNode.parentNode ;
    var objTableRow   = objTable.childNodes

    for ( var i = 0 ; i < objTableRow.length ; i++ )
    {
        if ( objTableRow[i].className == "clsTableRowSelectedOdd" )
            objTableRow[i].className = "clsTableRowOdd";

        if ( objTableRow[i].className == "clsTableRowSelectedEven" )
            objTableRow[i].className = "clsTableRowEven";
    }

    //cart operation
    if ( typeof(bIsCartPresent) != "undefined" )
    {
        Cart_RemoveAll();
    }
    //end cart operation
}

function _UTL_HtmlTable_RowUnTouchAllEx(strTableName,strForm,strType)
{

    var objTable      = document.getElementById(strTableName);
    var objTableRow   = null;

    //
    // Check if table exists before doing anything
    //
    if ( objTable )
    {
        objTableRow   = objTable.getElementsByTagName("TR");

        for ( var i = 0 ; i < objTableRow.length ; i++ )
        {
            if ( objTableRow[i].className == "clsTableRowSelectedOdd" )
                objTableRow[i].className = "clsTableRowOdd";

            if ( objTableRow[i].className == "clsTableRowSelectedEven" )
                objTableRow[i].className = "clsTableRowEven";
        }
    }

    //cart operation
    if ( typeof(bIsCartPresent) != "undefined" )
    {
        Cart_RemoveAll();
    }
    //end cart operation

}

// This function is created as a replacement for '_UTL_HtmlTable_RowTouchedAll'.
// For coloring of rows to work fine, event parameter needs to be passed in
// and it should be passed in only as a first parameter. Since '_UTL_HtmlTable_RowTouchedAll'
// is used in a large number of files (~185 files), it can not be simply replaced.
function _UTL_HtmlTable_RowTouchedSelectAll(evt, strType, el, strForm, bCheckForCart) 
{
   return _UTL_HtmlTable_RowTouchedAll(strType, el, strForm, bCheckForCart, evt);
}

function _UTL_HtmlTable_RowTouchedAll(strType, el, strForm, bCheckForCart, evt) 
{
    var objTR         = "";
    var objTable      = "";
    var objEvtTarget  = "";
    var bFlag         = "";
    var objTemp       = "";
    var bSkippedFirst = "";

    evt = SYS_Browser_GetEventObject(evt);
    objEvtTarget = SYS_Browser_GetEventTarget(evt);
        
    objTable      = objEvtTarget.parentNode.parentNode.parentNode;
    objTR         = objTable.childNodes;
    bFlag         = objEvtTarget.checked ;
    objTemp       = null ;
    bSkippedFirst = false ;

    /*
     * Loop through the list, find all TR and set the color and
     * selection for the input
    */
    for ( var i = 0 ; i < objTR.length ; i++ )
    {
        objTemp = objTR.item(i);

        if ( objTemp.tagName == "TR" )
        {
            if ( objTemp.getElementsByTagName("INPUT").length > 0 && 
                (objTemp.getElementsByTagName("INPUT")[0].type == "checkbox") && 
                (objTemp.getElementsByTagName("INPUT")[0].disabled != "true"))
            {
                if ( bSkippedFirst == false )
                {
                    bSkippedFirst = true ;
                    continue ;
                }// end skip check
                if ( bFlag )
                {
                    if ( (i % 2) == 0 )
                        objTemp.className = "clsTableRowSelectedOdd";
                     else
                        objTemp.className = "clsTableRowSelectedEven";
                }
                else
                {
                    if ( (i % 2) == 0 )
                        objTemp.className = "clsTableRowOdd";
                    else
                        objTemp.className = "clsTableRowEven";

                }// end table even check
            }
            else
            {
                if (objTemp.className != "clsTableHeadingRow")
                {
                    if ( (i % 2) == 0 )
                        objTemp.className = "clsTableRowOdd";
                    else
                        objTemp.className = "clsTableRowEven";
                }
            }
        }// end TR check
    }// end for length loop
  
    objTR = objTable.getElementsByTagName("INPUT") ; 
     
    iTypeLen = strType.length;
    
    for ( var i = 0 ; i < objTR.length ; i++ )
    {
        objTemp = objTR[i];     // making square brackets

        if ( objTemp.type == "checkbox"
             && objTemp.name.substring(0,iTypeLen) == strType
             && !objTemp.disabled ) // removed the tagname check
        {
            objTemp.checked = bFlag ;
        }// end checkbox test
    }// end loop

    // Extra condition check is put so that select all functionality can exist without cart functionality. 
    if ((typeof (bCheckForCart) == "undefined") || 
        ((typeof (bCheckForCart) != "undefined") && (String(bCheckForCart) == "true")))
    {    
        // cart operations.
        if ( typeof( bIsCartPresent ) != "undefined" )
        {
            Cart_CheckClickAll( el , strType );
        }
        //end cart operations.
    }

}

function _UTL_HtmlTable_GetCheckedData(strForm, strTable, strName, bIsRadio)
{
    var objTable      = document.getElementById(strTable); 
    var objTR         = null ;
    var objTemp       = null ;
    var strList       = "";

    if ( bIsRadio == null )
        bIsRadio = false;

    // Check if anything has been selected before submitting form
    if (objTable == null )                                                             
        return "";

    objTR = objTable.getElementsByTagName("INPUT") ; 

    for ( var i = 0 ; i < objTR.length ; i++ )
    {
        objTemp = objTR[i]; // Using Square Brackets

        if ( !bIsRadio )
        {
            if ( objTemp.type == "checkbox" && objTemp.name == strName && objTemp.checked )
                strList += objTemp.value + ",";
        }
        else
        {
            if ( objTemp.type == "radio" && objTemp.name == strName && objTemp.checked ) 
                strList = objTemp.value ;
        }
    }
    
    return strList ;
}


function _UTL_HtmlTable_GetSelectedCheckedData(strForm, strTable, strName, bIsRadio, strPropName)
{
    var objForm       = document.forms[strForm];    // Accessing through forms collection
    var objTable      = document.getElementById(strTable);                      
    var objTR         = null ;
    var objTemp       = null ;
    var strList       = "";

    if ( bIsRadio == null ) bIsRadio = false;
    //
    // Check if anything has been selected before submitting form
    //

    if ( objTable == null )                                                                               // For Netscape ignore this check
        return "";

    objTR =  objTable.getElementsByTagName("INPUT") ;                            
    for ( var i = 0 ; i < objTR.length ; i++ )
    {
        objTemp = objTR[i]; // Using Square Brackets

        if ( !bIsRadio )
        {
            if ( objTemp.type == "checkbox" && objTemp.name == strName && objTemp.checked ) 
            {
                if( typeof( objTemp.getAttribute(strPropName) ) != "undefined" && objTemp.getAttribute(strPropName).length > 0 )
                {
                    strList += objTemp.getAttribute(strPropName) + ";";
                }
            }
        }
        else
        {
             if ( objTemp.type == "radio" && objTemp.name == strName && objTemp.checked ) // Removed the tagName check for Netscae compatibility
            {
                strList = objTemp[strPropName];
            }
        }
    }
    return strList ;
}


/////////////////////////////////////////////////////////////////////////////
//
// Function Name : Search support client side functions
//
// Parameters    : strAspLink   -- Either a link to an ASP document or a JavaScript statement
//                                  that performs the search operation.
//                 strForm      -- the name of the form containing the search box
//                                  (required for netscape 4.x ignored for others)
//                 bLinkIsJS    -- false - strAspLink refers to an ASP document
//                                 true  - strAspLink is a JavaScript statement to be evaluated
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_SearchBox_Search(strAspLink,strForm,bLinkIsJS)  // Added the strForm Argument to generalize this function for Netscape
{
    // When strAspLink is JavaScript code, then it does all the work -- just call it and return.
    if ( bLinkIsJS )    // Will be false if the parameter is undefined
    {
        //1-19-06 MinJie replaced eval with wrapper
        SYS_SEC_EvalHtmlCodeBlock( strAspLink );
        return;
    }

    var objSearch = document.getElementsByName("SearchStrInput")[0] ;
    var strTerm   = _UTL_Trim(objSearch.value);


    //
    // If the advanced search data exists clear this before continuing search
    //
    if ( typeof(_UTL_AdvSearchClear) != "undefined" )
    {
        //1-19-06 MinJie replaced eval with squarebracket
        var strObjForm = (strForm.indexOf('document')>0 || 
                          strForm.indexOf('window')>0 ) ?
                          SYS_SEC_EvalHtmlCodeBlock(strForm) : document[strForm] ;
        _UTL_AdvSearchClear(strObjForm);
    }

    // if form is defined use it for posting.
    if ( strForm )
    {
        //1-19-06 MinJie replaced eval with squarebracket
        var objForm = (strForm.indexOf('document')>0 || 
                          strForm.indexOf('window')>0 ) ?
                          SYS_SEC_EvalHtmlCodeBlock(strForm) : document[strForm] ;
        //var objForm = eval (strObjForm );
        objForm.action = strAspLink + "&SearchStr=" + escape(strTerm);
    
        //check if the cart is defined
        if ( typeof(bIsCartPresent) != "undefined" )
        {
            //for search functionality, make 'current page' equal to 1 deliberately
            //otherwise, search will not work if 'current page' is more than 1
            if(typeof(objForm.CurrentPage) != "undefined")
                objForm.CurrentPage.value = 1;

            Cart_SetCartFormValue( objForm );
            objForm.submit();
            return;
        }

    }

    window.location  = strAspLink + "&SearchStr=" + escape(strTerm);
}

function _UTL_SearchBox_SearchStr(strForm)  // could not find the calling function. Udpdating for Netscape compatibility
{

    var objSearch = document.getElementsByName("SearchStrInput")[0] ;
    var strTerm   = _UTL_Trim(objSearch.value);

    return strTerm ;

}

// This function is created as a replacement for '_UTL_SearchBox_SearchKP'.
// For coloring of rows to work fine, event parameter needs to be passed in
// and it should be passed in only as a first parameter. Since '_UTL_SearchBox_SearchKP'
// is used in a large number of files, it can not be simply replaced.
function _UTL_SearchBox_SearchEvt(evt, strAspLink,strForm,bLinkIsJS)    // Added the strForm Argument
{
    return _UTL_SearchBox_SearchKP(strAspLink,strForm,bLinkIsJS,evt);  
}

function _UTL_SearchBox_SearchKP(strAspLink,strForm,bLinkIsJS,evt)    // Added the strForm Argument
{

    var objSearch = document.getElementsByName("SearchStrInput")[0] ;
    //
    // Event handler for key press
    //
    if ( _UTL_EnterPressed(evt) )
    {
         _UTL_SearchBox_Search(strAspLink,strForm,bLinkIsJS);     // Added the strForm Argument
         
         SYS_Browser_StopEventPropagation(evt);
         
    }
    return false ;
}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : ObjHtmlDate support client side functions
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////

var g_UTL_DaysInMonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

function _UTL_HtmlDate_GetDays(month, year)
{
    //
    // Test for leap year when February is selected.
    //
    if (1 == month)
        return ((0 == year % 4) && (0 != (year % 100))) || (0 == year % 400) ? 29 : 28;
    else
        return g_UTL_DaysInMonth[month];
}

function _UTL_HtmlDate_YearChanged(strId,el,bRequiresNone,bRequiresNull)
{
    var objForm     = el.form;// gives the reference to the elements form
    var objTemp     = "";
    var sName       = "";
    var iDays       = "";
    var iDay        = "";
    var iMonth      = "";
    var iYear       = "";
    var objDayList  = "";

    for ( var i = 0 ; i < objForm.length ; i++ )
    {

        objTemp = objForm[i];   // Using Square Brackets
        sName = objTemp.name;

        if ( objTemp.type == "select-one")  // Removed the tagName check for Netscae compatibility
        {
         if (sName.indexOf(strId) > 0)
         {
            if (sName.indexOf('year') >= 0)     iYear       = parseInt(objTemp.options[objTemp.options.selectedIndex].value);
            if (sName.indexOf('month') >= 0)    iMonth      = parseInt(objTemp.options[objTemp.options.selectedIndex].value);
         } // end check strId
        }// end check type
    }

    if((bRequiresNone && !bRequiresNull) ||(!bRequiresNone && bRequiresNull))
    {
        if(iYear == -1 )
        {
                for ( var i = 0 ; i < objForm.length ; i++ )
                {

                    objTemp = objForm[i];   // Using Square Brackets
                    sName = objTemp.name;

                    if ( objTemp.type == "select-one")  // Removed the tagName check for Netscae compatibility
                    {
                        if (sName.indexOf(strId) > 0)
                        {
                           if (sName.indexOf('month') >= 0)    objTemp.options.selectedIndex = 0;
                           if (sName.indexOf('year') >= 0)     objTemp.options.selectedIndex = 0;
                           if (sName.indexOf('day') >= 0)      objTemp.options.selectedIndex = 0;

                        } // end check strId
                    }// end check type
                }

                return;
        }

    }

    if(bRequiresNone && bRequiresNull)
    {
        for ( var i = 0 ; i < objForm.length ; i++ )
        {
            objTemp = objForm[i];   // Using Square Brackets
            sName = objTemp.name;

            if ( objTemp.type == "select-one")  // Removed the tagName check for Netscae compatibility
            {
                if (sName.indexOf(strId) > 0)
                {
                   if(iYear == -1 )
                   {
                    if (sName.indexOf('month') >= 0)    objTemp.options.selectedIndex = 1;
                    if (sName.indexOf('year') >= 0)     objTemp.options.selectedIndex = 1;
                    if (sName.indexOf('day') >= 0)      objTemp.options.selectedIndex = 1;

                   }
                   else if(iYear == -2)
                   {
                    if (sName.indexOf('month') >= 0)    objTemp.options.selectedIndex = 0;
                    if (sName.indexOf('year') >= 0)     objTemp.options.selectedIndex = 0;
                    if (sName.indexOf('day') >= 0)      objTemp.options.selectedIndex = 0;

                   }

                } // end check strId
            }// end check type
         }
        if(iYear == -1 || iYear == -2 )
            return;
    }

    if(iMonth>0)
        _UTL_HtmlDate_MonthChanged(strId,el,bRequiresNone,bRequiresNull);

}

function _UTL_HtmlDate_MonthChanged(strId,el,bRequiresNone,bRequiresNull)
{
    var objForm     = el.form;// gives the reference to the elements form
    var objTemp     = "";
    var sName       = "";
    var iDays       = "";
    var iDay        = "";
    var iMonth      = "";
    var iYear       = "";
    var objDayList  = "";
    var nOffSet     = 0;

    for ( var i = 0 ; i < objForm.length ; i++ )
    {

        objTemp = objForm[i];   // Using Square Brackets
        sName = objTemp.name;

        if ( objTemp.type == "select-one")  // Removed the tagName check for Netscae compatibility
        {
         if (sName.indexOf(strId) > 0)
         {
        if (sName.indexOf('month') >= 0)    iMonth      = parseInt(objTemp.options[objTemp.options.selectedIndex].value);
        if (sName.indexOf('year') >= 0)     iYear       = parseInt(objTemp.options[objTemp.options.selectedIndex].value);
        if (sName.indexOf('day') >= 0)      { objDayList  = objTemp;}// iDay = parseInt(objTemp.options[objTemp.options.selectedIndex].value);}
         } // end check strId
        }// end check type
    }

    if((bRequiresNone && !bRequiresNull) ||(!bRequiresNone && bRequiresNull))
    {
        if(iMonth == -1 )
        {
                for ( var i = 0 ; i < objForm.length ; i++ )
                {

                    objTemp = objForm[i];   // Using Square Brackets
                    sName = objTemp.name;

                    if ( objTemp.type == "select-one")  // Removed the tagName check for Netscae compatibility
                    {
                        if (sName.indexOf(strId) > 0)
                        {
                           if (sName.indexOf('month') >= 0)    objTemp.options.selectedIndex = 0;
                           if (sName.indexOf('year') >= 0)     objTemp.options.selectedIndex = 0;
                           if (sName.indexOf('day') >= 0)      objTemp.options.selectedIndex = 0;

                        } // end check strId
                    }// end check type
                }
                return;
        }

    }


    if(bRequiresNone && bRequiresNull)
    {
        for ( var i = 0 ; i < objForm.length ; i++ )
        {
            objTemp = objForm[i];   // Using Square Brackets
            sName = objTemp.name;

            if ( objTemp.type == "select-one")  // Removed the tagName check for Netscae compatibility
            {
                if (sName.indexOf(strId) > 0)
                {
                   if(iMonth == -1 )
                   {
                    if (sName.indexOf('month') >= 0)    objTemp.options.selectedIndex = 1;
                    if (sName.indexOf('year') >= 0)     objTemp.options.selectedIndex = 1;
                    if (sName.indexOf('day') >= 0)      objTemp.options.selectedIndex = 1;

                   }
                   else if(iMonth == -2)
                   {
                    if (sName.indexOf('month') >= 0)    objTemp.options.selectedIndex = 0;
                    if (sName.indexOf('year') >= 0)     objTemp.options.selectedIndex = 0;
                    if (sName.indexOf('day') >= 0)      objTemp.options.selectedIndex = 0;

                   }

                } // end check strId
            }// end check type
         }
        if(iMonth == -1 || iMonth == -2 )
        return;
    }


    iDays      = _UTL_HtmlDate_GetDays(iMonth, iYear,bRequiresNone,bRequiresNull);

    //
    // Remove all existing options
    //
    if(bRequiresNone && bRequiresNull){
        while (objDayList.options.length > 2)
            objDayList.options[objDayList.options.length - 1] = null;
        nOffSet = 2;
    }
    else if(bRequiresNone && !bRequiresNull){
        while (objDayList.options.length > 1)
            objDayList.options[objDayList.options.length - 1] = null;
        nOffSet = 1;
    }
    else if(!bRequiresNone && bRequiresNull){
        while (objDayList.options.length > 1)
            objDayList.options[objDayList.options.length - 1] = null;
         nOffSet = 1;
    }
    else{
        while (objDayList.options.length)
            objDayList.options[0] = null;
         nOffSet=0;
    }

    for (iDay = (nOffSet + 1) ; iDay <= (iDays + nOffSet) ; iDay++)
    {
        objDay       = new Option;
        objDay.value = (iDay - nOffSet);
        objDay.text  = (iDay - nOffSet);
        objDayList.options[iDay -1] = objDay;
    }

    if(bRequiresNone && bRequiresNull){
        objDayList.options.selectedIndex = 2;
    }
    else if(bRequiresNone && !bRequiresNull){
        objDayList.options.selectedIndex = 1;
    }
    else if(!bRequiresNone && bRequiresNull){
        objDayList.options.selectedIndex = 1;
    }
    else{
        objDayList.options.selectedIndex = 0;
    }


}

function _UTL_DATE_GetCurrentDate(objDate)
{
//This function takes a date object as a parameter.  If objDate is null, then it takes in current 
//date and formats the date to the way the calendar control wants the date input.  This function is to be used
//when default dates are needed for PopCalendar control.
    var strDate = "";
    var dtNew   = objDate;

    strDate = (dtNew.getMonth() + 1).toString().replace(/(^[0-9]$)/g, "0$1") + L_Info_DateSep +
                dtNew.getDate().toString().replace(/(^[0-9]$)/g, "0$1") + L_Info_DateSep +
                dtNew.getFullYear().toString() + " ";

    var nd = objDate;
    var h=nd.getHours(), m=nd.getMinutes(), ampmSign=h>11?L_Info_ClockPM:L_Info_ClockAM;
    var _inc=5;

    if ((h>12||h==0)) h=Math.abs(h-12);
    m = Math.floor(m/_inc)*_inc;

    h = parseInt(h, 10);
    h = h<10?'0'+h:h;

    m = parseInt(m,10);
    m = m<10?'0'+m:m;

    strDate = strDate + h + L_Info_TimeSep + m + ampmSign;  

    return strDate ;

}

function _UTL_HtmlDate_DayChanged(strId,el,bRequiresNone,bRequiresNull)
{
    var objForm     = el.form;// gives the reference to the elements form
    var objTemp     = "";
    var sName       = "";
    var iDays       = "";
    var iDay        = "";
    var iMonth      = "";
    var iYear       = "";
    var objDayList  = "";

    for ( var i = 0 ; i < objForm.length ; i++ )
    {

        objTemp = objForm[i];   // Using Square Brackets
        sName = objTemp.name;

        if ( objTemp.type == "select-one")  // Removed the tagName check for Netscae compatibility
        {
         if (sName.indexOf(strId) > 0)
         {
            if (sName.indexOf('day') >= 0)      iDay        = parseInt(objTemp.options[objTemp.options.selectedIndex].value);
         } // end check strId
        }// end check type
    }


    if((bRequiresNone && !bRequiresNull) ||(!bRequiresNone && bRequiresNull))
    {
        if(iDay == -1 )
        {
                for ( var i = 0 ; i < objForm.length ; i++ )
                {

                    objTemp = objForm[i];   // Using Square Brackets
                    sName = objTemp.name;

                    if ( objTemp.type == "select-one")  // Removed the tagName check for Netscae compatibility
                    {
                        if (sName.indexOf(strId) > 0)
                        {
                           if (sName.indexOf('month') >= 0)    objTemp.options.selectedIndex = 0;
                           if (sName.indexOf('year') >= 0)     objTemp.options.selectedIndex = 0;
                           if (sName.indexOf('day') >= 0)      objTemp.options.selectedIndex = 0;

                        } // end check strId
                    }// end check type
                }
        }
        return;
    }

    if(bRequiresNone && bRequiresNull)
    {
        for ( var i = 0 ; i < objForm.length ; i++ )
        {
            objTemp = objForm[i];   // Using Square Brackets
            sName = objTemp.name;

            if ( objTemp.type == "select-one")  // Removed the tagName check for Netscae compatibility
            {
                if (sName.indexOf(strId) > 0)
                {
                   if(iDay == -1 )
                   {
                    if (sName.indexOf('month') >= 0)    objTemp.options.selectedIndex = 1;
                    if (sName.indexOf('year') >= 0)     objTemp.options.selectedIndex = 1;
                    if (sName.indexOf('day') >= 0)      objTemp.options.selectedIndex = 1;

                   }
                   else if(iDay == -2)
                   {
                    if (sName.indexOf('month') >= 0)    objTemp.options.selectedIndex = 0;
                    if (sName.indexOf('year') >= 0)     objTemp.options.selectedIndex = 0;
                    if (sName.indexOf('day') >= 0)      objTemp.options.selectedIndex = 0;

                   }

                } // end check strId
            }// end check type
         }
        return;
    }

}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : ObjHtmlInfoBox support client side functions
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_HtmlInfoBox_Toggle_Close(strName, strOpenAlt)
{

    var objBoxHT  = document.getElementById(strName+"-headtbl");
    var objBoxHLI = document.getElementById(strName+"-headlimg");
    var objBoxHRI = document.getElementById(strName+"-headrimg");
    var objBoxDD  = document.getElementById(strName+"-datadiv");


    if ( objBoxDD.style.display == "" )
    {
        objBoxHT.className     = "clsBoxHeaderClosed";
        objBoxHLI.src          = g_imgHtmlInfoBoxLC.src ;
        objBoxHRI.src          = g_imgHtmlInfoBoxRC.src ;
        objBoxHRI.alt          = strOpenAlt ;
        objBoxHRI.title        = strOpenAlt ;
        objBoxDD.style.display = "none";
    }
}

function _UTL_HtmlInfoBox_Toggle_Open (strName, strCloseAlt)
{

    var objBoxHT  = document.getElementById(strName+"-headtbl");
    var objBoxHLI = document.getElementById(strName+"-headlimg");
    var objBoxHRI = document.getElementById(strName+"-headrimg");
    var objBoxDD  = document.getElementById(strName+"-datadiv");


    if ( objBoxDD.style.display != "" )
    {
        objBoxHT.className     = "clsBoxHeaderOpen";
        objBoxHLI.src          = g_imgHtmlInfoBoxLO.src ;
        objBoxHRI.src          = g_imgHtmlInfoBoxRO.src ;
        objBoxHRI.alt          = strCloseAlt ;
        objBoxHRI.title        = strCloseAlt ;
        objBoxDD.style.display = "";
    }
}

function _UTL_HtmlInfoBox_Toggle(strName, strOpenAlt, strCloseAlt,parentElement)
{

    var objBoxHT  = document.getElementById(strName+"-headtbl");
    var objBoxHLI = document.getElementById(strName+"-headlimg");
    var objBoxHRI = document.getElementById(strName+"-headrimg");
    var objBoxDD  = document.getElementById(strName+"-datadiv");

    if ( objBoxDD.style.display == "" )
        _UTL_HtmlInfoBox_Toggle_Close(strName, strOpenAlt);
    else
        _UTL_HtmlInfoBox_Toggle_Open(strName, strCloseAlt);
}

function _UTL_HtmlInfoBox_Toggle_ExpandAll(strName,strList,strAlt)
{
    var arrList = strList.split(',');

    for ( var i = 0 ; i < arrList.length ; i++ )
    {
        _UTL_HtmlInfoBox_Toggle_Open(strName+arrList[i], strAlt);
    }// end for
}

function _UTL_HtmlInfoBox_Toggle_CollapseAll(strName,strList,strAlt)
{
    var arrList = strList.split(',');

    for ( var i = 0 ; i < arrList.length ; i++ )
    {
        _UTL_HtmlInfoBox_Toggle_Close(strName+arrList[i], strAlt);
    }// end for
}

function _UTL_HtmlInfoBox_getIndex(el) { // This function gets the id of an element from the layer collection
    ind = null;
    for (i=0; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        if (whichEl.id == el) {
            ind = i;
            break;
        }
    }
    return ind;
}

function _UTL_HtmlInfoBox_arrange(firstInd) {
    var nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.height;
    for (i=firstInd+1; i<document.layers.length; i++) {
        var whichEl = document.layers[i];
        if (whichEl.visibility != "hide") {
            whichEl.pageY = nextY;
            nextY += whichEl.document.height + 2;
        }
    }
}

function _UTL_HtmlInfoBox_getDivNames(strName)       // removes all "-"from the name
{
    var str = "";
    str = strName.replace(/-/g,"") ;//str + arrTemp[i]
    return str;
}


//
// ObjForm Object
//
// ObjForm wraps a user form in HTML and performs validation against the fields
//     in the form.
//
function ObjForm(p_strFormName, p_strValidationHeader, nMaxErrors) {

    var m_objPageForm   = null;
    var m_objFocusField = null;
    var m_strMessage    = '';
    var m_strHeader     = p_strValidationHeader;
    var m_bIsValid      = true;
    var m_nCurErrors    = 0 ;
    var m_nMaxErrors    = 5 ;

    if ( typeof(nMaxErrors) != "undefined" )
        m_nMaxErrors = nMaxErrors;


    //
    // code modified to work in both IE and Netscape
    //
    //1-19-06 MinJie replaced eval with squarebracket
    m_objPageForm = document.forms[p_strFormName];

    //
    // DOES NOT display messages that have accumulated due to
    // validation checking. Returns a boolean indicating
    // the validation state of the form.
    //
    ObjForm.prototype.CheckValidityOnly = function() {
        return m_bIsValid;
    }
    //To access QueueValidationError outside this object.
    ObjForm.prototype.QueueValidationError = SYS_UTL_QueueValidationError;

    //
    // displays any messages that have accumulated due to
    // validation checking. returns a boolean indicating
    // the validation state of the form.
    //
    ObjForm.prototype.CheckValidity = function() 
    {
        if (!m_bIsValid) 
        {
            alert(m_strMessage);

            if( !m_objFocusField )
                return;
            
            if( m_objFocusField.type && m_objFocusField.type.toLowerCase() == "hidden" )
                return;
                
            if (m_objFocusField.disabled == false)
            {
                m_objFocusField.focus();
            }
        }

        return m_bIsValid;
    }
    

    //
    // sets the default value of a field if it's left blank
    //
    ObjForm.prototype.SetDefaultValue = function(   p_strFieldName,
                                                    p_strDefault) {
        //1-19-06 MinJie replaced eval with squarebracket
        var objField = m_objPageForm[p_strFieldName];
        var strValue = _UTL_Trim(objField.value);

        if (strValue.match(/[^.]/) == null) {
            objField.value = p_strDefault;
        }
    }

    //
    // validates a field according to the maximum length of the field.
    //
    ObjForm.prototype.ValidateLength = function(    p_strFieldName,
                                                    p_iLength,
                                                    p_strViolationMessage) {

        var bRetValue = false;
        var objField = m_objPageForm[p_strFieldName];
        var strValue = _UTL_Trim(objField.value);

        if (strValue.length > p_iLength) {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
            bRetValue = true;
        }
        return bRetValue;
    }
    //
    // validates a field according to the length greater than the specified length and check it is only digit fro the spacified start positon of the text.
    //
    ObjForm.prototype.ValidateDigitLength = function(    p_strFieldName,
                                                    p_iLength,p_StPos,
                                                    p_strViolationMessage) {
        var bRetValue = false;
        var objField = eval('m_objPageForm.' + p_strFieldName);
        var strValue = _UTL_Trim(objField.value);
        if (strValue.length != p_iLength || !isNumeric(strValue,p_StPos)) {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
            bRetValue = true;
        }
        return bRetValue;
    }
    
    ObjForm.prototype.ValidateNotEmpty = function( p_strFieldName,  p_strViolationMessage )
    {
        //1-19-06 MinJie replaced eval with squarebracket
        var bRetValue = false;
        var objField  = m_objPageForm[p_strFieldName];
        var strValue  = _UTL_Trim(objField.value);
        
        if( strValue.length == 0 )
        {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
            bRetValue = true;
        }
        return bRetValue;
    
    }


    //
    // Validates a floating point field, it also checks for a valid range of values
    // if needed.
    //
    ObjForm.prototype.ValidateFloat = function( p_strFieldName,
                                                p_strViolationMessage,
                                                bRequired,
                                                p_fMinValue,
                                                p_fMaxValue )
    {
        //1-19-06 MinJie replaced eval with squarebracket
        var bRetValue = false;
        var objField = m_objPageForm[p_strFieldName];
        var strValue = _UTL_Trim(objField.value);

        if( typeof( bRequired ) == "undefined" )
            bRequired = false;

        if( strValue.length > 0 )
        {
            var fValue = parseFloat( strValue );

            //
            // Validate range
            //
            if( typeof( p_fMinValue ) == "number" && typeof( p_fMaxValue ) == "number" )
            {
                if( fValue < p_fMinValue || fValue > p_fMaxValue )
                {
                    SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
                    bRetValue = true;
                }
            }
            //
            // If return value has already been made true ie; is not a valid float
            // then we dont want to queue up the other errors with the same message.
            //
            if( !bRetValue )
            {
            //
            // Validate length and allowed characters, assume that we allow a maximum of 4 decimal digits and
            // 7 integral digits.
            //
            if( !isFinite( fValue ) )
            {
                SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
                bRetValue = true;
            }                
            else
                {
                bRetValue = this.ValidateText( p_strFieldName, /^[+]?([0-9]{1,7})?(\.[0-9]{1,4})?$/, p_strViolationMessage);
        }
            }
        }
        else if( bRequired )
        {
            // Required field message
            SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
            bRetValue = true;
        }
        return bRetValue;
    }

    ObjForm.prototype.ValidateInteger = function( p_strFieldName, p_strViolationMessage, bRequired, p_fMinValue, p_fMaxValue )
    {
        //1-19-06 MinJie replaced eval with squarebracket
        var objField = m_objPageForm[p_strFieldName];
        var strValue = _UTL_Trim(objField.value);
        var bRetValue = false;

        if( typeof( bRequired ) == "undefined" )
            bRequired = false;

        if( strValue.length > 0 )
        {
            var fValue = parseInt( strValue,10 );
            //
            // Validate range
            //
            if( typeof( p_fMinValue ) == "number" )//&& typeof( p_fMaxValue ) == "number" )
            {
                if( fValue < p_fMinValue)// || fValue > p_fMaxValue )
                {
                    SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
                    bRetValue = true;
                }
            }    
            if( typeof( p_fMaxValue ) == "number" )   
            {
                if( fValue > p_fMaxValue )
                {
                    SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
                    bRetValue = true;
                }
            }
            var iInteger = parseInt( strValue );
            if( iInteger > 2147483647 || iInteger < -2147483648 )
            {
                SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
                bRetValue = true;
            }
            else
            {
                bRetValue = this.ValidateText( p_strFieldName, /^[+-]?([0-9]{1,7})$/, p_strViolationMessage);
            }
        }
        else if( bRequired )
        {
            // Required field message
            SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
            bRetValue = true;
        }
        return bRetValue;
    }

    ObjForm.prototype.ValidateMoney = function( p_strFieldName, p_strViolationMessage, bRequired, iNumDecimals, bAllowNegative )
    {
        //1-19-06 MinJie replaced eval with squarebracket
        var objField = m_objPageForm[p_strFieldName];
        var strValue = _UTL_Trim(objField.value);
        var bRetValue = false;

        var CNST_MAX_MONEY=9999999999999.99;
        var CNST_MIN_MONEY=-9999999999999.99;
        // Note: To overcome a bug in ADO, we need to set the maximum allowed money value to 
        // 922337203685473 instead of the SQL documented 922,337,203,685,477.5807. In ADO, passing 
        // a number > 922337203685473 will cause rounding issues on the number that gets stored.
        var CNST_MAX_ADO_MONEY=922337203685473;
        var regExMoney=/^[+]?([0-9]{1,13})?(\.[0-9]{1,2})?$/;
        
        if( typeof( bRequired ) == "undefined" )
            bRequired = false;
            
        if( typeof( iNumDecimals ) == "undefined" )
            iNumDecimals = 2;
            
        if( typeof( bAllowNegative ) == "undefined" )
            bAllowNegative = false;
            
        if( strValue.length > 0 )
        {
            var iMoney = parseFloat(_UTL_Trim(strValue)) ;
            if (bAllowNegative)
            {
                if( iMoney > CNST_MAX_MONEY || iMoney < CNST_MIN_MONEY )
                {
                    SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
                    bRetValue = true;
                }   
            }
            else
            {
                if( iMoney > CNST_MAX_MONEY || iMoney < 0 )
                {
                    SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
                    bRetValue = true;
                }
                else
                {
                    bRetValue = this.ValidateText( p_strFieldName, regExMoney, p_strViolationMessage);
                }
            }
        }
        else if( bRequired )
        {
            // Required field message
            SYS_UTL_QueueValidationError( objField, p_strViolationMessage );
            bRetValue = true;
        }
        return bRetValue;
    }


    //
    // validates a date field in the form for proper date.
    //
    ObjForm.prototype.ValidateDate = function(    p_strYear,
                                                  p_strMonth,
                                                  p_strDay,
                                                  p_strFieldName,
                                                  p_strViolationMessage) {
        var strValue = 1;
        var dt;
        var bRetValue = false;
        
        if (! ((p_strYear == -1 ) || (p_strMonth == -1) || (p_strDay == -1)) )
        {
            var dt = new Date(p_strYear, p_strMonth, p_strDay);
            if( ! isNaN(dt)) {
                strValue = 0;
            }
        }

        //1-19-06 MinJie replaced eval with squarebracket
        var objField = m_objPageForm.elements(p_strFieldName);

        if (strValue) {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
            bRetValue = true;
        }
        return bRetValue;
    }

    //
    // compares two given dates, returns validation message if the first date is earlier than the first date
    //
    ObjForm.prototype.CompareDate = function( strValue1, strValue2, strFieldName, strViolationMessage){

        var dt1 = new Date(strValue1);
        var dt2 = new Date(strValue2);
        var strValue = 0;

        if(isNaN(dt1))
        {
         //pick the date value as today's date
         dt1 = new Date();
        }

        if(isNaN(dt2))
        {
         //pick the date value as today's date
         dt2 = new Date();
        }

        if(dt1 < dt2)
        {
            strValue = 1 ;
        }

        //1-19-06 MinJie replaced eval with squarebracket
        var objField = m_objPageForm.elements(strFieldName);
        if (strValue) {
            SYS_UTL_QueueValidationError(objField, strViolationMessage);
            return;
        }
    }

    ObjForm.prototype.ValidateDateRange = function( strDateRangeFieldName, strMsgNullStDate, strMsgNullEndDate, strMsgDatesOutOfRange )
    {
        var objFormElements = m_objPageForm.elements;
        var strStartDt      = objFormElements[ "rangedate__" + strDateRangeFieldName + "1" ].value;
        var strEndDt        = objFormElements[ "rangedate__" + strDateRangeFieldName + "2" ].value;   
        var objField        = null;

        //
        // Verify that either both dates are null or both of them have actual values
        //
        if( strStartDt != "" && strEndDt == "" ) 
        {
            objField = objFormElements[ 'popcal-rangedate__' + strDateRangeFieldName + '2' ];
            SYS_UTL_QueueValidationError( objField, strMsgNullEndDate );
            return;
        }
        if( strStartDt == "" && strEndDt != "" )
        {
            objField = objFormElements[ 'popcal-rangedate__' + strDateRangeFieldName + '1' ];
            SYS_UTL_QueueValidationError( objField, strMsgNullStDate );
            return;
        }
          
        //
        // Verify that the end date is later than start date
        // 
        var dtStartDate = new Date( 
                                objFormElements[ 'year-rangedate__'   + strDateRangeFieldName + '1' ].value,
                                objFormElements[ 'month-rangedate__'  + strDateRangeFieldName + '1' ].value,
                                objFormElements[ 'day-rangedate__'    + strDateRangeFieldName + '1' ].value,
                                objFormElements[ 'hour-rangedate__'   + strDateRangeFieldName + '1' ].value,
                                objFormElements[ 'minute-rangedate__' + strDateRangeFieldName + '1' ].value
                          );
        var dtEndDate   = new Date(
                                objFormElements[ 'year-rangedate__'   + strDateRangeFieldName + '2' ].value,
                                objFormElements[ 'month-rangedate__'  + strDateRangeFieldName + '2' ].value,
                                objFormElements[ 'day-rangedate__'    + strDateRangeFieldName + '2' ].value,
                                objFormElements[ 'hour-rangedate__'   + strDateRangeFieldName + '2' ].value,
                                objFormElements[ 'minute-rangedate__' + strDateRangeFieldName + '2' ].value
                          );
                          
        if( dtEndDate < dtStartDate )
        {
            objField = objFormElements[ 'popcal-rangedate__' + strDateRangeFieldName + '2' ];
            SYS_UTL_QueueValidationError( objField, strMsgDatesOutOfRange );
            return;
        }                 
    }

    //
    // validates a field in the form based on a matching condition.
    // the matching condition should be a regular expression.
    //
    ObjForm.prototype.ValidateText = function(  p_strFieldName,
                                                p_objValidMatch,
                                                p_strViolationMessage   ) {

        //1-19-06 MinJie replaced eval with squarebracket
        var objField = m_objPageForm[p_strFieldName];
        var strValue = _UTL_Trim(objField.value);
        var bRetValue = false;

        if (strValue.match(p_objValidMatch) == null) {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
            bRetValue = true;
        }
        return bRetValue;
    }

    //
    // validates a field in the form based on an exclusion condition.
    // the matching condition should be a regular expression.
    //
    ObjForm.prototype.ValidateExclude = function(p_strFieldName,
                                                 p_objValidMatch,
                                                 p_strViolationMessage) {
        //1-19-06 MinJie replaced eval with squarebracket
        var objField = m_objPageForm[p_strFieldName];
        var strValue = _UTL_Trim(objField.value);
        var bRetValue = false;

        if (strValue != strValue.replace(p_objValidMatch, ''))
        {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
            bRetValue = true;
        }
        return bRetValue;
    }


     //
    // validates a Combobox in the form based on a matching condition.
    // the matching condition should be a regular expression.
    //
    ObjForm.prototype.ValidateCombo = function ( p_strFieldName,
                                        p_objValidMatch,
                                        p_strViolationMessage   )   {

        var bRetValue = false;
        
        if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )
        {
            //1-19-06 MinJie replaced eval with squarebracket
            var objField = m_objPageForm[p_strFieldName].selectedIndex;
            var strValue = objField;
        }
        else
        {
            //1-19-06 MinJie replaced eval with squarebracket
            var objField = m_objPageForm[p_strFieldName];
            var strValue = objField.value;
        }
        if (strValue == 0)  {
        SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
        bRetValue = true;
        }
        return bRetValue;
    }

    //
    // SubmitForm() submits the form
    //     the action property of the form can also be set
    //     if not set, the default action of the form will be used.
    //     if the form is not valid, then neither the action is
    //     changed nor is the submit event called.
    //
    ObjForm.prototype.SubmitForm = function(p_strAction) {
        if (m_bIsValid) {
            if (arguments.length == 0 || p_strAction != '') {
                m_objPageForm.action = p_strAction;
            }
            m_objPageForm.submit();
        }
    }

    function SYS_UTL_QueueValidationError(p_objField, p_strMessage) {

    if (p_strMessage.length > 0) {
        if (m_bIsValid) {
            m_objFocusField = p_objField;
            m_strMessage = m_strHeader + '\n';
        }
        if ( m_nCurErrors >= m_nMaxErrors )
        {
            // reached limit skill further errors
        }
        else
        {   
            m_strMessage += p_strMessage + '\n';            
        }            
        m_bIsValid = false;
        m_nCurErrors++;
    }
    }

    //
    // validates Credit Card Number based on Credit Card Types
    // Validated for VISA, MASTER, AMERICAL EXPRESS AND DISCOVER Cards
    //
    ObjForm.prototype.ValidateCreditCardNumber = function (
                                                            p_strFieldName, 
                                                            p_sCCType, 
                                                            p_strViolationMessage)
    {   
        var bRetValue = true;
        var objField = m_objPageForm[p_strFieldName];
        var strValue = _UTL_Trim(objField.value);
        var bTemp    = false;
        var sTemp    = "";
        var bValidNumber = false;
        
        //Validate if the number provided is numeric.
        bValidNumber = isNumeric( strValue,0 );
        
        //if the value is numeric then only do other validations.
        if( bValidNumber )
        {
            switch ( String( p_sCCType ) )
            {
             case "VISA" : //VISA
                
                // Credit card number for a VISA card should be of length 13 or 16
                // and it should start with number 4.
                bTemp = (((strValue.length==13)||(strValue.length==16))?true:false);
                if ( bTemp )
                {
                    sTemp = strValue.substring(0, 1);
                    if (sTemp == "4")
                    {
                        bRetValue = false;
                    }
                }
                break ;
             case "MASTERCARD" : //MasterCard
            
                // Credit card number for a MasterCard should be of length 16
                // and it should start with numbers 51-55.
                bTemp = ((strValue.length==16)?true:false);
                if ( bTemp )
                {
                    sTemp = strValue.substring(0, 2);
                    if ((sTemp == "51") || (sTemp == "52") || (sTemp == "53") || (sTemp == "54") || (sTemp == "55"))
                    {
                        bRetValue = false;
                    }
                }
                break ;
             case "AMERICAN EXPRESS" : //American Express
                
                // Credit card number for a American Express card should be of length 15
                // and it should start with numbers 34 or 37.
                bTemp = ((strValue.length==15)?true:false);
                if ( bTemp )
                {
                    sTemp = strValue.substring(0, 2);
                    if ((sTemp == "34") || (sTemp == "37"))
                    {
                        bRetValue = false;
                    }
                }
                break ;
             case "DISCOVER" : //Discover
                
                // Credit card number for a American Express card should be of length 16
                // and it should start with number 6011.
                bTemp = ((strValue.length==16)?true:false);
                if ( bTemp )
                {
                    sTemp = strValue.substring(0, 4);
                    if (sTemp == "6011")
                    {
                        bRetValue = false;
                    }
                }
                break ;
             default : //If its any other card.
                bRetValue = false;
            }
            
            // Bug 51027 - Begin: Luhn algorithm check on Credit Card number
            if (bRetValue == false)         
            {
                 var nCheck = 0;
                 var nDigit = 0;
                 var bEven = false;
                 
                 for (n = strValue.length - 1; n >= 0; n--) 
                 {
                    var cDigit = strValue.charAt(n);
                    var nDigit = parseInt(cDigit, 10);
                    if (bEven)
                    {
                       if ((nDigit *= 2) > 9)
                          nDigit -= 9;
                    }
                    nCheck += nDigit;
                    bEven = ! bEven;
                 }
                 if (nCheck % 10 != 0)
                     bRetValue = true;
            }
            // Bug 51027 - End
        }
        else //if the value is not numeric
        {
            bRetValue = true; 
        }

        if ( bRetValue == true )
        {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
        }
        return bRetValue;   
    }

    //
    // validates Expiry Month
    // If Year is Current Year then only we required to call this Function to Month is expired or not
    //
    ObjForm.prototype.ValidateExpiryMonth = function (
                                                       p_strFieldName, 
                                                       p_strViolationMessage,
                                                       p_iCurrentMonth )
    {
        var bRetValue = true;
        var objField = m_objPageForm[p_strFieldName];
        var strValue = _UTL_Trim(objField.value);

        if (strValue >= p_iCurrentMonth)
        {
            bRetValue = false;
        }

        if (bRetValue == true)
        {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
        }
        return bRetValue;   
    }

    ObjForm.prototype.QueueValidationError = SYS_UTL_QueueValidationError;
    //To access QueueValidationError outside this object.
}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : Mouse over button support
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_MButton_Create(pic, picMO, picD, bHasD, desc)
{

    this.pic              = new Image();
    this.pic.src          = pic;
    this.pic_active       = new Image();
    if ( typeof(picMO) != "undefined" && picMO != "" )
    {
        this.pic_active.src   = picMO ;
    }
    else
        this.pic_active.src   = pic.substring(0, pic.length - 4) + "_mouseover.gif";
    if ( bHasD )
    {
        this.pic_disabled     = new Image();
        if ( typeof(picD) != "undefined" && picD != "" )
        {
            this.pic_disabled.src = picD;
        }
        else
            this.pic_disabled.src = pic.substring(0, pic.length - 4) + "_disabled.gif";
    }

    this.text             = desc;

}

function _UTL_MButton_MoveOver(id)
{

    if ( g_objButton[id] )
    {
        if ( typeof(g_objButton[id].pic_disabled) != "undefined" && document[id].src == g_objButton[id].pic_disabled.src )
            return ;
        document[id].src = g_objButton[id].pic_active.src;
        window.status    = g_objButton[id].text;
    }
}

function _UTL_MButton_MoveAway(id)
{

    if ( g_objButton[id] )
    {
        if ( typeof(g_objButton[id].pic_disabled) != "undefined" && document[id].src == g_objButton[id].pic_disabled.src )
            return ;
        document[id].src = g_objButton[id].pic.src;
        window.status = "";
    }
}


function _UTL_MButton_Enable(id)
{

    if ( g_objButton[id] && document[id] )
    {
        document[id].style.cursor   = "hand";
        document[id].src            = g_objButton[id].pic.src;
        window.status               = "";

    }
}


function _UTL_MButton_Disable(id)
{
    if ( g_objButton[id] && document[id] )
    {
        document[id].style.cursor   = "default";
        document[id].src            = g_objButton[id].pic_disabled.src;
        window.status               = "";
    }

}

function _UTL_GetCoreAuthoringPagePath(strPage)
{
    return ( STRING_SITE_PREFIX + "/core/authoring/" + strPage );

}




function _UTL_GetCoreAuthoringPagePath(strPage)
{
    return ( STRING_SITE_PREFIX + "/core/authoring/" + strPage );

}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : _UTL_GetUniqueString
//
// Parameters    :
//
// Return        : Unique String based on time. dd-MM-yyyy_HH-mm-ss_SSS
//
// Synopsis      : returns a unique string based on the time.
//                 the format in which the string is returned is dd-MM-yyyy_HH-mm-ss_SSS
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_GetUniqueString ()
{
    //format : dd-MM-yyyy_HH-mm-ss_SSS

    var date = new Date();
    var szUnique = "";

    var dd = date.getDate();
    if (dd<10) dd = "0" + dd;

    var MM = date.getMonth();
    if (MM<10) MM = "0" + MM ;

    var yyyy = date.getYear();

    var HH = date.getHours();
    if (HH<10) HH = "0" + HH;


    var mm = date.getMinutes();
    if ( mm < 10 ) mm = "0" + mm;

    var ss = date.getSeconds();
    if ( ss < 10 ) ss = "0" + ss;

    var SSS = date.getMilliseconds();
    SSS = SSS * 10 ;
    if ( SSS < 100 ) SSS = "00" + SSS ;
    else
        if ( SSS < 1000 ) SSS =  "0" + SSS ;

    szUnique = dd + "-" + MM + "-" + yyyy + "_" + HH + "-" + mm + "-" + ss + "_" + SSS;

    return szUnique;

}//:~_UTL_GetUniqueString

// Added one parameter bSkipTextArea to skip concatenating long text inside textarea to querystring.
function _UTL_ExportToExcel(bShowExportOpt, nRecords, bIsPost, strFormName, strOpenURL, bSkipTextArea, bUseSSL )
{
    if(typeof(bSkipTextArea) == 'undefined')
    {
        bSkipTextArea = false;
    }
    if(typeof(bUseSSL) == 'undefined')
    {
        bUseSSL = false;
    }
    
    if(nRecords == 0)
    {
        alert(L_Export_NoDataForExport);
        return;
    }
    var strTemp = window.location.toString().split("?");
    strOpenURL = strTemp[0];

    if(bIsPost != true)
    {
        if(bShowExportOpt)
        {
            strURL = _UTL_GetPagePath("management/LMS_ExportToExcel_Opt.asp");
            if( bUseSSL )
            {
                strURL += "?ForceSSL=1";
            }
            strWindowName = "Export";
            strURL = _UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(strURL);
            if( bUseSSL )
            {
                strURL += "&ForceSSL=1";
            }
            _UTL_OpenModalWindow(strURL, strWindowName, 370, 270 );

        }
        else
        {
            strURL = window.location.toString();
            var pos = strURL.indexOf("?");
            if(pos == -1)
                strURL += "?ExportToExcel=1&ExportAllData=1";
            else
                strURL += "&ExportToExcel=1&ExportAllData=1";

            strWindowName = "Export";

            strURL = _UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(strURL);
            _UTL_OpenModalWindow(strURL, strWindowName, 370, 270 );
        }
    }
    else
    {
        if(bShowExportOpt)
        {
            strURL = _UTL_GetPagePath("management/LMS_ExportToExcel_Opt.asp");
            strURL = strURL + "?"  + "IsRequestPost=1" +"&FormName=" + strFormName +  "&OpenerURL=" + strOpenURL; //IsRequestPost=1 + strOpenURL
            if( bUseSSL )
            {
                strURL += "&ForceSSL=1";
            }
            strWindowName = "Export";
            strURL = _UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(strURL);
            if( bUseSSL )
            {
                strURL += "&ForceSSL=1";
            }
            _UTL_OpenModalWindow(strURL, strWindowName, 370, 270, bUseSSL ? true : undefined );
        }
        else
        {
            //
            // [Murali:Begin]
            // Instead of using GET to retrive the data, we now use POST.
            // Commenting out the code that builds a query string from form variables.
            //
            
            /*strURL = unescape(_UTL_CreateExportQueryString(window,strOpenURL,strFormName, bSkipTextArea));

            var pos = strURL.indexOf("?");
            if(pos == -1)
                strURL += "?ExportToExcel=1&ExportAllData=1";
            else
                strURL += "&ExportToExcel=1&ExportAllData=1";

            */
            
            strWindowName = "Export";
            
            //
            // Build a form object.
            //
            objFormObject = _UTL_PostFormToExportData(window, strOpenURL, strFormName, 1, false);
            
            strURL = _UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(objFormObject.action);
            if( bUseSSL )
            {
                strURL += "&ForceSSL=1";
            }

            //
            // Send the form object as a dialog argument. 
            //            
            _UTL_OpenModalWindow(strURL, strWindowName, 370, 270, undefined, objFormObject);
            //
            //[Murali:End]
            //
            
           
        }
    }
}


function _UTL_WindowPrint()
{

    if(g_objBrowser.IsIE() && g_objBrowser.Version() < 500 )
    {
        //
        // Special control for printing on IE4, needs testing, needs object on page
        //
        // IEControl.ExecWB(6, 1)
    }
    else
        window.print();

}

function _UTL_URL(strValue,blnMandatory,strType)
{
    var blnReturn = false;
    var strData ;
    var strsplitURL;
    var iSplit;
    blnReturn = (_UTL_Trim(strValue).length > 0)?true:false;
    if(blnReturn == false && blnMandatory == true)
    {
        return false;
    }
    else if(blnReturn == false && blnMandatory == false)
    {
        return true;
    }

    strValue = _UTL_Trim(strValue);
    var blnError = false;
    if(strValue.length < 12)
    {
        return false;
    }
    else
    {
        if (strType=="http://")
        {
            if(strValue.substring(0,7).toLowerCase() != "http://")
            {
                return false;
            }
            else
            {
                strData = strValue.substring(7,strValue.length)
                if (strData.match(/[:\*?\"\<\>|\/\\]/))
                {
                    return false;
                }
            }
        }
        else if (strType=="https://")
        {
            if(strValue.substring(0,8).toLowerCase() != "https://")
            {
                return false;
            }
            else
            {
                strData = strValue.substring(8,strValue.length)
                if (strData.match(/[:\*?\"\<\>|\/\\]/))
                {
                    return false;
                }
            }
        }
        else
        {
            if(strValue.substring(0,7).toLowerCase() != "http://" && strValue.substring(0,8).toLowerCase() != "https://")
            {
                return false;
            }
            else
            {

                if (strValue.substring(0,7).toLowerCase() != "http://")
                {
                    strData = strValue.substring(8,strValue.length)
                }
                else
                {
                    strData = strValue.substring(7,strValue.length)
                }
                if (strData.match(/[:\*?\"\<\>|\/\\]/))
                {
                    return false;
                }
            }
        }

    }


    strsplitURL = strValue.split(".");

    for (iSplit=0;iSplit < strsplitURL.length ; iSplit ++)
    {
        // to check that the each part of the URL has a length, i.e. no 2 dots after each other.
        if (strsplitURL[iSplit].length == 0)
        {
            return false;
        }
        // to check that there are no spaces entered in URL.
        if (_UTL_Trim(strsplitURL[iSplit]).length != strsplitURL[iSplit].length )
        {
            return false;
        }

        // to check that there are no spaces entered in URL between words.
        if (_UTL_WhiteSpace(strsplitURL[iSplit])==true)
        {
            return false;
        }
    }
    return true;
}

function _UTL_WhiteSpace(strValue)
{
    strValue = strValue+"";
    var strCheck = "";
    var strValid = "Y";
    var strwhitespace =" ";

    if  ((strValue == null) || (strValue.length == 0))
    {
        return true;
    }

    for (iCounter = 0; iCounter < strValue.length; iCounter++)
    {
        // Check that current character isn't whitespace.
        var strCheck = strValue.charAt(iCounter);
        if (strwhitespace.indexOf(strCheck) != -1)
        {
            strValid = "N";
            break;
        }
    }

    if (strValid == "N")
    {
        return true;
    }
    else
    {
        return false;
    }
}

// Added one parameter bSkipTextArea to skip concatenating long text inside textarea to querystring.
function _UTL_CreateExportQueryString(objOpener,strURL,strFormName, bSkipTextArea)
{
    var strURLTemp = strURL + "?";
    var myform = objOpener.document.forms[strFormName];
    if( typeof(bSkipTextArea) == 'undefined' )
    {
        bFromRoster = false;
    }
    for ( var i = 0; i < myform.elements.length; i++)
    {   
        // skip adding textarea text into querystring.
        if( bSkipTextArea )
        {
           if( myform.elements[i].type != 'textarea')
            {
                if(i == myform.elements.length - 1)
                    strURLTemp += ( myform.elements[i].name + "=" + escape(myform.elements[i].value));
                else
                    strURLTemp += ( myform.elements[i].name + "=" + escape(myform.elements[i].value)) + "&";
            }  
        }
        else
        {
            if(i == myform.elements.length - 1)
                strURLTemp += ( myform.elements[i].name + "=" + escape(myform.elements[i].value));
            else
                strURLTemp += ( myform.elements[i].name + "=" + escape(myform.elements[i].value)) + "&";
         }
    }

    return strURLTemp;
}

//
// [Murali:Begin]
//
///
/// <summary>
/// This function submits data to page using 'POST' method. The submitted data is then exported to MS-Excel.
/// </summary>
/// <parameters>
/// <param name="objOpener"> object - Object identifying the opener of the current window.</param>
/// <param name="strOpenURL"> string - URL of the page whose data is to be exported.</param>
/// <param name="strFormName"> String - Name of the HTML form. </param>
/// <param name="bExportAllData"> String - Flag to determine whether or not to export all the data. </param>
/// <param name="bSubmitForm"> boolean - Flag indicating whether to submit the data or return the 'form' object.</param>
/// </parameters>
/// 
function _UTL_PostFormToExportData(objOpener, strOpenURL, strFormName, bExportAllData, bSubmitForm)
{
    //
    // Get the original form object and it's action string.
    //
    var objOriginalHTMLForm = objOpener.document.forms[strFormName];    
    var strURL              = strOpenURL; 
    var bSubmit;
    
    if (typeof(objOriginalHTMLForm) != 'undefined' && (objOriginalHTMLForm != null))
    {
        if (typeof(bSubmitForm) == 'undefined')
        {
            bSubmit = true;
        }
        else
        {
            bSubmit = bSubmitForm;
        }
        
        //
        // Build the appropriate URL based on export parameters.
        //
        var pos = strURL.indexOf("?");  
        if(pos == -1)
        {   
            strURL += "?ExportToExcel=1&ExportAllData=" + bExportAllData;
        }  
        else
        {   
            strURL += "&ExportToExcel=1&ExportAllData=" + bExportAllData;
        };  
        //
        // Create a temporary form on this popup window.
        // Set the HTTP method to 'post' and then import all the form variables
        // from the original form. 
        //
                
        var objNewForm            = document.createElement("form");
        objNewForm.method         = "post";
        objNewForm.target         = "_self";
        objNewForm.action         = strURL;
        objNewForm.style.display  = "none";
        objNewForm.name           = strFormName;    
        objNewForm.innerHTML      = objOriginalHTMLForm.innerHTML;     

        if (bSubmit)
        {
            //
            // Post the new form.
            //        
            document.body.appendChild(objNewForm);
            objNewForm.submit();    
            document.body.removeChild(objNewForm);
        }
        else
        {
            return objNewForm;
        }
        
    }
    else
    {
        return null;
    }
}
//
// [Murali:End]
//


function _UTL_RefreshCookie(strCookies, strCookieName, path)
{
    var i = 0;
    var cookies = strCookies.split(';');
    var strCookie = "";

    for (i = 0; i < cookies.length; i++) 
    {
       if (-1 != (cookies[i]).indexOf(strCookieName, 0))
       {
           var date = new Date();
           date.setTime(date.getTime() + 5 * 60 * 1000);
           strCookie = cookies[i] + "; path=" + path + "; expires=" + date.toGMTString();
           break;
       }
    }
    return strCookie;
}

var objXMLRequest = null;

function _UTL_ExportWindow_Close (strBaseURL)
{

//  var strURL = window.location.toString();
//  var iIndex = strURL.indexOf ("?");
//  var path   = strURL.substring  (0, iIndex);
//  var oDlgArg= window.dialogArguments;

    var path       =   _UTL_GetPagePath("common/SYS_SEC_ExportFileCleanup.asp");
    var strPostUrl =    strBaseURL + path;
    var strParams  = "CleanExportData=1";

    objXMLRequest = SYS_Browser_CreateXMLHttpRequest();
    objXMLRequest.open('POST', strPostUrl, true);
    objXMLRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    objXMLRequest.onreadystatechange = _UTL_ExportWindow_XMLHttpRequest_Handler;
    objXMLRequest.send(strParams);          
}

function _UTL_ExportWindow_XMLHttpRequest_Handler ()
{
    if (objXMLRequest.readyState == 4)
    {
        if( g_objBrowser.IsNetscape())
        {
            return;
        }
        else
            parent.SYS_ModalDialog_Close();
    }
}

function _UTL_ExportWindow_CloseEx (strURL)
{
    _UTL_ExportWindow_Close (strURL);

    if (g_objBrowser.IsNetscape())
    {
        parent.SYS_ModalDialog_Close();
    }
}


function _UTL_OpenWindow_Export(strURL)
{
    var strURL = String(strURL);

    while (true)
    { // only deal with full URL
        if (strURL.indexOf(":") <= 0)
        { 
            break;
        }
        var i = strURL.indexOf("//");
        if (i <= 0)
        {
            break;
        }
        i = strURL.indexOf("/", i + 2);
        if (i <= 0)
        {
            break;
        }
        var path = strURL.substr(i);
        var strCookie = "";

        strCookie = _UTL_RefreshCookie(parent.window.document.cookie, g_strAuthCookie, path);
        parent.window.document.cookie = strCookie;
        break;
    }
    // Using window.open only for IE as in Netscape when opening a .xls file using window.open we get an extra blank window
    if( g_objBrowser.IsIE())
      parent.window.open(strURL);
}

function _UTL_ProgressBarNS()
{
    if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500)
    {
        document.progressdivStart.visibility    = "hide";
        document.progressdivComplete.visibility = "show";
    }
}

/**
* shows the file upload progress
*/
function _UTL_ShowUploadProgress( PID )
{
    var iRefreshTime = 5;      // refresh time is 5 sec
    var strProgressURL = _UTL_GetPagePath("authoring/UTL_UploadProgressFrame.asp") + "?to=" + iRefreshTime + "&PID=" + PID ;

    if( g_objBrowser.IsIE() && g_objBrowser.Version() >= 500 )
    {
        var winstyle = "dialogWidth=375px; dialogHeight:160px; center:yes";
        window.showModelessDialog( strProgressURL, null, winstyle );
    }
    else
    {
        // To center the window on the screen
        var winleft = (screen.width - 400) / 2;
        var wintop  = (screen.height - 140) / 2;
        var attr    = "width=400,height=140,left=" + winleft + ",top=" + wintop ;
        window.open( strProgressURL, '', attr, true);
    }

    return true;
}

/**
* Makes the first document object invisible and the second document object visible
* This function needs clsVisibleDiv and clsInvisibleDiv style sheet classes. There are
* available in CDS_common.css
*/
function _UTL_ChangeVisibility(strObject1, strObject2)
{
    document.all[strObject1].className='clsInvisibleDiv';
    document.all[strObject2].className='clsVisibleDiv';

    return true;
}

// CFR BS Fix: there are very few pages called from learner and manager side 
// nCallerPage introduced to identify them
function _UTL_ShowDSVerify(nOperation, objType, nCallerPage, strReturnFunc)
{
    var strURL = _UTL_GetPagePath("management/LMS_DSVerify.asp?nOperation="+nOperation+"&objType="+objType);
    strURL = _UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(escape(strURL));
    if ( nCallerPage != 1)
    {
        var bRet = _UTL_OpenModalWindow(strURL, "",430,370);
        return bRet;
    }
    else
    {
        _UTL_OpenCBModalWindow(strURL, "",430,370,"","",strReturnFunc);
    }
}

/*
    This function is to show the Signature popup from where signer gives his signature
*/
function _UTL_ShowSignaturePopUp(strSignatureList,strSignatureType,strReturnFunc)
{
    //return true;
    var strURL = _UTL_GetPagePath("management/LMS_DSVerify.asp");
    strURL = _UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(escape(strURL + "?SignatureList=" + strSignatureList + "&objType=Transcript_Signatures&SignatureType=" + strSignatureType));
    _UTL_OpenCBModalWindow(strURL, "",430,390,"","",strReturnFunc);
}


function _UTL_CheckDS(strName)
{
    var bRet ;
    //1-19-06 MinJie replaced eval with wrapper
    if ( SYS_SEC_EvalStringOnly("L_Verify_DS_"+strName) == "1")
        return true;

    _UTL_CreateCFRTxnID();

    return false;
}

//
// Client side version of SYS_STR_CleanForDisplay
//
function _UTL_CleanForDisplay(strValue)
{
    //
    // Replace tags
    //
    var str1 = strValue.replace(/\</g,"&lt;");
    var str2 = str1.replace(/\>/g,"&gt;");
    var str3 = str2.replace(/\'/g,"&#39;");
    var str4 = str3.replace(/\"/g,"&quot;");

    return str4 ;
}


function  _UTL_CreateCFRTxnID()
{
    if (!CFR_ENABLED)
        return;

    var url = _UTL_GetPagePath("management/CFR/LMS_CreateCFRTransId.asp");

    if (window.XMLHttpRequest)
    {
        srvr_req = new XMLHttpRequest();
    }
    else if ( window.ActiveXObject )
    {
        srvr_req = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if ( srvr_req )
    {
        srvr_req.open("GET", url, false);
        srvr_req.onreadystatechange = CFR_GetReturnedData;
        srvr_req.send(null);
    }
}


function CFR_GetReturnedData()
{
    if ( srvr_req.readyState == 4 )
    {       // the document has been fully received
        if ( srvr_req.status == 200 )
        {           // The web server returned a valid document     
            return;
        }
        else
        {
            alert(L_Info_CFRError +  srvr_req.statusText);      
        }
    }
}


//
// Client side version of SYS_STR_CleanForDisplay
//
function _UTL_ReverseCleanForDisplay(strValue)
{
    if (strValue != null)
    {
        if (typeof(strValue) != "string")
        {
            strValue = String(strValue);
        }

        strValue = strValue.replace(/\&amp;/g,"&");
        strValue = strValue.replace(/&lt;/g,  "<");
        strValue = strValue.replace(/&gt;/g,  ">");
        strValue = strValue.replace(/&#39;/g, "'");
        strValue = strValue.replace(/&quot;/g,"\"");
    }

    return strValue;
}

function _UTL_LaunchComposer(strWindowName)
{
    var strRetVal     = null ;
    var iLaunchWidth  = 640 ;
    var iLaunchHeight = 480 ;
    var strDirName    = STRING_SITE_PREFIX + "/" + STRING_LANG_PATH
                            + "authoring/VCSEditor/CDS_VCSEditorLauncher.asp";

    strRetVal     = _UTL_OpenModalWindow(strDirName, strWindowName, iLaunchWidth, iLaunchHeight);
}

//Domains 3.0
function _UTL_Admin_SelectCurDom(nUserMode)
{

    var strRetVal = null ;

    strRetVal = _UTL_OpenModalWindow(_UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(_UTL_GetPagePath("administration/user/domain/ADM_ListViewDomains.asp") + "?Mode=1&Caller=0&Type=1&UserMode=" + nUserMode),
                                     "Domains");

    //
    // Reload page
    //
    if ( strRetVal != "" && String(strRetVal) != "undefined")
    {
        var iRetVal = parseInt(strRetVal);
        document.idChangeCurrentDomain.idCurDomain.value = strRetVal;
        document.idChangeCurrentDomain.submit();
    }


}


/////////////////////////////////////////////////////////////////////////////
//
// Function Name :
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
//   Admin mode view security
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_Admin_ViewSecurity(nUserMode)
{

    var strRetVal = null ;

    strRetVal = _UTL_OpenModalWindow(_UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(_UTL_GetPagePath("administration/security/roles/ADM_EditPermissions.asp?AdminHome=Yes")) );


    //
    // Reload page
    //
    if ( strRetVal != "" && String(strRetVal) != "undefined")
        window.location = _UTL_GetPagePath("administration/ADM_AdminHome.asp") ;


}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name :
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
//   Admin mode view security
//
/////////////////////////////////////////////////////////////////////////////
function _UTL_CollapseLeftMenu_Toggle(strName, strOpenAlt, strCloseAlt,parentElement)
{

    {
        var objBoxHT  = document.getElementById(strName+"-headtbl");
        var objBoxHLI = document.getElementById(strName+"-headlimg");
        var objBoxHRI = document.getElementById(strName+"-headrimg");
        var objBoxDD  = document.getElementById(strName+"-datadiv");

        if ( objBoxDD.style.display == "" )
        {
            objBoxHRI.src          = g_imgCollapseLeftMenuRC.src ;
            objBoxHRI.alt          = strOpenAlt ;
            objBoxHRI.title        = strOpenAlt ;  //Bug#50473 Fix
            objBoxDD.style.display = "none";
        }
        else
        {
            objBoxHRI.src          = g_imgCollapseLeftMenuRO.src ;
            objBoxHRI.alt          = strCloseAlt ;
            objBoxHRI.title        = strCloseAlt ; //Bug#50473 Fix
            objBoxDD.style.display = "";
        }
    } //browser check
}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name :
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
//   Admin mode view security
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_FlatCalendarInit(idCalTable, objCal)
{
    //
    // Initialize calendar size
    //
    var objCalTable = document.getElementById(idCalTable);

    if ( objCalTable != null )
    {

        document.getElementById(idCalTable).style.visibility="visible";

    };
}



/////////////////////////////////////////////////////////////////////////////
//
// Function Name :
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
//   Show Delivery method Icons Legend
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_Learner_ShowDeliveryMethod(nUserMode)
{

    var strRetVal = null ;

    strRetVal = _UTL_OpenModalWindow(_UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" +      escape(_UTL_GetPagePath("administration/Security/SupplementalData/ADM_ListIcons.asp?Caller=11&TableName=LEMtd&UserMode=2")));
}


/////////////////////////////////////////////////////////////////////////////
//
// Function Name : _UTL_StripXSS
//
// Parameters    : String str
//
// Return        : remove string that contains the XSS vulnerabilities
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_StripXSS( str )
{
    //
    // 2004-04-01 : Muljadi Sulistio   move it to a function SYS_UTL_StripXSS for re-usability
    // 2004-02-26 : Anand Arvind
    //
    // Fix for security issues related to cross browser scripting, refer to
    // http://www.cert.org/advisories/CA-2000-02.html for more information
    //
    // Currently applicable for query string parameters, strip out
    // <scr\ipt*>,<\scr\ipt>,<applet*>,<\applet>,<object*>,</object>,<embed*>,</embed>
    //
    if (str != "undefined" && str.length > 5 )
    {
        var str1 = str.replace(/\<[\s\t]*scr\ipt[^>]*\>/gi,"");
        str  = str1.replace(/\<\/[\s\t]*scr\ipt[^>]*\>/gi,"");
        str1 = str.replace(/\<[\s\t]*applet[^>]*\>/gi,"");
        str  = str1.replace(/\<\/[\s\t]*applet[^>]*\>/gi,"");
        str1 = str.replace(/\<[\s\t]*object[^>]*\>/gi,"");
        str  = str1.replace(/\<\/[\s\t]*object[^>]*\>/gi,"");
        str1 = str.replace(/\<[\s\t]*embed[^>]*\>/gi,"");
        str  = str1.replace(/\<\/[\s\t]*embed[^>]*\>/gi,"");
    }
    return str;
}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : _UTL_CleanHTMLDesc
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_CleanHTMLDesc(strValue)
{
    if ( strValue == null )
        return "";

    if ( typeof strValue != "string" )
        strValue = String(strValue);

    //
    // Security cleanup
    //
    strValue = _UTL_StripXSS( strValue );

    //
    // Do other cleaning here
    //
    return strValue ;
}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : _UTL_DTM_CheckDateValid
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_DTM_CheckDateValid(dtObj, bMustExist)
{

    var bValid = false ;
    //1-17-06 MinJie removed eval code concat
    var objYear  = document.getElementById("year-"+ dtObj);
    var objMonth = document.getElementById("month-" + dtObj);
    var objDay   = document.getElementById("day-" + dtObj);

    if ( typeof(bMustExist) == "undefined" )
    {
        bMustExist = false ;
    }

    if ( bMustExist == false && (objYear.value == -1 || objMonth.value == -1 || objDay.value == -1))
    {
        bValid = true ;
    }
    else if ( bMustExist == true && (objYear.value == -1 || objMonth.value == -1 || objDay.value == -1))
    {
        bValid = false ;
    }
    else
    {
        var objDt = new Date(objYear.value,(parseInt(objMonth.value) + 1),objDay.value);

        if ( !(typeof(objDt) == "undefined" || String(objDt) == "NaN" || String(objDt) == "" ))
        {
            bValid = true ;
        }
    }

    return bValid;

}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : _UTL_DTM_CheckRangeValid
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_DTM_CheckRangeValid(dtObj1, dtObj2, bMustExist)
{

    var blnReturn = false;
    var Date1      = null;
    var Date2      = null;
    var bStartNull = false;
    var bEndNull   = false;

    if ( typeof(bMustExist) == "undefined" )
    {
        bMustExist = false ;
    }

    //
    // Start date
    //
    //1-17-06 MinJie removed eval code concat
    var objValueYear  = document.getElementById("year-"+dtObj1);
    var objValueMonth = document.getElementById("month-"+dtObj1);
    var objValueDay   = document.getElementById("day-"+dtObj1);
    var objValueHr    = document.getElementById("hour-" + dtObj1);
    var objValueMin   = document.getElementById("minute-" + dtObj1);

    if(objValueYear.value == -1 || objValueMonth.value == -1 || objValueDay.value == -1)
    {
        bStartNull = true;
    }
    else
    {
        if ( objValueHr != null && objValueMin != null )
        {
            Date1 = new Date(objValueYear.value,(parseInt(objValueMonth.value) + 1),objValueDay.value, objValueHr.value, objValueMin.value);
        }
        else
        {
            Date1 = new Date(objValueYear.value,(parseInt(objValueMonth.value) + 1),objValueDay.value);
        }
    }

    //
    // End date
    //
    //1-17-06 MinJie removed eval code concat
    objValueYear      = document.getElementById("year-"+dtObj2);
    objValueMonth     = document.getElementById("month-" + dtObj2);
    objValueDay       = document.getElementById("day-" + dtObj2 );
    var objValueHr    = document.getElementById("hour-" + dtObj2 );
    var objValueMin   = document.getElementById("minute-" + dtObj2 );

    if(objValueYear.value == -1 || objValueMonth.value == -1 || objValueDay.value == -1)
    {
        bEndNull = true;
    }
    else
    {
        if ( objValueHr != null && objValueMin != null )
        {
            Date2 = new Date(objValueYear.value,(parseInt(objValueMonth.value) + 1),objValueDay.value, objValueHr.value, objValueMin.value);
        }
        else
        {
            Date2 = new Date(objValueYear.value,(parseInt(objValueMonth.value) + 1),objValueDay.value);
        }
    }

    if ( bMustExist == true && (bStartNull || bEndNull ))
    {
        bInReturn = false ;
    }
    else if( bStartNull || bEndNull )
    {
        blnReturn = true;
    }
    else if ( Date2 >=  Date1 )
    {
        blnReturn = true;
    }
    else
    {
        blnReturn = false;
    }

    return blnReturn;

}
//
/////////////////////////////////////////////////////////////////////////////
//
// Function Name : _UTL_DATE_ISOFormat(objDate)
//
// Parameters    : a date - the date to be converted
//
// Return        : string
//
// Synopsis      : return a date to map SQL Server ISO datetime 
//                 conversion: yyyymmdd
//
/////////////////////////////////////////////////////////////////////////////
function _UTL_DATE_ISOFormat(objDate)
{

    var strDate = "";
    var dtNew   = objDate;

    strDate = dtNew.getFullYear().toString()                                 +
              (dtNew.getMonth() + 1).toString().replace(/(^[0-9]$)/g, "0$1") +
              dtNew.getDate().toString().replace(/(^[0-9]$)/g, "0$1");

    return strDate ;

}
//
/////////////////////////////////////////////////////////////////////////////
//
// Function Name : _UTL_AppendDate(strName)
//
// Parameters    : strName - the name to be appended
//
// Return        : a new string
//
// Synopsis      : Append a current date in the format of "yyyymmdd"
//
/////////////////////////////////////////////////////////////////////////////
function _UTL_AppendDate(strName)
{
    var dtNew = new Date();

    strName = strName + _UTL_DATE_ISOFormat(dtNew);

    return strName;
}

function _UTL_DisableDatePicker(strIdDate)
{
    objDateA    = document.getElementById("a-" + strIdDate);
    objDateImg  = document.getElementById("popcal-" + strIdDate);
    
    if ((objDateA == null) || (objDateImg == null))
        return false;
        
    objDateA.disabled       =   true;
    objDateA.style.cursor   =   "normal";        
    objDateImg.src          =   _UTL_GetImagePath("icon_calendar_inactive.gif");
    return true;
}

function _UTL_EnableDatePicker(strIdDate)
{ 
    objDateA    = document.getElementById("a-" + strIdDate);
    objDateImg  = document.getElementById("popcal-" + strIdDate);
    
    if ((objDateA == null) || (objDateImg == null))
        return false;
    
    objDateA.disabled       =   false;    
    objDateA.style.cursor   =   "hand";
    objDateImg.src          =   _UTL_GetImagePath("icon_calendar.gif");
    return true;   
}

function _UTL_DisableRangePicker(strIdDate1, strIdDate2)
{
    _UTL_DisableDatePicker(strIdDate1) && _UTL_DisableDatePicker(strIdDate2);    
}

function _UTL_EnableRangePicker()
{
    _UTL_EnableDatePicker(strIdDate1) && _UTL_EnableDatePicker(strIdDate2);
}


function _UTL_GetSelectedRadioButton( strFormName, strRadioGroupId )
{
    //1-19-06 Minjie replaced eval with squarebracket
    var objRadioList   = document[strFormName][strRadioGroupId];
    var objSelected    = null;
    
    if( typeof objRadioList.length == "undefined" )
    {
        if( objRadioList.checked )
        {  
            objSelected = objRadioList;
        } 
    }
    else
    {
        for( var i = 0; i < objRadioList.length; i++ )
        {       
            if( objRadioList[i].checked )
            {   
                objSelected    = objRadioList[i];
                break;
            }
        }
    }
    return objSelected;
}


/////////////////////////////////////////////////////////////////////////////
//
// Function Name : SYS_PropBag_PreviewAsText( strFieldName, strTextFieldId )
//
// Parameters    : strFieldName - the name of the field for previewing purpose
//          strTextFieldId - id of the Text field   
// 
// Return        : a new string
//
// Synopsis      :  Opens a model window for Text preview
//
/////////////////////////////////////////////////////////////////////////////
function SYS_PropBag_PreviewAsText( strFieldName, strTextFieldId )
{   
    var strText = SYS_PropBag_GetPlainText( strTextFieldId );
    SYS_PropBag_DoPreview( strFieldName, strText, 1 );
}
/////////////////////////////////////////////////////////////////////////////
//
// Function Name : SYS_PropBag_PreviewAsHtml( strFieldName, strTextFieldId )
//
// Parameters    : strFieldName - the name of the field for previewing purpose
//          strTextFieldId - Name of the Text field 
//
// Return        : None
//
// Synopsis      : Opens a model window for HTML preview
//
/////////////////////////////////////////////////////////////////////////////
function SYS_PropBag_PreviewAsHtml( strFieldName, strTextFieldId )
{
    
    var strHtml = SYS_PropBag_GetHTML( strTextFieldId );
    SYS_PropBag_DoPreview( strFieldName, strHtml, 0 );
}

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : SYS_PropBag_DoPreview( strFieldName, strPreviewThis, iPreviewType )
//
// Parameters    : strFieldName - the name of the field for previewing purpose
//          strPreviewThis - value of the Text field
//          iPreviewType - 0 for Html and 1 for Text preview    
//
// Return        : none
//
// Synopsis      : Opens a model window
//
/////////////////////////////////////////////////////////////////////////////
function SYS_PropBag_DoPreview( strFieldName, strPreviewThis, iPreviewType )
{  
    var strLaunchFeatures = "scroll: no; center:yes; help:no; status:no; dialogWidth: 600px; dialogHeight: 400px;"; 
    var arrDlgArgs        = new Array();

    //
    // Even though we are passing a single value to the dialog, we should still pass it as an array instead of a string. 
    // This is because when a string is passed, IE will only pass up to 4000 characters to it and the rest will get 
    // truncated. In case of arrays, because these are objects, no truncating occurs and we can send as much text as
    // we want.
    //
    arrDlgArgs[0] = strPreviewThis.replace(/\r\n/g,"<br>");
    arrDlgArgs[0] = strPreviewThis.replace(/\n/g,"<br>");
    
    arrDlgArgs[0] = "<P>" + arrDlgArgs[0] + "</P>";

    _UTL_OpenModalWindow( _UTL_GetPagePath( "common/SYS_PropBag_Preview.asp?PType=" + iPreviewType + "&FName=" + escape(strFieldName) ), 
                          "winPreview",
                          600,
                          400,
                          strLaunchFeatures,
                          arrDlgArgs );
}
/////////////////////////////////////////////////////////////////////////////
//
// Function Name : SYS_PropBag_GetHTML( strTextFieldId )
//
// Parameters    :  strTextFieldId - id of the Text field   
//
// Return        : a new string
//
// Synopsis      : Opens a model window for HTML preview
//
/////////////////////////////////////////////////////////////////////////////
function SYS_PropBag_GetHTML( strTextFieldId )
{  
    var objTextField     = document.getElementById( strTextFieldId );
    
    var str1 = _UTL_CleanHTMLDesc(objTextField.value);

    var  str2 = str1.replace(/\s\s\s/g,"&nbsp;&nbsp;&nbsp;");

    // Blocking the HTML, META, TITLE, DOCTYPE, BASE, LINK ,HEAD, INPUT, TEXTAREA,
    // IFRAME and BODY tags  
    str2 = str2.replace(/<\/?body[^>]*>/gi,"");
    str2 = str2.replace(/<\/?html[^>]*>/gi,"");
    str2 = str2.replace(/<\/?base[^>]*>/gi,"");
    str2 = str2.replace(/<\/?iframe[^>]*>/gi,"");
    str2 = formatURI(str2);
    return str2;
}
function formatURI(strText)
    {
        var objRegEx = /((http(s?)\:\/\/|ftp\:\/\/|www\.)([^\s\<\>]+\.)*|[^\s\<\>]+@)[^\s\<]+\/*([^\s\<]+\/*)*\.*[a-zA-Z0-9-_]+[\?|\/|#]*([a-zA-Z0-9-_\@{}%\/+~]+\=*[^\s\<]*&*)*/g;
        var objRegExAnchor = new RegExp("\\<a[^\\>]*","gi");
        //Extract all anchor strings and store in an array
        var arrAnchors = strText.match(objRegExAnchor);
        var strReplaceText = "\x01";
        
       // Replace anchor strings with replace text
       var strText = strText.replace(objRegExAnchor, strReplaceText);
        
        
        // find all URL instances defined by the expression and build an appropriate hyperlink for it.    
        strText = strText.replace(objRegEx,
                      function(strMatch)
                      {
                          // if the url starts with http or ftp
                          if (strMatch.match(/http(s?)|ftp/i) != null) {
                              return "<a href='" + strMatch.replace(/(<br>| )/, "") + "' class=\"clsALink\" target=\"_new\">" + strMatch + "</a>";
                          }
                          else
                          {
                              if (strMatch.match(/mailto/i) != null) {
                                  // if the url is an email address prefixed by "mailto"
                                  return "<a href='" + strMatch.replace(/(<br>| )/, "") + "' class=\"clsALink\">" + strMatch.replace(/mailto\:/, "") + "</a>";
                              }
                              else if (strMatch.match(/@/) != null) {
                                  // if the url is an email address that is not prefixed
                                  return "<a href='mailto:" + strMatch.replace(/(<br>| )/, "") + "' class=\"clsALink\">" + strMatch + "</a>";                                      
                              }
                              else {
                                  // All other matches, append the url with "http://"
                                  return "<a href='http://" + strMatch.replace(/(<br>| )/, "") + "' class=\"clsALink\" target=_new>" + strMatch + "</a>";                                 
                              }
                          }
                      });


        //Incorporate the anchor strings back
        if (arrAnchors != null)
        {
	        for (i=0; i<arrAnchors.length; i++)
		       strText = strText.replace(strReplaceText, arrAnchors[i]);
	}            
        return strText;    
    }


/////////////////////////////////////////////////////////////////////////////
//
// Function Name : SYS_PropBag_GetPlainText( strTextFieldId )
//
// Parameters    :  strTextFieldId - id of the Text field   
//
// Return        : a new string
//
// Synopsis      : Opens a model window for HTML preview
//
/////////////////////////////////////////////////////////////////////////////
function SYS_PropBag_GetPlainText( strTextFieldId )
{  
    var objConversionDiv = document.getElementById( "idDiv_" + strTextFieldId );
    var objTextField     = document.getElementById( strTextFieldId );
    
    var str1 = _UTL_CleanHTMLDesc(objTextField.value);
    var str2 = str1.replace(/<form[^>]*>/gi,"");

    str2 = str2.replace(/\r\n/g,"<br>");
    str2 = str2.replace(/\n/g,"<br>");
    str2 = str2.replace(/\s\s\s/g,"&nbsp;&nbsp;&nbsp;");

    // Blocking the HTML, META, TITLE, DOCTYPE, BASE, LINK ,HEAD, INPUT, TEXTAREA,
    // IFRAME and BODY tags  
   
    str2 = str2.replace(/<\/?body[^>]*>/gi,"");
    str2 = str2.replace(/<\/?html[^>]*>/gi,"");
    str2 = str2.replace(/<\/?meta[^>]*>/gi,"");
    str2 = str2.replace(/<\/?title[^>]*>/gi,""); 
    str2 = str2.replace(/<\!?DOCTYPE[^>]*>/gi,"");
    str2 = str2.replace(/<\/?base[^>]*>/gi,"");
    str2 = str2.replace(/<\/?link[^>]*>/gi,"");
    str2 = str2.replace(/<\/?head[^>]*>/gi,"");
    str2 = str2.replace(/<\/?input[^>]*>/gi,"");
    str2 = str2.replace(/<\/?textarea[^>]*>/gi,"");
    str2 = str2.replace(/<\/?iframe[^>]*>/gi,"");
    
    str2 = "<P>" + str2 + "</P>";
    objConversionDiv.innerHTML = str2;
    return objConversionDiv.innerText;
}

function SYS_SEC_EvalStringOnly(strDeclaration)
{
    var  objRegExKey=/^\w+$/g;

        if(strDeclaration == "" || strDeclaration == null || strDeclaration.match(objRegExKey) != null)
        {
                return eval(strDeclaration);
        }
        else
        {
                window.location=_UTL_GetPagePath("SYS_error.asp") + "?Mode=error&DispMode=normal&Log=" + "invalid expression in SYS_SEC_EvalStringOnly function";
        }
}  

function SYS_SEC_EvalObjDeclare(strDeclaration)
{
    var  objRegExKey=/^new\s+\w+(\.\w+)*\(\s*[\w\"\'-]*(\[[\w\"\'-]+\])*(\.\w+(\[[\w\"\'-]+\])*)*(,\s*[\w\"\'-]+(\[[\w\"\'-]+\])*(\.\w+(\[[\w\"\'-]+\])*)*)*\s*\)$/g;

    if(strDeclaration == "" || strDeclaration == null || strDeclaration.match(objRegExKey) != null)
    {

            return eval(strDeclaration);

    }
    else
    {
            window.location=_UTL_GetPagePath("SYS_error.asp") + "?Mode=error&DispMode=normal&Log=" + "invalid expression in SYS_SEC_EvalObjDeclare function";

    }

}  

function SYS_SEC_EvalFunctionCall(strFunctionCall, strRetVal)
{
    if (strRetVal != null)
        strFunctionCall = strFunctionCall + "(strRetVal)";

    var  objRegExKey=/^\w+(\.\w+)*\(\s*[\w\"\'\-]*(\[[\w\"\'\-]+\])*(\.[\w\"\'\-]+(\[[\w\"\'\-]+\])*)*(,\s*[\w\"\'\-]+(\[[\w\"\'\-]+\])*(\.\w+(\[\w+\])*)*)*\s*\)$/g;

    if(strFunctionCall == "" || strFunctionCall == null || strFunctionCall.match(objRegExKey) != null)
    {

            return eval(strFunctionCall);
    }
    else
    {
            window.location=_UTL_GetPagePath("SYS_error.asp") + "?Mode=error&DispMode=normal&Log=" + "invalid expression in SYS_SEC_EvalFunctionCall function";
    }

}  

function SYS_SEC_EvalHtmlCodeBlock(strCodeBlock)
{
   

   try//strCodeBlock != "" && strCodeBlock != null)
    {
        
          return eval(strCodeBlock); 
    }
    catch(e)
    {

       //window.location=_UTL_GetPagePath("SYS_error.asp") + "?Mode=error&DispMode=normal&Log=" + "invalid expression in SYS_SEC_EvalHtmlCodeBlock function";
    }

}  

// Ecommerce Merge
function _UTL_RoundNumber(fNumber,  iDecimals)
{
    var iMultFactor=Math.pow(10,iDecimals);
    var fTemp=Math.ceil(fNumber*iMultFactor);
    
    fTemp=(fTemp/iMultFactor);
    return fTemp;
}

//-----------------------------------------------------------
// Function:    isNumeric
//
// Summary:     Checks whether or not the specified value
//              is numeric from the specified start positon and returns true if
//              it is.
//-----------------------------------------------------------
function isNumeric(vsString,nPos)
{
    var sNumString = '1234567890';
    var sDigit = '';
    
    for (var nPosition = nPos; nPosition < vsString.length; nPosition++)
    {
        sDigit = vsString.substring(nPosition, nPosition + 1);

        // if the value we are checking isn't in the list of valid digits,
        // then return false
        if (sNumString.indexOf(sDigit) == -1)
            return false;
    }
    
    return true;
}

//-----------------------------------------------------------
// Function:    _UTL_ReportPrint
//
// Summary:     Print the page without the controls that we do not want to print like PRINT button
//              In it , we require to pass all the elements as an array if we want to 
//              make them invisible on hard copy.
//-----------------------------------------------------------
function _UTL_ReportPrint(strElement)
{
    if(g_objBrowser.IsIE() && g_objBrowser.Version() < 500 )
    {
        //
        // Special control for printing on IE4, needs testing, needs object on page
        //
        // IEControl.ExecWB(6, 1)
    }
    else
    {
         for ( var i = 0 ; i < strElement.length ; i++ )
         {
		if (document.getElementById(strElement[i]))
		{
            document.getElementById(strElement[i]).style.display = 'none'; 
		}

         }
         window.print();
         for ( var i = 0 ; i < strElement.length ; i++ )
         {
		if (document.getElementById(strElement[i]))
		{
            if (g_objBrowser.IsNetscape())
            {
                // In netscape, after the window.print() command, immediately the next line is executing which results in printing the print button also.
                //      to avoid that, added a timeout.
                setTimeout("_UTL_ReportPrintDelay(document.getElementById('" + strElement[i] + "'))",1000); 
            }
            else
            {
                document.getElementById(strElement[i]).style.display = 'inline'; 
            }
		}
        }
    }

}

function _UTL_ReportPrintDelay(strElement)
{
        strElement.style.display = 'inline'; 
}
