
/* jquery.news-slider.js */
jQuery.fn.slideNews = function(settings) {
	settings = jQuery.extend({
		headline: "Top Stories",
		newsWidth: 250,
		newsHeight: 55,
		newsSpeed: "normal",
		nbItem: 4,
		scrollType: "horizontal"
	}, settings);
	return this.each(function(i){
		jQuery(".messaging",this).css("display","none");

		jQuery(".footer_logo",this).css("overflow","hidden");
		jQuery(".footer_logo_int",this).css("overflow","hidden");
		jQuery(".footer_logo_int",this).css("position","relative");
		jQuery(".container",this).css("left","0px");
		jQuery(".container",this).css("top","0px");
		jQuery(".container",this).css("position","relative");

		itemLength = jQuery(".item",this).length;

		if (settings.scrollType=='horizontal')
		{
			newsContainerSize = itemLength * settings.newsWidth;
			jQuery(".container",this).css("width",newsContainerSize + "px");
			jQuery(".footer_logo",this).css("width",settings.newsWidth * settings.nbItem + "px");
		}
		else
		{
			newsContainerSize = itemLength * settings.newsHeight;
			jQuery(".container",this).css("height",newsContainerSize + "px");
			jQuery(".footer_logo",this).css("height",settings.newsHeight * settings.nbItem + "px");
		}

		animating = false;
		jQuery(".next",this).click(function() {
			thisParent = jQuery(this).parent().parent();
			if (animating == false) {
				animating = true;
				if (settings.scrollType=='horizontal') {
					animate = parseInt(jQuery(".container",thisParent).css("left")) - (settings.newsWidth * settings.nbItem);
					if (animate + parseInt(jQuery(".container",thisParent).css("width")) > 0) {
						jQuery(".container",thisParent).animate({left: animate}, settings.newsSpeed, function() {
							jQuery(this).css("left",animate);
							animating = false;
						});
					} else {
						animating = false;
					}
				} else {
					animate = parseInt(jQuery(".container",thisParent).css("top")) - (settings.newsHeight * settings.nbItem);
					if (animate + parseInt(jQuery(".container",thisParent).css("height")) > 0) {
						jQuery(".container",thisParent).animate({top: animate}, settings.newsSpeed, function() {
							jQuery(this).css("top",animate);
							animating = false;
						});
					} else {
						animating = false;
					}
				}

			}

			return false;
		});
		jQuery(".prev",this).click(function() {
			thisParent = jQuery(this).parent().parent();
			if (animating == false) {
				animating = true;
				if (settings.scrollType=='horizontal') {
					animate = parseInt(jQuery(".container",thisParent).css("left")) + (settings.newsWidth * settings.nbItem);
					if ((animate + parseInt(jQuery(".container",thisParent).css("width"))) <= parseInt(jQuery(".container",thisParent).css("width"))) {
						jQuery(".container",thisParent).animate({left: animate}, settings.newsSpeed, function() {
							jQuery(this).css("left",animate);
							animating = false;
						});
					} else {
						animating = false;
					}
				} else {
					animate = parseInt(jQuery(".container",thisParent).css("top")) + (settings.newsHeight * settings.nbItem);
					if ((animate + parseInt(jQuery(".container",thisParent).css("height"))) <= parseInt(jQuery(".container",thisParent).css("height"))) {
						jQuery(".container",thisParent).animate({top: animate}, settings.newsSpeed, function() {
							jQuery(this).css("top",animate);
							animating = false;
						});
					} else {
						animating = false;
					}
				}
			}

			return false;
		});
	});
};







$(document).ready(function()
{
        var options = {
		//newsWidth: 150,
		newsWidth: 200,
		newsHeight: 55,
		newsSpeed: "normal",
		nbItem: 3
	}
	$(".footer_logo").slideNews(options);

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

	$(".accessibilite a").blur(function(){
		$("../../..", this).addClass('accessibilite_off');
	});
	
	//Bouton afficher des listes d'années
	$('.nav_page_actu .input_submit').css('display','none');

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

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

 	$(".block_foldable h3").click(function(){
		$(".. .block_foldable", this).toggleClass('off');
	});
	//en edition on affiche tous les blocs
	$(".edit_form .block_foldable").removeClass('off');

	/*recherche de laureats*/
	$(".laureats .block_form .checkbox").addClass('off');

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

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

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

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

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

	/*les concerts de gala */
	$(".les-concerts-de-gala .block_form .checkbox").addClass('off');

	$(".les-concerts-de-gala .block_form .view").addClass('on');
	$(".les-concerts-de-gala .block_form .view").removeClass('off');
	$(".les-concerts-de-gala .block_form .view input").attr('checked', 'checked');

	$(".les-concerts-de-gala .block_form .violon p").click(function(){
		$(this).parent().parent().removeClass('off');
  		$(this).parent().parent().addClass('on');
  		$(".les-concerts-de-gala .block_form .piano").addClass('off');
		$(".les-concerts-de-gala .block_form .piano").removeClass('on');
		$(".les-concerts-de-gala .block_form .sans").addClass('off');
		$(".les-concerts-de-gala .block_form .sans").removeClass('on');

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

	$(".les-concerts-de-gala .block_form .piano p").click(function(){
		$(this).parent().parent().removeClass('off');
  		$(this).parent().parent().addClass('on');
  		$(".les-concerts-de-gala .block_form .violon").addClass('off');
		$(".les-concerts-de-gala .block_form .violon").removeClass('on');
		$(".les-concerts-de-gala .block_form .sans").addClass('off');
		$(".les-concerts-de-gala .block_form .sans").removeClass('on');

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

	$(".les-concerts-de-gala .block_form .sans p").click(function(){
		$(this).parent().parent().removeClass('off');
  		$(this).parent().parent().addClass('on');
  		$(".les-concerts-de-gala .block_form .violon").addClass('off');
		$(".les-concerts-de-gala .block_form .violon").removeClass('on');
		$(".les-concerts-de-gala .block_form .piano").addClass('off');
		$(".les-concerts-de-gala .block_form .piano").removeClass('on');

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

	/*bouton imprimer*/
	$(".print").click(function(){
		window.print();
	});

	$(".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;
	});
});


