
/* Declare a namespace for the site */
var Site = window.Site || {};

/* Create a closure to maintain scope of the '$'
   and remain compatible with other frameworks.  */
(function($) {
	
	//same as $(document).ready();
	$(function() {
		
		/* Animation Typo Collection Printemps 2011  */
		$('#left_container').animate({ left: 0}, {duration: 2000,easing: 'easeInOutExpo'});
		
		
	
	/* MouseOver Accueil-SideBox */
	$('#box1').hover(function(event) {
		 $(this).stop().animate({ opacity: 0.5 }, {duration: 'slow',easing: 'easeOutQuint'}); 
			},function(){$(this).stop().animate({ opacity: 1 }, {duration: 'slow',easing: 'easeOutQuint'});
			   });
			   
	$('#box2').hover(function(event) {
		 $(this).stop().animate({ opacity: 0.5 }, {duration: 'slow',easing: 'easeOutQuint'}); 
			},function(){$(this).stop().animate({ opacity: 1 }, {duration: 'slow',easing: 'easeOutQuint'});
			   });
			   
	$('#box3').hover(function(event) {
		 $(this).stop().animate({ opacity: 0.5 }, {duration: 'slow',easing: 'easeOutQuint'}); 
			},function(){$(this).stop().animate({ opacity: 1 }, {duration: 'slow',easing: 'easeOutQuint'});
			   });
		
		/* Collection Scrolling */
		$(".scrollable").scrollable({easing: 'easeInOutQuint', speed: 1100, circular: false, mousewheel: false, touch:false});
		
		/* Presse Scrolling */
		$(".presse_scrollable").scrollable({easing: 'easeInOutQuint', speed: 1100, circular: false, mousewheel: false, touch:false});
		
		/* Infolettre popup overlay */
		$(function() {
			$("a[rel]").overlay({effect: 'apple'});
		});
	
	});

	$(window).bind("load", function() {
		
		
	
	});
	
	
	
})(jQuery); 	

function check_day() {
	if (document.getElementById('disponibilite_1').checked == true) {
		document.getElementById('div_day_1').style.display = 'block';
		document.getElementById('div_day_2').style.display = 'block';
	} else {
		document.getElementById('div_day_1').style.display = 'none';
		document.getElementById('div_day_2').style.display = 'none';
		document.getElementById('disponibilite_4').checked = false;
		document.getElementById('disponibilite_7').checked = false;
	}
}

function check_evening() {
	if (document.getElementById('disponibilite_2').checked == true) {
		document.getElementById('div_evening_1').style.display = 'block';
		document.getElementById('div_evening_2').style.display = 'block';
	} else {
		document.getElementById('div_evening_1').style.display = 'none';
		document.getElementById('div_evening_2').style.display = 'none';
		document.getElementById('disponibilite_5').checked = false;
		document.getElementById('disponibilite_8').checked = false;
	}
}

function check_night() {
	if (document.getElementById('disponibilite_3').checked == true) {
		document.getElementById('div_night_1').style.display = 'block';
		document.getElementById('div_night_2').style.display = 'block';
	} else {
		document.getElementById('div_night_1').style.display = 'none';
		document.getElementById('div_night_2').style.display = 'none';
		document.getElementById('disponibilite_6').checked = false;
		document.getElementById('disponibilite_9').checked = false;
	}
}

function check_email(email) {
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	
	if (filter.test(email)) {
		return true;
	}
	
	return false;
}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function infolettre_form_submit() {
	var email = trim(jQuery('#infolettre_email').val());
	
	if (email == '' || !check_email(email)) {
		jQuery('#wrong_email').slideDown();
	}
	else {
		jQuery('#wrong_email').slideUp();
		
		var data_string = 'email=' + email;
		
		jQuery.ajax({
			type: 'POST',
			url: 'http://www.bsf.ca/includes/infolettre_form_save.php',
			data: data_string,
			
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(errorThrown);
			},
			
			success: function(msg) {
				//jQuery('#debug').html(msg);
				if (msg == 'OK') {
					jQuery('#infolettre_form_confirmation').slideDown();
				}
			}
		});
	}
}

