/////////////////////////////////////////////////////////////////////////////
//
// 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.
//
// $Id: SYS_browser.js,v 1.6 2002/09/05 02:46:49 rahuls Exp $
// $Date: 2002/09/05 02:46:49 $
// $RCSfile: SYS_browser.js,v $
// $Revision: 1.6 $
//
// Abstract:
//
//    Browser class to identify browsers and operating system
//
// Revision History:
//
//    2002-02-25   Anand Arvind    Created file
//
/////////////////////////////////////////////////////////////////////////////

var BROWSER_UNKNOWN              = 0
var BROWSER_IE                   = 1
var BROWSER_MOZILLA              = 2

/////////////////////////////////////////////////////////////////////////////
//
// Function Name : _ObjBrowser
//
// Parameters    :
//
// Return        :
//
// Synopsis      :
//
/////////////////////////////////////////////////////////////////////////////
function _ObjBrowser()
{

    this.$nBrowser        = BROWSER_UNKNOWN ;
    this.$nBrowserVersion = 100 ;
    this.$strUA           = String(navigator.userAgent);

    _ObjBrowser.prototype.Init = function()
    {

        var $nBrowserChar    = "";
        var $nBrowserStart   = 0 ;

        if ( this.$strUA.indexOf("MSIE") >= 0 )
        {

            this.$nBrowser        = BROWSER_IE ;
            this.$nBrowserVersion = "";

            $nBrowserStart   = this.$strUA.indexOf("MSIE")+5
            $nBrowserChar    = this.$strUA.charAt($nBrowserStart);

            while ( $nBrowserChar != ";" )
            {
                if ( ( $nBrowserChar >= '0' && $nBrowserChar <= '9' ) || $nBrowserChar == '.' )
                    this.$nBrowserVersion += $nBrowserChar ;
                $nBrowserStart++;
                $nBrowserChar     = this.$strUA.charAt($nBrowserStart);
            };

           this.$nBrowserVersion = parseInt( parseFloat( this.$nBrowserVersion ) * 100 ) ;

        }
        else if ( this.$strUA.indexOf("Mozilla") >= 0 )
        {
            this.$nBrowser        = BROWSER_MOZILLA ;
            this.$nBrowserVersion = parseInt ( (this.$strUA.substring( this.$strUA.indexOf("/") + 1,  this.$strUA.indexOf("/") + 5  )) * 100 );
        }

    };

    _ObjBrowser.prototype.IsNetscape = function()
    {
        if ( this.$nBrowser == BROWSER_MOZILLA )
            return true ;
        return false ;
    }

    _ObjBrowser.prototype.IsIE = function()
    {
        if ( this.$nBrowser == BROWSER_IE )
            return true ;
        return false ;
    }

    _ObjBrowser.prototype.Version = function()
    {
        return this.$nBrowserVersion ;
    }

    _ObjBrowser.IsOSWindows = function()
    {
        if ( this.$strUA.indexOf("win") >= 0 || this.$strUA.indexOf("Win") >= 0 )
            return true ;
        return false ;
    }

    _ObjBrowser.prototype.IsWin95 = function()
    {
        if ( this.$strUA.indexOf("Windows 95") >= 0 )
            return true ;
        return false ;
    }

    _ObjBrowser.prototype.IsWinNT = function()
    {
        if ( this.$strUA.indexOf("Windows NT") >= 0 || this.$strUA.indexOf("WinNT") >= 0 )
            return true ;
        return false ;
    }


    _ObjBrowser.prototype.IsWin2000 = function()
    {
        if ( this.$strUA.indexOf("Windows NT 5.0") >= 0 )
            return true ;
        return false ;
    }

    _ObjBrowser.prototype.IsWinXP = function()
    {
        if ( this.$strUA.indexOf("Windows NT 5.1") >= 0 )
            return true ;
        return false ;
    }

    _ObjBrowser.prototype.Supports = function(strValue)
    {

        if ( strValue == "try/catch" )
        {
            if ( this.$nBrowser == BROWSER_IE && this.$nBrowserVersion >= 500 )
                return true ;
        };

        if ( strValue == "highlights" )
        {
            if ( this.$nBrowser == BROWSER_IE && this.$nBrowserVersion >= 500 )
                return true ;
        };

        return false ;

    }

    _ObjBrowser.prototype.IsNS4 = function()
    {
        if ( this.IsNetscape() && this.Version() < 500 )
            return true ;
        return false ;
    }

    _ObjBrowser.prototype.IsNS6 = function()
    {
        if ( this.IsNetscape() && this.Version() >= 500 )
            return true ;
        return false ;
    }

    _ObjBrowser.prototype.IsIE4 = function()
    {
        if ( this.IsIE() && this.Version() < 500 )
            return true ;
        return false ;
    }

}

