/**
 * @author Actunet
 */
function bSyntaxeEmail(sMail)
{
	var re=/^[a-z\d]+((\.|-|_)[a-z\d]+)*@((?![-\d])[a-z\d-]{0,62}[a-z\d]\.){1,4}[a-z]{2,6}$/gi;
	return (sMail.match(re)==sMail)&&(sMail.substr(sMail.lastIndexOf("@")).length<=256);
}

function bDomainTLD(sMail)
{
	var re=/^(ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw|aero|arpa|asia|biz|com|coop|edu|eu|gov|info|int|mil|museum|name|net|org|pro|jobs|travel)$/gi;
	return sMail.substr(sMail.lastIndexOf(".") + 1).match(re)!=null;
} 

function isDate(d) {
	// Cette fonction permet de vérifier la validité d'une date au format jj/mm/aa ou jj/mm/aaaa
	// Par Romuald
	if (d == "") // si la variable est vide on retourne faux
	return false;
	e = new RegExp("^[0-9]{1,2}\/[0-9]{1,2}\/([0-9]{2}|[0-9]{4})$");
	if (!e.test(d)) // On teste l'expression régulière pour valider la forme de la date
	return false; // Si pas bon, retourne faux
	// On sépare la date en 3 variables pour vérification, parseInt() converti du texte en entier
	j = parseInt(d.split("/")[0], 10); // jour
	m = parseInt(d.split("/")[1], 10); // mois
	a = parseInt(d.split("/")[2], 10); // année
	// Si l'année n'est composée que de 2 chiffres on complète automatiquement
	if (a < 1000) {
	if (a < 89) a+=2000; // Si a < 89 alors on ajoute 2000 sinon on ajoute 1900
	else a+=1900;
	}
	// Définition du dernier jour de février
	// Année bissextile si annnée divisible par 4 et que ce n'est pas un siècle, ou bien si divisible par 400
	if (a%4 == 0 && a%100 !=0 || a%400 == 0) fev = 29;
	else fev = 28;
	// Nombre de jours pour chaque mois
	nbJours = new Array(31,fev,31,30,31,30,31,31,30,31,30,31);
	// Enfin, retourne vrai si le jour est bien entre 1 et le bon nombre de jours, idem pour les mois, sinon retourn faux
	return ( m >= 1 && m <=12 && j >= 1 && j <= nbJours[m-1] );
} 


function ClubPrefere(element,id_club)
{
	$.ajax({
		type: "POST",
	    url: "/inc/ajax.php",
		data: "ajax=ClubPrefere&id_discipline="+$(element).val()+"&id_club="+id_club,
		async: false,
		success:function(msg){
			$('#club_pref').html(msg);
		}
	});
	
	return false;
}

function openImp(page) {
	window.open('/template/journal/'+page, 'Impression', 'resizable=no, location=no, width=700, height=500, menubar=yes, status=no, scrollbars=yes');
}

//PRELOAD D'IMAGE
jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}
//On preload les images du menu
$.preloadImages("/template/journal/images/menu_commission_over.jpg", "/template/journal/images/menu_demande_over.jpg",
"/template/journal/images/menu_profession_over.jpg", "/template/journal/images/menu_contact_over.jpg");


function init_menu(){
	$("#menu li").mouseover(function () {
		var img = $(this).children("img").attr("id");
		$("#"+img).attr("src","/template/journal/images/menu_"+img+"_over.jpg");
		var $les_enfants = $(this).children("ul");
		$les_enfants.css("display","block");
	});
	$("#menu li").mouseout(function () {
		var $les_enfants = $(this).children("ul");
		$les_enfants.css("display","none");
		$("#profession").attr("src","/template/journal/images/menu_profession.jpg");
		$("#commission").attr("src","/template/journal/images/menu_commission.jpg");
		$("#demande").attr("src","/template/journal/images/menu_demande.jpg");
	});
	$("#les_s_rubriques li").mouseover(function () {
		//var img = $(this).children("img").attr("id");
		//$("#"+img).attr("src","/template/journal/images/menu_"+img+"_over.jpg");
		var $les_enfants = $(this).children("ul");
		$les_enfants.css("display","block");
	});
	$("#les_s_rubriques li").mouseout(function () {
		var $les_enfants = $(this).children("ul");
		$les_enfants.css("display","none");
		$("#profession").attr("src","/template/journal/images/menu_profession.jpg");
		$("#commission").attr("src","/template/journal/images/menu_commission.jpg");
		$("#demande").attr("src","/template/journal/images/menu_demande.jpg");
	});

 }

//fonction pour faire apparaitre el contenu pour le decoupage regional
function retourne_contenu(region) {
	$.ajax({
		type: "POST",
	    url: "/inc/ajax.php",
		data: "ajax=retourne_contenu_decoupage&region="+region,
		async: false,
		success:function(msg){
			$('#info_carte').html(msg);
		}
	});
}


function show_div(id) {
	$("#"+id).toggle();
}

function winBRopen(theURL, Name, popW, popH, scroll) { // V 1.0
	var winleft = (screen.width - popW) / 2;
	var winUp = (screen.height - popH) / 2;
	winProp = 'fullscreen=yes,resizable=no'
	Win = window.open(theURL, Name, winProp)
	if (parseInt(navigator.appVersion) >= 4) { Win.window.focus(); }
} 


$(document).ready(function() {
	init_menu();
	$("#bloc_gauche .titre_article").livequery("mouseover",function() {
		$(this).attr("class","titre_article_over");
		$("#bloc_gauche .titre_article").attr("class","titre_article");
	})
	$("#bloc_gauche .titre_article_over").livequery("mouseout",function(){
		$(this).attr("class","titre_article");
	});
	$("#bloc_gauche .titre_article_over").livequery("click",function(){
		location.href=$(this).attr("id");
		/*$.ajax({
			type: "POST",
			url: "/inc/ajax.php",
			data: "ajax=renvoi_url&id_article="+$(this).attr("id"),
			async: false,
			success:function(msg){
				//location.href=msg;
				alert(msg);
			}
		});*/
	});
});
