﻿function element(tag, attributes, html) {
    var ele = document.createElement(tag);
    if (attributes) {
        for (var n in attributes) {
            ele.setAttribute(n, attributes[n]);            
        }
    }
    
    if (html) {
        ele.innerHTML = html;
    }
    try {
        return ele;
    } finally {
        ele = null;
    }
}
function flash(id,data,w,h,wmode,flashvars)
{
    var v=null;
    wmode=wmode||'transparent';
    flashvars=flashvars||'';
    if (window.ActiveXObject) {
        v = element('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" name="' + id + '" />', {
            id: id,
            width: w,
            height: h
        });
        v.appendChild(element('param', {
            'name': 'allowscriptaccess',
            'value': 'always'
        }));
        v.appendChild(element('param', {
            'name': 'wmode',
            'value': wmode
        }));
        v.appendChild(element('param', {
            'name': 'menu',
            'value': 'false'
        }));
        v.appendChild(element('param', {
            'name': 'flashvars',
            'value': encodeURIComponent(flashvars)
        }));
        v.appendChild(element('param', {
            'name': 'movie',
            'value': data
        }));
    } else {        
        v = element('embed', {
            id: id,
            name: id,
            width: w,
            height: h,
            src: data,
            type: 'application/x-shockwave-flash',
            allowscriptaccess: 'always',
            wmode: wmode,
            menu: 'false',
            flashvars: encodeURIComponent(flashvars)
        });
    }    
    return v;
}