
//window.onload = startAnimation;
var toLoad;

$(window).resize(function () { reposObjects(); });

$(document).ready(function() {  
     
	 reposObjects();
	 
	 //if(showAnimation == true)
	 //{
		 // Modification des liens du menu
		 $('a').click(function() {
		 
			if(($(this).attr('target') != '_blank') && ($(this).attr('class') != 'thickbox'))
			{
				// Affichage du gif de chargement
				$('#loadingGif').show();
				
				// Récupération de la cible du lien
				toLoad = $(this).attr('href')+' #content'; 
				
				// Effacement du contenu
				$('#contentContainer').fadeOut(500, loadContent);
				
				return false;
			}
		 });
		 
		 // Démarrage de l'animation de l'image de fond
		 $('#contentContainer').hide();
		 showContent(); 
	//}
 });

function openFromFlash(page)
{

	$('#loadingGif').show();
				
	// Récupération de la cible du lien
	toLoad = page+' #content'; 
	
	// Effacement du contenu
	$('#contentContainer').fadeOut(500, loadContent);
}

function startAnimation()
// Initialisation et lancement de l'animation
{
	// Effacement des éléments
	$('#backgroundImg').hide();
	
	
	// Lancement de l'animation
	$('#backgroundImg').fadeIn(1000, showContent);

}

function loadContent()
{
	$('#contentContainer').load(toLoad,'',showContent);
}

function showContent()
{
	
	// Définition du titre de la page
	var winTitle = document.getElementById('pageTitle');
	//alert(winTitle );
	document.title = winTitle.innerHTML;


	$('#contentContainer a').click(function() {
		 
		 if(($(this).attr('target') != '_blank') && ($(this).attr('class') != 'thickbox'))
		{
		// Affichage du gif de chargement
			$('#loadingGif').show();
			
			// Récupération de la cible du lien
			toLoad = $(this).attr('href')+' #content'; 
			
			// Effacement du contenu
			$('#contentContainer').fadeOut(500, loadContent);
			
			return false;
		}
	 });
	 
	$('#contentContainer').fadeIn(500, function() {
		
		// Effacement du logo de chargement
		$('#loadingGif').fadeOut('slow');
	});
}

function reposObjects() 
{
	menu = document.getElementById("mainMenu");
	contentDiv = document.getElementById("contentContainer");
	pageLoader = document.getElementById("pageLoader");
	browserWidth = document.documentElement.clientWidth, browserHeight = document.documentElement.clientHeight;
	
	menu.style.top = "0px";
	menu.style.left = "0px";
	menu.style.width = (browserWidth / 2 - 10) + "px";
	menu.style.height = browserHeight + "px";

	contentDiv.style.top = "0px";
	contentDiv.style.left = (browserWidth/2)+"px";
}

function setObjectPos(objId, x, y)
{
	var obj = document.getElementById(objId);
	obj.style.top = y + "px";
	obj.style.marginLeft = "0px";
	obj.style.marginTop = "0px";
}

