//
// Dashboard
//
	var g_CheckDashboardFuncID = -1;
	var g_focusObject = null;
	var g_delayLoadTime = 500;

    var origWidth
    var origHeight
    
    if ( NS4 )
    {
	    origWidth = window.innerWidth
	    origHeight = window.innerHeight
	    window.onresize = NSResize
		g_delayLoadTime = 1000 // increase the timeout since Netscape is really slow in loading the applets.
    }
    else
    {
        window.onresize = onResizeFunction
    }
    
    function NSResize()
    {
     	if ( NS7 || NS6 || ( NS4 && ( HP || Sun ) ) )
    	{
    		window.location.reload()
    	}
    	else
    	{
	    	if ( window.innerWidth - 24 > 5 )
	    	{
				if ( typeof( window.document.applets.Dashboard ) != "undefined" )
				{
		        	document.Dashboard.setSize( window.innerWidth - 24, 18 )
		        	window.scroll( 0, 0 )
		        }
			}
		}
   }
	
    function onLoadFunction()
    {
    	pageLoaded = true

    	if ( !( isMac && NS4 ) )
    	{
			if ( typeof( window.document.applets.Dashboard ) != "undefined" )
			{
        		onResizeFunction()
			}
		}

		executeAtlasFunction( 'AtlasAutoSync', document.location )
		saveAtlasURL()

		if ( g_focusObject != null )
		{
			// sanity check...
			if ( g_CheckDashboardFuncID != -1 )
			{
				clearInterval( g_CheckDashboardFuncID );
			}

 			g_CheckDashboardFuncID = setInterval( "checkDashboardFunc()", g_delayLoadTime);
		}

        return false
    }

	function checkDashboardFunc()
	{
		var appletsLoaded = true;
		for ( var i = 0; i < window.document.applets.length; i++ )
		{
			if ( typeof( window.document.applets[i] ) != "object" )
			{
				appletsLoaded = false;
			}
		}

		if ( appletsLoaded )
		{
			if ( g_focusObject != null )
			{
				if ( typeof( g_focusObject ) == "string" )
				{
					g_focusObject = eval( g_focusObject );
				}
					
				if ( typeof( g_focusObject ) == "object" )
				{
					g_focusObject.focus();
				}

				clearInterval( g_CheckDashboardFuncID );
			}
		}
	}

    function onResizeFunction()
    {
		if ( typeof( window.document.applets.Dashboard ) != "undefined" )
		{
	        if ( NS4 )
	        {
	        	if ( !isMac )
	        	{
	        		if ( window.innerWidth > 5 )
	        		{
						if ( typeof( window.document.applets.Dashboard ) != "undefined" )
						{
		        			window.document.applets.Dashboard.setSize( Math.floor( window.innerWidth * ( 75 / 100 ) ), 18 )
		        			window.scroll( 0, 0 )
		        		}
	        		}
	        	}
	        }
	        else
	        {
	        	if ( window.document.body.clientWidth > 5 )
	            {
					// the 99/100 part is a little way of tricking IE.
					window.document.applets.Dashboard.width =  Math.floor( window.document.body.clientWidth * ( 70 / 100 ) )
				}
			}
 		}
		
        return false
    }
    
    function getAppletWidth()
    {
        var appSize

		// The applet width is relative in the beginning because before the page is layed
		// out the size is 0.
		// The proper size will be set through the onResize function
		appSize = Math.floor( window.document.body.clientWidth * ( 70 / 100 ) )
		
        return appSize
    }
