$(function() {
    // delete the cookie for debug
    $.cookie('autopromo', null);
    
    if ($.cookie('autopromo') != 'displayed') {
        $("head").append('<link rel="stylesheet" type="text/css" href="'+autopromo_url+'autopromo.css"/>');
        $("body").append('\
            <div id="postergen" title="Become a movie star!">\
                <embed src="'+autopromo_url+'tutorial300x250.swf" width="300" height="250" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash">\
                <p><a href="#">Close this window</a></p>\
            </div>\
        ');
        
        $("#postergen")
            .dialog({ width: 300, position:autopromo_position })
            // Wraps all the dialog html for later use in our css
            .parent().wrap('<div class="autopromo"></div>')
            // Move all the way to the top
            .parent().prependTo("body");
        
        $("#postergen p a").click(function() {
            $("#postergen").dialog('close');
        });
    }
    $.cookie('autopromo', 'displayed');
});
