window.addEvent('domready', function(){
    //Get Browser details
    getBrowserDetails();

    //Enter values in hidden inputs
    updateHiddenInputs();
});

// Get Browser Details
getBrowserDetails = function()
{
    // Screen Res
    if (self.screen)
    {
        S_RESOLUTION = screen.width + ' x ' + screen.height;
        S_COLOR_DEPTH = screen.colorDepth + ' bit';
    }
    else if (self.java)
    {
        var javaobj = java.awt.Toolkit.getDefaultToolkit();
        var screenobj = javaobj.getScreenSize();

        S_RESOLUTION = screenobj.width + ' x ' + screenobj.height;

        if (self.screen)
            S_COLOR_DEPTH = screen.colorDepth + ' bit'; ;
    }

    // Browser size
    var bsw = '';
    var bsh = '';

    if (window.innerWidth)
    {
        bsw = window.innerWidth;
        bsh = window.innerHeight;
    }
    else if (document.documentElement)
    {
        bsw = document.documentElement.clientWidth;
        bsh = document.documentElement.clientHeight;
    }
    else if (document.body)
    {
        bsw = document.body.clientWidth;
        bsh = document.body.clientHeight;
    }
    if (bsw != '' && bsh != '')
    {
        S_BROWSER_SIZE = bsw + ' x ' + bsh;
    }

    // Flash Version
    if (FlashDetect.major >= 1)
    {
        S_FLASH_VERSION = FlashDetect.major;

        S_FLASH_VERSION_FULL = FlashDetect.major + "." + FlashDetect.minor + "." + FlashDetect.revision;
    }
    else
    {
        S_FLASH_VERSION = "Not installed";
        S_FLASH_VERSION_FULL = "";
    }

    Cookie.set('ctest', true);
    if ( Cookie.get('ctest') )
    {
        S_COOKIES_ENABLED = 'Enabled';
        Cookie.remove('ctest');
    }
    else
    {
        S_COOKIES_ENABLED = 'Disabled';
    }
}

// Update hidden input fields
updateHiddenInputs = function()
{
    $("u_browser_details").setHTML(
        $("u_browser_details").innerHTML + '\n' +
        'Javascript:         Enabled\n' +
        'Cookies:            ' + S_COOKIES_ENABLED + '\n' + 
        'Flash Version Full: ' + S_FLASH_VERSION_FULL + '\n' +
        'Screen Resolution:  ' + S_RESOLUTION + '\n' +
        'Browser Size:       ' + S_BROWSER_SIZE + '\n' +
        'Color Depth:        ' + S_COLOR_DEPTH + '\n'
    );
}
