/*----------------------------------------------------------------------------//
// Javascript pour le site client  -------------------------------------------//
//----------------------------------------------------------------------------//
// Client : -
//----------------------------------------------------------------------------*/

function importJavascript(src) {
	document.write("<script type=\"text/javascript\" src=\"" + src + "\"></scr" + "ipt>");
}
function importCss(href, media) {
	document.write('<link rel="stylesheet" type="text/css" media="' + media + '" href="' + href + '" />');
}

/*----------------------------------------------------------------------------*/
// Importations de fichiers
/*----------------------------------------------------------------------------*/
// importJavascript("/includes/js/plugins/jquery.plugin.js");
// importCss("/includes/js/plugins/jquery.plugin.css", "screen");
importJavascript("/includes/js//plugins/jcarousellite.js");
importJavascript("/includes/js/swfobject.js");

/*----------------------------------------------------------------------------*/
// Declarations jQuery
/*----------------------------------------------------------------------------*/
$(document).ready(function(){
	
	// Misc
	$("#Contenu hr").replaceWith("<div class=\"HR\"></div>");
	
	// Caroussel d'accueil
	var autoChange = null;
	$(".CBloc.Caroussel").each(function(){
		var curr = $(this);
		var slides = $(".Images li", curr);
		var autoChange = ($(".Images li", curr).size() > 1) ? 10000 : null;

		if ( autoChange != null ) {
			var nav = "<ul class=\"Nav\">";
			$.each(slides, function(i, val) {
				nav += "<li><a class=\"CarousselNav" + (i + 1) + "\" href=\"javascript:void(0);\">" + (i + 1) + "</a></li>";
			});
			nav += "</ul>";
			curr.prepend(nav);
			
			var navBtns = [];
			$(".Nav a", curr).each(function(){
				navBtns.push("." + $(this).attr("class"));
			});
			
			$(".Images", curr).jCarouselLite({
				btnGo: navBtns,
				speed: 500,
				visible: 1,
				auto: autoChange
			});
		}
		
	});
	
	// Extraits Youtube
	$("#ExtraitsYoutube a").each(function(){
		var url = "http://www.youtube.com/watch?v=";
		var code = $(this).attr("href").substring(url.length, $(this).attr("href").length);
		$(this)
			.attr("href", "javascript:void(0);")
			.attr("rel", code)
			.removeAttr("target");

		$(this).click(function(){
//			if (  ) {
//			}
							   
			var output = '<object width="644" height="386" style="display:block;">';
			output += '<param value="http://www.youtube.com/v/' + $(this).attr("rel") + '&amp;hl=fr&amp;fs=1&amp;rel=0&amp;showinfo=0" name="movie">';
			output += '<embed width="644" height="386" flashvars="use_get_video_info=0" allowfullscreen="true" allowscriptaccess="always" type="application/x-shockwave-flash" src="http://www.youtube.com/v/' + $(this).attr("rel") + '&amp;hl=fr&amp;fs=1&amp;rel=0&amp;showinfo=0">';
			output += '</object>';
			$(".CBloc.Youtube").html(output);
		});					
	});

});






