$(function(){

	//menu
	$("#menu ul li").hover(function(){
		$(this).addClass("survol");
	},function(){
		$(this).removeClass("survol");
	});
	
	//my-prog
	$("ul.my-prog li").hover(function(){
		$(this).addClass("survol_prog");
	},function(){
		$(this).removeClass("survol_prog");
	});	
	
	
	//new coverflow
	var nbVideosCoverflow = $('#imagine ul li').length;
	var indexVideosCoverflow = 2;
	$('#imagine ul').css( 'width', nbVideosCoverflow * 333 );
	$('.letsplay').click(function() {
		var container = $(this).parents('li').find('.desired-video');
		if ( container.contents().length == 0 )
		{
			var sig = $(this).parents('li').attr( 'id' );
			
			/*
			var player = '<object type="application/x-shockwave-flash" data="http://s.kewego.com/swf/p3/epix.swf" width="400" height="223">';
			player += '<param name="flashVars" value="language_code=fr&playerKey=4f5632412361&skinKey=5e3d165c8676&sig=' + sig + '&autostart=false&advertise=1&theme_color=610199&autostart=true" />';
			player += '<param name="movie" value="http://s.kewego.com/swf/p3/epix.swf" />';
			player += '<param name="allowFullScreen" value="true" />';
			player += '<param name="allowscriptaccess" value="always" />';
			player += '<param name="wmode" value="transparent" />';
			player += '</object>';
			*/
			
			var player = '<object width="333" height="223" type="application/x-shockwave-flash" data="http://s.kewego.com/swf/kp.swf" name="kplayer_' + sig + '" id="kplayer_' + sig + '">';
			player += '<param name="bgcolor" value="0x000000" />';
			player += '<param name="allowfullscreen" value="true" />';
			player += '<param name="allowscriptaccess" value="always" />';
			player += '<param name="flashVars" value="language_code=fr&playerKey=4f5632412361&configKey=901fcbfdaa81&suffix=&sig=' + sig + '&autostart=true" />';
			player += '<param name="movie" value="http://s.kewego.com/swf/kp.swf" />';
			player += '<param name="wmode" value="opaque" />';
			player += '</object>';
						
			container.html( player )
		}
		
		container.show();
		return false;
	});
	$('.arrow').click(function() {
		$('.desired-video').hide();
		return false;
	});
	$('.arrowright').click(function() {
		$('#imagine ul').animate({left: '-=333px'});
		indexVideosCoverflow++;
		$('.arrowleft').show();
		if ( indexVideosCoverflow == nbVideosCoverflow )
			$(this).hide();
		else
			$(this).show();
	});
	$('.arrowleft').click(function() {
		$('#imagine ul').animate({left: '+=333px'});
		indexVideosCoverflow--;
		$('.arrowright').show();
		if ( indexVideosCoverflow == 1 )
			$(this).hide();
		else
			$(this).show();
	});

	//newsticker
	if (jQuery().liScroll)
	{
		$('#newsticker').liScroll();
	}

	//journal numerique
	$(".carousel").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		visible: 3,
		circular: false
	});

	//page programme onglets
	//$('.prem-tab').tabs();
	//$('.second-tab').tabs();
	//$('.tonight').tabs();
	
	//page contact accordion
	$('#weo-contact h3').click(function() {
		$(this).next().slideToggle('fast');
		return false;
	}).next().hide();
	$('.content-team:first').show();
		
	$('#txtSearch').focus( function() {
		$(this).val( '' );
	});
	
	//add to favorites
	$(".homemade").click(function(event){
        event.preventDefault();
        var url=this.href;
        var title=$("title").text();
        if(window.sidebar){ // Mozilla Firefox Bookmark
            window.sidebar.addPanel(title, url, "");
        } else if(window.external){ // IE Favorite
            window.external.AddFavorite(url, title);
        }
    });
	

	
	
});
