jQuery(document).ready(function()
{
    jQuery('#frames div.content, .ie6hidden').pngFix();
    jQuery(document).pngFix();
    jQuery('#flash-wrapper object, #flash-wrapper embed').attr('height', jQuery(document).height());
    jQuery(document).find('.flash-text').each(function(i)
    {
        var text = jQuery(this).html();
        jQuery(this).html('');
        
        jQuery('<span></span>')
            .addClass('flash-replaced')
            .html(text)
            .appendTo(jQuery(this));
        
        var source = '/otsikko.swf?headline=' + text + '&color=0xffffff';

/*
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="bg" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="allowFullScreen" value="false" />
    <param name="movie" value="/bg.swf" />
    <param name="quality" value="high" />
    <param name="wmode" value="transparent" />
    <embed src="/bg.swf" quality="high" wmode="transparent" width="100%" height="100%" name="bg" align="middle" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
*/
        var width = jQuery(this).width();
        var height = jQuery(this).height() * 2;
        
        jQuery('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/swflash.cab#version=9,0,0,0" width="' + width + '" height="' + height + '" align="left"></object>')
            .attr({
                id: 'replace_' + i
            })
            .css('border', 'solid 1px red')
            .appendTo(jQuery(this));
        
        jQuery('<param name="allowScriptAccess" value="sameDomain" />')
            .appendTo(jQuery(this).find('object'));
        
        jQuery('<param name="allowFullScreen" value="false" />')
            .appendTo(jQuery(this).find('object'));
        
        jQuery('<param name="movie" value="/bg.swf" />')
            .appendTo(jQuery(this).find('object'));
        
        jQuery('<param name="quality" value="high" />')
            .appendTo(jQuery(this).find('object'));
        
        jQuery('<param name="wmode" value="transparent" />')
            .appendTo(jQuery(this).find('object'));
        /*
        jQuery('<embed src="' + source + '" quality="high" wmode="transparent" width="' + width + '" height="' + height + '" name="bg" align="left" allowScriptAccess="sameDomain" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />')
            .appendTo(jQuery(this).find('object'));
        */
    });
});