document.dir = "rtl";

var indexEl = 1;
var anim = setTimeout("animateIndexArticle()", 15000);

var i = 0;
var video = 0;
var clic = 0;
var cpt	= 0;

// click facbook
function fbs_click(titre, code) {
	u = "http://"+window.location.host+"/article.php?code="+code;
	t =titre;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}
// Ajouter aux favoris
function siteFavoris(title, url) {if (document.all) window.external.AddFavorite(url, title); else if (window.sidebar)window.sidebar.addPanel(title, url, "");}

// Ajouter page de démarrage
function pageDemarrage() {this.style.behavior='url(#default#homepage)';this.setHomePage(window.location.href);}

// Date du jour
function OnEstQuelJour() {
   var csChaine;
   var nDay, nJour, nMois, nAnnee;
   var dtJour;
   var NomMois = new Array   ('جانفي','فيفري','مارس','أفريل','ماي','جوان','جويلية','أوت','سبتمبر','اكتوبر','نوفمبر','ديسمبر');
   var NomJour = new Array('الأحد','الإثنين','الثلاثاء','الأربعاء','الخميس','الجمعة','السبت');
   csChaine = " ";
   dtJour   = new Date();
   nDay     = dtJour.getDay();
   nJour    = dtJour.getDate();
   nMois    = dtJour.getMonth() ;
   nAnnee   = dtJour.getYear();
   csChaine += " " + NomJour[nDay]  + " ";
   csChaine += nJour;
   csChaine += " " + NomMois[nMois] + " ";
   if (nAnnee <= 200) nAnnee += 1900;
           csChaine += nAnnee + " ";
   document.write( csChaine );
}

// Tous les traitements

jQuery(document).ready(function() {
	
	// Animations gallery
		// #1
		setTimeout("AnimateGalPhotoPasse()", 10000);
		// #2
		jQuery("#gallery_event").children().hide();
		jQuery("#gallery_event").children(":first").show();
		setTimeout("AnimateGalPhotoEvent()", 8000);
		
	// Menu Services
	jQuery(".icone_left").parents("a").mouseover(function() {
		jQuery(this).find(".icone_left>img").each(function() {
			var image2 = jQuery(this).attr("src").replace("photo/menu", "photo/menu2");
			jQuery(this).attr("src", image2);
		});
	}).mouseout(function() {
		jQuery(this).find(".icone_left>img").each(function() {
			var image2 = jQuery(this).attr("src").replace("photo/menu2", "photo/menu");
			jQuery(this).attr("src", image2);
		});
	});
	
	// Tableauxinternes
	jQuery('dl.faq > dt').hide();
	jQuery('dl.faq > dt').first().show();		   
	jQuery('dl.faq > dd > span.link_moin_plus').first().text('-').parent().next().show();
	jQuery('span.link_moin_plus').css('cursor','pointer').click(function() {
		jQuery('dl.faq > dt').hide();
		jQuery('dl.faq > dd > span.link_moin_plus').text('+');
		var elem = jQuery(this).parent().next();
		if (elem.is(':hidden')) {
			jQuery(this).text("-");
			elem.show();
		}
		else {
			jQuery(this).text("+");
			elem.hide();
		}	
	});	
///////////////////////////////////  Font Size  ////////////////////////////////////////
	  // Reset Font Size
	  var originalFontSize = jQuery('html').css('font-size');
		jQuery(".resetFont").click(function() {
		jQuery('html').css('font-size', originalFontSize);
	  });
	  // Increase Font Size
	  jQuery(".increaseFont").click(function() {
		var currentFontSize = jQuery('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*1.2;
		if (newFontSize < 25) {
		//var newFontSize = 20;
		jQuery('html').css('font-size', newFontSize);
		}
		return false;
	  });
	  // Decrease Font Size
	  jQuery(".decreaseFont").click(function() {
		var currentFontSize = jQuery('html').css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*0.8;
		if (newFontSize > 10) {
		//var newFontSize = 12;
		jQuery('html').css('font-size', newFontSize);
		}
		return false;
	  });
	  
// Lecteur MP3
  jQuery("#music").change(function() {
	jQuery("#lecteurmp3").html('');
	jQuery.ajax({
		   type: "POST",
		   url: "lecteur_ajax.php",
		   data: "num_piste="+jQuery("#music").val(),
		   success: function(msg) {
			jQuery("#lecteurmp3").html(msg);
		   }
	});							   
  });


/***************    Animation du meteo    *****************/
		jQuery.ajax({
			type: "POST",
			url: "ajaxMeteo.php",
			success: function(msg){
				jQuery("#meteo").html(msg);
				jQuery("._meteo_anim").hide();
				jQuery("._meteo_anim").first().show();
				setTimeout('Animation('+i+')', 5000);
			}
		});

	
/************************ Vote ****************************/
	jQuery(".etoile").mouseover(function() {
		jQuery(".etoile").attr('src', 'ar/image/gif/star.gif');
		jQuery(this).prevAll().each(function(i){
			jQuery(this).attr('src', 'ar/image/gif/star_hover.gif');
		});
		jQuery(this).attr('src', 'ar/image/gif/star_hover.gif');
	}).mouseout(function() {
		jQuery(".etoile").attr('src', 'ar/image/gif/star.gif');
	}).click(function() {
		 jQuery.ajax({
		   type	: "POST",
		   url	: "vote.php",
		   data	: "vt="+jQuery(this).attr('id')+"&art="+jQuery("#codeArticle").val(),
		   success: function(msg) {
			 jQuery("#div_rate").html(msg);
		   }
		 });
	});
	
/****************** Début Animation articles *********************/
	jQuery("#fleche_haut").addClass("roller_top_desactive").removeClass("roller_top");
	if(jQuery(".scroller > ul").children("li:first").children("a").attr('id')) {
		jQuery(".scroller > ul").children("li:first").children("a").addClass("active");
		jQuery("#conteneur").html('<div class="tabs_bloc_load"><img src="static/ar/image/gif/px.gif" alt=" " /></div>');
		jQuery.ajax({
			type: "POST",
			url: "index_ajax.php",
			data: "idArticle="+jQuery(".scroller > ul").children("li:first").children("a").attr('id'),
			success: function(msg){
				jQuery("#conteneur").html(msg);
			}
		});
		
				
		if(jQuery(".scroller > ul").children("li").length >= 5) {
			
			// Vers le haut 
			
			jQuery("#fleche_bas").click(function() {
				if(jQuery(this).hasClass("roller_bottom"))
					clearTimeout(anim);
				animateVersLeHaut();
			});
			
			// Vers le bas 
			
			jQuery("#fleche_haut").click(function(){
				if(jQuery(this).hasClass("roller_top"))
					clearTimeout(anim);
				animateVersLeBas();
			});

		}
		
		// Récupération du contenu
		jQuery(".scroller > ul").children("li").children("a").click(function(){
			clic = 1;
			if(!jQuery(this).hasClass("active")) {
				jQuery(".scroller > ul").children("li").children("a").removeClass("active");
				jQuery(this).addClass("active");
				getContentAjax(jQuery(this));
				clearTimeout(anim);
				indexEl = jQuery(".scroller > ul").children("li").children("a").index(jQuery(this)) + 1;
				if(video == 0 && clic == 0)
					anim = setTimeout("animateIndexArticle()", 15000);
			}
		});
		
	}

		jQuery("#anim_art_conteneur").hover(function(){
			clearTimeout(anim);											 
		}, function(){
			if(video == 0)
				anim = setTimeout("animateIndexArticle()", 15000);
		});
		/**************************************************/		
		jQuery('.faq > dd').click(function() {
		var elem = jQuery(this).next();
		if (elem.is(':hidden')) {
			jQuery('span.link_moin_plus').text("-");
			jQueryt(this).next().show();
			
			}
		else {
			jQuery('span.link_moin_plus').text("+");
				jQueryt(this).next().hide();
			}
		});						
		/*****************************************/							
		jQuery('.num_important > dt:first').next().show();
		jQuery('.num_important > dt:first').parent().addClass("num_important_active");

		jQuery('.num_important > dt').click(function() {
		var elem = jQuery(this).next();
		if (elem.is(':hidden')) {
			jQuery(this).next().show();
			jQuery(this).parent().removeClass("num_important");
			jQuery(this).parent().addClass("num_important_active");
			
			}
		else {
			jQuery(this).next().hide();
			jQuery(this).parent().removeClass("num_important_active");
			jQuery(this).parent().addClass("num_important");
			
			}
		});		
		/*****************************************/		
		
		jQuery('#header_motcle').focus(function(){
			if(this.value=='إبحث في نشرية اليوم'){
				this.value = '';	
			}
		});
		
		jQuery('#header_motcle').blur(function(){
			if(this.value==''){
				this.value = 'إبحث في نشرية اليوم';	
			}
		});
		
		jQuery('#motcle_rec_av2').focus(function(){
			if(this.value=='الكلمات المفاتيح'){
				this.value = '';	
			}
		});
		
		jQuery('#motcle_rec_av2').blur(function(){
			if(this.value==''){
				this.value = 'الكلمات المفاتيح';	
			}
		});
		
		jQuery('#motcle_rec_av').focus(function(){
			if(this.value=='الكلمات المفاتيح'){
				this.value = '';	
			}
		});
		
		jQuery('#motcle_rec_av').blur(function(){
			if(this.value==''){
				this.value = 'الكلمات المفاتيح';	
			}
		});
		
		
		/**************** Début Paginattion contenu article ********************/
		jQuery(".anim_content:not(:first)").hide();
		jQuery("#prevpageart").hide();
		
		jQuery("#nextpageart").click(function(){
			nextPageContent();
		});
		
		jQuery("#prevpageart").click(function(){
			previousPageContent();
		});
		
		/**************** Fin Paginattion contenu article ********************/
		
		
		/**************** Debut Sondage Accueil ******************************/
			var x = jQuery("#sndg_index");
			jQuery.ajax({
				type: "POST",
				url: "ajaxSondage.php",
				data: "cd_mn="+x.attr('title'),
				success: function(msg){
					x.html(msg);
				}
			});
		
		/**************** Fin Sondage Accueil ********************************/
		
		
});


function nextPageContent() {
	jQuery(".anim_content:not(:hidden)").fadeOut();
	jQuery(".anim_content:not(:hidden)").next().fadeIn("normal",function(){
   			if(parseInt(jQuery(".anim_content").index(jQuery(".anim_content:not(:hidden)"))) == (parseInt(jQuery(".anim_content").length) - 1))
				jQuery("#nextpageart").hide();
			jQuery("#prevpageart").show();
	});
}

function previousPageContent() {
	jQuery(".anim_content:not(:hidden)").fadeOut();
	jQuery(".anim_content:not(:hidden)").prev().fadeIn("normal",function(){
   			if(parseInt(jQuery(".anim_content").index(jQuery(".anim_content:not(:hidden)"))) == 0)
				jQuery("#prevpageart").hide();
			jQuery("#nextpageart").show();
	});
}


function animateVersLeHaut() {
	if(parseInt(jQuery(".scroller > ul").css("marginTop")) > -((parseInt(jQuery(".scroller > ul").children("li").length)-5)*81)) {
		jQuery(".scroller > ul").stop().animate({"marginTop": "-=81px"}, 500, 
													function(){
														  jQuery("#fleche_haut").removeClass("roller_top_desactive").addClass("roller_top");
														  if(parseInt(jQuery(".scroller > ul").css("marginTop")) <= -((parseInt(jQuery(".scroller > ul").children("li").length)-5)*81)) {
																jQuery(".scroller > ul").css("marginTop", -((parseInt(jQuery(".scroller > ul").children("li").length)-5)*81));
																jQuery("#fleche_bas").addClass("roller_bottom_desactive").removeClass("roller_bottom");
														  }
													});
	} else {
		jQuery(".scroller > ul").css("marginTop", -((parseInt(jQuery(".scroller > ul").children("li").length)-5)*81));
		jQuery("#fleche_bas").addClass("roller_bottom_desactive").removeClass("roller_bottom");
	}
}

function animateVersLeBas() {
	if(parseInt(jQuery(".scroller > ul").css("marginTop")) < 0) {
		jQuery(".scroller > ul").stop().animate(
													{"marginTop": "+=81px"}, 
													500, 
													function(){
														  jQuery("#fleche_bas").removeClass("roller_bottom_desactive").addClass("roller_bottom");
														  if(parseInt(jQuery(".scroller > ul").css("marginTop")) >= 0) {
																jQuery(".scroller > ul").css("marginTop", 0);
																jQuery("#fleche_haut").addClass("roller_top_desactive").removeClass("roller_top");
														  }
													}
												);
	} else {
		jQuery(".scroller > ul").css("marginTop", 0);
		jQuery("#fleche_haut").addClass("roller_top_desactive").removeClass("roller_top");
	}	
}

function animateVersLeDebut() {
	jQuery(".scroller > ul").stop().animate(
											{"marginTop": "0"}, 
											1000, 
											function(){
												  jQuery("#fleche_bas").removeClass("roller_bottom_desactive").addClass("roller_bottom");
												  if(parseInt(jQuery(".scroller > ul").css("marginTop")) >= 0) {
														jQuery(".scroller > ul").css("marginTop", 0);
														jQuery("#fleche_haut").addClass("roller_top_desactive").removeClass("roller_top");
												  }
											}
										);
}

function getContentAjax(x){
	jQuery("#conteneur").prepend('<div class="tabs_bloc_load"><img src="static/ar/image/gif/px.gif" alt=" " /></div>');
	jQuery.ajax({
		type: "POST",
		url: "index_ajax.php",
		data: "idArticle="+x.attr('id'),
		success: function(msg){
			jQuery("#conteneur").html(msg);


			jQuery("#img_art_vid").click(function(){
				video = 1;
				clearTimeout(anim);
				var elem = jQuery(this);
				var x = jQuery(this).parents('div').attr('id');
				//jQuery(this).parent().html('<img src="image/gif/loading.gif" alt=" " />');
				jQuery.ajax({
					type: "POST",
					url: "ajaxVideoArticle.php",
					data: "idArticle="+x,
					success: function(msg){
						jQuery("#"+x).html(msg);
					}
				});
				
			});


			clearTimeout(anim);
			if(clic == 0)
				anim = setTimeout("animateIndexArticle()", 15000);
		}
	});	
}


function animateIndexArticle() {
	if(indexEl == 0)
		animateVersLeDebut();
	var elems = jQuery(".scroller > ul").children("li").children("a");
	jQuery.each(elems, function(i){
		if(elems.length > 5 && indexEl >= 5)
			animateVersLeHaut();
		if(i == indexEl) {
			elems.removeClass("active");
			jQuery(this).addClass("active");
			getContentAjax(jQuery(this));
		}
	});
	indexEl++;
	if(indexEl == elems.length)
		indexEl = 0;	
	anim = setTimeout("animateIndexArticle()", 15000);
}

function Animation(i) {
	var nbr_elems 	= jQuery('._meteo_anim').length;
	elem_aff = jQuery("._meteo_anim:visible");
	elem_aff.fadeOut('normal', function(){
		if(i<nbr_elems-1){
			elem_aff.next('._meteo_anim').fadeIn();
			i++;
		}else{
			i = 0;
			jQuery("._meteo_anim").first().fadeIn();
		}
		setTimeout('Animation('+i+')', 5000);
	});
}

// Calendrier
if (window.addEvent) {
	window.addEvent('domready', function() { 
		new vlaCalendar('exampleV', { startMonday: true });
	});	
}

// Autres Fonctions
function alerte(obj) {
	if (typeof obj == 'object') {
		var foo = '';
		for (var i in obj) {
			if (obj.hasOwnProperty(i)) {
				foo += '[' + i + '] => ' + obj[i] + '\n';
			}
		}
		alert(foo);
	}
	else {
		alert(obj);
	}
}

function validDate(strDate){
	var validformat = /^\d{4}(\-|\/|\.)\d{1,2}(\-|\/|\.)\d{1,2}$/
	
	var returnval=false
	if(!validformat.test(strDate)){
		return false;
	}else{
		var monthfield=strDate.split("/")[1]
		var dayfield=strDate.split("/")[2]
		var yearfield=strDate.split("/")[0]
		var dayobj = new Date(yearfield, monthfield-1, dayfield)
		if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield)){
			return false;
		}else{
			return true;
		}
	}
}

// Calendar YUI
YAHOO.util.Event.onDOMReady(function(){

	var Event = YAHOO.util.Event,
		Dom = YAHOO.util.Dom,
		dialogMax,dialogMin,
		calendarMax,calendarMin;

	var showCalMax = Dom.get("showCalMax");

	Event.on(showCalMax, "click", function() {
		if(!validDate(Dom.get("rec_av_date_search_max").value)){
				Dom.get("rec_av_date_search_max").value = '';
		}
		if(document.getElementById('ContainerCalendarSeachMax').style.display==''){
			document.getElementById('ContainerCalendarSeachMax').style.display='none';
		}else{
		// Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
		if (!dialogMax) {

			// Hide Calendar if we click anywhere in the document other than the calendar

			function resetHandler() {
				// Reset the current calendar page to the select date, or 
				// to today if nothing is selected.
				var selDates = calendarMax.getSelectedDates();
				var resetDate;
	
				if (selDates.length > 0) {
					resetDate = selDates[0];
				} else {
					resetDate = calendarMax.today;
				}
	
				calendarMax.cfg.setProperty("pagedate", resetDate);
				calendarMax.render();
			}
	
			function closeHandler() {
				dialogMax.hide();
				document.getElementById('ContainerCalendarSeachMax').style.display='none';			
			}

			dialogMax = new YAHOO.widget.Dialog("containerMax", {
				visible:false,
				context:["show", "tl", "bl"],
				draggable:false,
				close:false
			});
			dialogMax.render(document.getElementById('calendarSeachMax'));

			dialogMax.showEvent.subscribe(function() {
				if (YAHOO.env.ua.ie) {
					// Since we're hiding the table using yui-overlay-hidden, we 
					// want to let the dialogMax know that the content size has changed, when
					// shown
					dialogMax.fireEvent("changeContent");
				}
			});
		}

		// Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
		if (!calendarMax) {

			calendarMax = new YAHOO.widget.Calendar("calendarSeachMax", {
				iframe:false,          // Turn iframe off, since container has iframe support.
				hide_blank_weeks:true  // Enable, to demonstrate how we handle changing height, using changeContent
			});
			calendarMax.render();

			calendarMax.selectEvent.subscribe(function() {

				if (calendarMax.getSelectedDates().length > 0) {

					var selDate = calendarMax.getSelectedDates()[0];

					var dStr = selDate.getDate();
					var mStr = selDate.getMonth() + 1;
					var yStr = selDate.getFullYear();
	
					Dom.get("rec_av_date_search_max").value = yStr + "/" + mStr + "/" + dStr;
				} else {
					Dom.get("rec_av_date_search_max").value = "";
				}
				dialogMax.hide();
				document.getElementById('ContainerCalendarSeachMax').style.display='none';
			});

			calendarMax.renderEvent.subscribe(function() {
				// Tell Dialog it's contents have changed, which allows 
				// container to redraw the underlay (for IE6/Safari2)
				dialogMax.fireEvent("changeContent");
			});
		}

		var seldate = calendarMax.getSelectedDates();

		if (seldate.length > 0) {
			// Set the pagedate to show the selected date if it exists
			calendarMax.cfg.setProperty("pagedate", seldate[0]);
			calendarMax.render();
		}else{
			var d = Dom.get("rec_av_date_search_max").value;
			if((d!='')&&(d!='-/--/--')){
				var tb = d.split('/');
				var strd = tb[1]+'/'+tb[2]+'/'+tb[0];
				calendarMax.select(strd);
				calendarMax.render();
			}
		}

		document.getElementById('ContainerCalendarSeachMax').style.display='';
		dialogMax.show();
		}
	});
	
	var showCalMin = Dom.get("showCalMin");

	Event.on(showCalMin, "click", function() {		
		if(!validDate(Dom.get("rec_av_date_search_min").value)){
				Dom.get("rec_av_date_search_min").value = '';
		}
		if(document.getElementById('ContainerCalendarSeachMin').style.display==''){
			document.getElementById('ContainerCalendarSeachMin').style.display='none';
		}else{
		// Lazy Dialog Creation - Wait to create the Dialog, and setup document click listeners, until the first time the button is clicked.
		if (!dialogMin) {


			function resetHandler() {
				// Reset the current calendar page to the select date, or 
				// to today if nothing is selected.
				var selDates = calendarMin.getSelectedDates();
				var resetDate;
	
				if (selDates.length > 0) {
					resetDate = selDates[0];
				} else {
					resetDate = calendarMin.today;
				}
	
				calendarMin.cfg.setProperty("pagedate", resetDate);
				calendarMin.render();
			}
	
			function closeHandler() {
				dialogMin.hide();
				document.getElementById('ContainerCalendarSeachMin').style.display='none';			
			}

			dialogMin = new YAHOO.widget.Dialog("containerMin", {
				visible:false,
				context:["show", "tl", "bl"],
				draggable:false,
				close:false
			});
			dialogMin.render(document.getElementById('calendarSeachMin'));

			dialogMin.showEvent.subscribe(function() {
				if (YAHOO.env.ua.ie) {
					// Since we're hiding the table using yui-overlay-hidden, we 
					// want to let the dialogMin know that the content size has changed, when
					// shown
					dialogMin.fireEvent("changeContent");
				}
			});
		}

		// Lazy Calendar Creation - Wait to create the Calendar until the first time the button is clicked.
		if (!calendarMin) {

			calendarMin = new YAHOO.widget.Calendar("calendarSeachMin", {
				iframe:false,          // Turn iframe off, since container has iframe support.
				hide_blank_weeks:true  // Enable, to demonstrate how we handle changing height, using changeContent
			});
			calendarMin.render();

			calendarMin.selectEvent.subscribe(function() {
				if (calendarMin.getSelectedDates().length > 0) {

					var selDate = calendarMin.getSelectedDates()[0];

					var dStr = selDate.getDate();
					var mStr = selDate.getMonth() + 1;
					var yStr = selDate.getFullYear();
					Dom.get("rec_av_date_search_min").value = yStr + "/" + mStr + "/" + dStr;	
				} else {
					Dom.get("rec_av_date_search_min").value = "";
				}
				dialogMin.hide();
				document.getElementById('ContainerCalendarSeachMin').style.display='none';
			});

			calendarMin.renderEvent.subscribe(function() {
				// Tell Dialog it's contents have changed, which allows 
				// container to redraw the underlay (for IE6/Safari2)
				dialogMin.fireEvent("changeContent");
			});
		}

		var seldate = calendarMin.getSelectedDates();

		if (seldate.length > 0) {
			// Set the pagedate to show the selected date if it exists
			if(seldate[0]!='Invalid Date'){
				calendarMin.cfg.setProperty("pagedate", seldate[0]);
			}else{
				Dom.get("rec_av_date_search_min").value = '';	
			}
			calendarMin.render();
		}else{
			var d = Dom.get("rec_av_date_search_min").value;
			if((d!='')&&(d!='-/--/--')){
				var tb = d.split('/');
				var strd = tb[1]+'/'+tb[2]+'/'+tb[0];
				calendarMin.select(strd);
				calendarMin.render();
			}
		}

		document.getElementById('ContainerCalendarSeachMin').style.display='';
		dialogMin.show();
		}
	});
});


function getClavierArabe(where){
	window.open ('static/clavier_arabe/clavier_arabe.php?where='+where, 'clavier_popup', config='height=300, width=780, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
}

function AnimateGalPhotoPasse() {
	var nbr = jQuery("#gallery_histoire > div").children().length;
	if(parseInt(jQuery("#gallery_histoire").children(":first").css("margin-left")) > ((nbr-1) * (-238))) {
		jQuery("#gallery_histoire").children(":first").animate({ marginLeft: (parseInt(jQuery("#gallery_histoire").children(":first").css("margin-left")) - 238 )+"px"}, 1500 );	
	} else {
		jQuery("#gallery_histoire").children(":first").animate({ marginLeft: "0px"}, 1500 );
	}
	setTimeout("AnimateGalPhotoPasse()", 20000);
}

function AnimateGalPhotoEvent() {
	var nbrPht = jQuery("#gallery_event").children().length;
	
	var nbr_elems 	= jQuery('#gallery_event').length;
	elem_aff = jQuery("#gallery_event").children(":visible");
	elem_aff.fadeOut('normal', function(){
		if(cpt<nbrPht-1){
			elem_aff.next().fadeIn();
			cpt++;
		}else{
			cpt = 0;
			jQuery("#gallery_event").children(":first").fadeIn();
		}
		setTimeout('AnimateGalPhotoEvent()', 18000);
	});
}
