/* *********************************************************************************** */ 
/* *********************************************************************************** APPEL GENERAL DES FONCTIONS */
/* *********************************************************************************** */
$(document).ready(function() {
	flashAudio();											// flash audio
	menuAnnexe(); menu();									// menus
	cycleDiapo();											// diaporama
});

/* *********************************************************************************** */ 
/* *********************************************************************************** FONCTIONS */
/* *********************************************************************************** */

/* *********************************************************************************** FLASH AUDIO */
var flashAudio = function() {
	if( jQuery("#flash-audio").length < 1 ) return false;
	
	var flashvars = {};

	var params = {};
	params.menu = "false";
	params.quality = "high";
	params.wmode = "transparent";
	
	var attributes = {};
	swfobject.embedSWF("swf/90x20.swf", "flash-audio", "90", "20", "9.0.0", "swf/expressInstall.swf", flashvars, params, attributes);	
}

/* *********************************************************************************** FOCUS INPUT */
var swapInput = function() { swapValues=[]; $(".swapValue").each(function(i){swapValues[i]=$(this).val();$(this).focus(function(){if($(this).val()==swapValues[i]){$(this).val("")}}).blur(function(){if($.trim($(this).val())==""){$(this).val(swapValues[i])}})});};

/* *********************************************************************************** HOVER CLASS */
$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};	

/* *********************************************************************************** MENUS */
var menuAnnexe = function() {
	$("#annexe li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
	if (document.all) {
		$("#annexe li").hoverClass ("sfHover");
	}
}

var menu = function() {
	$("#menu li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);

	$("#menu li").hoverClass ("sfHover");

}

/* *********************************************************************************** CYCLE DIAPORAMA */
var cycleDiapo = function() {
	$('#diapo').cycle({ 
    	fx:     'fade', 
    	timeout: 3000
	});	
}
$.fn.cycle.transitions.scrollLeft = function($cont, $slides, opts) {
	$cont.css('overflow','hidden');
	opts.before.push($.fn.cycle.commonReset);
	var w = $cont.width();
	opts.cssFirst = { left: 0 };
	opts.cssBefore= { left: w, top: 0 };
	opts.animIn	  = { left: 0 };
	opts.animOut  = { left: 0-w };
};


////////////////////////////////////////////////////////////////////////////////////////////////
function validNewsletter () {
	var	n_mail					= document.emailForm.email.value;
	//document.newsForm.method	= 'POST';
	
	if (n_mail == "") {
		alert ("Vous devez saisir votre email, merci.");
	} else {
		var reg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,3}$/;

		if (!reg.exec(n_mail)) {
			alert ("Vous devez saisir votre email, merci.");
		} else {
			document.emailForm.submit ();
		}
	}
}
