/* ACTUALITES */
function actualites_item_on (number)
{
	$("div.actualites_item:nth-child("+number+") div.actualites_container").stop();
	$("div.actualites_item:nth-child("+number+") div.actualites_container").animate({bottom:"0px"},500);
}
function actualites_item_off (number)
{
	$("div.actualites_item:nth-child("+number+") div.actualites_container").stop();
	$("div.actualites_item:nth-child("+number+") div.actualites_container").animate({bottom:"-40px"},500);
}

/* VIE */
function vie_menu_on (number)
{
	if (vie_current != number)
	{
		$("div.vie_menu:nth-child("+number+") div.vie_menu_background").stop();
		$("div.vie_menu:nth-child("+number+") div.vie_menu_background").animate({opacity:"0.75"},500);
	}
}
function vie_menu_off (number)
{
	if (vie_current != number)
	{
		$("div.vie_menu:nth-child("+number+") div.vie_menu_background").stop();
		$("div.vie_menu:nth-child("+number+") div.vie_menu_background").animate({opacity:"0.5"},500);
	}
}
function vie_menu_click (number)
{
	if (vie_current != number)
	{
		$("div.vie_menu:nth-child("+vie_current+") div.vie_menu_background").stop();
		$("div.vie_menu:nth-child("+vie_current+") div.vie_menu_background").animate({opacity:"0.5"},500);
		vie_current = number;
		$("div.vie_menu:nth-child("+vie_current+") div.vie_menu_background").stop();
		$("div.vie_menu:nth-child("+vie_current+") div.vie_menu_background").animate({opacity:"0.75"},500);
		
		$("div#vie_container").stop();
		$("div#vie_container").animate({opacity:"0"},500,function()
		{		
			location.hash = "m="+menu_current+"&t=v&p="+vie_current;
			
			$("div#vie_container").css("left",(vie_current-1)*(-100)+"%");
			$("div#vie_container").animate({opacity:"1"},500);
		});
	}
}
function vie_saints_on (number)
{
	$("div.vie_saints:nth-child("+number+") div.vie_saints_container").stop();
	$("div.vie_saints:nth-child("+number+") div.vie_saints_container").animate({opacity:"1"},500);
}
function vie_saints_off (number)
{
	$("div.vie_saints:nth-child("+number+") div.vie_saints_container").stop();
	$("div.vie_saints:nth-child("+number+") div.vie_saints_container").animate({opacity:"0"},500);
}

/* PREDICATIONS */
function predications_annee_on (number)
{
	if (annee_current != number)
	{
		$("div#predications_menu_item_"+number+" div.predications_menu_item_background").stop();
		$("div#predications_menu_item_"+number+" div.predications_menu_item_background").animate({opacity:"0.75"},500);
	}
}
function predications_annee_off (number)
{
	if (annee_current != number)
	{
		$("div#predications_menu_item_"+number+" div.predications_menu_item_background").stop();
		$("div#predications_menu_item_"+number+" div.predications_menu_item_background").animate({opacity:"0.5"},500);
	}
}
function predications_annee_click (number)
{
	if (annee_current != number)
	{
		$("div#predications_menu_item_"+annee_current+" div.predications_menu_item_background").stop();
		$("div#predications_menu_item_"+annee_current+" div.predications_menu_item_background").animate({opacity:"0.5"},500);
		$("div#predications_menu_item_"+annee_current+" div.predications_menu_item_content").css("color","#FFFFFF");
		annee_current = number;
		
		$("div#predications_container").stop();
		$("div#predications_container").animate({opacity:"0"},500);
		
		$("div#predications_list").stop();
		$("div#predications_list").animate({opacity:"0"},500,function()
		{
			$("div#predications_list_content").css("opacity","0");
			$("div#predications_list_content").html("");
			
			$("div#predications_list").animate({opacity:"1"},500,function()
			{
				$("div#page").css("cursor","progress");
				$("div#predications_list_content").load("pages/html/predications_"+number+".html",function()
				{
					if (status == "error")
					{
						// Si le chargement ne s'est pas déroulé correctement, indiquer l'erreur
						$("div#predications_list_content").load("pages/html/erreur_annees.html");
						
						annee_current = "";
						predications_current_number = 0;
						predications_current_page = "";
						
						// Changer l'url de la page
						location.hash = "m="+menu_current;
					}
					else
					{
						annee_current = number;
						predications_current_number = 0;
						predications_current_page = "";
						
						// Changer l'url de la page
						location.hash = "m="+menu_current+"&t=p&a="+annee_current;
						
						$("div#predications_menu_item_"+annee_current+" div.predications_menu_item_background").stop();
						$("div#predications_menu_item_"+annee_current+" div.predications_menu_item_background").animate({opacity:"0.75"},500);
						$("div#predications_menu_item_"+annee_current+" div.predications_menu_item_content").css("color","#EE0000");
					}
					
					$("div#page").css("cursor","auto");
					
					if (version_IE != "IE7" && version_IE != "IE6")
					{
						$("div#predications_list_text").jScrollPane({showArrows: true, autoReinitialise: true});
					}
					
					$("div#predications_list_content").animate({opacity:"1"},500);
				});
			});
		});
	}
}
function predications_item_click (number, page)
{
	if (predications_current_number != number)
	{
		$("div#predications_container").stop();
		$("div#predications_container_content").stop();
		
		$("div#predications_container").animate({opacity:"0"},500,function()
		{
			$("div#predications_container_content").css("opacity","0");
			$("div#predications_container_content").html("");
			
			$("div#predications_container").animate({opacity:"1"},500,function()
			{
				$("div#page").css("cursor","progress");
				
				$("div#predications_container_content").load("pages/html/predications/"+annee_current+"/"+page+".html",function(response, status, xhr)
				{
					$("div.predications_list_item:nth-child("+predications_current_number+")").css("color","#FFFFFF");
					
					if (status == "error")
					{
						// Si le chargement ne s'est pas déroulé correctement, indiquer l'erreur
						$("div#predications_container_content").load("pages/html/erreur_predications.html");
						
						predications_current_number = 0;
						predications_current_page = page;
						
						// Changer l'url de la page
						location.hash = "m="+menu_current+"&t=p&a="+annee_current;
					}
					else
					{
						predications_current_number = number;
						predications_current_page = page;
						$("div.predications_list_item:nth-child("+predications_current_number+")").css("color","#EE0000");
						
						// Changer l'url de la page
						location.hash = "m="+menu_current+"&t=p&a="+annee_current+"&p="+predications_current_page+"&n="+predications_current_number;
					}
					
					$("div#page").css("cursor","auto");
					
					if (version_IE != "IE7" && version_IE != "IE6")
					{
						$("div#predications_container_text").jScrollPane({showArrows: true, autoReinitialise: true});
					}
					
					$("div#predications_container_content").animate({opacity:"1"},500);
				});
			});
		});
	}
}

/* PAROISSE */
function paroisse_item_on (number)
{
	$("div.paroisse_item:nth-child("+number+") div.paroisse_item_background").stop();
	$("div.paroisse_item:nth-child("+number+") div.paroisse_item_background").animate({opacity:"1"},500);
}
function paroisse_item_off (number)
{
	$("div.paroisse_item:nth-child("+number+") div.paroisse_item_background").stop();
	$("div.paroisse_item:nth-child("+number+") div.paroisse_item_background").animate({opacity:"0.75"},500);
}

/* PHOTOS */
function photos_arrow_click (direction, maximum, width)
{
	var left_current = $("div#paroisse_photos_content").position().left;
	
	$("div#paroisse_photos_container").stop();
	$("div#paroisse_photos_content").stop();
	
	$("div#paroisse_photos_container").animate({opacity:"0"},500,function()
	{
		if (direction == "left")
		{
			if (left_current < 0) 	$("div#paroisse_photos_content").css("left",(left_current+width)+"px");
			else					$("div#paroisse_photos_content").css("left",(maximum-1)*(-width)+"px");
		}
		else
		{
			if (left_current > (maximum-1)*(-width)) 	$("div#paroisse_photos_content").css("left",(left_current-width)+"px");
			else										$("div#paroisse_photos_content").css("left","0px");
		}
		
		$("div#paroisse_photos_container").animate({opacity:"1"},500);
	});
}
