// Fonction qui verifie si le email est valide
function isValidEmail(email)
{
	if (email.search(/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/) != -1) return true;
	else return false;
}
function checkForm(form)
{
	var valid = true;
	if(form.nom)
	{
		if(form.nom.value == "")
		{
			document.getElementById('msg_nom').innerHTML = "Veuillez entrer votre nom";
			document.getElementById('nom').style.borderColor = "#FF0000";
			valid = false;
		}
		else
		{
			document.getElementById('msg_nom').innerHTML = "";
			document.getElementById('nom').style.borderColor = "#a3a0a4";
		}
	}
	
	if(form.email.value == "")
	{
		document.getElementById('msg_email').innerHTML = "Veuillez entrer votre courriel";
		document.getElementById('email').style.borderColor = "#FF0000";
		valid = false;
	}
	else if(isValidEmail(form.email.value) == false)
	{
		document.getElementById('msg_email').innerHTML = "Veuillez entrer un courriel valide";
		document.getElementById('email').style.borderColor = "#FF0000";
		valid = false;
	}
	else
	{
		document.getElementById('msg_email').innerHTML = "";
		document.getElementById('email').style.borderColor = "#a3a0a4";
	}
	return valid;
}

function clearText(field){
    if (field.defaultValue == field.value)
	{
		field.style.color = "#a3a0a4";
		field.value = '';	
	}
}
function returnText(field){
	if (field.value == '') 
	{
		field.style.color = "#cfcfcf";
		field.value = field.defaultValue;
	}
}

function showMore(num){
	
	
	var block = "block_"+num;
	var more = "more"+num;
	var inner = document.getElementById(more).innerHTML;
	
	if(inner == "&gt; En savoir plus")
	{
		document.getElementById(more).innerHTML = "&gt; R&eacute;duire";
		document.getElementById(block).style.display = 'block';	
	}
	else
	{
		document.getElementById(more).innerHTML = "&gt; En savoir plus";
		document.getElementById(block).style.display = 'none';	
	}
}

/* Rotation Banner */


var current_banner = 1;
var t;

function $F(id) {
var $F = document.getElementById(id);

$F.fadeIn = function(delay,callbk,out) {
    var _this = this;
	var filter = (navigator.appName == "Microsoft Internet Explorer") ? 50 : 100;

	if (out == undefined) _this.style.display = "block";
    for (i = 1; i <= 100; i++) {
      (function(j) {
            setTimeout(function() {  
                  if (out==true) j=100-j;
                  _this.style.opacity = j/100;
                  _this.style.MozOpacity = j/100;
                  _this.style.KhtmlOpacity = j/100;
                  _this.style.zoom = 1; // for ie, set haslayout
                   if (j==100&&callbk!=undefined) {callbk.call(_this);}
                   else if (out==true&&callbk!=undefined&&j==0) {callbk.call(_this);}
                  _this.style.filter = "alpha(opacity=" + j + ");";},j*delay/filter);                 
        })(i);   
    }
};

$F.fadeOut = function(delay,callbk) {
    $F.fadeIn(delay,callbk,true);
};

return $F;
}

function clickBox(id,img_num)
{
	if(id.className.split(" ",1) == "flash_btn")
	{
		rotate(img_num);	
	}
}

function init_rotate()
{
	$F("imgid"+4).fadeOut(1);
	$F("imgid"+3).fadeOut(1);
	$F("imgid"+2).fadeOut(1);
	t = setTimeout(function(){rotate(2)},5000);
}

function rotate(img_num) 
{
	clearTimeout(t);
	var time;
	if(navigator.appName == "Microsoft Internet Explorer"){
		time = 180;
	}
	else
		time = 1000;
	document.getElementById('btn_flash'+current_banner).className = 'flash_btn';
	$F("imgid"+current_banner).fadeOut(time);
	
	document.getElementById('flashlink').href = document.getElementById('imgid'+img_num).getAttribute('name');
	
	document.getElementById('btn_flash'+img_num).className = 'flash_btn_active';
	$F("imgid"+img_num).fadeIn(time);
	
	current_banner = img_num;

	if(img_num >= 4 || img_num <=0)
	{
		img_num = 1;
	}
	else
	{
		img_num++;	
	}

	t = setTimeout(function(){rotate(img_num)},5000);
}

/* End rotation banner */
