/////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2002 Click2Learn Corporation
//
// The copyright to the computer software herein is proprietary and remains
// the property of Click2Learn, USA. It may be used and/or copied only with
// the written consent of Click2Learn 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_objButton       = new Array();
var g_objBrowser      = new _ObjBrowser();
g_objBrowser.Init();

//
// Logging code
//
var g_UTL_DebugFlag   = false ;
var g_UTL_DebugWindow = null ;

function _UTL_EnterPressed()
{

    if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500)
    {
        return false ;
    }
    else
    {
        if ( window.event.keyCode == 13 )
            return true ;

        return false ;
    }

    return false ;
}

function _UTL_Trim(strValue)
{

    //
    // Remove leading and trailing spaces
    //
    var str1 = strValue.replace(/^\s*/,"");
    var str2 = str1.replace(/\s*$/,"");

    return str2 ;

}

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
    //
    document.onmousedown   = _UTL_BlockRightClick ;

    //
    // Context menu
    //
    document.oncontextmenu = _UTL_BlockContextMenu ;

    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()
{

    //
    // If CTRL pressed show context menu
    //
    if ( event.ctrlKey == true )
        return true ;

    //
    // Enable right click on hyperlinks and form fields: text-area and single line inputs
    //
    if ( event.srcElement.tagName == "TEXTAREA" ||
         event.srcElement.tagName == "INPUT"    ||
         event.srcElement.tagName == "A"  ||
         event.srcElement.tagName == "IMG"  ||
         event.srcElement.tagName == "IMAGE"  )
    {

    }
    else
    {

        event.cancelBubble = true ;
        event.returnValue  = false ;
        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_OpenWindow(strURL, strWindowName, nLaunchWidth, nLaunchHeight, strLaunchFeatures)
{

    var nScreenWidth      = 800 ;
    var nScreenHeight     = 600 ;
    var nLaunchWidth      = 800 ;
    var 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)
{
    var startURL            = strURL.indexOf("Path")
    var strLaunchFeatures   = "center:yes; help:no; status:no;"
    var nScreenWidth        = 800 ;
    var nScreenHeight       = 600 ;

    if ( arguments.length < 3 )
    {
        nLaunchWidth      = 800 ;
        nLaunchHeight     = 600 ;
    };

    if (window.screen)
    {

        nScreenWidth  = screen.availWidth  - 30;
        nScreenHeight = screen.availHeight - 15;
        nLaunchWidth  = Math.min(nLaunchWidth, nScreenWidth);
        nLaunchHeight = Math.min(nLaunchHeight, nScreenHeight);

    }

    if ( g_objBrowser.IsNS4() || g_objBrowser.IsIE4())
    {
        strLaunchFeatures   = "height=" + nLaunchHeight + ",width=" + nLaunchWidth + ""
        return _UTL_OpenModalWindowInNS(strURL,nLaunchWidth,nLaunchHeight, "return()", "win");
    }
    else
    {
        strLaunchFeatures += "dialogWidth:" + nLaunchWidth + "px; dialogHeight:" + nLaunchHeight + "px; ";
        return window.showModalDialog(strURL, self, strLaunchFeatures);
    }
}

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 "avc" :
        strDirName += "VirClass/_AspenVirClass.htm";
        break ;
    default :
        strDirName += "Learner/_AspenLearner.htm";
    }

    _UTL_OpenWindow(strDirName, "AspenHelp", 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] ;
            eval("bValue = ! ( typeof(" + strCheck + ") == \"undefined\" )");
            if ( bValue == false )
                break ;
        }
    }
    else
        eval("bValue = ! ( 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)
{

    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_PreLoadImage(imgObj,imgSrc)
{
    if (document.images)
    {
        eval(imgObj+' = new Image()')
        eval(imgObj+'.src = "'+imgSrc+'"')
    }
}


/////////////////////////////////////////////////////////////////////////////
//
// Function Name :
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
//   Manager mode employee selection
//
/////////////////////////////////////////////////////////////////////////////

function _UTL_Manager_SelectEmployee(nUserMode)
{

    var strRetVal = null ;

    strRetVal = _UTL_OpenModalWindow(_UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(_UTL_GetPagePath("management/LMS_EmpSelect.asp") + "?UserMode=" + nUserMode),
                                     "SkillInfo");

    //
    // Reload page
    //
    if ( strRetVal != "" && String(strRetVal) != "undefined")
        window.location = _UTL_GetPagePath("management/LMS_ManagerHome.asp") ;


}

/////////////////////////////////////////////////////////////////////////////
//
// 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()
{
    if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )
    {
         return;
    }

    var objElement  = event.srcElement ;
    var objTableRow = objElement.parentElement.parentElement ;

    if ( objElement.type == "radio" )
        _UTL_HtmlTable_RowUnTouchAll();

    if ( objElement.checked )
    {
        if ( objTableRow.className == "clsTableRowOdd" )
            objTableRow.className = "clsTableRowSelectedOdd";
        else
            objTableRow.className = "clsTableRowSelectedEven";
    }
    else
    {
        if ( objTableRow.className == "clsTableRowSelectedOdd" )
            objTableRow.className = "clsTableRowOdd";
        else
            objTableRow.className = "clsTableRowEven";
    }
}


function _UTL_HtmlTable_RowUnTouchAll()
{
    if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )
    {
         return;
    }

    var objTable      = event.srcElement.parentElement.parentElement.parentElement ;
    var objTableRow   = objTable.children

    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";
    }
}

function _UTL_HtmlTable_RowUnTouchAllEx(strTableName,strForm,strType)
{
    if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )
    {
        var objTemp = "";
        var bFlag   = false;
        var objTR   = document.forms[strForm];

        for ( var i = 0 ; i < objTR.length ; i++ )
        {
            objTemp = objTR[i];     // making square brackets
            if ( objTemp.type == "option" && objTemp.name == strType ) // removed the tagname check
            {
                objTemp.checked = bFlag ;
            }// end checkbox test
        }// end loop

    }// browser
    else
    {
        var objTable      = document.all[strTableName];
        var objTableRow   = null;

        //
        // Check if table exists before doing anything
        //
        if ( objTable )
        {
            objTableRow   = objTable.all.tags("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";
            }
        }

    }//browser
}

function _UTL_HtmlTable_RowTouchedAll(strType,el,strForm) // Adding el and strForm arguments to make it Netscape compatible.
{
    /*
     * <table><tr><td><input>
     */

    var objTR       = "";
    var objTable    = "";
    var bFlag       = "";
    var objTemp     = "";
    var bSkippedFirst   = "";

    if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )
    {
        bFlag = el.checked;
    }
    else
    {
        objTable      = event.srcElement.parentElement.parentElement.parentElement ;
        objTR         = objTable.children
        bFlag         = event.srcElement.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(i);

            if ( objTemp.tagName == "TR" )
            {
                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
            }// end TR check
        }// end for length loop
    }// end netscape check

    objTR = (g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )? document.forms[strForm]:objTable.all.tags("INPUT") ; // for netscape use the form element

    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
}

function _UTL_HtmlTable_GetCheckedData(strForm, strTable, strName)
{
    /*
     * <table><tr><td><input>
     */
    var objForm       = document.forms[strForm];    // Accessing through forms collection
    var objTable      = (g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )? null: document.all[strTable];                     // For Netscape assign Null
    var objTR         = null ;
    var objTemp       = null ;
    var strList       = "";

    //
    // Check if anything has been selected before submitting form
    //

    if ( !g_objBrowser.IsNetscape() && objTable == null )                                                                               // For Netscape ignore this check
        return "";

    objTR = (g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )?objForm:objTable.all.tags("INPUT") ;                           // For Netscape use form object

    for ( var i = 0 ; i < objTR.length ; i++ )
    {
        objTemp = objTR[i]; // Using Square Brackets

        if ( objTemp.type == "checkbox" && objTemp.name == strName && objTemp.checked ) // Removed the tagName check for Netscae compatibility
        {
            strList += objTemp.value + ",";
        }
    }
    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
    {
        eval( strAspLink );
        return;
    }

    var objSearch = ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 ? document.forms[strForm].SearchStrInput : document.all["SearchStrInput"]);
    var strTerm   = _UTL_Trim(objSearch.value);

/*
    if ( strTerm.length == 0 )
    {
        alert(L_Error_SysNoSearchTerm);
        objSearch.focus();
        return ;
    }
*/

    if (g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )document.write(""); // For Some reason this make it work in NS
    window.location  = strAspLink + "&SearchStr=" + escape(strTerm);
}

function _UTL_SearchBox_SearchStr(strForm)  // could not find the calling function. Udpdating for Netscape compatibility
{

    var objSearch = ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 ? document.forms[strForm].SearchStrInput : document.all["SearchStrInput"]);
    var strTerm   = _UTL_Trim(objSearch.value);

    return strTerm ;

}

function _UTL_SearchBox_SearchKP(strAspLink,strForm,bLinkIsJS)    // Added the strForm Argument
{
    var objSearch = ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 ? document.forms[strForm].SearchStrInput : document.all["SearchStrInput"]);

    //
    // Event handler for key press
    //
    if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500)
    {
    document.forms[strForm].SearchStrInput.onkeypress = function(e) // mapping the keypress function
    {
        if ( e.which == 13 ) // checking for enter key pressed
        {
        _UTL_SearchBox_Search(strAspLink,strForm,bLinkIsJS);  // Added the strForm Argument
        } // end key code check
    }// end function
    }
    else
    {
    if ( _UTL_EnterPressed() )
    {
         _UTL_SearchBox_Search(strAspLink,strForm,bLinkIsJS);     // Added the strForm Argument
         window.event.cancelBubble=true;
         window.event.returnValue=false;
         return false ;
    }
    else
    {
         return false ;
    }
    }// end browser check
}

/////////////////////////////////////////////////////////////////////////////
//
// 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_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(strName, strCloseAlt, strOpenAlt,parentElement)
{
    if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )
    {
        var firstEl = parentElement;
        var firstInd = _UTL_HtmlInfoBox_getIndex(firstEl);
        var tempName = _UTL_HtmlInfoBox_getDivNames(strName) // removes all "-"from the name

        whichEl = eval("document." + tempName + "Child");
        if (whichEl.visibility == "hide") {
            whichEl.visibility = "show";
        }
        else {
            whichEl.visibility = "hide";
        }

        _UTL_HtmlInfoBox_arrange(firstInd);



    }
    else // browser check
    {
        var objBoxHT  = document.all[strName+"-headtbl"];
        var objBoxHLI = document.all[strName+"-headlimg"];
        var objBoxHRI = document.all[strName+"-headrimg"];
        var objBoxDD  = document.all[strName+"-datadiv"];

        if ( objBoxDD.style.display == "" )
        {
            objBoxHT.className     = "clsBoxHeaderClosed";
            objBoxHLI.src          = g_imgHtmlInfoBoxLC.src ;
            objBoxHRI.src          = g_imgHtmlInfoBoxRC.src ;
            objBoxHRI.alt          = strOpenAlt ;
            objBoxDD.style.display = "none";
        }
        else
        {
            objBoxHT.className     = "clsBoxHeaderOpen";
            objBoxHLI.src          = g_imgHtmlInfoBoxLO.src ;
            objBoxHRI.src          = g_imgHtmlInfoBoxRO.src ;
            objBoxHRI.alt          = strCloseAlt ;
            objBoxDD.style.display = "";
        }
    } //browser check
}

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 specific to IE right now
    //
    m_objPageForm = eval('document.' + p_strFormName);

    //
    // 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);
            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) {
        var objField = eval('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 objField = eval('m_objPageForm.' + p_strFieldName);
        var strValue = _UTL_Trim(objField.value);

        if (strValue.length > p_iLength) {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
        }
    }

    //
    // 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   ) {

        var objField = eval('m_objPageForm.' + p_strFieldName);
        var strValue = _UTL_Trim(objField.value);

        if (strValue.match(p_objValidMatch) == null) {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
        }
    }

    //
    // 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) {

        var objField = eval('m_objPageForm.' + p_strFieldName);
        var strValue = _UTL_Trim(objField.value);

        if (strValue != strValue.replace(p_objValidMatch, ''))
        {
            SYS_UTL_QueueValidationError(objField, p_strViolationMessage);            
        }
    }


     //
    // 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   )   {


        if ( g_objBrowser.IsNetscape() && g_objBrowser.Version() < 500 )
        {
            var objField = eval('m_objPageForm.'+ p_strFieldName+'.selectedIndex');
            var strValue = objField;
        }
        else
        {
            var objField = eval('m_objPageForm.' + p_strFieldName);
            var strValue = objField.value;
        }
        if (strValue == 0)  {
        SYS_UTL_QueueValidationError(objField, p_strViolationMessage);
        }
    }

    //
    // 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 (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++;
    }
}

/////////////////////////////////////////////////////////////////////////////
//
// 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].src = g_objButton[id].pic.src;
        window.status = "";
    }
}


function _UTL_MButton_Disable(id)
{

    if ( g_objButton[id] && document[id] )
    {
        document[id].src = g_objButton[id].pic_disabled.src;
        window.status = "";
    }

}

function _UTL_GetCoreAuthoringPagePath(strPage)
{
    //alert(STRING_SITE_PREFIX + "/core/authoring/" + strPage );
    return ( STRING_SITE_PREFIX + "/core/authoring/" + strPage );

}




function _UTL_GetCoreAuthoringPagePath(strPage)
{
    //alert(STRING_SITE_PREFIX + "/core/authoring/" + 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

function _UTL_ExportToExcel(bShowExportOpt, nRecords, bIsPost, strFormName, strOpenURL)
{
    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");
            strWindowName = "Export";

            strURL = _UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(strURL);
            _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
            strWindowName = "Export";

            strURL = _UTL_GetCorePagePath("SYS_ModalDialog.asp") + "?Path=" + escape(strURL);
        //strURL = unescape(strURL);

            _UTL_OpenModalWindow(strURL, strWindowName,370,270);
        }
        else
        {
            strURL = _UTL_CreateExportQueryString(window,strOpenURL,strFormName)

            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(escape(strURL));
            _UTL_OpenModalWindow(strURL, strWindowName,370,270);
        }
    }
}


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;
    }
}

function _UTL_CreateExportQueryString(objOpener,strURL,strFormName)
{
    var strURLTemp = strURL + "?";
    var myform = objOpener.document.forms[strFormName];
    for ( var i = 0; i < myform.elements.length; i++)
    {
        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;
}

function _UTL_OpenWindow_Export(strURL)
{
    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:130px; center:yes";
        window.showModelessDialog(strProgressURL, null, winstyle);
    }
     
    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;
}
