// Borrowed from addons.mozilla.org - thanks :)

var PLATFORM_OTHER    = 0;
var PLATFORM_WINDOWS  = 1;
var PLATFORM_LINUX    = 2;
var PLATFORM_MACOSX   = 3;
var PLATFORM_MAC      = 4;

// Default to windows
var gPlatform = PLATFORM_WINDOWS;

if (navigator.platform.indexOf("Win32") != -1)
  gPlatform = PLATFORM_WINDOWS;
else if (navigator.platform.indexOf("Linux") != -1)
  gPlatform = PLATFORM_LINUX;
else if (navigator.userAgent.indexOf("Mac OS X") != -1)
  gPlatform = PLATFORM_MACOSX;
else if (navigator.userAgent.indexOf("MSIE 5.2") != -1)
  gPlatform = PLATFORM_MACOSX;
else if (navigator.platform.indexOf("Mac") != -1)
  gPlatform = PLATFORM_MAC;
else
  gPlatform = PLATFORM_OTHER;

// This function is used on the firstrun pages to show the correct image next to the
// "click this close button" text
function loadFirstRunInstallImage() {

    // The only thing we care about is if it's a mac, we're going to switch the
    // class, otherwise, stick with defaults.
    if (gPlatform == PLATFORM_MAC || gPlatform == PLATFORM_MACOSX) {
        document.getElementById('tab-close').setAttribute('class','mac');
    }

}

// Will change the class for the given element.  This is currently used on
// /index.html and /firefox/index.html
function rotateBackgroundForDiv(div_id) {

    // We're leaving a blank in here, since that is another (default) image
    var class_options = new Array( "variation1", "variation2", "variation3" );

    if (Math.random) {
        var choice = Math.floor(Math.random() * (class_options.length));

        // Just in case javascript gets carried away...
        choice = ( (choice < class_options.length)  && choice >= 0) ? choice : 0;

        if (document.getElementById(div_id)) {
            document.getElementById(div_id).setAttribute('class',class_options[choice]);
        }
    }

}
