/*
 * @author mju
 */

$(document).ready(function(){

	// Class js si le js est actif pour le css
	$('html').addClass('js');
	
	/*
	 * div: div will contain video's player link: video's link img:
	 * image preview for video autoPlay: variable for auto start
	 * video
	 */
	 
	function createPlayer(div, link, img, autoPlay, dim) {
		var flashvars = {
			'file' : link,
			'repeat' : 'none',
			'abouttext' : 'hors-norme.com',
			'aboutlink' : 'hors-norme.com',
			'image' : img,
			'autostart' : autoPlay
		};

		var params = {
			'allowfullscreen' : "true",
			'allowscriptaccess' : "always",
			'bgcolor' : '346377',
			'frontcolor' : 'ffffff'
		};

		var attributes = {
			'id' : "player" + div,
			'name' : "player" + div
		};

		swfobject.embedSWF("swf/player.swf", div, dim.w, dim.h,
				"9.0.115", false, flashvars, params, attributes);
	}

	var dim = {
		w : 223,
		h : 158
	};
	var liVideo = $("li[id^='playvideo']");
	var nbVideo = liVideo.parent(".contentArticle").length;

	if (nbVideo == 1) {
		dim.w = 600;
		dim.h = 342;

		var link = liVideo.find("a").attr("href");
		var imgPreview = liVideo.find("a").find("img").attr("src");
		var idDiv = liVideo.attr("id");

		createPlayer(idDiv, link, imgPreview, 'true', dim);
  }
});


