Cufon.replace('.vitesseBlack', { fontFamily: 'vitesseBlack',forceHitArea: true, hover: true});
Cufon.replace('.vitesseLight', { fontFamily: '.vitesseLight' });
Cufon.replace('.vitesseMedium', { fontFamily: 'vitesseMedium' });
Cufon.replace('.vitesseSansLight', { fontFamily: 'vitesseSansLight' });
Cufon.replace('.vitesseSansMedium', { fontFamily: 'vitesseSansMedium' });
Cufon.replace('.vitesseSansBook', { fontFamily: 'vitesseSansBook' });
Cufon.replace('.vitesseBold', { fontFamily: 'vitesseBold' });
//Cufon.replace('#innerFooter div.menu ul li a', { fontFamily: 'vitesseMedium',forceHitArea: true, hover: true });
//Cufon.replace('#innerFooter div.menu ul li ul li a', { fontFamily: 'vitesseSansLight',forceHitArea: true, hover: true });
Cufon.replace('.titreNouvelle', { fontFamily: '.vitesseLight' });
Cufon.replace('.pagenav a', { fontFamily: 'vitesseBlack' });
Cufon.replace('.pagenav ul li a', { fontFamily: 'vitesseSansLight',forceHitArea: true });
//Cufon.replace('.uneCol li a', { fontFamily: 'vitesseSansLight',forceHitArea: true, hover: true });



var imgRotArray = '';
var imgSpec = '';

/*
 * Hover sur les liens qui sont cufoné
 */
$(document).ready(function(){
	
	var lastInfo = '';
	var isInfoOpen = '';
	var etatContact = '';
	

	if(imgRotArray != ''){
		slideShow(imgRotArray);
	}

	if(imgSpec != ''){
		displayImg(imgSpec);
	}
	/*
	 * Message d'intro
	 * Doit apparaitre 1 seule fois
	 */
	
	$('#main').addClass('clearfix');
	
	if($.cookie('bqa__v') == null){
		$('#homeVideo object').hide();
		timerIntro();
		$.cookie('bqa__v', 'visited');
	}else{
		$('#intro').hide();
	}
	
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	var txt_fb = 'suivez nous sur facebook';
	var txt_mail = 'ajoutez votre nom à notre liste d’envoi';
	var txt_flicker = 'regardez notre galerie d’images sur flickr';
	
	$('#sideLink_fb').mouseenter(function(){
		$('#homeShare p.text').html(txt_fb);
		$('#sideLink_mail').css("backgroundPosition","-137px -10px");
		$('#sideLink_flicker').css("backgroundPosition","-168px -10px");
	});
	$('#sideLink_fb').mouseout(function(){
		$('#homeShare p.text').html('&nbsp;');
		$('#sideLink_mail').css("backgroundPosition","-42px -10px");
		$('#sideLink_flicker').css("backgroundPosition","-73px -10px");
	});
	
	$('#sideLink_mail').mouseenter(function(){
		$('#homeShare p.text').html(txt_mail);
		$('#sideLink_fb').css("backgroundPosition","-105px -10px");
		$('#sideLink_flicker').css("backgroundPosition","-168px -10px");
	});
	$('#sideLink_mail').mouseout(function(){
		$('#homeShare p.text').html('&nbsp;');
		$('#sideLink_fb').css("backgroundPosition","-10px -10px");
		$('#sideLink_flicker').css("backgroundPosition","-73px -10px");
	});
	
	$('#sideLink_flicker').mouseenter(function(){
		$('#homeShare p.text').html(txt_flicker);
		$('#sideLink_fb').css("backgroundPosition","-105px -10px");
		$('#sideLink_mail').css("backgroundPosition","-137px -10px");
	});
	$('#sideLink_flicker').mouseout(function(){
		$('#homeShare p.text').html('&nbsp;');
		$('#sideLink_fb').css("backgroundPosition","-10px -10px");
		$('#sideLink_mail').css("backgroundPosition","-42px -10px");
	});
	
	$('#sideLink_mail').click(function(){
		showNewsLetter();
	});
	$('#newsLetter span.close').click(function(){
		closeNewsLetter();
	});
	
	
	$('#containerHome .col_rr a').mouseenter(function(){
		var who = $(this).attr('rel');
		comImg('in',who);
		if(isInfoOpen != who){
			$(this).css("color","#00aeef");
			Cufon.refresh();
		}
	});
	$('#containerHome .col_rr a').mouseleave(function(){
		var who = $(this).attr('rel');
		comImg('out',who);
		if(isInfoOpen != who){
			$(this).css("color","#939598");
			Cufon.refresh();
		}
	});
	$('#containerHome .col_rr a').click(function(){
		if(lastInfo != ''){
			$('#'+lastInfo+'i').hide();
		}
		var who = $(this).attr('rel');
		isInfoOpen = who;
		$('#containerHome .col_rr a').css("color","#939598");
		$('#'+who+'t').css("color","#00aeef");
		Cufon.refresh();
		lastInfo = who;
		$('#comImg').fadeOut('slow', function(){
			$('#'+who+'i').fadeIn('slow');
			$('#infoCom').fadeIn('slow');
		});
		return false;
	});
	
	$('#comImg img').mouseenter(function(){
		var who = $(this).attr('id');
		if(isInfoOpen != who){
			$('#'+who+'t').css("color","#00aeef");
			Cufon.refresh();
		}
	});
	$('#comImg img').mouseleave(function(){
		var who = $(this).attr('id');
		if(isInfoOpen != who){
			$('#'+who+'t').css("color","#939598");
			Cufon.refresh();
		}
	});
	$('#comImg img').click(function(){
		var who = $(this).attr('id');
		isInfoOpen = who;
		$('#containerHome .col_r a').css("color","#939598");
		$('#'+who+'t').css("color","#00aeef");
		Cufon.refresh();
		lastInfo = who;
		$('#comImg').fadeOut('slow', function(){
			$('#'+who+'i').fadeIn('slow');
			$('#infoCom').fadeIn('slow');
		});
		return false;
	});
	
	$('#closeCom').click(function(){
		isInfoOpen = '';
		$('#containerHome .col_r a').css("color","#939598");
		Cufon.refresh();
		$('#'+lastInfo+'i').hide();
		$('#comImg').fadeIn('slow');
		return false;
	});
	
	/*
	 * Clique sur contact 
	 */
	$('#menu-item-31').click(function(){
		if(etatContact){
			$('#contact').fadeOut();
			etatContact = false;
		}else{
			$('#contact').fadeIn();
			etatContact = true;
		}
		return false;
	});
	$('#closeContact').click(function(){
		$('#contact').fadeOut();
		etatContact = false;
		return false;
	});
	
	
});

var comImg = function(q,who){
	if(q=='in'){
		$('#'+who).addClass('in');
	}else{
		$('#'+who).removeClass('in');
	}
};

var timerIntro = function(){
	var t=setTimeout("fadeIntro()",3000);
}

var fadeIntro = function(){
	
	$("#intro").fadeOut("slow", function(){
		$('#homeVideo object').show();
	});
}

/*
 * Slideshow accueil
 */
var imgFront = '';
var imgBack = '';
var imgCour = '';
var imgNext = 0;
var nbImg = '';
var monarrrayImg = '';
var conteurTimer = 0;
var tempsImg = 4000;

var slideShow = function(arrayImg){
	arrayImg.splice(0,1);
	monarrrayImg = arrayImg;
	
	nbImg = arrayImg.length;
	
	imgBack = arrayImg[imgNext];
	imgFront = arrayImg[imgNext];
	
	imgNext++;
	
	if(imgNext == nbImg){
		imgNext = 0;
	}
	imgCour = imgBack;
	
	$("#S1").attr("src",imgBack);
	
	imgBack = arrayImg[imgNext];
	
	imgNext++;
	if(imgNext == nbImg){
		imgNext = 0;
	}
	
	var t=setTimeout("loop()",2000);
}
var loop = function(){
	//var t=setTimeout("changeImg()",4000);
	//var t2=setTimeout("loop()",8000);
	$("#S2").fadeOut(4000, function(){
		changeImg();
		$(this).show();
	});
}


var changeImg = function(){
		$("#S1").attr("src",imgBack);
		$("#S2").attr("src",imgFront);
		imgFront = imgBack;
		imgBack = monarrrayImg[imgNext];
		
		imgNext++;
		if(imgNext == nbImg){
			imgNext = 0;
		}
		var t2=setTimeout("loop()",4000);
}
var displayImg = function(imgSpec){
	
	// <a href="<?php echo get_settings('siteurl'); ?>/wp-content/themes/banquette/images/banquette/spectacle/<?php the_ID(); ?>/full/1.jpg" rel="prettyPhoto[pp_gal]" title="You can add caption to pictures."><img src="<?php echo get_settings('siteurl'); ?>/wp-content/themes/banquette/images/banquette/spectacle/<?php the_ID(); ?>/1.jpg" alt="bob" /></a>
	
	var nbImgSpec = imgSpec.length;
	var construction = '';
	imgSpec.splice(0,1);
	imgSpecFull.splice(0,1);
	
	for(i=1;i<nbImgSpec;i++){
		construction += '<a href="'+url+'/'+imgSpecFull[i-1]+'" rel="prettyPhoto[pp_gal]" title=" ">';
		construction += '<img src="'+url+'/'+imgSpec[i-1]+'" alt=" " />';
		construction += '</a>';
	}
	//console.log(construction);
	$('#contImg').html(construction);
}
var showNewsLetter = function(){
	$('#newsLetter').show();
}
var closeNewsLetter = function(){
	$('.step2').hide();
	$('.step1').show();
	$('#newsLetter').hide();
}
var subNewsLetter = function(){
	var s = true;
	if($('.needed1').val()==''){
		$('.needed1').addClass('error');
		s = false;
		//alert('err1');
	}else{
		$('.needed1').removeClass('error');
	}
	if($('.needed2').val()==''){
		$('.needed2').addClass('error');
		s = false;
		//alert('err2');
	}else{
		$('.needed2').removeClass('error');
	}
	if(validateEmail($('.needed3').val())==false){
		$('.needed3').addClass('error');
		s = false;
		//alert('err3');
	}else{
		$('.needed3').removeClass('error');
	}
	if(s){
		var adresse_saisie = $('.domicile:checked').val();
		var coord_saisie = $('.coordonnees:checked').val();
		var prenom = $('#prenom_newsl').val();
		var nom = $('#nom_newsl').val();
		var courriel = $('#courriel_newsl').val();
		var adresse = $('#adresse_newsl').val();
		var ville = $('#ville_newsl').val();
		var province = $('#province_newsl').val();
		var pays = $('#pays_newsl').val();
		var code_postal = $('#code_postal_newsl').val();
		var telephone = $('#telephone_newsl').val();

		//var site = url+"/test.php";
		//var site = "http://sleclerc.developers.turbulent.ca/test.php";
		var site = "http://www.banquettearriere.com/test.php";
		//alert(site);
		//console.log(adresse_saisie);
		$.post(site, { adresse_saisie: adresse_saisie, coord_saisie: coord_saisie , prenom: prenom 
		, pays: pays , nom: nom , courriel: courriel , adresse: adresse , ville: ville , province: province 
		, code_postal: code_postal , telephone: telephone },
		function(data){
			$('.step1').hide();
			$('.step2').show();
		});
	}
	return false;
}
function validateEmail(email){  
	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
	return emailPattern.test(email);  
}  
