if (typeof Ferengi == "undefined") {
    var Ferengi = {
        Version: "1.0"
    };
    Ferengi.namespace = function() {
        var a = arguments,
			o = null,
			i, j, d;
        for (i = 0; i < a.length; ++i) {
            d = a[i].split(".");
            o = Ferengi;
            for (j = (d[0] == "Ferengi") ? 1 : 0; j < d.length; ++j) {
                o[d[j]] = o[d[j]] || {};
                o = o[d[j]];
            }
        }
        return o;
    };
};
Ferengi.namespace("Pxp");
// Creating a class
Ferengi.Pxp.Video = new Class({
    Implements: Options,
    options: {
        Id: ""
    },
    initialize: function(options) {
        this.setOptions(options);
        // initialize commands goes here
    }

});


Ferengi.Pxp.Video.implement({

load: function(o) {
    flowplayer('Ferengi_Pxp_Video_' + this.options.Id , { src: '/Tools/FlowPlayer.swf', wmode: 'transparent' }, {
    clip: {
    loop: false,
    hideControls: false,
    autoBuffering: true,
    showMenu: false,
    autoPlay: false,
    baseUrl: '/Gallery'
    }
    ,
    playlist: [this.options.Id + '.flv']
    });
}
});

window.addEvent("domready", function() {
    //Busca todos los divs que tengan como clase Ferengi_Pxp_Video por si hay varios videos en la pagina
var oo = $$('.Ferengi_Pxp_Video'); /*console.log(oo.length);*/
    for (var i = 0; i < oo.length; i++) {
        var o = oo[i];

        var oparams = {};
        var attrs = o.getAttribute('Ferengi_Pxp_Video')
        /* ** obtiene el id del archivo*/
        if (attrs.split(/=/g).length == 1) {
            oparams.Id = attrs;
        }
        else {
            var arrAttrs = attrs.split(/&/g)
            for (var i2 = 0; i2 < arrAttrs.length; i2++) {
                var attr = arrAttrs[i2]
                var arrPair = attr.split(/=/);
                if (arrPair.length > 1) {
                    var name = arrPair[0];
                    var value = arrPair[1];
                    if (name == "Id") oparams.Id = value;
                }
            }
        }

        o.id = 'Ferengi_Pxp_Video_' + oparams.Id; 
        var gp = new Ferengi.Pxp.Video(oparams);
        gp.load(o);
    }
});