// JavaScript Document
$VPlaya = {
    box : new Object(),
    drag : new Object(),
    vid : new String(),
    bid : new String(),
    did : new String(),
    fid : new String(),

    init : function(bid, did, fid) {
        $VPlaya.bid = bid;
        $VPlaya.did = did;
        $VPlaya.fid = fid;
    },
    loadVideo : function(v, e) {
        $VPlaya.vid = v;
        $VPlaya.build(e);
        $VPlaya.play();
    },
    build : function(e) {
        E($VPlaya.bid).erase();
        var div = E().create('div');
        div.setAttribute('id', $VPlaya.bid);

        var drag = E().create('div');
        drag.setAttribute('id', $VPlaya.did);

        var a = E().create('a');
        a.setAttribute('id', 'hello');
        a.addEvent('click', $VPlaya.close);
        a.addText('Fermer');
        drag.appendChild(a);

        var flv = E().create('div');
        flv.setAttribute('id', $VPlaya.fid);

        div.style.position = 'absolute';
        div.style.backgroundColor = '#000000';
        div.style.left = (e.pageX || (e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft))+'px';
        div.style.top  = (e.pageY || (e.clientY + document.documentElement.scrollTop + document.body.scrollTop))+'px';
        
        div.appendChild(drag);
        div.appendChild(flv);
        document.body.appendChild(div);

        //DragObj.init($VPlaya.did);
    },
    play : function() {
        var so = new FlashObject('./__swf__/vid2.swf', 'myvid', '360', '270', '8', '#4B1300');
        /*so.addParam('wmode', 'transparent');*/
        so.addVariable('vidPath', $VPlaya.vid);
        so.write($VPlaya.fid);
    },
    close : function(e) {
        this.removeEvent('click', $VPlaya.close);
        E('myvid').closeFlash();
        E($VPlaya.bid).erase();
        return false;
    }
}
