var scr_width;			// Taille x de l'écran
var scr_height;			// Taille y de l'écran
var web_width;			// Taille x de la page
var web_height;			// Taille y de la page

var left_map = 34;		// Position x de la map
var bottom_map;			// Position de la barre du bas
var right_map;			// Position de la barre de droite
var height_zone;		// Taille de la zone menu de gauche

var map_x = 0;			// Position X de la map
var map_y = 0;			// Position Y de la map
var map_width = 0;		// Taille X du contenu de la map
var map_height = 0;		// Taille Y du contenu de la map

var map_zone_x;			// Position X du conteneur de map
var map_zone_y;			// Position Y du conteneur de map
var map_zone_width;		// Taille Width du conteneur de map
var map_zone_height;	// Taille Height du conteneur de map

var update_map_time = 50;	// On update le contenu de la map toutes les ... millisecondes

var move_x = 0;			// Valeur de déplacement de la map en up
var move_y = 0;			// Valeur de déplacement de la map en left

var leftState = 0;		// Etat de la barre du menu de gauche

var fixPage = true;
var pubPage = true;

var serverHour = 0;		// Heure du serveur
var serverMin = 0;		// Minutes du serveur
var serverSec = 0;		// Secondes du serveur
var twoPointsHour = false;	// Clignotement de l'heure

var pageXHR = null;

var toUpdateObjects = new Array();

var connect_popup_open = true;
var subscribe_popup_open = false;
var help_popup_open = false;

var currentStyle = 0;

var nbreFreeKDor = 0;
var nbreKDor = 0;

var inMoving = false;
var blocMoveY = false;
var blocMoveX = false;

var isOnLink = false;

var moveCB = new Array();

var myId = 0;
var myEmail = "";

var ie = (navigator.appName == 'Microsoft Internet Explorer') ? true:false;

function closeAccueil()
{
	removeAllNodes( document.getElementById('accueil_flash'), true );
}

function refreshPage()
{
	changeCurrentPage(openedFile);
}

function deconnexion()
{
	var tempXHR = initXHR();
	ajaxRequest( "././php/deconnexion.php", tempXHR, deconnexionDone, "" );
}

function deconnexionDone(result)
{
	if( trackSqlError( result ) )
	{
		nbreFreeKDor = 0;
		nbreKDor = 0;
		myId = 0;
		myEmail = "";
		rang = 0;
		
		setConnexion(false);
		document.getElementById('deconnexion_button').style.display = "none";
		loadTopBar();
		clearMenu();
		document.getElementById('favory_disconnected').style.display = "block";
		document.getElementById('right_infos').style.top = "60px";
	
		changeCurrentPage(openedFile);
	}
}

function openReglement()
{
	window.open("reglement.pdf");
}

function changeStyle()
{
	document.getElementById("map_map").style.display = "none";
	if( currentStyle == 0 )
	{
		currentStyle = 1;
		document.getElementById("custom_css").href = "data/styles/style2.css";
	}
	else
	{
		currentStyle = 0;
		document.getElementById("custom_css").href = "data/styles/style1.css";
	}
	setTimeout(function() { document.getElementById("map_map").style.display = "block"; },100);
}

function bodyMouseUp(event)
{
	stopScrollMenu();
	inMoving = false;
	move_y = 0;
	move_x = 0;
}

function bodyMouseDown(event)
{
	if( !isOnLink )
		inMoving = true;
}

function setMovePointer()
{
	if( !fixPage )
		document.getElementById("my_body").style.cursor = "move";
}

function resetMousePointer()
{
	document.getElementById("my_body").style.cursor = "default";
}

function bodyMove(event)
{
	setBodyMouse(event);
	if( document.getElementById("my_body").style.cursor != "pointer" )
	{
		if( bodyMouseX < 54 && bodyMouseX > 54 + map_zone_width && bodyMouseY < 106 && bodyMouseY > 106 + map_zone_height )
			document.getElementById("my_body").style.cursor = "default";
	}
	if( menuIsInScroll )
		scrollMenu();
	if( inMoving && !isOnLink )
	{
		if( !blocMoveX )
			move_x = bodyMouseX - prevBodyMouseX;
		else
			move_x = 0;
		if( !blocMoveY )
			move_y = bodyMouseY - prevBodyMouseY;
		else
			move_y = 0;
		updateMapContained();
	}
}

function goToIndex()
{
	changeCurrentPage("./data/xml/index.xml");
}

function flashGoToPage(page)
{
	changeCurrentPage(page);
}

function openForumFromHelp()
{
	window.open( "http://www.hookdo.com/forum/index.php" ); 
	closeHelpPopup();
}

function openBlogFromHelp()
{
	window.open( "http://hook-blog.blogspot.com/" ); 
	closeHelpPopup();
}

function openContactFromHelp()
{
	document.getElementById('common_popup_help_contained').style.display = "none";
	document.getElementById('common_popup_contact_contained').style.display = "block";
	document.getElementById('common_popup_txt').firstChild.nodeValue = "Contact : contact@hookdo.com";	// Change popup title
	
	if( myEmail != "" )
		document.getElementById('contact_email_input').value = myEmail;
	else
		document.getElementById('contact_email_input').value = "";
	document.getElementById('contact_sujet_input').value = "";
	document.getElementById('contact_message_input').value = "";
}

function contactSend()
{
	var email = document.getElementById('contact_email_input').value;
	var sujet = document.getElementById('contact_sujet_input').value;
	var message = document.getElementById('contact_message_input').value;
	
	// Check
	if( !isCorrectEmail(email) )
		alert("Email invalide !");
	else if( sujet == "" )
		alert("Merci de remplir le sujet !");
	else if( message == "" )
		alert("Merci de remplir le message !");
	else
	{
		var tempXHR = initXHR();
		ajaxRequest( "././php/sendContact.php", tempXHR, sendContactDone, "email=" + email + "&sujet=" + sujet + "&message=" + message );
	}
}

function sendContactDone(result)
{
	if( result == "0" )
		alert("Envoi échoué ! Paramètres incorrects !");
	else
		alert("Votre message a été envoyé... Vous aurez une réponse au plus vite !");
}

function openConnexionPopup()
{
	if( subscribe_popup_open )
		closeSubscribePopup();
	if( help_popup_open )
		closeHelpPopup();
	connect_popup_open = true;
	subscribe_popup_open = false;
	help_popup_open = false;
	drawMapContained();
	document.getElementById('common_popup').style.display = "block";
	document.getElementById('common_popup_txt').firstChild.nodeValue = "Connexion";	// Change popup title
	document.getElementById('common_popup_close').onclick = closeConnexionPopup;
	document.getElementById('common_popup_connexion_contained').style.display = "block";
}

function closeConnexionPopup()
{
	connect_popup_open = false;
	document.getElementById('common_popup_connexion_contained').style.display = "none";
	document.getElementById('common_popup').style.display = "none";
}

function openSubscribePopup()
{
	if( connect_popup_open )
		closeConnexionPopup();
	if( help_popup_open )
		closeHelpPopup();
	subscribe_popup_open = true;
	connect_popup_open = false;
	help_popup_open = false;
	drawMapContained();
	document.getElementById('common_popup').style.display = "block";
	document.getElementById('common_popup_txt').firstChild.nodeValue = "Inscription";	// Change popup title
	document.getElementById('common_popup_close').onclick = closeSubscribePopup;
	document.getElementById('common_popup_subscribe_contained').style.display = "block";
}

function closeSubscribePopup()
{
	subscribe_popup_open = false;
	document.getElementById('common_popup_subscribe_contained').style.display = "none";
	document.getElementById('common_popup').style.display = "none";
}

function openHelpPopup()
{
	if( connect_popup_open )
		closeConnexionPopup();
	if( subscribe_popup_open )
		closeSubscribePopup();
	help_popup_open = true;
	subscribe_popup_open = false;
	connect_popup_open = false;
	drawMapContained();
	document.getElementById('common_popup').style.display = "block";
	document.getElementById('common_popup_txt').firstChild.nodeValue = "Aide";	// Change popup title
	document.getElementById('common_popup_close').onclick = closeHelpPopup;
	closeFAQFromHelp();
	document.getElementById('common_popup_contact_contained').style.display = "none";
	document.getElementById('common_popup_help_contained').style.display = "block";
}

function closeHelpPopup()
{
	help_popup_open = false;
	document.getElementById('common_popup_help_contained').style.display = "none";
	document.getElementById('common_popup_faq_contained').style.display = "none";
	document.getElementById('common_popup_contact_contained').style.display = "none";
	document.getElementById('common_popup').style.display = "none";
}

function setConnexion(state)
{
	if( connected != state )
	{
		connected = state;
		
		if( connected == true )
		{
			document.getElementById('top_hooky_bar').style.visibility = "visible";
			document.getElementById('top_connect_bar').style.display = "none";
			document.getElementById('top_kdor_bar').style.visibility = "visible";
			document.getElementById('top_subscribe_bar').style.display = "none";
			document.getElementById('top_kdorfree_bar').style.visibility = "visible";
			
			// On redimensionne
			var width_bar1 = parseInt((web_width - 184) * 0.338);		// Taille des barres redimensionnables
			var width_bar2 = web_width - 184 - width_bar1;			// Taille des barres redimensionnables
			
			document.getElementById('top_hooky_bar').style.left = (width_bar1 - 187) / 2 + "px";
			document.getElementById('top_kdor_bar').style.left = (width_bar2 - 365) / 4 + "px";
			document.getElementById('top_kdorfree_bar').style.left = (width_bar2 - 365) / 2 + 161 + "px";
		}
		else
		{
			document.getElementById('top_hooky_bar').style.visibility = "hidden";
			document.getElementById('top_connect_bar').style.display = "block";
			document.getElementById('top_kdor_bar').style.visibility = "hidden";
			document.getElementById('top_subscribe_bar').style.display = "block";
			document.getElementById('top_kdorfree_bar').style.visibility = "hidden";
		}
	}
}

function connexionSucced(hooky, freekdor, kdor, menu, id, email, pseudo)
{
	myId = id;
	myEmail = email;
	setConnexion(true);
	setTimeout( "tempoConnexionSucced(" + hooky + ", " + freekdor + "," + kdor + ")", 1000 );
	document.getElementById('deconnexion_button').style.display = "block";
	document.getElementById('right_infos').style.top = "100px";
	document.getElementById('favory_disconnected').style.display = "none";
	loadTopBar();
	recFillMenuPerso( menu, null, 1 );
	
	changeCurrentPage(openedFile);
	
	if( pseudo != "" )
	{
		var wipubIF = document.createElement("iframe");
		wipubIF.width = 1;
		wipubIF.height = 1;
		wipubIF.src = "http://www.wipub.com/formulaire.php?id_annonceur=3767&email=" + id + ";" + email + ";" + pseudo;
		wipubIF.scrolling = "no";
		wipubIF.hspace = 0;
		wipubIF.vspace = 0;
		wipubIF.frameBorder = 0;
		wipubIF.marginHeight = 0;
		wipubIF.marginWidth = 0;
		document.getElementById("my_body").appendChild(wipubIF);
	}
}

function tempoConnexionSucced(hooky, freekdor, kdor)
{
	setHooky(hooky);
	setKDor(kdor);
	setKDorFree(freekdor);
	
	nbreFreeKDor = freekdor;
	nbreKDor = kdor;
}

function updateObjects()
{
	for( var i = 0; i < toUpdateObjects.length; i++ )
	{
		var instance = toUpdateObjects[i];
		instance.updateStyle();
	}
}

function setServerHour(hour, min, sec)
{
	serverHour = hour;
	serverMin = min;
	serverSec = sec;
}

function addSec()
{
	var zeroHour = "";
	var zeroMin = "";
	
	serverSec++;
	if( serverSec > 59 )
	{
		serverSec = 0;
		serverMin++;
		if( serverMin > 59 )
		{
			serverMin = 0;
			serverHour++;
			if( serverHour > 23 )
				serverHour = 0;
		}
	}
	
	if( serverHour < 10 )
		zeroHour = "0";
		
	if( serverMin < 10 )
		zeroMin = "0";
	
	if( twoPointsHour == true )
	{
		document.getElementById('clock').firstChild.nodeValue = zeroHour + serverHour + ":" + zeroMin + serverMin;
		twoPointsHour = false;
	}
	else
	{
		document.getElementById('clock').firstChild.nodeValue = zeroHour + serverHour + " " + zeroMin + serverMin;
		twoPointsHour = true;
	}
				
	setTimeout("addSec()",1000);
}

function setHooky(nbre)
{
	window.document["top_hooky_bar_flash"].SetVariable("toSet", nbre);
}

function addHooky(nbre)
{
	window.document["top_hooky_bar_flash"].SetVariable("toAdd", nbre);
}

function delHooky(nbre)
{
	window.document["top_hooky_bar_flash"].SetVariable("toDel", nbre);
}

function setKDor(nbre)
{
	window.document["top_kdor_bar_flash"].SetVariable("toSet", nbre);
}

function addKDor(nbre)
{
	nbreKDor += nbre;
	window.document["top_kdor_bar_flash"].SetVariable("toAdd", nbre);
}

function delKDor(nbre)
{
	window.document["top_kdor_bar_flash"].SetVariable("toDel", nbre);
}

function setKDorFree(nbre)
{
	window.document["top_kdorfree_bar_flash"].SetVariable("toSet", nbre);
}

function addKDorFree(nbre)
{
	window.document["top_kdorfree_bar_flash"].SetVariable("toAdd", nbre);
}

function delKDorFree(nbre)
{
	window.document["top_kdorfree_bar_flash"].SetVariable("toDel", nbre);
}

function delGlobalKDor(nbre)
{
	var rest = nbre;
	if( nbreFreeKDor >= nbre )
	{
		nbreFreeKDor -= nbre;
		delKDorFree(nbre);
	}
	else
	{
		delKDorFree(nbreFreeKDor);
		rest -= nbreFreeKDor;
		nbreFreeKDor = 0;
		
		if( nbreKDor >= rest )
		{
			delKDor(rest);
			nbreKDor -= rest;
		}
		else
		{
			// Problem !
			delKDor(nbreKDor);
			nbreKDor = 0;
		}
	}
}
			
function getWindowHeight()
{
	var windowHeight = 0;
    	if( typeof( window.innerHeight ) == 'number' )
    	{
        	windowHeight = window.innerHeight;
    	}
    	else
    	{
		if( document.documentElement && document.documentElement.clientHeight )
		{
			windowHeight = document.documentElement.clientHeight;
		}
		else
		{
			if( document.body && document.body.clientHeight )
			{
				windowHeight = document.body.clientHeight;
			}
     		}
    	}
   	return windowHeight;
}

function getWindowWidth()
{
	var windowWidth = 0;
	if( typeof( window.innerWidth ) == 'number' )
	{
		windowWidth = window.innerWidth;
	}
	else
	{
	if( document.documentElement && document.documentElement.clientWidth )
	{
		windowWidth = document.documentElement.clientWidth;
	}
	else
	{
		if( document.body && document.body.clientWidth )
		{
			windowWidth = document.body.clientWidth;
		}
		}
	}
   	return windowWidth;
}

function start(page)
{
	var supportedFile = "";
	for( var i = 0; i < page.length; i++ )
	{
		if( page.charAt(i) == "#" )
			supportedFile += "&";
		else
			supportedFile += page.charAt(i);
	}
	
	initDatasUpdater();
	
	createRequestObject();
	
	loadSkin();
	
	registerDataBase();
	
	pageXHR = initXHR();
	loadXMLPage( supportedFile, 0, pageXHR );
	
	initFAQ();
	
	if( connected )
	{
		document.getElementById('favory_disconnected').style.display = "none";
		document.getElementById('right_infos').style.top = "100px";
		document.getElementById('deconnexion_button').style.display = "block";
	}
	else
	{
		document.getElementById('favory_disconnected').style.display = "block";
		document.getElementById('right_infos').style.top = "60px";
		document.getElementById('deconnexion_button').style.display = "none";
	}
}
			
// Chargement de la page
function loadSkin()
{
	scr_width = getWindowWidth();
	scr_height = getWindowHeight();
	
	if( scr_width < 800 )
		web_width = 800;
	else
		web_width = scr_width;
		
	if( scr_height < 600 )
		web_height = 600;
	else
		web_height = scr_height;
		
	loadTopBar();
	loadLeftBar();
	loadMap();
	loadRightBar();
	loadBottomBar();
	
	map_y = 0;
	updateMapContained();
	drawMapContained();
}
			
// Chargement de la barre du haut
function loadTopBar()
{
	// On redimensionne
	var width_bar1;		// Taille des barres redimensionnables
	if( connected )
		width_bar1 = parseInt((web_width - 256) * 0.338);
	else
		width_bar1 = parseInt((web_width - 184) * 0.338);
	var width_bar2 = web_width - 184 - width_bar1;			// Taille des barres redimensionnables

	// Barre du haut
	document.getElementById('top_bar1_2').style.width = width_bar1 + "px";
	if( connected )
	{
		document.getElementById('top_hooky_bar').style.left = (width_bar1 - 194) / 2 + "px";
		document.getElementById('top_kdor_bar').style.left = (width_bar2 - 424) / 4 + "px";
		document.getElementById('top_kdorfree_bar').style.left = (width_bar2 - 428) / 2 + 162 + "px";
		document.getElementById('top_help_bar').style.left = (width_bar2 - 130) / 2 + 159 + ((web_width / 800) - 1 ) * 120 + "px";
	}
	else
	{
		document.getElementById('top_connect_bar').style.left = (width_bar1 - 220) / 2 + "px";
		document.getElementById('top_subscribe_bar').style.left = (width_bar2 - 260) / 4 + "px";
		document.getElementById('top_help_bar').style.left = (width_bar2 - 155) / 2 + 161 + "px";
	}
	document.getElementById('top_bar1_3').style.left = width_bar1 + 12 + "px";
	document.getElementById('top_bar1_4').style.left = width_bar1 + 172 + "px";
	document.getElementById('top_bar1_4').style.width = width_bar2 + "px";
	document.getElementById('top_bar1_5').style.left = width_bar1 + width_bar2 + 172 + "px";
}

// Chargement de la carte
function loadMap()
{
	// On redimensionne
	right_map = web_width - 160;							// Position de la barre de droite
	
	map_zone_x = 32;										// Position X du conteneur de map
	map_zone_y = 102;										// Position Y du conteneur de map
	map_zone_width = parseInt(web_width - 194);				// Taille Width du conteneur de map
	map_zone_height = parseInt(web_height - 137);			// Taille Height du conteneur de map
	
	document.getElementById('map_map').style.left = "34px";
	document.getElementById('map_map').style.top = "102px";
	document.getElementById('map_map').style.width = map_zone_width - 6 + "px";
	document.getElementById('map_map').style.height = map_zone_height - 6 + "px";
}

function switchMenu()
{
	if( leftState == 0 )
	{
		left_map += 20;
		leftState = 1;
		loadLeftBar();
		setTimeout("switchMenu()",10);
	}
	else if( leftState == 1 )
	{
		left_map += 20;
		loadLeftBar();
		if( left_map < 280 )
			setTimeout("switchMenu()",10);
		else
			leftState = 2;
	}
	else if( leftState == 2 )
	{
		left_map -= 20;
		leftState = 3;
		loadLeftBar();
		setTimeout("switchMenu()",10);
	}
	else if( leftState == 3 )
	{
		left_map -= 20;
		loadLeftBar();
		if( left_map > 36 )
			setTimeout("switchMenu()",10);
		else
			leftState = 0;
	}
}

// Chargement de la barre de gauche
function loadLeftBar()
{
	// On redimensionne
	var height_bar = parseInt((web_height - 131) / 2);		// Taille height des barres redimensionnables
	height_zone = parseInt(height_bar * 2 + 56);			// Taille height de la zone
	bottom_bar = height_zone + 40;					// Position de la barre du bas
	
	// Barre de gauche
	document.getElementById('left_bar1_2').style.width = left_map - 34 + "px";
	document.getElementById('left_bar1_2').style.height = height_zone + "px";
	document.getElementById('left_bar1_2').style.left = "8px";
	document.getElementById('left_bar1_3').style.left = left_map - 26 + "px";
	
	document.getElementById('left_bar2_1').style.height = height_zone - 8 + "px";
	document.getElementById('left_bar2_2').style.height = height_zone - 8 + "px";
	document.getElementById('left_bar2_2').style.left = left_map - 26 + "px";
	
	menuContainHeight = height_zone - 72;
	document.getElementById('favory_contained').style.height = menuContainHeight + "px";
	menuMaxScroll = height_zone - 102;
	document.getElementById('scroll_bar_line').style.height = menuMaxScroll + "px";
	document.getElementById('scroll_bar_dot2').style.top = height_zone - 83 + "px";
	
	document.getElementById('left_bar2_2_txt').style.top = (height_zone - 480) / 2 + "px";
	
	updateMenuScrollButton();
}

// Chargement de la barre de droite
function loadRightBar()
{
	// Barre de droite
	document.getElementById('right_bar1_1').style.left = right_map + "px";
	document.getElementById('right_bar1_1').style.height = height_zone + "px";
	document.getElementById('right_bar1_2').style.left = right_map + 152 + "px";
	document.getElementById('right_bar2_1').style.left = right_map + 152 + "px";
	document.getElementById('right_bar2_1').style.height = height_zone - 8 + "px";
}

// Chargement de la barre du bas
function loadBottomBar()
{
	// On redimensionne
	var width_bar = parseInt(web_width - 32);	// Taille width des barres redimensionnables
	
	// Barre du bas
	document.getElementById('bottom_bar1_1').style.top = bottom_bar + "px";
	document.getElementById('bottom_bar1_2').style.top = bottom_bar + "px";
	document.getElementById('bottom_bar1_2').style.width = width_bar + "px";
	document.getElementById('bottom_bar1_3').style.top = bottom_bar + "px";
	document.getElementById('bottom_bar1_3').style.left = width_bar + 16 + "px";
}

// Redimensionne le contenu de la map
function redimMapContained(x, y, width, height)
{
	if( (x + width) > map_width )map_width = x + width;
	if( (y + height) > map_height )map_height = y + height;
	document.getElementById('map_contained').style.width = map_width + "px";
	document.getElementById('map_contained').style.height = map_height + "px";
}	

// Affiche le contenu de la map
function drawMapContained()
{
	if( fixPage )
	{
		map_x = -(map_width / 2 - map_zone_width / 2);
		map_y = -(map_height / 2 - map_zone_height / 2);
	}
	
	if( blocMoveY )
		map_y = -(map_height / 2 - map_zone_height / 2);
	
	document.getElementById('top_bar_tools').style.width = map_zone_width + "px";
	
	var leftPub = (map_zone_width - 468) / 2 + 20;
	document.getElementById('map_pub_bar_contained').style.left = leftPub + "px";
	if( leftPub > 120 )
	{
		document.getElementById('top_bar_left_but').style.width = "120px";
		document.getElementById('top_bar_left_but').style.left = (leftPub - 120) / 2 + "px";
	}
	else
	{
		document.getElementById('top_bar_left_but').style.width = leftPub + "px";
		document.getElementById('top_bar_left_but').style.left = "0px";
	}
	var rightButWidth = map_zone_width - leftPub - 468;
	if( rightButWidth > 62 )
	{
		document.getElementById('top_bar_right_but').style.width = "60px";
		document.getElementById('top_bar_right_but').style.left = (leftPub + 468) + (map_zone_width - (leftPub + 468) - 60) / 2 + "px";
	}
	else
	{
		document.getElementById('top_bar_right_but').style.width = rightButWidth + "px";
		document.getElementById('top_bar_right_but').style.left = map_zone_width - rightButWidth + "px";
	}
	
	document.getElementById('map_contained').style.left = map_x + "px";
	document.getElementById('map_contained').style.top = map_y + "px";
	
	document.getElementById('loading_pop').style.left = parseInt((map_zone_width - 464) / 2) + "px";
	document.getElementById('loading_pop').style.top = parseInt((map_zone_height - 241) / 2) + "px";
	
	updateObjects();

	if( connect_popup_open || subscribe_popup_open || help_popup_open)
	{
		var popup_width = parseInt(map_zone_width * 0.9);
		var popup_height = parseInt(map_zone_height * 0.95);
		document.getElementById('common_popup').style.left = (map_zone_width - popup_width) / 2 + "px";
		document.getElementById('common_popup').style.top = (map_zone_height - popup_height) / 2 + "px";
		document.getElementById('common_popup_bar1_2').style.width = popup_width - 48 + "px";
		document.getElementById('common_popup_bar1_3').style.left = popup_width - 24 + "px";
		document.getElementById('common_popup_bar2_1').style.height = popup_height - 30 + "px";
		document.getElementById('common_popup_bar2_2').style.height = popup_height - 30 + "px";
		document.getElementById('common_popup_bar2_2').style.left = popup_width - 4 + "px";
		document.getElementById('common_popup_bar3_1').style.top = popup_height - 6 + "px";
		document.getElementById('common_popup_bar3_2').style.top = popup_height - 6 + "px";
		document.getElementById('common_popup_bar3_2').style.width = popup_width - 12 + "px";
		document.getElementById('common_popup_bar3_3').style.left = popup_width - 6 + "px";
		document.getElementById('common_popup_bar3_3').style.top = popup_height - 6 + "px";
		if( connect_popup_open )
		{
			document.getElementById('common_popup_connexion_contained').style.width = popup_width - 8 + "px";
			document.getElementById('common_popup_connexion_contained').style.height = popup_height - 30 + "px";
		}
		else if( subscribe_popup_open )
		{
			document.getElementById('common_popup_subscribe_contained').style.width = popup_width - 8 + "px";
			document.getElementById('common_popup_subscribe_contained').style.height = popup_height - 30 + "px";
		}
		else if( help_popup_open )
		{
			document.getElementById('common_popup_help_contained').style.width = popup_width - 8 + "px";
			document.getElementById('common_popup_help_contained').style.height = popup_height - 30 + "px";
			document.getElementById('common_popup_faq_contained').style.width = popup_width - 8 + "px";
			document.getElementById('common_popup_faq_contained').style.height = popup_height - 30 + "px";
			document.getElementById('common_popup_contact_contained').style.width = popup_width - 8 + "px";
			document.getElementById('common_popup_contact_contained').style.height = popup_height - 30 + "px";
		}
		document.getElementById('common_popup_close').style.left = popup_width - 24 + "px";
	}
}

// Update du contenu de la map
function updateMapContained()
{
	if( fixPage )
		return;
	
	map_x += move_x;
	map_y += move_y;
	
	if( map_width > map_zone_width )
	{
		if( map_x > 0 )
			map_x = 0;
		if( map_x + map_width < map_zone_width )
			map_x = map_zone_width - map_width;
	}
	else
	{
		if( map_x < 0 )
			map_x = 0;
		if( map_x + map_width > map_zone_width )
			map_x = map_zone_width - map_width;
	}
	
	if( map_height > map_zone_height )
	{
		if( map_y > 0 )
			map_y = 0;
		if( map_y + map_height < map_zone_height )
			map_y = map_zone_height - map_height;
	}
	else
	{
		if( map_y < 0 )
			map_y = 0;
		if( map_y + map_height > map_zone_height )
			map_y = map_zone_height - map_height;
	}
	
	if( move_x != 0 || move_y != 0 )
	{
		var mi = 0;
		while( mi < moveCB.length )
		{
			moveCB[mi]();
			mi++;
		}
		drawMapContained();
	}
}

// Si on redimensionne la le navigateur, on redimensionne aussi le skin
window.onresize = loadSkin;