/* JS actions */
$(document).ready(function(){
	$('a.spip_out').attr('target','_blank');
	$('#bg').cycle({
		cleartype: true,
		cleartypeNoBg: true
	});
	
	$('#diapo_res').cycle();
	$("a.map_link").fancybox();
	
	$("a.map_link").each(function(){
		attr_href = $(this).attr('href');
		$(this).attr('href','#'+attr_href);
	});
	
	//accordeon sous menu de droite
	nb_on=0;
	$('.accordeon_me ul li').each(function(){
		if($(this).hasClass('on')){nb_on++;}
	});
	if(nb_on==1){
		$(".accordeon_me ul").css("display","block");
		$(this).css("background","url('xprod/img_web/fleche_orange.png') no-repeat left");
		$(".accordeon_me .fisrt_accordeon").toggle(function () {
		  $(this).css("background","url('xprod/img_web/fleche_orange.png') no-repeat scroll 150px 4px transparent");
	      $(this).next("ul").slideDown('slow');
	    }, function () {
	      $(this).css("background","url('xprod/img_web/triangle-gris.png') no-repeat scroll 150px 4px transparent");
	      $(this).next("ul").slideUp('slow');
		});
	} else {
		$(".accordeon_me ul").css("display","none");
		$(".accordeon_me .fisrt_accordeon").toggle(function () {
		  $(this).css("background","url('xprod/img_web/fleche_orange.png') no-repeat scroll 150px 4px transparent");
	      $(this).next("ul").slideDown('slow');
	    }, function () {
	      $(this).css("background","url('xprod/img_web/triangle-gris.png') no-repeat scroll 150px 4px transparent");
	      $(this).next("ul").slideUp('slow');
		});
	}
	
        
                    /** Gestion du positionnement et de l'affichage de l'arbre selon la taille de la fenetre */

            function adapt() {
                if($(window).width() <= 1024)
                {
                   $('#equipe').fadeOut('fast');
                   $('#page').css({
                        'width': '850px',
                        'margin-left': 'auto',
                        'margin-right': 'auto'
                    });
                }
                else if($(window).width() > 1024 && $(window).width() < 1300)
                {
                    $('#equipe').fadeIn('fast').animate({marginRight: '-60px'});
                    $('#page').animate({
                        width: '850px',
                        marginLeft: '2%'
                    });
                }
                else
                {
                   $('#equipe').fadeIn('fast').animate({marginRight: '0'});
                   $('#page').css({
                        'width': '850px',
                        'margin-left': 'auto',
                        'margin-right': 'auto'
                    });
                }
            }
            
             adapt();

            $(window).resize(function() {
                adapt()
            });
});
