var teaserAffiche = 1;
var animation = true;
var T_GLOBAL = false;
document.write("<script type='text/javascript' src='http://www.musiclassroom.com/jquery-ui.js'></script>" );
function afficherSuivante()
{
	if(animation)
	{
		$('#slide'+teaserAffiche).fadeOut(0);
		if(teaserAffiche == $('.slide').size())	teaserAffiche = 1;
		else	teaserAffiche += 1;
		$('#slide'+teaserAffiche).effect( 'slide', { direction: "right" }, 500, '' );
		$('#slide'+teaserAffiche+' div').show();
		$('.navteaser .last span').html(teaserAffiche);
		clearInterval(T_GLOBAL);
		T_GLOBAL = setTimeout('afficherSuivante();',5000);
	}
}
function animTubo()	{
	var i = 0;
	$('.boxTubo .tuboscopie').each(function(i)	{
		$(this).animate({marginLeft: '-=180'}, 1500, function() {
			if($(this).css('margin-left') == '-180px')	$(this).css('margin-left',($('.boxTubo .tuboscopie').size()-1)*180+'px');
			i++;
			if(i == $('.boxTubo .tuboscopie').size())	setTimeout('animTubo()',1000);
		});
	});
}
jQuery(function ($) {
	$(document).ready(function() {
		$('#divaccueil,#divactualites,#divcours,#divpartitions,#divwebtv').hide();
		$('.actif').css('background','url(http://www.musiclassroom.com/images/'+$('.actif').attr('id')+'.png) no-repeat 0 1px');
		$('.actif,.actif a').css('color','#FFF');
		$('#slide1').show();
		/**Onglet**/
		$(".tab_content").hide(); //Hide all content
		$("#tabs ul li:first").addClass("active").show(); //Activate first tab
		$(".tab_content:first").show(); //Show first tab content

		//On Click Event 
		$("#tabs ul li").click(function() {
			$("#tabs ul li").removeClass("active"); //Remove any "active" class
			$(this).addClass("active"); //Add "active" class to selected tab
			$(".tab_content").hide(); //Hide all tab content

			var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
			$(activeTab).fadeIn(); //Fade in the active ID content
			return false;
		});
		$("#tabs ul li").hover(function() {
			$("#tabs ul li").removeClass("active"); //Remove any "active" class
			$(this).addClass("active"); //Add "active" class to selected tab
			$(".tab_content").hide(); //Hide all tab content

			var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
			$(activeTab).fadeIn(); //Fade in the active ID content
			return false;
		},function()	{});
		$('.menuGauche .current ul').show();
		
		$('.boxTubo .tuboscopie').each(function(i)	{
			$(this).css('margin-left',$(this).attr('id')*180+'px');
		});
		setTimeout('animTubo()',1000);
		
		T_GLOBAL = setTimeout('afficherSuivante();',5000);
	});
	$('#menu li').hover(function(e)	{
		$('#divMenu div').hide();
		$('.gauche2').css('top','380px');
		$('.droite3').css('top','400px');
		$('#menu li').css('background','none');
		$('#menu li,#menu li a').css('color','#444');
		$(this).css('background','url(http://www.musiclassroom.com/images/'+$(this).attr('id')+'.png) no-repeat 0 1px');
		if(($(this).attr('id')!= 'contact')&&($(this).attr('id')!= 'accueil'))
		{
			$(this).css('color','#FFF');
			$('#divMenu').show();
			$('#div'+$(this).attr('id')+',#div'+$(this).attr('id')+' div').show();
		}
		else
		{
			$('.gauche2').css('top','230px');
			$('.droite3').css('top','250px');
			$('a',this).css('color','#FFF');
		}
	},function(e)	 {
	});
	$('#menuBlock').hover(function(e)	{
	},function(e)	 {
		$('.gauche2').css('top','230px');
		$('.droite3').css('top','250px');
		$('#menu li').css('background','none');
		$('#menu li,#menu li a').css('color','#444');
		$('#divMenu,#divMenu div').hide();
		$('.actif').css('background','url(http://www.musiclassroom.com/images/'+$('.actif').attr('id')+'.png) no-repeat 0 1px');
		$('.actif,.actif a').css('color','#FFF');
	});
	$('#pause img').click(function(e)	{
		e.preventDefault();
		if($(this).attr('src') == 'http://www.musiclassroom.com/images/pause.png')
		{
			animation = false;
			$(this).attr('src','http://www.musiclassroom.com/images/play.png');
			$(this).attr('alt','D&eacute;marrer');
			return false;
		}
		if($(this).attr('src') == 'http://www.musiclassroom.com/images/play.png')
		{
			animation = true;
			$(this).attr('src','http://www.musiclassroom.com/images/pause.png');
			$(this).attr('alt','Arr&ecirc;ter');
			clearInterval(T_GLOBAL);
			T_GLOBAL = setTimeout('afficherSuivante();',11000);
			return false;
		}
	});
	$('#prev').click(function(e)	{
		e.preventDefault();
		$('#slide'+teaserAffiche).fadeOut(0);
		if(teaserAffiche == 1)	teaserAffiche = $('.slide').size();
		else	teaserAffiche -= 1;
		$('#slide'+teaserAffiche).effect( 'slide', { direction: "right" }, 500, '' );
		$('#slide'+teaserAffiche+' div').show();
		$('.navteaser .last span').html(teaserAffiche);
		clearInterval(T_GLOBAL);
		T_GLOBAL = setTimeout('afficherSuivante();',11000);
	});
	$('#next').click(function(e)	{
		e.preventDefault();
		$('#slide'+teaserAffiche).fadeOut(0);
		if(teaserAffiche == $('.slide').size())	teaserAffiche = 1;
		else	teaserAffiche += 1;
		$('#slide'+teaserAffiche).effect( 'slide', { direction: "right" }, 500, '' );
		$('#slide'+teaserAffiche+' div').show();
		$('.navteaser .last span').html(teaserAffiche);
		clearInterval(T_GLOBAL);
		T_GLOBAL = setTimeout('afficherSuivante();',5000);
	});
});
