// multiModal generic object handler
// Usage: multiModal.open('object.swf', {method: 'object'});
multiModal.contentHandlers.object = function(url, options, container, caller) {
    var obj = document.createElement('object');

    // Parameters can be passed in options.params in URL format (name=val&name2=val2)
    if ( options.params ) {
        var pairs = options.params.split('&');

        for ( var i = pairs.length-1; i >= 0; i-- ) {
            var name_val = pairs[i].split('=');
            var param = document.createElement('param');

            param.setAttribute('name', decodeURIComponent(name_val[0]));
            param.setAttribute('value', decodeURIComponent(name_val[1]));
            obj.appendChild(param);
        }
    }

    var IE//@cc_on=1

    // Use iframe for text/html instead; IE's <object> tag can't handle it correctly and it breaks in odd ways
    // This adds the normal window-close handler just in case it gets used anyway
    if ( ! IE && options.type == 'text/html' ) {
        _addEvent(obj, 'load', function(evt) {
            if ( obj.contentWindow ) { // Make sure we actually loaded a html page first
                _addEvent(obj.contentWindow.document, 'keypress', multiModal._keypressCloseWindow);
                if ( obj.contentWindow.multiModal ) {
                    obj.contentWindow.multiModal.caller = caller;
                }
            }
        });
    }

    // Force IE to load SWF files correctly
    if ( IE && options.type == 'application/x-shockwave-flash' ) {
        var param = document.createElement('param');

        param.setAttribute('name', 'movie');
        param.setAttribute('value', url);
        obj.appendChild(param);

        obj.setAttribute('classid', 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000');
    }
    else {
        obj.setAttribute('type', options.type);
        obj.setAttribute('data', url);
    }

    set_styles(obj, {
        position:   'absolute',
        width:      container.style.width,
        height:     container.style.height
    });

    return obj;
}

