/*
 * Navigator
 */
var jsNavigator = new _jsNavigator();

function _jsNavigator()
{
    this.name = navigator.appName;
    this.platform = navigator.platform;
    this.agent = navigator.userAgent;

    /* Check the navigator name */
    var agent = this.agent.toLowerCase();
    this.isMozilla = ( ( agent.indexOf( "mozilla" ) != -1 ) &&
                       ( agent.indexOf( "gecko" ) != -1 ) );
    this.isNetscape = ( ( agent.indexOf( "mozilla" ) != -1 ) &&
                       ( agent.indexOf( "gecko" ) == -1 ) &&
                       ( agent.indexOf( "compatible" ) == -1 ) &&
                       ( agent.indexOf( "opera" ) == -1 ) &&
                       ( agent.indexOf( "webtv" ) == -1 ) );
    this.isIE = ( agent.indexOf( "msie" ) != -1 );
    this.isOpera = ( agent.indexOf( "opera" ) != -1 );
    this.isKonqueror = ( agent.indexOf( "konqueror" ) != -1 );
    this.isAOL = ( agent.indexOf( "aol" ) != -1 );
    this.isWebTV = ( agent.indexOf( "webtv" ) != -1 );
    this.isSafari = ( agent.indexOf( "safari" ) != -1 );
    this.isUnknown = ( ! this.isMozilla && ! this.isNetscape &&
                       ! this.isIE && ! this.isOpera &&
                       ! this.isKonqueror && ! this.isAOL &&
		       ! this.isWebTV && ! this.isSafari);


    /* Parse the version number */
    var version;
    if ( this.isIE )
        version = this.agent.substring( this.agent.indexOf( "MSIE" ) + 5 );
    else
        version = navigator.appVersion;

    var i;
    i = version.search( "[^0-9\.]" );
    if ( i != -1 )
        version = version.substring( 0, i );

    this.version = version;
    this.major = parseInt( version );
    this.minor = parseInt( version.substring( version.indexOf( "." ) + 1 ) );

    /* Check the language */
    if ( this.isIE )
        this.language = navigator.userLanguage;
    else
        this.language = navigator.language;
}

/*
 * Add missing methods on builtin objects
 */
if ( jsNavigator.isIE && jsNavigator.major <= 5 )
{
    Array.prototype.push = function ( item )
    {
        this[this.length] = item;
    };

    Function.prototype.apply = function ( obj, args )
    {
        var _args = new Array();
        for ( var i = 0; i < args.length; ++i )
            _args.push( "args[" + i + "]" );
        _args = _args.join( "," );

        obj._func = this;
        eval( "obj._func(" + _args + ")" );
        obj._func = null;
    };
}


