var detect = navigator.userAgent.toLowerCase();
var windowsIE = ( checkPlatform( "msie" ) && checkPlatform( "win" ) );

function checkPlatform( string )
{
    place = detect.indexOf( string ) + 1;
    thestring = string;
    return place;
}

function webstartVersionCheck( versionString )
{
    // Mozilla may not recognize new plugins without this refresh
    navigator.plugins.refresh( true );
    
    // First, determine if Web Start is available
    if( navigator.mimeTypes[ 'application/x-java-jnlp-file' ] )
    {
        // Next, check for appropriate version family
        for( var i = 0; i < navigator.mimeTypes.length; i++ )
        {
            pluginType = navigator.mimeTypes[ i ].type;
            
            if( pluginType == "application/x-java-applet;version=" + versionString )
            {
                return true;
            }
	}
    }
}

function launch( app )
{
	if( windowsIE )
	{
	    document.write( "<object codeBase=\"http://java.sun.com/update/1.5.0/jinstall-1_5_0_05-windows-i586.cab\" classid=\"clsid:5852F5ED-8BF4-11D4-A245-0080C6F74284\" height=\"0\" width=\"0\">" );
	    document.write( "\t<param name=\"app\" value=\"" + app + "\">" );
		document.write( "\t<param name=\"back\" value=\"false\">" );
		document.write( "</object>" );
	}
	else
	{
		if( webstartVersionCheck( "1.5" ) )
	    {
	        clearInterval( launchTID );
	        window.location = app;
	    }
	    else
	    {
	    	window.open( "http://jdl.sun.com/webapps/getjava/BrowserRedirect?locale=en&host=java.com", "needdownload" );
	    }
	    
		launchTID = setInterval( 'launch( "' + app + '" )', 100 );
	}
}