var detectVideoSupport = function (){
    var detect = document.createElement('video') || false;
    this.html5 = detect && typeof detect.canPlayType !== "undefined";
    this.mp4 = this.html5 && (detect.canPlayType("video/mp4") === "maybe" || detect.canPlayType("video/mp4") === "probably");
    this.ogg = this.html5 && (detect.canPlayType("video/ogg") === "maybe" || detect.canPlayType("video/ogg") === "probably");
    return this;
};

function show_black(fichier){
	var bkg = new Element('div',{
		id: 'black_bkg',
		styles: {
			'background-color': '#000',
			'z-index': 15,
			'position': 'fixed',
			'width': '100%',
			'height': '100%',
			'opacity': 0.6,
			'top': 0,
			'left': 0,
			'cursor':'pointer'
		}
	});
	bkg.inject($$('body').pick());
	var size = window.getSize();
	var container = new Element('div',{
		id: 'container',
		styles: {
			'background-color': '#000',
			'z-index': 16,
			'position': 'fixed',
			'width': '889px',
			'top': '30px',
			'border': '2px #ccc solid',
			'border-radius': '7px',
			'height': '500px',
			'margin-left': ((size.x-889)/2)+'px',
			'padding': '0'
		}
	});
	container.inject($$('body').pick());
	var close_box = new Element('div',{
		id: 'close_box',
		html: 'X',
		styles: {
			'background-color': '#333',
			'z-index': 17,
			'position': 'absolute',
			'text-align': 'center',
			'top' : '-20px',
			'left': '-20px',
			'border-radius': '15px',
			'width': '30px',
			'height': '30px',
			'display': 'block',
			'line-height': '30px',
			'cursor': 'pointer',
			'font-weight': 'bold',
			'font-size': '16px'
		}
	});
	close_box.inject(container);
	bkg.addEvent('click',function(){
		$('container').destroy();
		this.destroy();
	});
	close_box.addEvent('click',function(){
		$('black_bkg').fireEvent('click');
	});
	var type = detectVideoSupport();
    if(type.ogg || type.mp4){
        var toto = new Element('video',{
            'width': 889,
            'height': 500,
            'controls': true
        });
        if(type.mp4){
            var toto2 = new Element('source',{
                'src': '/videos_mp4/'+fichier+'.mp4',
                'type': 'video/mp4'
            });
            toto2.inject(toto);
        }
        else{
            var toto2 = new Element('source',{
                'src': '/videos_ogv/'+fichier+'.ogv',
                'type': 'video/ogg'
            });
            toto2.inject(toto);
        }
        toto.inject(container);
        toto.play();
    }
    else{
        var toto = new Element('embed',{
            'flashvars': "file=/videos_mp4/"+fichier+".mp4&autostart=true&controlbar.position=over",
            'allowfullscreen': true,
            'src': '/mediaplayer/player.swf',
            'width': 889,
            'height': 500,
            'seamlesstabbing': true
        });
        toto.inject(container);
    }
}

function show_bio(){
	var bkg = new Element('div',{
		id: 'black_bkg',
		styles: {
			'background-color': '#000',
			'z-index': 15,
			'position': 'fixed',
			'width': '100%',
			'height': '100%',
			'opacity': 0.6,
			'top': 0,
			'left': 0,
			'cursor':'pointer'
		}
	});
	bkg.inject($$('body').pick());
	var size = window.getSize();
	var container = new Element('div',{
		id: 'container',
		styles: {
			'background-color': '#000',
			'z-index': 16,
			'position': 'fixed',
			'width': '889px',
			'top': '30px',
			'border': '2px #ccc solid',
			'border-radius': '7px',
			'height': '500px',
			'margin-left': ((size.x-889)/2)+'px',
			'padding': '0',
			'color': '#FFF',
			'padding': '5px',
		}
	});
	container.inject($$('body').pick());
	var container2 = new Element('div',{
		styles: {
		'overflow': 'auto',
		'width': '100%',
		'height': '100%'
		}
	});
	container2.inject(container);
	var close_box = new Element('div',{
		id: 'close_box',
		html: 'X',
		styles: {
			'background-color': '#333',
			'z-index': 17,
			'position': 'absolute',
			'text-align': 'center',
			'top' : '-20px',
			'left': '-20px',
			'border-radius': '15px',
			'width': '30px',
			'height': '30px',
			'display': 'block',
			'line-height': '30px',
			'cursor': 'pointer',
			'font-weight': 'bold',
			'font-size': '16px'
		}
	});
	container2.set('html',$('bio_texte').get('html'));
	close_box.inject(container);
	bkg.addEvent('click',function(){
		$('container').destroy();
		this.destroy();
	});
	close_box.addEvent('click',function(){
		$('black_bkg').fireEvent('click');
	});	
}
