﻿/*  TETIERE */
/* Ouvrir la Popup Bourse */
var showHeaderBourse = function(){
	var el = jQuery("#BoursePopup");
	if(el.length)
		el.removeClass("NavInterneSite");
}

/* Fermer la Popup Bourse */
var closeHeaderBourse = function(){
	var el = jQuery("#BoursePopup");
	if(el.length)
		el.addClass("NavInterneSite");
}

/* Récupérer le XML des informations Bourse */
var updateBourseData = function(){
	//Appel AJAX
	jQuery.ajax({
		url: "xml/cours_bourse.php",
		cache: false,
		complete: function(xhr, textStatus){
			processUpdateBourseData(xhr.responseText,textStatus);
		}
	});
}

/* Renseigner la Popup Bourse */
var processUpdateBourseData = function(data, textStatus){
	var strTemp = "";
	var arrData = new Array(); //Tableaux des données
	var arrDataLib = Array("ticker","name","last","variation","date","previous");
	if(window.DOMParser){ // Initialisation du Parser XML
		parser = new DOMParser();
		xmlDoc = parser.parseFromString(data,"text/xml");
	}else{ // Pour IE
		xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async = "false";
		xmlDoc.loadXML(data);
	}
	var nodeName = "";
	for(i = 0; i < arrDataLib.length; i++){
		nodeName = arrDataLib[i];
		arrData[nodeName] = new Array();
		for(j = 0; j < xmlDoc.getElementsByTagName(nodeName).length; j++){
			if(xmlDoc.getElementsByTagName(nodeName)[j].firstChild)
				arrData[nodeName][j] = xmlDoc.getElementsByTagName(nodeName)[j].firstChild.nodeValue;
			else
				arrData[nodeName][j] = "";
		}
	}
	jQuery(".teteModuleBourse .bourseOpen .bourseTitre").html(arrData["name"][0]); // Afficher les données
	jQuery(".teteModuleBourse .bourseOpen .bourseValeur").html(arrData["last"][0] + "€");
	jQuery(".teteModuleBourse .bourseOpen .bourseVariable").html(arrData["variation"][0] + "%");
	jQuery(".teteModuleBourse .boursePopGauche .popChiffreNom").html(arrData["name"][0]);
	jQuery(".teteModuleBourse .boursePopGauche .popChiffreEnCours").html(arrData["last"][0].replace(".",",") + " €");
	if(parseFloat(arrData["variation"][0]) > 0)
		jQuery(".teteModuleBourse .boursePopGauche .popChiffreValeur").addClass("popPlus");
	else
		jQuery(".teteModuleBourse .boursePopGauche .popChiffreValeur").addClass("popMoins");
	jQuery(".teteModuleBourse .boursePopGauche .popChiffreVar").html(arrData["variation"][0].replace(".",",") + "%");
	jQuery(".teteModuleBourse .boursePopGauche .boursePopDate").html(arrData["date"][0].substring(8,10) + "/" + arrData["date"][0].substring(5,7) + "/" + arrData["date"][0].substring(0,4));
	jQuery(".teteModuleBourse .boursePopDroite .popChiffreNom").html(arrData["name"][1]);
	strTemp = arrData["last"][1].substring(0,1) + " " + arrData["last"][1].substring(1,arrData["last"][1].length);
	jQuery(".teteModuleBourse .boursePopDroite .popChiffreEnCours").html(strTemp.replace(".",",") + " pt");
	if(parseFloat(arrData["variation"][1]) > 0){
		strTemp = "+" + arrData["variation"][1].replace(".",",") + "%";
		jQuery(".teteModuleBourse .boursePopDroite .popChiffreValeur").addClass("popPlus");
	}else{
		strTemp = arrData["variation"][1].replace(".",",") + "%";
		jQuery(".teteModuleBourse .boursePopDroite .popChiffreValeur").addClass("popMoins");
	}
	jQuery(".teteModuleBourse .boursePopDroite .popChiffreVar").html(strTemp);
	jQuery(".teteModuleBourse .boursePopDroite .boursePopHeure").html(arrData["date"][0].substring(11,arrData["date"][0].length));
}
/*  FIN TETIERE */
/* Trouver la version d'Internet Explorer */
function GetVersionIe(){
	var ua = window.navigator.userAgent;
	var msie = ua.indexOf("MSIE ");

	if(msie > 0) // Pour Internet Explorer
		return(parseInt(ua.substring(msie + 5,ua.indexOf(".",msie))));
	else // Pour navigateurs respectant les DOM
		return(0);
}

/* Ajouter une fonction au chargement */
function addLoadEvent(func){
  var oldonload = window.onload;

  if(typeof window.onload != "function")
    window.onload = func;
  else{
    window.onload = function(){
      if(oldonload)
        oldonload();
      func();
    }
  }
}

function initialisation(){
	if(!InitiEffectue){
		InitiEffectue = true;
		Recalcule();
		if(document.getElementById("MenuGauche"))
			initialiseMenuGauche();
	}
	// Ajout de la gestion effet iphone pour plan du site
	if(nomDeLaPage == "plansite")
		effetiPhone = true;
	pageChargee = true;
	if(MeaFlashObject != null)
		MeaFlashObject.write("meaFlashBox");
	if(isBigScroll)
		document.getElementById("RetourHomeBigScroll").style.height = (document.getElementById("CONTENU").offsetHeight - document.getElementById("COLONNE_DROITE").offsetHeight) + "px";
}
// recalage du fond
function Recalcule(){
	if((nomDeLaPage == "index")||(nomDeLaPage == "etudiants")||(nomDeLaPage == "jeunes_diplomes")||(nomDeLaPage == "experimentes")){
		var heighttmp = jQuery(window).height() - jQuery("#SOUSPAGE").height() - jQuery("#PIEDPAGE").height() - 71;
		if(heighttmp < 450){
			heighttmp = 450;
		}
		jQuery("#PAGE").height(heighttmp);
	}else{
		if(document.getElementById("FONDSITE")){
			var navigateurWidth = jQuery(window).width();
			if(navigateurWidth < 2165)
				navigateurWidth = navigateurWidth + ((2165 - navigateurWidth) / 2) - 97;
			document.getElementById("FONDSITE").style.width = navigateurWidth + "px";
		}
	}
}

function envoieRequeteInfo(url, position){
	timer++;
	var xhr_object = null;
	var testLocal = timer;

	if(window.XMLHttpRequest)
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject)
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	if((position != "zoneScrollML") && (position != "zoneScrollCredits"))
		xhr_object.open("GET",url + "&s=" + SlideActuel,true);
	else
		xhr_object.open("GET",url,true);
	xhr_object.onreadystatechange = function(){
		if(xhr_object.readyState == 4){ // j'affiche dans la DIV spécifiée le contenu retourné par le fichier
			if(testLocal == timer){
				if((position == "zoneScroll") || (position == "MiniScroll"))
					setTimeout(ActiveScrollBar,1000);
				document.getElementById(position).style.visibility = "visible";
				document.getElementById(position).innerHTML = xhr_object.responseText;
					new Effect.Pulsate(document.getElementById(position)
						,{pulses: 1
							,duration: 0.5
							,queue: {position: 'end'
								,scope: 'Ongletscope'
								,limit: 1
							}
						}
					);
				if(position == "zoneCible")
					Scroller.reset("zoneCible");
				ActiveScriptDiv(position);
				d = document.getElementById(position);
				var scrajx = d.getElementsByTagName('script');

				for(var i in scrajx)
					eval(scrajx[i].text);
			}
		}
	}
	xhr_object.send(null); // dans le cas du get
}

function ActiveScriptDiv(position){
	divContent = document.getElementById(position);
	var All = divContent.getElementsByTagName("*");

	for(i = 0; i < All.length; i++){
		All[i].id = All[i].getAttribute("id");
		All[i].name = All[i].getAttribute("name");
		if(ieVersion == 0)
			All[i].className = All[i].getAttribute("class");
	}
	var AllScripts = divContent.getElementsByTagName("script");

	for(i = 0; i < AllScripts.length; i++){
		var s = AllScripts[i];

		if(s.src && s.src != "") // Basculement en mode synchrone pour éviter des problèmes de dépendances de scripts
			eval(getFileContent(s.src));
		else
			eval(s.innerHTML);
	}
}

var timer = 0;
var last_timer = 0;

function envoieRequete(url, position, onglet, ancienDiv){
	timer++;
	var xhr_object = null;
	var testLocal = timer;

	if(window.XMLHttpRequest) // On ouvre la requete vers la page désirée et si anim Flash on transmet la version
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject)
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	url = url + "?fV=" + flashVersion["major"] + "&s=" + SlideActuel + "&nivh1=" + NiveauH1;
	if(param != "")
		url = url + "&param=" + param;
	var urlErreur = "versionFlash.php?fV=" + flashVersion["major"] + "&s=" + SlideActuel + "&nivh1=" + NiveauH1;

	if(flashVersion["major"] > 7)
		xhr_object.open("GET",url,true);
	else{
		switch(onglet){
			case "Texte":
				xhr_object.open("GET",url,true);
				break;
			case "Flash":
				xhr_object.open("GET","_F/" + urlErreur,true);
				break;
			case "Video":
				if(sessionLangue != "fr")
					xhr_object.open("GET","_V" + sessionLangue + "/" + urlErreur,true);
				else
					xhr_object.open("GET","_V/" + urlErreur,true);
				break;
		}
	}
	xhr_object.onreadystatechange = function(){
		if(xhr_object.readyState == 4){ // Insérer contenu du fichier dans la DIV indiquée
			if(testLocal == timer){
				if(onglet == "Texte")
					setTimeout(ActiveScrollBar,1000);
				document.getElementById(position).innerHTML = xhr_object.responseText;
				new Effect.Appear(document.getElementById(position)
					,{duration: .7
						,queue: {position: 'end'
							,scope: 'Ongletscope'
						}
					}
				);
				OngletActuel = onglet;
				if(onglet == "Texte"){
					d = document.getElementById(position);
					var scrajx = d.getElementsByTagName("script");

					for(var i in scrajx){
						if(scrajx[i] != null)
							eval(scrajx[i].text);
					}
				}else
					ActiveScriptDiv(position);
			}
		}
	}
	xhr_object.send(null); // dans le cas du get
}

var globaleval =  function(script){
	if(window.execScript)
		return(window.execScript(script));
	else if(navigator.userAgent.indexOf('KHTML') != -1){ // pour safari, konqueror..
		var s = document.createElement('script');

		s.type = 'text/javascript';
		s.innerHTML = script;
		document.getElementsByTagName('head')[0].appendChild(s);
	}else
		return(window.eval(script));
}

function ActiveScrollBar(){
	last_timer = timer;

	initialiseMenuGauche();	// Verifie la nécessité d'un scroll pour le menu Gauche
	if(ieVersion > 0){
		if(document.getElementById("zoneScroll"))
			Scroller.reset("zoneScroll");
		if(document.getElementById("MiniScroll"))
			Scroller.reset("MiniScroll");
	}else
		Scroller.updateAll();
	Scroller.updateAll();
	if(document.getElementById("zoneScroll"))
		Scroller.reset("zoneScroll");
	if(document.getElementById("MiniScroll"))
		Scroller.reset("MiniScroll");
}

function initialiseMenuGauche(){
	if(document.getElementById("MenuGauche")){
		if(document.getElementById("monteMenu").style.display != "inline"){
			var monMenu = document.getElementById("MenuGauche");

			cleanWhitespace(monMenu);
			if(monMenu.firstChild.offsetHeight > monMenu.offsetHeight){
				if(document.getElementById("MenuGaucheRetour"))
					monMenu.style.height = '331px';
				else
					monMenu.style.height = '376px';
				document.getElementById("monteMenu").style.display = "inline"; // affiche les éléments de scroll
				document.getElementById("descendMenu").style.display = "inline";
			}else{
				if(document.getElementById("monteMenu")){
					document.getElementById("monteMenu").style.display = "none";
					document.getElementById("descendMenu").style.display = "none";
				}
			}
		}
	}
}

var notWhitespace = /\S/;

function cleanWhitespace(node){
	for(var x = 0; x < node.childNodes.length; x++){
		var childNode = node.childNodes[x];

		if((childNode.nodeType == 3)&&(!notWhitespace.test(childNode.nodeValue))){ // that is, if it's a whitespace text node
			node.removeChild(node.childNodes[x]);
			x--;
		}
		if(childNode.nodeType == 1) // elements can have text child nodes of their own
			cleanWhitespace(childNode)
	}
}

function OuvreTexte(){
	if(sessionLangue != "fr")
		fermeAncien("_T" + sessionLangue + "/" + nomDeLaPage + "_T.php","INFOS_PAGE","Texte",OngletActuel);
	else
		fermeAncien("_T/" + nomDeLaPage + "_T.php","INFOS_PAGE","Texte",OngletActuel);
}

function OuvreFlash(){
	fermeAncien("_F/" + nomDeLaPage + "_F.php","INFOS_PAGE","Flash",OngletActuel);
}

function OuvreVideo(){
	if(sessionLangue != "fr")
		fermeAncien("_V" + sessionLangue + "/" + nomDeLaPage + "_V.php","INFOS_PAGE","Video",OngletActuel);
	else
		fermeAncien("_V/" + nomDeLaPage + "_V.php","INFOS_PAGE","Video",OngletActuel);
}

function changePicto(lePicto){
	switch(lePicto){
		case "Texte":
			document.getElementById("pictoTexte").style.display = "none";
			if(OngletTexte){
				if(OngletZoom)
					document.getElementById("pictoZoom").style.display = "inline";
				if(OngletRSS)
					document.getElementById("pictoRSS").style.display = "inline";
				if(OngletSocial)
					document.getElementById("pictoSocial").style.display = "inline";
				if(OngletImprimer)
					document.getElementById("pictoPrint").style.display = "inline";
			}
			break;
		case "Flash":
			document.getElementById("pictoFlash").style.display = "none";
			if(OngletTexte){
				if(OngletZoom)
					document.getElementById("pictoZoom").style.display = "none";
				if(OngletRSS)
					document.getElementById("pictoRSS").style.display = "none";
				if(OngletSocial)
					document.getElementById("pictoSocial").style.display = "none";
				if(OngletImprimer)
					document.getElementById("pictoPrint").style.display = "none";
			}
			break;
		case "Video":
			document.getElementById("pictoVideo").style.display = "none";
			if(OngletTexte){
				if(OngletZoom)
					document.getElementById("pictoZoom").style.display = "none";
				if(OngletRSS)
					document.getElementById("pictoRSS").style.display = "none";
				if(OngletSocial)
					document.getElementById("pictoSocial").style.display = "none";
				if(OngletImprimer)
					document.getElementById("pictoPrint").style.display = "none";
			}
			break;
	}
}

function fermeAncien(lien, iddiv, formatDemande, onglet){
	if((ieVersion > 0) && (ieVersion < 7))
		envoieRequete(lien,iddiv,formatDemande,onglet);
	else{
		new Effect.Fade(document.getElementById("INFOS_PAGE")
			,{duration: .7
				,queue: {position: 'end'
					,scope: 'Ongletscope'
				}
				,afterFinish : function(){ envoieRequete(lien,iddiv,formatDemande,onglet);}
			}
		);
	}
	changePicto(formatDemande);
	switch(onglet){
		case "Texte":
			document.getElementById("pictoTexte").style.display = "inline";
			break;
		case "Flash":
			document.getElementById("pictoFlash").style.display = "inline";
			break;
		case "Video":
			document.getElementById("pictoVideo").style.display = "inline";
			break;
	}
}

var compteur = 0;
var ChangementZoom = false;

function ChangerTexte(){
	if(pageChargee){
		var contenuHTML = "";

		if(document.getElementById("MiniScroll")){
			divContent = document.getElementById("MiniScroll");
			var All = divContent.getElementsByTagName("*");

			contenuHTML = All[0].innerHTML; // on ne prend que le div de scroll
		}else if(document.getElementById("zoneScroll")){
			divContent = document.getElementById("zoneScroll");
			var All = divContent.getElementsByTagName("*");

			contenuHTML = All[0].innerHTML; // on ne prend que le div de scroll
		}
		if(document.getElementById("MiniScroll"))
			document.getElementById("MiniScroll").innerHTML = contenuHTML;
		else if(document.getElementById("zoneScroll"))
			document.getElementById("zoneScroll").innerHTML = contenuHTML;
		compteur++;
		if(compteur < 3)
			document.getElementById("cssText").href = "style/style" + (compteur + 1) + ".css";
		else{
			compteur = 0;
			document.getElementById("cssText").href = "style/style" + (compteur + 1) + ".css";
		}
		ChangementZoom = true;
		if(document.getElementById("MiniScroll"))
			Scroller.reset("MiniScroll");
		else if(document.getElementById("zoneScroll"))
			Scroller.reset("zoneScroll");
		Scroller.updateAll();
	}
}

var printIndice = -1;
var pageActivMetier = "";
var indiceAjax = "";
var sectionAjax = "";
var lienAjax = "";

function OuvrePrint(){
	if(pageChargee){
		var fichier = "print.php?indiceAjax=" + indiceAjax + "&sectionAjax=" + sectionAjax + "&p=" + nomDeLaPage + "_T.php&fV=" + flashVersion['major'] + "&printIndice=" + printIndice + "&pAM=" + pageActivMetier + "&nivh1=" + NiveauH1;

		w = open(fichier,"","width=650,height=320,toolbar=no,scrollbars=yes,resizable=yes");
		w.document.close();
	}
}

var AncienItemLM = 0;
var AncienObjCible1 = "itemInit";
var AncienObjCible2 = "sousItemInit";
var AncienElement = "eltBoxInit";

function MeaModifier(nomMea,meaImg){
	if(document.getElementById("mise_en_avant")){
		cssjs('remove', document.getElementById("MeaBox_" + VisuelPrecedent), 'hoverFlash');
		getMovieName("mise_en_avant").miseEnPause(meaImg);
	}
}

function RepriseAnimation(){
	if(document.getElementById("mise_en_avant")){
		try{ // Exécuter la fonction existante dans le flash ou capter l'erreur de retour
			getMovieName("mise_en_avant").repriseAnimation();
		}catch(e){
		}
	}
}

function AutoHoverMEA(VisuelActuel){
	if(document.getElementById("MeaBox_" + VisuelPrecedent)){
		if(ieVersion > 0)
			cssjs("remove",document.getElementById("MeaBox_" + VisuelPrecedent),"hoverFlash");
		else
			document.getElementById("MeaBox_" + VisuelPrecedent).removeAttribute("class");
		cssjs('add', document.getElementById("MeaBox_" + VisuelActuel), 'hoverFlash');
	}
	VisuelPrecedent = VisuelActuel;
}

var VisuelPrecedent = 1;

// Chargement info calendrier
function StockePeriode(Mois, Annee){
	leMoisCalendrier = Mois;
	lAnneeCalendrier = Annee;
}

function ChargeInfoCal(Etudiant, JeuneDiplome, Experimente, Ville){
	var FiltreLeCalendrierSur = "";
	var fichier = "";

	if(sessionLangue != "fr")
		fichier = "commun/consulteCal_" + sessionLangue + ".php?choixVille=" + Ville + "&Etudiant=" + Etudiant + "&JeuneDiplome=" + JeuneDiplome + "&Experimente=" + Experimente;
	else
		fichier = "commun/consulteCal.php?choixVille=" + Ville + "&Etudiant=" + Etudiant + "&JeuneDiplome=" + JeuneDiplome + "&Experimente=" + Experimente;

	laVilleCalendrier = Ville;
	if(document.getElementById("zoneScroll")){
		envoieRequeteInfo(fichier,"zoneScroll");
		AncienElement = "eltBoxInit";
	}
	if(Etudiant == 1)
		FiltreLeCalendrierSur = "ETU";
	if(JeuneDiplome == 1)
		FiltreLeCalendrierSur = "JD";
	if(Experimente == 1)
		FiltreLeCalendrierSur = "EXP";
	navigate(leMoisCalendrier,lAnneeCalendrier,FiltreLeCalendrierSur,laVilleCalendrier,sessionLangue); // MAJ des dates du calendrier
	document.getElementById("MenuDeroulantCal").style.height = "25px";
	sectionAjax = "forums";
	printIndice = Etudiant + "-" + JeuneDiplome + "-" + Experimente;
	indiceAjax = Etudiant + "@" + JeuneDiplome + "@" + Experimente + "@9999@12@31@" + laVilleCalendrier;
}

function ChargeInfoCalOuverture(){
	document.getElementById("MenuDeroulantCal").style.height = "140px";
}

function ChargeInfoCalFermeture(){
	document.getElementById("MenuDeroulantCal").style.height = "25px";
}

function ChargeInfoCalDate(Etudiant, JeuneDiplome, Experimente, Annee, Mois, Jour, ident){
	var fichier = "";
	if(sessionLangue != "fr")
		fichier = "commun/consulteCal_" + sessionLangue + ".php?choixVille=" + laVilleCalendrier + "&Etudiant=" + Etudiant + "&JeuneDiplome=" + JeuneDiplome + "&Experimente=" + Experimente + "&Annee=" + Annee + "&Mois=" + Mois + "&Jour=" + Jour + "&ident=" + ident;
	else
		fichier = "commun/consulteCal.php?choixVille=" + laVilleCalendrier + "&Etudiant=" + Etudiant + "&JeuneDiplome=" + JeuneDiplome + "&Experimente=" + Experimente + "&Annee=" + Annee + "&Mois=" + Mois + "&Jour=" + Jour + "&ident=" + ident;

	if(document.getElementById("zoneScroll")){
		envoieRequeteInfo(fichier,"zoneScroll");
		AncienElement = "eltBoxInit";
	}
	sectionAjax = "forums";
	printIndice = Etudiant + "-" + JeuneDiplome + "-" + Experimente;
	indiceAjax = Etudiant + "@" + JeuneDiplome + "@" + Experimente + "@" + Annee + "@" + Mois + "@" + Jour + "@" + laVilleCalendrier;
}

function annuleFiltreCalendrier(Etudiant, JeuneDiplome, Experimente){
	laVilleCalendrier = "0";
	ChargeInfoCal(Etudiant,JeuneDiplome,Experimente,laVilleCalendrier);
	if(document.getElementById("menu_villes_flash"))
		getMovieName("menu_villes_flash").remiseAZeroListe();
}

// Chargement info Partenariat
function ChargeInfoPartenariat(fichier,indice,cible){
	printIndice = indice;
	if(sessionLangue != "fr")
		envoieRequeteInfo("_T" + sessionLangue + "/infosPartenariat/" + fichier,"zoneCible");
	else
		envoieRequeteInfo("_T/infosPartenariat/" + fichier,"zoneCible");
}

function OuvreElementBox(lienCible, cssActif, cssDefaut){
	if(cssjs('check',lienCible.parentNode,cssActif)){
		cssjs('remove',lienCible.parentNode,cssActif);
		cssjs('add',lienCible.parentNode,cssDefaut);
		AncienElement = "";
	}else{
		if(AncienElement != ""){
			if(AncienElement == "eltBoxInit"){
				if(document.getElementById(AncienElement)){
					cssjs('remove',document.getElementById(AncienElement),cssActif);
					cssjs('add',document.getElementById(AncienElement),cssDefaut);
				}
			}else{
				cssjs('remove',AncienElement,cssActif);
				cssjs('add',AncienElement,cssDefaut);
			}
		}
		if(AncienElement != lienCible.parentNode){
			cssjs('remove',lienCible.parentNode,cssDefaut);
			cssjs('add',lienCible.parentNode,cssActif);
			AncienElement = lienCible.parentNode;
		}else
			AncienElement = "";
	}
	initialiseMenuGauche();
}

function ChargeInfo(fichier, objCible){
	pageActivMetier = fichier;
	if(document.getElementById("zoneScroll"))
		envoieRequeteInfo(fichier,"zoneScroll");
	if(document.getElementById("MiniScroll"))
		envoieRequeteInfo(fichier,"MiniScroll");
	if(AncienObjCible1 != ""){
		if(AncienObjCible1 == "itemInit"){
			if(document.getElementById(AncienObjCible1))
				cssjs('remove',document.getElementById(AncienObjCible1),'courant');
		}else
			cssjs('remove',AncienObjCible1,'courant');
	}
	if(AncienObjCible2 != ""){
		if(AncienObjCible2 == "sousItemInit"){
			if(document.getElementById(AncienObjCible2))
				cssjs('remove',document.getElementById(AncienObjCible2),'courant');
		}else
			cssjs('remove',AncienObjCible2,'courant');
	}
	cssjs('add',objCible,'courant');
	AncienObjCible1 = objCible;
	AncienObjCible2 = objCible;
	document.location.href = "#itemTop";
}

function RelanceScroller(){
	if(document.getElementById("zoneScroll"))
		Scroller.reset("zoneScroll");
}

function InitialiseMenuScroll(){
	leScrollAM = setInterval(function(){
			RelanceScrollerDecalage();
		}
		,1000
	);
}

function RelanceScrollerDecalage(){
	clearInterval(leScrollAM);
	if(document.getElementById("LM").offsetHeight < 225){
		document.getElementById("LMHAUT").style.display = "none";
		document.getElementById("LMBAS").style.display = "none";
	}
}

var leScrollAM;

function scrollMenuLM(direction){
	if(direction == "stop")
		clearInterval(leScrollAM);
	else{
		var hauteur = document.getElementById("MenuGaucheContenu").offsetHeight;
		var posYActuel = document.getElementById("MenuGauche").offsetTop;

		sens = "+";
		decalage = 0;
		if(direction == "bas"){
			sens = "+";
			decalage = 80;
		}else{
			sens = "-";
			decalage = 80;
		}
		if(decalage != 0){
			jQuery(document).ready(function(){
				jQuery("div.scrollable").scrollTo(
					sens + "=" + decalage + "px",
					500,
					{axis:"y"}
				);
			});
		}
		clearInterval(leScrollAM);
		leScrollAM = setInterval(function(){ scrollMenuLM(direction);},500);
	}
}

var PopActif = false;
var PopMail = false;
var PopRSS = false;
var PopSocial = false;

// Si on a envoyé le mail : on affiche le message de confirmation ou d'erreur si existant
if(!Sys_EnvoiMail){
	PopActif = true;
	PopMail = true;
}

function OuvreMail(){
	if(pageChargee){
		if(PopSocial)
			FermeSocial();
		if(!PopActif){
			if(!PopMail){
				PopActif = true;
				PopMail = true;
				new Effect.Grow(document.getElementById("POP_ENVOIAMI")
					,{duration: .7
					}
				);
			}else{
				PopActif = false;
				PopMail = false;
				new Effect.Shrink(document.getElementById("POP_ENVOIAMI")
					,{duration: .7
					}
				);
			}
		}
	}
}

function FermeMail(){
	if(PopMail){
		PopActif = false;
		PopMail = false;
		new Effect.Shrink(document.getElementById("POP_ENVOIAMI")
			,{duration: .7
			}
		);
	}
}

// Si on a envoyé le mail : on affiche le message de confirmation ou d'erreur si existant
function FermeConfirmMail(){
	PopActif = false;
	PopMail = false;
	new Effect.Shrink(document.getElementById("POP_ENVOIAMICONFIRM")
		,{duration: .7
		}
	);
}

function EnvoiMailAmi(){
	if(PopMail){
		var okEnvoi = true;

		if((document.formEnvoiAmi.Nom.value == "") && (okEnvoi)){
			if(sessionLangue == "fr")
				alert("Vous devez indiquer votre nom.");
			else if(sessionLangue == "uk")
				alert("Please enter your name.");
			document.formEnvoiAmi.Nom.focus();
			okEnvoi = false;
			return(false);
		}
		if((document.formEnvoiAmi.NomAmi.value == "") && (okEnvoi)){
			if(sessionLangue == "fr")
				alert("Vous devez indiquer le nom de votre ami.");
			else if(sessionLangue == "uk")
				alert("Please enter your friend's name.");
			document.formEnvoiAmi.NomAmi.focus();
			okEnvoi = false;
			return(false);
		}
		if((document.formEnvoiAmi.EmailAmi.value == "") && (okEnvoi)){
			if(sessionLangue == "fr")
				alert("Vous devez indiquer l'e-mail de votre ami.");
			else if(sessionLangue == "uk")
				alert("Please enter your friend's e-mail.");
			document.formEnvoiAmi.EmailAmi.focus();
			okEnvoi = false;
			return(false);
		}
		document.formEnvoiAmi.lienDirecte.value = lienAjax;
		if(okEnvoi){
			PopActif = false;
			PopMail = false;
			TrackEvenementValueGA('Partage '+sessionLangue, 'Email', encodeURIComponent(SharingUrl), 1);
			document.getElementById("formEnvoiAmi").submit();
		}
	}
}

function OuvreRSS(){
	if(!PopActif){
		if(!PopRSS){
			PopActif = true;
			PopRSS = true;
			new Effect.Grow(document.getElementById("POP_RSS")
				,{duration: .7
				}
			);
		}else{
			PopActif = false;
			PopRSS = false;
			new Effect.Shrink(document.getElementById("POP_RSS")
				,{duration: .7
				}
			);
		}
	}
}

function FermeRSS(){
	if(PopRSS){
		PopActif = false;
		PopRSS = false;
		new Effect.Shrink(document.getElementById("POP_RSS")
			,{duration: .7
			}
		);
	}
}

function ValideRSS(){
	if(PopRSS){
		PopActif = false;
		PopRSS = false;
		new Effect.Shrink(document.getElementById("POP_RSS")
			,{duration: .7
			}
		);
	}
}

function OuvreSocial(){
	if(!PopActif){
		if(!PopSocial){
			PopActif = true;
			PopSocial = true;
			new Effect.Grow(document.getElementById("POP_Social")
				,{duration: .7
				}
			);
		}else{
			PopActif = false;
			PopSocial = false;
			new Effect.Shrink(document.getElementById("POP_Social")
				,{duration: .7
				}
			);
		}
	}
}

function FermeSocial(){
	if(PopSocial){
		PopActif = false;
		PopSocial = false;
		new Effect.Shrink(document.getElementById("POP_Social")
			,{duration: .7
			}
		);
	}
}

function CreationPermalien(lePermalien, newTitle){
	SharingUrl = SharingDomainePage + lePermalien;
	SharingTitle = newTitle + " - " + SharingBaseTitle;
	SharingTitle = SharingTitle.replace("«","");
	SharingTitle = SharingTitle.replace("»","");
	SharingTitle = SharingTitle.replace('"',"");
	SharingTitle = SharingTitle.replace('"',"");
}

function ShareOnFacebook(){
	var u = encodeURIComponent(SharingUrl);

	window.open("http://www.facebook.com/sharer.php?u=" + u,"sharer","toolbar=0,status=0");
	TrackEvenementValueGA("Partage " + sessionLangue,"Facebook",encodeURIComponent(SharingUrl),1);
}

function ShareOnTwitter(){
	var t = encodeURIComponent(SharingTitle);
	var u = SharingUrl;

	window.open("http://twitter.com/home?status=" + t + " " + u,"sharer","toolbar=0,status=0");
	TrackEvenementValueGA("Partage " + sessionLangue,"Twitter",encodeURIComponent(SharingUrl),1);
}

function ShareOnViadeo(){
	var t = encodeURIComponent(SharingTitle);
	var u = encodeURIComponent(SharingUrl);

	window.open("http://www.viadeo.com/shareit/share/?url=" + u,"sharer","toolbar=0,status=0");
	TrackEvenementValueGA("Partage " + sessionLangue,"Viadeo",encodeURIComponent(SharingUrl),1);
}

function ShareOnLinkedin(){
	var t = encodeURIComponent(SharingTitle);
	var u = encodeURIComponent(SharingUrl);
	var d = encodeURIComponent(SharingDomaine);

	window.open("http://www.linkedin.com/shareArticle?mini=true&url=" + u + "&title=" + t + "&source=" + d,"sharer","toolbar=0,status=0");
	TrackEvenementValueGA("Partage " + sessionLangue,"Linkedin",encodeURIComponent(SharingUrl),1);
}
/*
var TweetThisLink = {
	shorten: function(t,u){
			// this stops the click, which will later be handled in the  response method
		//e.preventDefault();
			// find the link starting at the second 'http://'
		//var url = this.href.substr(this.href.indexOf('http:',5));
		var url = SharingUrl;

		BitlyClient.shorten(url,"TweetThisLink.response");
	},
	response: function(data){
		var bitly_link = null;

		for(var r in data.results){
			bitly_link = data.results[r]["shortUrl"];
			break;
		}
		//var tweet_text = encodeURIComponent(SharingTitle);
		//document.location = "http://twitter.com/home?status=" + encodeURIComponent(tweet_text + " " + bitly_link);
		window.open("http://twitter.com/home?status=" + encodeURIComponent(SharingTitle + " " + bitly_link),"sharer","toolbar=0,status=0");
	}
}
*/
function cssjs(action, object, className){
	if(action == 'add'){
		if(!cssjs('check',object,className))
			object.className += object.className ? ' ' + className : className;
	}else if(action == 'remove'){
		var rep = object.className.match(' ' + className) ? ' ' + className : className;

		object.className = object.className.replace(rep,'');
	}else if(action == 'check')
		return(new RegExp('\\b' + className + '\\b').test(object.className));
	return(true);
}

function getMovieName(movieName){
	if(navigator.appName.indexOf("Microsoft") != -1)
		return(window[movieName]);
	else
		return(document[movieName]);
}

function confirmerRetour(cible, target){
	var msgConfirm = "";

	if(sessionLangue == "fr")
		msgConfirm = "Etes-vous sûr(e) de vouloir vous déconnecter de votre espace candidat ?";
	else if(sessionLangue == "uk")
		msgConfirm = "Do you want to logout from your profile space";
	if(confirm(msgConfirm)){
		if(target == "_self")
			window.location.href = cible;
		else if(target == "_blank")
			window.open(cible,"","");
	}
}

function EtapChanger(etapCible){
	if(AncienEtapCible != ""){
		if(AncienEtapCible == "etapInit"){
			if(document.getElementById(AncienEtapCible))
				cssjs("remove",document.getElementById(AncienEtapCible),"etapActif");
		}else
			cssjs("remove",AncienEtapCible,"etapActif");
	}
	cssjs("add",etapCible.parentNode,"etapActif");
	AncienEtapCible = etapCible.parentNode;
}

function EtapSiChanger(cheminOnglet, etapCible){
	ChargeInfo(cheminOnglet,etapCible);
	AncienEtapCible = etapCible.parentNode;
}

function EtapSiSurvoler(etapCible){
	if(AncienEtapSurvolCible != etapCible.parentNode){
		if(AncienEtapSurvolCible != ""){
			if(AncienEtapSurvolCible == "etapInit")
				AncienEtapSurvolCible = jQuery("#etapInit");
			else
				AncienEtapSurvolCible = jQuery(AncienEtapSurvolCible);
			AncienEtapSurvolCible.find(".imgPetite").find(".imgEtapOff").fadeIn();
			AncienEtapSurvolCible.find(".imgGrande").find(".imgEtapOff").fadeIn();
			AncienEtapSurvolCible.find(".imgPetite").find(".imgEtapOn").fadeOut();
			AncienEtapSurvolCible.find(".imgGrande").find(".imgEtapOn").fadeOut();
		}
		jQuery(etapCible).find(".imgEtapOff").fadeOut();
		jQuery(etapCible).find(".imgEtapOn").fadeIn();
		AncienEtapSurvolCible = etapCible.parentNode;
	}
}

function EtapSiSortir(){
	if(AncienEtapSurvolCible != AncienEtapCible){
		if(AncienEtapCible == "etapInit")
			AncienEtapCible = document.getElementById("etapInit");
		if(AncienEtapSurvolCible != ""){
			if(AncienEtapSurvolCible == "etapInit")
				AncienEtapSurvolCible = jQuery("#etapInit");
			else
				AncienEtapSurvolCible = jQuery(AncienEtapSurvolCible);
			AncienEtapSurvolCible.find(".imgPetite").find(".imgEtapOff").fadeIn();
			AncienEtapSurvolCible.find(".imgPetite").find(".imgEtapOn").fadeOut();
			AncienEtapSurvolCible.find(".imgGrande").find(".imgEtapOff").fadeIn();
			AncienEtapSurvolCible.find(".imgGrande").find(".imgEtapOn").fadeOut();
		}
		jQuery(AncienEtapCible).find(".imgEtapOff").fadeOut();
		jQuery(AncienEtapCible).find(".imgEtapOn").fadeIn();
		AncienEtapSurvolCible = AncienEtapCible;
	}
}
