// JavaScript Document

/* FERMER LA COLORBOX (lightbox) */
function closepopup(){
	$.colorbox.close();
	homePageSlider(1);
}

/* CONTROLER LE SLIDE DE LA HOMEPAGE */
function homePageSlider(play){
	if(play==1){
		$('#slider').data('nivoslider').start();
	}else{
		$('#slider').data('nivoslider').stop();
	}
}

/* CHARGER UN VIDEO EN HTML5 */
function videoHtml5(vid2load, cible, video_w, video_h){
	poster = 'poster="'+vid2load+'.jpg"';
	source = '<source src="'+vid2load+'.mp4" type="video/mp4" />';
	source += '<source src="'+vid2load+'.webm" type="video/webm" />';
	source += '<source src="'+vid2load+'.ogv" type="video/ogg" />';
	newVideo = '<video width="'+video_w+'" height="'+video_h+'" '+poster+' controls="controls" autoplay="autoplay"> '+source+' Votre navigateur ne supporte pas le HTML5.</video>';
	$(cible).html(newVideo); 
}

/* CHARGER UN VIDEO AVEC FLASH SINON EN HTML5 */
function flashOrHtml5Video(flash_file, video_w, video_h, flash_version, videofile, cible){
	if($.flash.available && $.flash.hasVersion(flash_version)){
		//alert(videofile);
		videofile = videofile.replace("swf/", "")+'.flv';
		$(cible).flash({swf: flash_file, width: video_w, height : video_h+25, wmode: 'transparent', flashvars:{file:videofile}, bufferlength: 3});
		/*
		jwplayer(cible).setup({
			'flashplayer': 	flash_file,
			'width':	video_w,
			'height':	video_h+25,
			'file':		videofile
		});*/
	}else{
		videoHtml5(videofile, cible, video_w, video_h);
	}
}



