
/**
 * Liens pour vidéos en fullscreen mode
 */

function evt_windowLoad (ev) {
    var videos = [];
    // video 2D and 3D
    var fullscreen = document.getElementsByClassName('fullscreenVideo');
    for (var i = 0; i < fullscreen.length; i++) {
        videos.push(new NVP_FullscreenVideo(fullscreen[i]));
    }
    // downloadable video
    var download = document.getElementsByClassName('downloadVideo');
    for (var i = 0; i < download.length; i++) {
        videos.push(new NVP_FullscreenVideo(download[i], 'download'));
    }
}

var NVP_FullscreenVideo = Class.create();
NVP_FullscreenVideo.prototype = {
    initialize : function (obj, type) {
    	this.type = (type) ? type : 'fullscreen';
        this.html = obj;
        this.id = obj.id;
        Event.observe(this.html, 'click', this.launchFullscreen.bind(this), false);
    },
    
    getId : function () {
        return this.id;
    },
    
    launchFullscreen : function (ev) {
		switch (this.type) {
			case 'download' :
				var fen = window.open('/video/flash/libs/fullscreenVideo.php?type=download&id=' + this.getId(), '', 'width=800,height=600');
				break;
			case 'fullscreen' :
			default :
		        // Works well everywhere even in Safari !
		        var fen = window.open('/video/flash/libs/fullscreenVideo.php?id=' + this.getId(), '', 'toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menubar=0,fullscreen=1,top=0,left=0,width='+screen.width+',height='+screen.height);
		        // works well everywhere but not in Safari
		        /*
		        var fen = window.open('hop2.html','', 'toolbar=0, location=0, directories=0, status=no, scrollbars=0, resizable=0, copyhistory=0, menubar=0,fullscreen=1'); 
		        fen.moveTo(0,0);
		        fen.resizeTo(screen.width,screen.height);
		        */
		        break;
	    }
	}
}

Event.observe(window, 'load', evt_windowLoad, false);

