var fractalMap =
{
    client: "na",
    pluginBuild: 57,
    mapLoaded : false,
    optionsLoaded : false,
    flashInitialised : false,
    
    includes : function()
    {
        var inc;
        var agt = navigator.userAgent.toLowerCase();
        
        this.isSafari = ( agt.indexOf( "safari" )!= -1 );
        
        var isKhtml = ( this.isSafari || ( agt.indexOf( "konqueror" ) != -1 ) );
        var isGecko = ( ( !isKhtml ) && ( navigator.product ) && ( navigator.product.toLowerCase() =="gecko" ) );
        
        this.isWin = ( agt.indexOf( "win" )!= -1 );
        this.isIE = ( ( this.isWin ) && ( navigator.appName.toLowerCase().indexOf( 'internet explorer' ) != -1 ) );
        this.isMoz = ( ( agt.indexOf( "mozilla/5" ) !=-1 ) && ( agt.indexOf( "spoofer" ) == -1 ) && ( agt.indexOf( "compatible" ) == -1 ) && ( agt.indexOf( "opera" ) == -1 ) && ( agt.indexOf( "webtv" ) == -1 ) && ( agt.indexOf( "hotjava" ) == -1 ) && ( isGecko ) &&  ( ( navigator.vendor == "" ) || ( navigator.vendor == "Mozilla " ) || ( navigator.vendor == "Debian" ) ) );

        this.client = this.parameter( "install", this.client );
        
        if ( this.client == "na" )
        {
            if ( this.checkClient( "plugin" ) )
            {
                this.client = "plugin";
            }
            else if ( this.checkClient( "flash" ) )
            {
                this.client = "flash";
            }
            else if ( this.checkClient( "ajax" ) )
            {
                this.client = "ajax";
            }
        }

        inc = '<link rel="stylesheet" type="text/css" href="' + fractalMapVars.clientURL + 'fractalmap.css">';
        inc += '<script language="JavaScript" type="text/javascript" src="' + fractalMapVars.clientURL + 'fractalmaptooltip.js"></script>';
        
        if ( this.client == "ajax" )
        {
            inc += '<link rel="stylesheet" type="text/css" href="' + fractalMapVars.clientURL + 'fractalmapajax.css">';
            inc += '<script language="JavaScript" type="text/javascript" src="' + fractalMapVars.clientURL + 'fractalmapajax.js"></script>';
            inc += '<script language="JavaScript" type="text/javascript" src="' + fractalMapVars.clientURL + 'fractalmapajaxtooltip.js"></script>';
        }
        
        if ( this.client == "flash" )
        {
            inc += '<script language="JavaScript" type="text/javascript" src="' + fractalMapVars.clientURL + 'fractalmapflashtooltip.js"></script>';
        }
        
        return inc;
    },
    
    html : function()
    {
        var v1, v2;
        var words;
        var i;
        var html = "";
        
        if ( this.client == "na" )
        {
            html = '<div id="FractalMap">Sorry, no appropriate client could be found to display the Fractal Map on your browser.</div>';
        }        
        else if ( this.isIE )
        {
            if ( this.client == "plugin" )
            {
                html = '<object id="FractalMap" codebase="' + fractalMapVars.pluginURL + 'FractalMapBrowserPlugin.cab#Version=2,0,0,' + this.pluginBuild + '" classid="clsid:9E5B17BA-6A83-4b2f-8BEF-3DA20CCD6C33"><param name="resource" value="' + this.includeURL( "fmp" ) + '"/></object>';
            }
            else if ( this.client == "flash" )
            {
                html = '<object id="FractalMap" codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#Version=9,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="allowScriptAccess" value="always" /><param name="movie" value="' + fractalMapVars.flashURL + 'FractalMap.swf" /><param name="wmode" value="transparent" /><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="bgcolor" value="#ffffff" /><param name="FlashVars" value="data=' + escape( this.includeURL( "flash" ) ) + '&options=' + escape( fractalMapVars.includesURL + 'options.js' ) + '" /></object>';
            }
        }
        else if ( this.isMoz || this.isSafari )
        {
            if ( ( this.client == "plugin" ) && ( this.isWin ) )
            {
                if ( navigator.plugins[ "Fractal:Edge Browser Plugin" ] )
                {
                    words = navigator.plugins[ "Fractal:Edge Browser Plugin" ].description.split( " " );

                    for ( i = 0, v1 = new Number( "2." + this.pluginBuild ); i < words.length; i++ )
                    {
                        v2 = parseFloat( words[ i ] );
                        
                        if ( ( !isNaN( v2 ) ) && ( v2 >= v1 ) )
                        {
                            html = '<embed name="FractalMap" id="FractalMap" border="0" type="application/x-fractaledge" src="' + this.includeURL( "fmp" ) + '"/>';
                            break;
                        }
                    }
                }
                
                if ( html == "" )
                {
                    html = '<a href="javascript: void fractalMap.xpiPluginDownload();">Firefox (and other Mozilla-based browsers) users please click here to install the required plugin.</a><br><br><a href="http://www.fractaledge.com/components/help/">Click here</a> for online Fractal Map help.';
                }
            }
            else if ( this.client == "flash" )
            {
                html = '<embed src="' + fractalMapVars.flashURL + 'FractalMap.swf" quality="high" scale="exactfit" bgcolor="#ffffff" id="FractalMap" allowScriptAccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="data=' + escape( this.includeURL( "flash" ) ) + '&options=' + escape( fractalMapVars.includesURL + 'options.js' ) + '"></embed>';
            }
        }
       
        if ( this.client == "ajax" )
        {
            html = '<img id="FractalMap" src="" alt="" usemap="#im" onload="fractalMapAjax.onImageLoaded();" oncontextmenu="return fractalMapAjax.fractalMapContextMenu( event );"/>'
            + '<map id="im" name="im"></map>'
            + '<div id="FractalMapOverlay" style="position: absolute; background: #FFFFFF; width: ' + fractalMapVars.width + 'px; height: ' + fractalMapVars.height + 'px;">'
            + '<img style="position: relative; left: 50%; top: 50%; margin-left: -12px; margin-top: -12px; width: 24px; height: 24px;" src="' + fractalMapVars.imagesURL + 'fmanimated.gif" alt="" /></div>';
        }
        
        html += '<div id="FractalMapSplash" onclick="fractalMap.showSplash( false );">'
        + '<img src="' + fractalMapVars.imagesURL + 'logo128.gif" width="128" height="158" alt="Fractal Edge Logo" /><br />'
        + '<div class="FractalMapProgress"><div id="FractalMapProgress"></div></div>'
        + '<div id="FractalProgressText">&nbsp;</div><br />'
        + 'By using this product you agree to be bound by its <a href="http://www.fractaledge.com/components/terms.htm" target="popup">Terms of Use</a>.<br /><br />'
        + 'Copyright &copy; <a href="http://www.fractaledge.com" target="_blank">Fractal Edge Limited</a> 1998-2008. All rights reserved.<br /><br />'
        + 'Fractal Edge, the Fractal Edge logo and Fractal Map are either registered trademarks or trademarks of Fractal Edge Limited in the United Kingdom and/or other territories.<br /><br />'
        + 'This product is protected in Belgium, France, Ireland, Italy, the Netherlands, Spain and the United Kingdom by patent EP1105817, in Germany by patent GE698 08 152.8-08,  in the United States of America by patent US6,775,659, in Australia by patent AU775871 and by further patents and pending patents in these and other territories.'
        + '</div>';
        
        if ( this.client == "ajax" )
        {
            html += '<span id="FractalMapText"></span><div id="FractalMapDivs"></div><div id="FractalMapMenu"></div>';
        }

        if ( ( this.client == "ajax" ) || ( this.client == "flash" ) )
        {
            html += '<div id="FractalMapTooltip"></div>';
        }

        return html;
    },
    
    parameter : function( name, value )
    {
        var i;
        var param;
        
        name += "=";
        
        if ( ( ( i = document.URL.indexOf( "?" ) ) >= 0 ) && ( ( i = document.URL.indexOf( name, i ) ) >= 0 ) )
        {
            param = document.URL.substring( i + name.length );
            
            if ( ( i = param.indexOf( "&" ) ) >= 0 )
            {
                param = param.substring( 0, i );
            }
            
            if ( param.length > 0 )
            {
                value = param;
            }
        }
        return value;
    },
    
    includeURL : function( op )
    {
        var opt;
        var i;
        
        opt = ( op == "flash" ) ? this.parameter( "structure", "" ) : "";
        
        if ( fractalMapVars.serverURL )
        {
            if ( opt == "" )
            {
                for ( i = 0; i < fractalMapOptions.hierarchy.length; i++ )
                {
                    if ( fractalMapOptions.hierarchy[ i ].active )
                    {
                        opt = fractalMapOptions.hierarchy[ i ].subid;
                        break;
                    }  
                }
            }
            
            opt = "&structure=" + opt;
            
            return fractalMapVars.serverURL + "project=" + fractalMapVars.project + "&op=" + op + opt;
        }
        else switch ( op )
        {
        case "fmp":
        
            return fractalMapVars.includesURL + fractalMapVars.project + ".fmp";

        case "flash":
        
            if ( opt != "" ) opt = "_" + opt;
            
            return fractalMapVars.includesURL + fractalMapVars.project + opt + ".js";
        }
        return "";
    },
    
    initialise : function()
    {
        var a;
        
        if ( fractalMapOptions )
        {
            this.setOptions( fractalMapOptions );
        }
        
        if ( ( this.client == "flash" ) && !this.flashInitialised )
        {
            document.getElementById( "FractalMapSplash" ).style.display = "none";
        }        
        else if ( this.client == "na" )
        {
            this.mapLoaded = true;
            
            this.showSplash( false );
        }
        else if ( !this.mapLoaded )
        {
            this.showSplash( true );
        }
        
        if ( null != ( a = document.getElementById( "FractalMapClientPlugin" ) ) )
        {
            a.style.display = ( ( !fractalMapVars.pluginURL ) || ( this.client == "plugin" ) || ( !this.isWin ) || !( this.isIE || this.isMoz || this.isSafari ) ) ? "none" : "inline";
        }
        if ( null != ( a = document.getElementById( "FractalMapClientFlash" ) ) )
        {
            a.style.display = ( ( fractalMapVars.flashURL ) && ( this.client != "flash" ) ) ? "inline" : "none";
        }
        if ( null != ( a = document.getElementById( "FractalMapClientAjax" ) ) )
        {
            a.style.display = ( ( fractalMapVars.serverURL ) && ( this.client != "ajax" ) ) ? "inline" : "none";
        }
    },
    
    checkClient : function( client )
    {
        switch ( client )
        {
        case "plugin":
        
            return ( ( fractalMapVars.pluginURL ) && ( this.checkPlugin( "FractalMapPluginMSIE", "Fractal:Edge Browser Plugin" ) ) );
            
        case "flash":
        
            return ( ( fractalMapVars.flashURL ) && ( this.checkPlugin( "ShockwaveFlash.ShockwaveFlash.9", "Shockwave Flash" ) ) );

        case "ajax":
        
            return ( fractalMapVars.serverURL ) ? true : false;            
        }
        return false;
    },
    
    checkPlugin : function( ax, pl )
    {
        var obj;

        try
        {
            if ( this.isIE )
            {
                obj = new ActiveXObject( ax );
                obj = null;
                
                return true;
            }
            else if ( ( ( ax != "FractalMapPluginMSIE" ) || !this.isSafari || this.isWin ) && ( navigator.plugins[ pl ] ) )
            {
                return true;
            }
        }
        catch ( e )
        {
        }
        return false;
    },
    
    setOptions : function( data )
    {
        var opt;
        
        this.data = data;
        
        this.createOptions( data.analytic, "analytic:", this.analytic = document.getElementById( "FractalMapColour" ) );
        this.createOptions( data.ashaders, "ashaders:", this.ashaders = document.getElementById( "FractalMapShade" ) );
        this.createOptions( data.hierarchy, "hierarchy:", this.hierarchy = document.getElementById( "FractalMapStructure" ) );
        this.createOptions( data.dicons, "dicons:", this.dicons = document.getElementById( "FractalMapArrows" ) );
        this.createOptions( data.sort, "sort:", this.sort = document.getElementById( "FractalMapSort" ) );
        this.createOptions( data.sizing, "sizing:", this.sizing = document.getElementById( "FractalMapSizing" ) );
        
        if ( this.ashaders != null )
        {
            this.onOptionChanged( this.ashaders.options[ this.ashaders.selectedIndex ].value );
        }

        if ( ( this.analytic != null ) && ( ( this.legend = document.getElementById( "FractalMapLegend" ) ) != null ) )
        {
            this.onOptionChanged( this.analytic.options[ this.analytic.selectedIndex ].value );
        }
        
        this.optionsLoaded = true;
        
        if ( this.client == "ajax" )
        {
            fractalMapAjax = new fractalMapAJAXClient();
            
            fractalMapAjax.loadNode( "" );
        }
 
        this.showSplash( false );
    },
    
    getOption : function( select )
    {
        return ( ( select != null ) && ( select.options.length > 0 ) ) ? select.options[ select.selectedIndex ].value + ";" : "";
    },
    
    getOptions : function()
    {
        return  this.getOption( this.analytic )
        +       this.getOption( this.ashaders )
        +       this.getOption( this.hierarchy )
        +       this.getOption( this.dicons )
        +       this.getOption( this.sort )
        +       this.getOption( this.sizing );
    },
    
    createOptions : function( data, option, select )
    {
        var i;
        var selected;
        var empty;
        var active;

        if ( select != null )
        {
            active = ( option == "hierarchy:" ) ? this.parameter( "structure", "" ) : "";
            
            for ( i = 0, selected = 0; i < data.length; i++ )
            {
                if ( active != "" )
                {
                    if ( data[ i ].subid == active )
                    {
                        selected = i;
                    }
                }
                else if ( data[ i ].active )
                {
                    selected = i;
                }
                
                select.add( new Option( data[ i ].title, option + data[ i ].subid, false, false ), empty );
            }
            
            select.selectedIndex = selected;
            
            this.setEvent( select, "change", fractalMapSelectOption );
        }
    },
    
    setOption : function( event )
    {
        var node;
        var i;
        var select = ( event.srcElement ) ? event.srcElement : event.target;
        var opt = select.options[ select.selectedIndex ].value;
        
        switch ( this.client )
        {
        case "plugin":
        
            document.getElementById( "FractalMap" ).Display.setOption( "option", opt );
            break;
            
        case "flash":
        
            if ( opt.indexOf( "hierarchy" ) == 0 )
            {
                opt = opt.substring( 10 );
                
                for ( i = 0; i < this.data.hierarchy.length; i++ )
                {
                    if ( this.data.hierarchy[ i ].subid == opt )
                    {
                        opt = ( this.data.hierarchy[ i ].active ) ? "" : "&structure=" + opt;
                        break;
                    }
                }
                window.open( "?install=flash" + opt, "_self" );
            }
            else
            {
                document.getElementById( "FractalMap" ).setOption( "option", opt );
                this.onOptionChanged( opt );
            }
            break;
            
        case "ajax":

            fractalMapAjax.loadNode( ( ( opt.indexOf( "hierarchy" ) == 0 ) || ( opt.indexOf( "sort" ) == 0 ) ) ? "" : fractalMapAjax.currNode );
            this.onOptionChanged( opt );
            break;
        }
    },
    
    onOptionChanged : function( option )
    {
        var i, j, k, l, m;
        var col, col2;
        var w, w2, w3, w4, w5;
        var img;
        var tl, tc, tr;

        if ( ( this.ashaders != null ) && ( option.indexOf( "ashaders:" ) == 0 ) )
        {
            option = option.substring( 9 );
            
            for ( i = 0; i < this.data.ashaders.length; i++ )
            {
                if ( this.data.ashaders[ i ].subid == option )
                {
                    for ( j = 0; j < 3; j++ )
                    {
                        img = document.images[ "FractalMapShade" + j ];
                        
                        if ( this.data.ashaders[ i ].shaders.length > j )
                        {
                            img.src = fractalMapVars.imagesURL + 'shade' + this.data.ashaders[ i ].shaders[ j ].value + '.gif';
                            img.alt = this.data.ashaders[ i ].shaders[ j ].label;
                            img.title = this.data.ashaders[ i ].shaders[ j ].label;
                            img.style.visibility = 'visible';
                        }
                        else
                        {
                            img.style.visibility = 'hidden';
                        }
                    }
                    break;
                }
            }
        }
        
        if ( ( this.analytic != null ) && ( option.indexOf( "analytic:" ) == 0 ) )
        {
            option = option.substring( 9 );
            
            for ( i = 0; i < this.data.analytic.length; i++ )
            {
                if ( this.data.analytic[ i ].subid == option )
                {
                    while ( this.legend.firstChild != null )
                    {
                        this.legend.removeChild( this.legend.firstChild );
                    }
                    
                    if ( this.data.analytic[ i ].gradient )
                    {
                        w = fractalMapVars.width + fractalMapVars.extraWidth;
                        
                        if ( this.data.analytic[ i ].belowRange )
                        {
                            this.createLegend( this.data.analytic[ i ].belowRange, 26 );
                            w -= 26;
                        }

                        if ( this.data.analytic[ i ].aboveRange )
                        {
                            w -= 26;
                        }
                        
                        if ( this.data.analytic[ i ].noData )
                        {
                            w -= 26;
                        }

                        col = this.data.analytic[ i ].gradient[ 0 ].colour;
                        col2 = new Array( 3 );
                        
                        for ( j = 1, w2 = 1, w3 = 1 / ( this.data.analytic[ i ].gradient.length - 1 ); j < w; j++ )
                        {
                            for ( k = j / w, l = w3, m = 0; k > l; l += w3, m++ );
                            
                            k = ( k - ( l - w3 ) ) / w3;
                            
                            this.calculateGradient( this.data.analytic[ i ].gradient[ m ].colour, this.data.analytic[ i ].gradient[ m + 1 ].colour, col2, k );
                            
                            if ( ( col[ 0 ] == col2[ 0 ] ) && ( col[ 1 ] == col2[ 1 ] ) && ( col[ 2 ] == col2[ 2 ] ) )
                            {
                                w2++;
                            }
                            else
                            {
                                this.createLegend( col, w2 );

                                w2 = 1;
                                col = col2;
                                col2 = new Array( 3 );
                            }
                        }
                                
                        this.createLegend( col, w2 );

                        if ( this.data.analytic[ i ].aboveRange )
                        {
                            this.createLegend( this.data.analytic[ i ].aboveRange, 26 );
                        }
                        
                        if ( this.data.analytic[ i ].noData )
                        {
                            this.createLegend( this.data.analytic[ i ].noData, 26 );
                        }

                        if ( this.data.analytic[ i ].belowRange )
                        {
                            this.createLegendValue( "&lt;", "center", 26 );
                        }

                        for ( j = 0, w2 = Math.floor( w / this.data.analytic[ i ].gradient.length ); j < this.data.analytic[ i ].gradient.length; j++, w -= w2 )
                        {
                            if ( j == 0 )
                            {
                                this.createLegendValue( this.data.analytic[ i ].gradient[ j ].value, "left", w2 );
                            }
                            else if ( j == ( this.data.analytic[ i ].gradient.length - 1 ) )
                            {
                                this.createLegendValue( this.data.analytic[ i ].gradient[ j ].value, "right", w );
                            }
                            else
                            {
                                this.createLegendValue( this.data.analytic[ i ].gradient[ j ].value, "center", w2 );
                            }
                        }
                                
                        if ( this.data.analytic[ i ].aboveRange )
                        {
                            this.createLegendValue( "&gt;", "center", 26 );
                        }

                        if ( this.data.analytic[ i ].noData )
                        {
                            this.createLegendValue( "NA", "center", 26 );
                        }
                    }
                    else if ( this.data.analytic[ i ].bands )
                    {
                        w = fractalMapVars.width + fractalMapVars.extraWidth;
                        
                        if ( this.data.analytic[ i ].noBand )
                        {
                            w -= 26;
                        }
                        
                        if ( this.data.analytic[ i ].noData )
                        {
                            w -= 26;
                        }

                        w2 = Math.floor( w / this.data.analytic[ i ].bands.length );
                        
                        for ( j = 0, w3 = w; j < this.data.analytic[ i ].bands.length; j++, w3 -= w2 )
                        {
                            for ( k = 0; k < this.data.analytic[ i ].bands.length; k++ )
                            {
                                if ( this.data.analytic[ i ].bands[ k ].map == j )
                                {
                                    if ( j == ( this.data.analytic[ i ].bands.length - 1 ) )
                                    {
                                        w2 = w3;
                                    }
                                    this.createLegend( this.data.analytic[ i ].bands[ k ].colour, w2 );
                                    break;
                                }
                            }
                        }
                                
                        if ( this.data.analytic[ i ].noBand )
                        {
                            this.createLegend( this.data.analytic[ i ].noBand, 26 );
                        }

                        if ( this.data.analytic[ i ].noData )
                        {
                            this.createLegend( this.data.analytic[ i ].noData, 26 );
                        }

                        for ( j = 0, w3 = w; j < this.data.analytic[ i ].bands.length; j++, w3 -= w2 )
                        {
                            for ( k = 0; k < this.data.analytic[ i ].bands.length; k++ )
                            {
                                if ( this.data.analytic[ i ].bands[ k ].map == j )
                                {
                                    if ( j == ( this.data.analytic[ i ].bands.length - 1 ) )
                                    {
                                        w2 = w3;
                                    }
                                    
                                    tl = tc = tr = null;
                                    
                                    if ( this.data.analytic[ i ].bands[ k ].min )
                                    {
                                        tl = "[ " + this.data.analytic[ i ].bands[ k ].min;
                                    }
                                    else
                                    {
                                        tl = "&lt;";
                                    }

                                    if ( this.data.analytic[ i ].bands[ k ].max )
                                    {
                                        tr = this.data.analytic[ i ].bands[ k ].max + "]";
                                    }
                                    else
                                    {
                                        tr = "&gt;";
                                    }

                                    if ( ( this.data.analytic[ i ].bands[ k ].min ) && ( this.data.analytic[ i ].bands[ k ].max ) && ( this.data.analytic[ i ].bands[ k ].min == this.data.analytic[ i ].bands[ k ].max ) )
                                    {
                                        tl = "[";
                                        tc = this.data.analytic[ i ].bands[ k ].min;
                                        tr = "]";
                                    }
                                    
                                    if ( tc != null )
                                    {
                                        w4 = Math.floor( w2 / 3 );
                                        w5 = w2 - ( w4 * 2 );
                                    }
                                    else
                                    {
                                        w4 = Math.floor( w2 / 2 );
                                        w5 = w2 - w4;
                                    }
                                        
                                    this.createLegendValue( tl, "left", w4 );
                                    
                                    if ( tc != null )
                                    {
                                        this.createLegendValue( tc, "center", w4 );
                                    }

                                    this.createLegendValue( tr, "right", w5 );
                                    break;
                                }
                            }
                        }
                                
                        if ( this.data.analytic[ i ].noBand )
                        {
                            this.createLegendValue( "!", "center", 26 );
                        }

                        if ( this.data.analytic[ i ].noData )
                        {
                            this.createLegendValue( "NA", "center", 26 );
                        }
                    }
                    break;
                }
            }
        }
    },
    
    createLegend : function( colour, width )
    {
        var span;
        
        span = this.legend.appendChild( document.createElement( "SPAN" ) );
        
        span.className = "colour";
        span.style.width = width + "px";
        span.style.backgroundColor = this.styleColour( colour );
    },
    
    createLegendValue : function( value, align, width )
    {
        var span;
        
        span = this.legend.appendChild( document.createElement( "SPAN" ) );
        
        span.style.width = width + "px";
        span.style.textAlign = align;
        span.innerHTML = value;
    },

    calculateGradient : function( src, dst, result, pos )
    {
        var i;
        
        for ( i = 0; i < 3; i++ )
        {
            result[ i ] = Math.floor( src[ i ] + ( ( dst[ i ] - src[ i ] ) * pos ) );
        }
    },
    
    styleColour : function( colour )
    {
        return "#" + this.hexColour( colour[ 0 ] ) + this.hexColour( colour[ 1 ] ) + this.hexColour( colour[ 2 ] );
    },
    
    hexColour : function( colour )
    {
        colour = new Number( colour ).toString( 16 );
        
        return ( colour.length < 2 ) ? "0" + colour : colour;
    },
    
    showSplash : function( show )
    {
        if ( !show && !( this.mapLoaded && this.optionsLoaded ) ) return;
        
        document.getElementById( "FractalMapSplash" ).style.display = ( show ) ? "block" : "none";
        
        if ( this.client != "flash" )
        {
            document.getElementById( "FractalMap" ).style.display = ( show ) ? "none" : "block";
        }
        
        document.getElementById( "FractalMap" ).visible = !show;
	    this.showControls( !show );
    },
    
    showControls : function ( show )
    {
        document.getElementById( "FractalMapControls" ).style.display = ( show ) ? "block" : "none";
    },
    
    setProgress : function( current, total )
    {
        var text;
        
        document.getElementById( "FractalMapProgress" ).style.width = ( ( current * 100 ) / total ) + '%';
        
        if ( null != ( text = document.getElementById( 'FractalProgressText' ) ) )
        {
            text.innerHTML = Math.round( ( current / 1024 ) ) + ' KB of ' + Math.round( ( total / 1024 ) ) + ' KB';
        }
    },
    
    setEvent : function( node, name, callback )
    {
		if ( node.attachEvent )
		{
			node.attachEvent( "on" + name, callback );
		}
		else
		{
			node.addEventListener( name, callback, false );
		}
    },
    
    makeSafePng : function( img, imgsrc )
    {
        if ( this.isIE )
        {
            img.src = fractalMapVars.imagesURL + "blank.gif";
    	    img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + fractalMapVars.imagesURL + imgsrc + "',sizingMethod='scale')";
        }
        else
        {
            img.src = fractalMapVars.imagesURL + imgsrc;
        }
    },
    
    xpiInstallCallback : function( url, status )
    {
        switch ( status )
        {
        case 0:

            navigator.plugins.refresh( true );
            
            document.URL = document.URL;
            
        case -210:
        
            break;
            
        case 999:

            window.alert( "You must reboot to finish this installation." );
            break;
        
        default:

            window.alert( "An error occured during installation (" + url + "; code = " + status + "). The plugin was not installed." );
            break;
        }
    },

    xpiPluginDownload : function()
    {
        if ( InstallTrigger )
        {
            var xpi = { "Fractal:Edge Mozilla Plugin" : fractalMapVars.pluginURL + "FractalMapBrowserPlugin.xpi" }; 
            
            InstallTrigger.install( xpi, this.xpiInstallCallback );
        }
    }
};

////////////////////
// Plugin Callbacks
////////////////////

function fractalMapShowSplash( show )
{
    if ( show == "visible" ) show = true;

    fractalMap.showSplash( show );
}

function fractalMapSetProgress( current, total )
{
    fractalMap.setProgress( current, total );
}

function fractalMapEventsOnOptionChanged( opt )
{
    fractalMap.onOptionChanged( opt );
}

function fractalMapEventsOnTooltip( destination, show, x, y )
{
    if ( destination == "FLASH" )
    {
        fractalMapTooltip.show( show, x, y );
    }
    else
    {
        document.getElementById( destination ).innerHTML = document.getElementById( 'FractalMap' ).tooltip;
    }
}

function fractalMapSelectOption( event )
{
    fractalMap.setOption( event );
}

function fractalMapLoaded()
{
    fractalMap.mapLoaded = true;
    
    fractalMap.showSplash( false );
}

function fractalMapFlashInitialised()
{
    fractalMap.flashInitialised = true;
    
    fractalMap.showSplash( true );
}

document.writeln( fractalMap.includes() );