$(document).ready(function(){
		$("a.love").live('click',function() {
			url = $(this).attr('node_url');
			like = $(this).children(".like");
			id_node_love = $(this).attr("id_node_love");
			$.get(url, { id_node:id_node_love }, 
					function(data) {
						if(data.status=="ok") {
							like.html(data.nb_like);
							$(this).addClass('like_on');
						} else {
							$(this).addClass('like_on');
						}
					}
			,"json");
		});
		
		$('.player').live('click',function() {
			url = $(this).attr('node_url');
			id_node = $(this).attr("id_node");
			nb_visits = $(this).next().children('.nb_visits');
			$.getJSON(url, { id_node: id_node }, function(json) {
				alert("toto");
				if(json.status=="ok") {
					alert(nb_visits.html());
					nb_visits.html(json.nb_visits);
					alert(nb_visits.html());
				}
			});
		});
		
		$.fn.delay = function(time, callback){
			jQuery.fx.step.delay = function(){};
			return this.animate({delay:1}, time, callback);
		}
		
/*		$('.toggler').hover(
			function(){
				$(this).stop(true, false).delay(600, function(){
					
					$('.toggler').each(function(i,item){
						$(item).find('.menu').fadeTo(300, 0.2);
					});
					
					$(this).find('.menu').fadeTo(300, 1.0);
				
					$(this).find('.subnav').slideDown(600);
				});
			}, 
			function(){
				if (!$(this).hasClass('current')){
				
					$(this).stop(true, false).delay(300, function(){

						$(this).find('.subnav').slideUp(600);
						
						$('.toggler').each(function(i,item){
							$(item).find('.menu').fadeTo(300, 1.0);
						});
					});
				}
			}
		);
*/		
		//Cufon.replace('.cufon');
		
		$("#leftColContent .blockVideos").each(function(){
			
			var blockVideoId = $(this).attr('id');	
			
			if(blockVideoId!="") {
				$("#"+blockVideoId+" .tab_content").hide(); //Hide all content
				$("#"+blockVideoId+" ul.tabs li:first").addClass("active").show(); //Activate first tab
				$("#"+blockVideoId+" .tab_content:first").show(); //Show first tab content
				
				//On Click Event
				$("#"+blockVideoId+" ul.tabs li").click(function() {
				
					$("#"+blockVideoId+" ul.tabs li").removeClass("active"); //Remove any "active" class
					$(this).addClass("active"); //Add "active" class to selected tab
					$("#"+blockVideoId+" .tab_content").hide(); //Hide all tab content
					var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
					$(activeTab).fadeIn(); //Fade in the active content
					
					return false;
				});
			}
		 });

		$("#CF_login").click(function() {
			var connect_panel_display = $("#connect_panel").css('display');
			if(connect_panel_display=="block") {
				$("#connect_panel").hide("fast");
			} else {
				$("#connect_panel").show("fast");
			}
		})
		
	});
