var content_xml = '/index.xml';

// Has the SSI run?
if (content_xml.indexOf ("xml") < 0)
{
    content_xml = "index.xml";
}


// Measure the box containing the flash stack_mov
function stackMovSize()
{
    var stack_mov_width = 1024;
    var stack_mov_height = 400;

    if (document.getElementById)
    {
        var stack_box = document.getElementById ("headBox");
        if (stack_box)
        {
            // Set size in ems or % - 
            // use this script to measure the desired size 
            stack_mov_width = stack_box.offsetWidth;
        }
    } // use WindowUtil.width() instead?
    return [stack_mov_width, stack_mov_height];
}


function scaleFlashMovie()
{
    if (document.getElementById)
    {
        var stack_mov = document.getElementById ("stackMov");
        if (stack_mov)
        {
            var new_stack_mov_size = stackMovSize();
            stack_mov.width = new_stack_mov_size[0];
            stack_mov.height = new_stack_mov_size[1];
        }
        return true;
    }
    return false;
}

window.onresize = scaleFlashMovie;



// Write the flash code
var flash_embed = new FlashEmbed();

// We target the Flash 9 player (actionscript 3)
flash_embed.initDetect (9);

flash_embed.addParam ("conf_file", "/Stack/Stack.conf");

flash_embed.addQueryParam ("logging");

// This is set by SSI script
flash_embed.addParam ("content_xml", content_xml);


var stack_mov_size = stackMovSize();
flash_embed.doEmbed
(
    "/Stack/Stack.swf",
    stack_mov_size[0],
    stack_mov_size[1],
    "#ffffff", // 
    "stackMov" // Ensure it matches the 'scaleFlashMovie' function above
);
