// JavaScript Document
var playItself
var rotating = false
$(document).ready(function() {

	/*Main Navigation sub menu and hover*/
	$('#nav li').hover(
			function() { $('ul', this).css('display', 'block'); },
			function() { $('ul', this).css('display', 'none');
			});
	

	/*hover*/
	$("#nav li").hover(
		  function () {
			$(this).children(':first-child').addClass("hover");
		  },
		  function () {
			$(this).children(':first-child').removeClass("hover");
		  }
	);

	/*search*/
	$("#searchkeyword").focus(function(){
		this.value = ''; 
	});
	
	//detect IE6
	if($.browser.msie){
		if (!$.cookie('ypgIE6detect')) {
			var version = $.browser.version
			if (version.match(/^6/)) {
				$.cookie('ypgIE6detect', '1');
				window.location.href = '/iedetect';
			}
		}
	}




	// PLAYER
	$(".playerImages").css("opacity",0)
	$(".playerImages").eq(0).css("opacity",1)
	
	playItself = $("#listPlayer .diffuChiffre a").size()
	$images = $(".playerImages")
	$(".diffuChiffre a").click(function() {
		if(rotating == false){
			window.clearInterval(playit)
		}
		rotating = false;
		var $this = $(this)
		var movePlayer = $this.attr("rel")
		movePlayer -= 1
		$("#listPlayer a").removeClass("active")
		$this.addClass("active")
		
		$images.animate({opacity:0},300,'easeInQuad',function(){
			$images.css('z-index',1)
			$images.eq(movePlayer).animate({opacity:1},400,'easeInQuad')
			$images.eq(movePlayer).css('z-index',2)
		})
		return false;
	});

	if(playItself != 0){
	
		var playit = window.setInterval("playPlayer()",5000)
	}
});


var playNow = 0
 function playPlayer(){
	playNow +=1
	if(playNow == playItself){
		playNow = 0
	}
	rotating = true
	$("#listPlayer a").eq(playNow).trigger("click")
}		

function webcastWindow(url) {

    window.open(url,'mywindow','menubar=1,resizable=1,width=600,height=800');
}
