// set the flash cookie if it's not already done

var flash_handler = {
    flash_version : 7,
    disabled : true,
    do_flash : function(src, x, y, pxwidth, pxheight)
    {
        if (!FlashReplace.checkForFlash(this.flash_version)) {
            disable_flash_local();
            return;
        }
        this.disabled = false;
        this.src = src;
        this.pxwidth = pxwidth;
        this.pxheight = pxheight;
        flash_element = document.getElementById('flash-replace');
        flash_element.style.top = y;
        flash_element.style.left = x;
        flash_element.style.width = pxwidth + 'px';
        flash_element.style.height = pxheight + 'px';
        if (this.get_cookie()=='on')
            this.enable_flash();
        else
            this.disable_flash();
    },
    enable_flash : function () {
        if (this.disabled) return;
        document.cookie = "percolflash=on;path=/";
        document.getElementById('flash-replace').style.display = 'block';
        document.getElementById('flash-replace-enable').style.display = 'none';
        document.getElementById('flash-replace-disable').style.display = 'block';
        enable_flash_local();
        FlashReplace.replace('flash-replace',this.src,'flash-element-id',this.pxwidth,this.pxheight,this.flash_version,{wmode:'transparent'});
    },
    disable_flash : function () {
        if (this.disabled) return;
        document.cookie = "percolflash=off;path=/";
        document.getElementById('flash-replace').style.display = 'none';
        document.getElementById('flash-replace-disable').style.display = 'none';
        document.getElementById('flash-replace-enable').style.display = 'block';
        disable_flash_local();
        FlashReplace.restore('flash-replace');
    },
    get_cookie : function () {
        var cookies = '; '+document.cookie+';';
        if (cookies.indexOf('; percolflash=off;')>=0)
            return 'off';
        else
            return 'on';
    }
}

