
var PagesMenu = new Array("identite", "competences", "services", "partenaires", "references", "contact", "recrutement", "extranet");

function MM_preloadImages()
{
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MouseEvent(ligne,evt)
{
	switch (evt)
	{
		case "OVER" :
			if (ligne.className != "LigneSelectionnee")
				ligne.className = "LigneMouseOver";
		break;

		case "OUT" :
      if (ligne.className != "LigneSelectionnee")
				ligne.className = "LigneDefaut";
		break;

		case "CLICK" :
			//-- Cas où une ligne était déjà sélectionnée
      if (document.Infos.ID.value != 0)
				document.getElementById("TR" + document.Infos.ID.value).className = "LigneDefaut";

			//-- Sélectionne-t-on une nouvelle ligne, ou déselectionnet-ton la ligne actuellement sélectionnée
			if ("TR" + document.Infos.ID.value == ligne.id)
			{
				document.Infos.ID.value = 0;
				ligne.className = "LigneDefaut";
			}
			else
			{
				ligne.className = "LigneSelectionnee";

				tmp = new String(ligne.id);
				tab = tmp.split("TR");
				document.Infos.ID.value = tab[1];
			}
		break;

    default :
			alert("Erreur");
		break;
	}
}

function OuvrePopup(URL, largeur_popup, hauteur_popup)
{
 	x = (Math.round((screen.availWidth - largeur_popup)/ 2));
 	y = (Math.round((screen.availHeight - hauteur_popup)/ 2));
	window.open(URL,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,top=" + y + ",left=" + x + ",width=" + largeur_popup + ",height=" + hauteur_popup);
}

function ResizeWindow(largeur,hauteur)
{
	x = (Math.round((screen.availWidth - largeur)/ 2));
 	y = (Math.round((screen.availHeight - hauteur)/ 2));
	self.moveTo(x,y);
	self.resizeTo(largeur,hauteur);
}

function AfficheTitre(titre,sous_titre)
{
	document.write("<table cellpadding=7 cellspacing=0 align=center border=0>");
	document.write("<tr><td class=CelluleTitre>&nbsp;&nbsp;&nbsp;" + titre + "&nbsp;&nbsp;&nbsp;</td></tr>");
	if (sous_titre != "")
		document.write("<tr><td class=CelluleTitreSousTitre>&nbsp;&nbsp;&nbsp;" + sous_titre + "&nbsp;&nbsp;&nbsp;</td></tr>");
	document.write("<tr><td class=CelluleDefaut>&nbsp;</td></tr>");
	document.write("</table>");
}

function AfficheMessage(titre,message,urlRetour)
//-- Si titre = "", pas d'affichage du titre
//-- Si urlRetour = "", pas d'affichage de cette URL
{
	document.write("<br><br><br>");
	document.write("<table cellpadding=7 cellspacing=0 align=center border=0>");
		if (titre)
		{
			document.write("<tr><td class=CelluleSousTitreUnique>" + titre + "</td></tr>");
			document.write("<tr><td class=CelluleUnique align=center><br>" + message + "<br>&nbsp;</td></tr>");
		}
		else
			document.write("<tr><td class=CelluleUnique align=center><br>" + message + "<br>&nbsp;</td></tr>");
		document.write("<tr><td class=CelluleDefaut>&nbsp;</td></tr>");
		if (urlRetour)
			document.write("<tr><td class=CelluleMenus><a class=Defaut href='" + urlRetour + "'>Retour</a></td></tr>");
	document.write("</table>");
}

function InitialiseBoutonsTri(RepImages,NbBoutonTri)
{
	NoBoutonTriCourant = (document.Infos.NoBoutonTriCourant.value == "")?1:document.Infos.NoBoutonTriCourant.value;
	//TypeTri = (document.Infos.NoBoutonTriCourant.value == "")?"up":document.Infos.TypeTri.value;
	TypeTri = (document.Infos.TypeTri.value == "")?"up":document.Infos.TypeTri.value;
	//TypeTri = document.Infos.TypeTri.value;

	for (i=1; i<=NbBoutonTri; i++)
		//-- Bouton sur lequel un tri à été demandé (bouton n° 1 par défaut)
		if (i == NoBoutonTriCourant)
		{
			eval("document.BoutonTri_" + i + ".src = '" + RepImages + "sort_" + TypeTri + "_sel.gif'");
			tmp = (TypeTri == "up")?"Ordre décroissant":"Ordre croissant";
			eval("document.BoutonTri_" + i + ".alt = '" + tmp + "'");
		}
		//-- Autres boutons
		else
		{
			eval("document.BoutonTri_" + i + ".src = '" + RepImages + "sort_up_off.gif'");
			eval("document.BoutonTri_" + i + ".alt = 'Ordre croissant'");
		}

	document.Infos.NoBoutonTriCourant.value = NoBoutonTriCourant;
	document.Infos.TypeTri.value = TypeTri;
}

//-- Renvoie "up" pour "down" et vice-versa
function StrUpDown(str)
{
	if (str == "up")
		return ("down");
	return ("up");
}

function EventBoutonTri(objBouton, evt, ChampTri, FormAction)
//-- Les variables ChampTri et FormAction ne servent que si evt = "CLICK"
{
	switch (evt)
	{
		case "OVER" :
				objBouton.src = objBouton.src.replace("_off.","_on.");
		break;

    case "OUT" :
				objBouton.src = objBouton.src.replace("_on.","_off.");
		break;

    case "CLICK" :
    	//-- Cas où on clicke sur un bouton de tri déjà actif
    	if (objBouton.src.indexOf("_sel.") != -1)
			{
        //-- On change d'orientation le bouton de tri actuellement actif
        new_TrypeTri = StrUpDown(document.Infos.TypeTri.value);
				objBouton.src = objBouton.src.replace(document.Infos.TypeTri.value, StrUpDown(document.Infos.TypeTri.value));

				//-- Mise à jour du champ caché "TypeTri"
				document.Infos.TypeTri.value = new_TrypeTri;
			}

			//-- Cas où on clicke sur un bouton de tri non actif
			else
			{
        //-- On désactive le bouton de tri actif jusqu'à présent
				new_src = eval("document.BoutonTri_" + document.Infos.NoBoutonTriCourant.value + ".src");
				new_src = new_src.replace("_sel.","_off.");
				new_src = new_src.replace(document.Infos.TypeTri.value, "up");
				eval("document.BoutonTri_" + document.Infos.NoBoutonTriCourant.value + ".src = '" + new_src + "'");

				//-- On active le bouton de tri désormais actif
				objBouton.src = objBouton.src.replace("_on.", "_sel.");

        //-- Mise à jour du champ caché "TypeTri"
				document.Infos.TypeTri.value = "up";

				//-- Mise à jour du champ caché "NoBoutonTriCourant"
				document.Infos.NoBoutonTriCourant.value = objBouton.name.slice(objBouton.name.indexOf("_") + 1);
			}

			//-- Mise à jour du champ caché "Query"
			tmp1 = document.Infos.Query.value.split(" order by ");
			tmp2 = tmp1[1].split(" desc");
			orderby = (document.Infos.TypeTri.value == "down")?" desc":"";
			document.Infos.Query.value = tmp1[0] + " order by " + ChampTri + orderby;

			//-- Validation du forumulaire avec la nouvelle requête
			document.Infos.action = FormAction;
			document.Infos.submit();
		break;

    default :
			alert("Erreur !");
		break;
	}
}

																	/**********************************************************/

function checkBrowser()
{
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie55=((this.ver.indexOf("MSIE 5.5")>-1 || this.ie6) && this.dom)?1:0;
	this.ie5=((this.ver.indexOf("MSIE 5")>-1 || this.ie5 || this.ie6) && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.ie4plus=(this.ie6 || this.ie5 || this.ie4);
	this.ie5plus=(this.ie6 || this.ie5)
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns5);
	return this;
}

bw = new checkBrowser();

if (!document.getElementById)
{
	document.getElementById = getObjectById;
}

function getObjectById(ID)
{
	var obj;
	if (bw.dom)
		return document.getElementById(ID);
	else if (bw.ie4)
		return document.all(ID);
	else if (bw.ns4)
		return eval('document.' + ID);
}

																	/**********************************************************/

function CheckEmail(value)
{
	str = new String(value);

	if (!str.length)
		return false;

	if ((str.indexOf("@") == -1) || (str.indexOf(".") == -1) || (str.lastIndexOf(".") < str.indexOf("@")) || (str.lastIndexOf(".") + 1 == str.length))
		return false;

	i = 0;
	ArrobaseFound = false;
	PointFound = false;
	while (i < str.length)
	{
		ch = str.substring(i, i + 1);

		if (ch == "@")
			if (ArrobaseFound)
				return false;
			else
				ArrobaseFound = true;

	if (ch == ".")
		PointFound = true;

	if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == "@") || (ch == ".") || (ch == "_") || (ch == "-") || (ch >= "0" && ch <= "9"))
		i++;
	else
		return false;
	}

	return true;
}

function CheckInteger(str)
{
	return (parseInt(str) == str);
}

