var CURL = new Array();
var sp = []; // Starting points
AC_FL_RunContent = 0;

$(document).ready(function()
{
        // Optimisation : On conserve des points d'entree dans la page
	sp['header'] = $('div.header:eq(0)');
	sp['nav_main'] = $('div.nav_main:eq(0)');
	sp['main'] = $('div.main:eq(0)');
	sp['content'] = $('div.content:eq(0)', sp['main_int']);
	sp['footer'] = $('div.footer:eq(0)');

        $('div.footer_logo', sp['footer']).slideNews({
	        newsWidth: 70,
	        newsHeight: 150,
	        newsSpeed: 1000,
	        nbItem: 3
  	});
  	
  	// Date
	if ($("div.actu div.block_news li .date").length > 0) {
		var re1 = new RegExp("([0-9]{4})(\/)");
		var re2 = new RegExp("(\/)([0-9]{4})");
		if($("html").attr("lang") == "en-gb") {
			$("div.actu div.block_news li .date").replaceText(re1, "$1<br />");
		} else {
			$("div.actu div.block_news li .date").replaceText(re2, "<br />$2");
		}
	}

	// liens d'evitement
	$("div.accessibilite a").focus(function(){
		$(this).parent().parent().parent().removeClass('accessibilite_off');
	});

	$("div.accessibilite a").blur(function(){
		$(this).parent().parent().parent().addClass('accessibilite_off');
	});

	//Bouton afficher des listes d'années
	$('div.nav_page_actu .input_submit').css('display','none');

	//Blocs depliables
	$("div.block_foldable").addClass('off');
	$("div.block_foldable.view").removeClass('off');

	//afficher le premier bloc
	$("div.block_foldable:first").removeClass('off');

 	$("div.block_foldable h3").click(function(){
		$(this).parents('.block_foldable').toggleClass('off');
	});

	//en edition on affiche tous les blocs
	$("div.edit_form div.block_foldable").removeClass('off');

	/*recherche de laureats*/
	if ($('body.laureats').size())
	{
		$("div.block_form .checkbox").addClass('off');
	
		$("div.block_form .view").addClass('on').removeClass('off');
		$("div.block_form .view input").attr('checked', 'checked');
	
		$("div.block_form div.violon p").click(function(){
			$(this).parent().parent().removeClass('off');
	  		$(this).parent().parent().addClass('on');
	  		$("div.block_form div.piano").addClass('off').removeClass('on');
	  		$("div.block_form div.chant").addClass('off').removeClass('on');
	
	  		//boutons radios
			$("div.block_form div.violon input#v_violon").attr('checked','checked');
	   		$("div.block_form div.piano input#v_piano").removeAttr('checked');
	   		$("div.block_form div.chant input#v_chant").removeAttr('checked');
		});
	
		$("div.block_form div.piano p").click(function(){
			$(this).parent().parent().removeClass('off');
	  		$(this).parent().parent().addClass('on');
	  		$("div.block_form div.violon").addClass('off').removeClass('on');
	  		$("div.block_form div.chant").addClass('off').removeClass('on');
	
			//boutons radios
			$("div.block_form div.piano input#v_piano").attr('checked','checked');
	                $("div.block_form div.violon input#v_violon").removeAttr('checked');
	                $("div.block_form div.chant input#v_chant").removeAttr('checked');
		});
		
		$("div.block_form div.chant p").click(function(){
			$(this).parent().parent().removeClass('off');
	  		$(this).parent().parent().addClass('on');
	  		$("div.block_form div.piano").addClass('off').removeClass('on');
	  		$("div.block_form div.violon").addClass('off').removeClass('on');
	
			//boutons radios
			$("div.block_form div.chant input#v_chant").attr('checked','checked');
	                $("div.block_form div.violon input#v_violon").removeAttr('checked');
	                $("div.block_form div.piano input#v_piano").removeAttr('checked');
		});
	}

	/*les concerts de gala */
	if ($('body.les-concerts-de-gala').size())
	{
		$("div.block_form .checkbox").addClass('off');

		$("div.block_form .view").addClass('on').removeClass('off');
		$("div.block_form .view input").attr('checked', 'checked');

		$("div.block_form div.violon p").click(function(){
			$(this).parent().parent().removeClass('off');
	  		$(this).parent().parent().addClass('on');
	  		$("div.block_form .piano").addClass('off').removeClass('on');
			$("div.block_form .sans").addClass('off').removeClass('on');

	  		//boutons radios
			$("div.block_form div.violon input#v_violon").attr('checked','checked');
	   		$("div.block_form div.piano input#v_piano").removeAttr('checked');
	   		$("div.block_form div.sans input#v_sans").removeAttr('checked');
		});

		$("div.block_form div.piano p").click(function(){
			$(this).parent().parent().removeClass('off');
	  		$(this).parent().parent().addClass('on');
	  		$("div.block_form div.violon").addClass('off').removeClass('on');
			$("div.block_form div.sans").addClass('off').removeClass('on');

			//boutons radios
			$("div.block_form div.piano input#v_piano").attr('checked','checked');
	                $("div.block_form div.violon input#v_violon").removeAttr('checked');
	                $("div.block_form div.sans input#v_sans").removeAttr('checked');
		});

		$("div.block_form div.sans p").click(function(){
			$(this).parent().parent().removeClass('off');
	  		$(this).parent().parent().addClass('on');
	  		$("div.block_form div.violon").addClass('off').removeClass('on');
			$("div.block_form div.piano").addClass('off').removeClass('on');

			//boutons radios
			$("div.block_form div.sans input#v_sans").attr('checked','checked');
	                $("div.block_form div.violon input#v_violon").removeAttr('checked');
	                $("div.block_form div.piano input#v_piano").removeAttr('checked');
		});
	}

	/*bouton imprimer*/
	$("p.print").click(function(){
			window.print();
		}).hover(function() {
				$(this).addClass('hover');
				return false;
			},function(){
	  		$(this).removeClass('hover');
		});

	//ajoute une classe pdf à tous les liens qui pointent vers un fichier pdf
	$('a').each(function(){
		if(this.href.match(/\.pdf$/))
		        $(this).addClass('pdf');
	});

	//lien externe
	$('a.external_link').click(function(){
		window.open(this.href, '_blank');
		return false;
	});
});



