
$(document).ready(function() {

	// liens externes : blank
	$("a.spip_out").click(function() {
		window.open(this.href);
		return false;
	});

	// profils
	$('#change_profil').change(function() 
	{
	   document.location = $(this).attr('value');
	});

	// selectionner new profil
	$('a.new_profil').click(function() 
	{
	   $('#profilselected').addClass("invisible");
	   $('#selectprofil').removeClass("invisible");
	   return false;
	});
	
	// accordeon
	$('a.lienaccordeon').click(function() 
	{
		
		$('.accordeonouvert').slideToggle('slow', function() {
			$('.accordeonouvert').removeClass("accordeonouvert");
		});
		
		toSlide = $(this).closest(".blocaccordeon").children('.accordeon').not(".accordeonouvert");
		toSlide.slideToggle('slow', function() {
			toSlide.addClass("accordeonouvert");
		});
		return false;
	});
	
	// font size +
	$('a.increasefontsize').click(function() 
	{
		var max=24;
		var p = $(".entry-content p, .chapo p, .contact p, .item p, .inforub p, .item, .box p");//document.getElementsByTagName('p');
		if(p){
			for(i=0;i<p.length;i++) {
				if(p[i].style.fontSize) {
					var s = parseInt(p[i].style.fontSize.replace("px",""));
				} else {
					var s = 12;
				}
				if(s!=max) {
					s += 2;
				}
				p[i].style.fontSize = s+"px"
			}
		}
		return false;
	});
	
	// font size -
	$('a.decreasefontsize').click(function() 
	{
		var min=8;
		var p = $(".entry-content p, .chapo p, .contact p, .item p, .inforub p, .item, .box p");//document.getElementsByTagName('p');
		for(i=0;i<p.length;i++) {
			if(p[i].style.fontSize) {
				var s = parseInt(p[i].style.fontSize.replace("px",""));
			} else {
				var s = 12;
			}
			if(s!=min) {
				s -= 2;
			}
			p[i].style.fontSize = s+"px"
		}
		return false;
	});
	
	
	// fancybox : fiche conseiller
	$("a.lienficheconseiller").fancybox({
		'width' : 640,
		'height' : 460,
		'overlayShow'	: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	});
	$("area.lienficheconseiller").fancybox({
		'type' : 'iframe',
		'titleShow' : false,
		'width' : 640,
		'height' : 460,
		'overlayShow'	: true,
		'transitionIn'	: 'fade',
		'transitionOut'	: 'fade'
	});
	
	
	// fancybox : diaporama
	$("#documents_portfolio a").fancybox({
		'opacity'		: true,
		'overlayShow'	: false,
		'transitionIn'	: 'fade',
		'transitionOut'	: 'none'
	});

	// fancybox : diaporama
	$(".fancybox").fancybox({
		'opacity'		: true,
		'overlayShow'	: true,
		'transitionIn'	: 'fade',
		'transitionOut'	: 'none'
	});
	
});
