/* Contenido multimedia */

document.observe('dom:loaded', function() {

    hs.graphicsDir = 'javascript/highslide/graphics/';
    hs.align = 'center';
    hs.transitions = ['expand', 'crossfade'];
    hs.fadeInOut = true;
    hs.outlineType = 'rounded-white';
    hs.captionEval = 'this.a.title';
    hs.useBox = true;
    hs.width = document.viewport.getWidth()-200;
    hs.height = document.viewport.getHeight()-200;
    hs.dimmingOpacity = 0.8;

    hs.Expander.prototype.onBeforeClose = function() {
        if (this.a.rel != 'multimedia') return;
        var object = $(this.content).down('object');
        if (!object) return;
        object.sendEvent('STOP', 'true');
    }

    $$('a[rel="multimedia"]').each(function(item) {
        Object.extend(item, {

            play: function() {
                if (!this.flash) {
                    this.flash = this.href;
                    this.href = 'inc/mediaplayer/player.swf';
                }

                hs.htmlExpand(this, {
                    wrapperClassName: 'dark borderless floating-caption',
                    align: 'center',
                    dimmingOpacity: .75,
                    objectType: 'swf',
                    width: 425,
                    objectWidth: 425,
                    objectHeight: 344,
                    height: 370,
                    swfOptions: {
                        flashvars: {
                            file: this.flash,
                            autostart: 'true',
                            backcolor: '000000',
                            frontcolor: 'FFFFFF'/*,
                            image: 'images/add-address-book-tools-utils.gif'*/
                        },
                        params: {
                            allowfullscreen: 'true'
                        }
                    }
                });

                return false;
            }
        });

        item.observe('click', function(ev) {
            ev.stop();
            return (ev.target.nodeName == 'A' ? ev.target : ev.target.getParent('a')).play();
        });
    });

});
