jQuery(function($){
	initFontSize();
	initFontContrast();

	//Création des liens retours
	$('.retour a').click(function() {
		history.go(-1); return false;
	});

	//Initialisation du champ de recherche
	search_txt = $('.search input[type=text]').val();
	$('.search input[type=text]').focus(function() {
		this.value = '';
	});
	$('.search input[type=text]').blur(function() {
		if(this.value=='') this.value = search_txt;
	});

	//Initialisation du champ d'inscription à la newsletter
	$('#newsletter_txt input[type=text]').val('adresse email');
	$('#newsletter_txt input[type=text]').focus(function() {
		this.value = '';
	});
	$('#newsletter_txt input[type=text]').blur(function() {
		if(this.value=='') this.value = 'adresse email';
	});
	
	if($('#banner img').length == 1) {
		$('#banner img').css('display', 'block');
	} else if ($('#banner img').length > 0) {
		showDiapo();
	}
	
	$(document).pngFix(); 
});

var fs = 100;
function initFontSize()
{
	var cookie = readCookie("font_size");
	fs = cookie ? cookie : fs;
	setFontSize();

	$('#print').click(function() {
		window.print(); return false;
	});
	$('#typocontrast').click(function() {
		setActiveStyleSheet('typo_contrast', 'switch'); return false;
	});
	$('#typomoins').click(function() {
		setFontSize(-1); return false;
	});
	$('#typoplus').click(function() {
		setFontSize(+1); return false;
	});
}
function setFontSize(val) {
	if(val != '') val = eval(fs + ' + ' + (val*20));
	if(val >= 100 && val <= 160)
	{
		fs = val;
		createCookie("font_size", fs, 365);	
	}
	$('#col_center').css('font-size', fs + '%');
}

var fc = 0;
function initFontContrast()
{
	var cookie = readCookie("contrast");
	fc = cookie ? cookie : fs;
	if(fc == 1) setFontContrast();	
}

photo = 0;
function showDiapo()
{
	var i = 0;
	$('#banner img').each(function(j)
	{
		if (i == photo) $(this).show();
		else $(this).hide();
		i++;
	});
	photo = (photo >= (i - 1)) ? 0 : photo + 1;
	$('#banner a').fadeIn("slow", function(){
		setTimeout('hideDiapo()', 5000);
	});
}
function hideDiapo()
{
	$('#banner a').fadeOut("slow", function(){
		showDiapo();
	});
}

