var defienjeu_courant = 1;
var actionprio_courant = 1;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


// FONCTION ROLL OVER DES LAYERS

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


// FONCTION ROLL OVER DES IMAGES

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function changerImage(zoneId,source) {
	doc = window.document.getElementById(zoneId);
	
	if(doc.src!==source)
	doc.imgSource = doc.src;
	
	doc.src = source;
}
function remettreImage(num) {
//REMETTRE IMAGE
	doc1 = window.document.getElementById("linkcontextuel");
	if(num!==1 && doc1 && doc1.imgSource && doc1.imgSource!==undefined)
	doc1.src = doc1.imgSource;
	
	doc2 = window.document.getElementById("linkcontextuel2");	
	if(num!==2 && doc2 && doc2.imgSource && doc2.imgSource!==undefined)
	doc2.src = doc2.imgSource;
	
	doc3 = window.document.getElementById("linkcontextuel3");	
	if(num!==3 && doc3 && doc3.imgSource && doc3.imgSource!==undefined)
	doc3.src = doc3.imgSource;
}



// CHARGEMENT DE L'IFRAME QUAND ON CLIQUE SUR LE CONTEXTUEL
function goUrl(theURL) {
var objIframe = document.getElementById("contextiframe");

if (objIframe) {
     objIframe.src = theURL;
     }
}


function afficher_masquer_zone(nom_element,sens)
{
var test_support = (document.getElementById || document.all || document.layers);
	if (test_support)
	{
		doc = (document.all) ? document.all[nom_element] : document.getElementById(nom_element);
		doc.style.display = ((doc.style.display == 'none' && sens==1) || sens==1) ? 'block' : 'none';
	}

}
var hauteurInitiale = -1;
function capturerHauteur(sens)
{
	a = document.getElementById("conteneurCentral");
	if(sens==1 && hauteurInitiale==-1)
	hauteurInitiale = a.style.height;

	//Hauteur de l'iframe du contextuel
	a.style.height = (sens==1) ? "1000px" : hauteurInitiale;
}

function afficher_context (url)
{
	if(navigator.userAgent.indexOf("Opera")==-1)
	{
		//Ce n'est pas Opera
		if(navigator.appName=="Microsoft Internet Explorer")
		{
		doc = (document.all) ? document.all["conteneurIFrameMast"] : document.getElementById("conteneurIFrameMast");
		doc.style.left = "1px";
		}
		
		capturerHauteur(1);
		afficher_masquer_zone('conteneurCentral',-1);
		afficher_masquer_zone('conteneurIFrame',1);
		MM_showHideLayers('allclose','','visible');
		goUrl(url);
		
	}
	else
	{
		PopUp(url,"popup_context","scrollbars=yes,resizable=no,toolbar=no,menuBar=no,top=70,left=20,width=585,height=680");
	}
}
function masquer_context ()
{
	afficher_masquer_zone('conteneurCentral',1);
	afficher_masquer_zone('conteneurIFrame',-1);
	MM_showHideLayers('allclose','','hidden');
	capturerHauteur(-1);
	MM_swapImage();
}
// Test  /
//function goUrl(theURL) {
//alert("Vous allez tre redirig s sur " + theURL);
//var iframe = document.divcontextiframe;
//if (iframe) {
//     iframe['contextiframe'].src = theURL;
//	}
//} 

/*
function adjustIFrameSize (iframeWindow) {
  if (iframeWindow.document.height) {
    var iframeElement = parent.document.getElementById(iframeWindow.name);
    iframeElement.style.height = iframeWindow.document.height + 'px'; //Mozilla, Netscape
    }
  else if (document.all) {
    var iframeElement = parent.document.all[iframeWindow.name];
    if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat') 
    {
      iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight +  5 +  'px'; //IE
    }
    else {
      iframeElement.style.height = iframeWindow.document.body.scrollHeight  + 5 +  'px';
    }
  }
}
*/



function control(){
txt=0;
errmessage='';
	if (document.contact.email.value == '' || document.contact.message.value == '')
	{
	txt=1;
	errmessage='Merci de renseigner tous les champs obligatoires.';
	}
	if ( txt==1 )
		{
		alert( errmessage);
		}
	else
	{
		str = document.contact.email.value
		valAt = str.indexOf("@")
		valSpace = str.indexOf(" ")
		valAt2 = str.indexOf("@",valAt+1)
		valDot = str.indexOf(".")
		valid = true;
	
		if(valSpace != -1) // if there is a space
			valid = false
		else if(valAt == -1) // if there isn't an @
			valid = false
		else if(valAt == 0)	// the @ is the first character
			valid = false
		else if(valAt == (valDot +1)) // the dot cames just before the @
			valid = false
		else if(valDot == -1)	// there is no dot
			valid = false
		else if(valAt2 != -1)	// there is a second @
			valid = false
		else if(!isNaN(str.substring(0,1)))		// the first character is a number
			valid = false
		else if(valDot == (str.length - 1))		// we have a final dot
			valid = false

		if(!valid)
			{
			alert('Entrez une adresse e-mail valide')
			}
		else
			{
			alert('Merci. Votre message a bien t  envoy, il sera trait  dans les meilleurs dlais.');
			document.contact.submit();
			}
	}
}



// OUVERTURE DE LA POPUP INSTANTANNEE DU FOOTER
function PopUp(page,options) {
	var top=(screen.height-462)/2;
	var left=(screen.width-550)/2;
window.open(page,"zoom","top="+top+",left="+left+",width="+550+",height="+462+","+options);
}
// ouverture de la popup dans actions et réalisations
function PopUp2(page,options) {
	var top=(screen.height-455)/2;
	var left=(screen.width-440)/2;
window.open(page,"zoom","top="+top+",left="+left+",width="+440+",height="+455+","+options);
}

function changer_classe(zoneId,classe)
{
	doc = (document.all) ? document.all[zoneId] : document.getElementById(zoneId);
	doc.className = classe;
}

function scrolldroite(){
	window.bandeau.scrollBy(168,0);
}

function scrollgauche(){
	window.bandeau.scrollBy(-168,0);
}

function scrollgauchehome(nb_defienjeu){
	if (defienjeu_courant == 1)
	{
		window.bandeau.scrollTo(300*nb_defienjeu,0);
		defienjeu_courant = nb_defienjeu;
	}
	else
	{
		window.bandeau.scrollBy(-300,0);
		defienjeu_courant--;
	}
}

function scrolldroitehome(nb_defienjeu){
	if (defienjeu_courant == nb_defienjeu)
	{
		window.bandeau.scrollTo(0,0);
		defienjeu_courant = 1;
	}
	else
	{
		window.bandeau.scrollBy(300,0);
		defienjeu_courant++;
	}
}

function scrolldroitehomepage(nb_actionprio){
	if (actionprio_courant == nb_actionprio)
	{
		window.bandeau.scrollTo(0,0);
		actionprio_courant = 1;
	}
	else
	{
		window.bandeau.scrollBy(211,0);
		actionprio_courant++;
	}
}

function scrollgauchehomepage(nb_actionprio){
	if (actionprio_courant == 1)
	{
		window.bandeau.scrollTo(211*nb_actionprio,0);
		actionprio_courant = nb_actionprio;
	}
	else
	{
		window.bandeau.scrollBy(-211,0);
		actionprio_courant--;
	}
}


function scrollinit(numBloc)
{
	window.scrollBy((numBloc-1)*168,0);
}

function redir_form(page)
{	
	window.location=""+page;
}

function Onsubmit()
{
    document.recherche_simple.submit();
}

function Onsubmitbis()
{
    document.recherche_avance.submit();
}

function formRechercheSimple()
{
    var texte;
    var pageLength;
    texte=window.document.recherche_simple.texte.value;
    pageLength=window.document.recherche_simple.pageLength.value;
    window.location = 'index_recherche.php?texte='+escape(texte)+'&pageLength='+escape(pageLength)+'&form=1';
}

function formRechercheAvance()
{
    var texte;
    var m_groupe;
    var m_cp;
    var t_finances;
    var t_innovation;
    var t_industriel;
    var m_dp;
    var m_magazine;
    var date1;
    var date2;
    var dateop;
    var pageLength;
    var form;
    form=1;

    texte=window.document.recherche_avance.texte.value;

    if(window.document.recherche_avance.m_groupe && window.document.recherche_avance.m_groupe.checked)
        m_groupe=window.document.recherche_avance.m_groupe.value;
    else
        m_groupe='';

    if(window.document.recherche_avance.m_cp && indow.document.recherche_avance.m_cp.checked)
        m_cp=window.document.recherche_avance.m_cp.value;
    else
        m_cp='';

    if(window.document.recherche_avance.t_finances && window.document.recherche_avance.t_finances.checked)
        t_finances=window.document.recherche_avance.t_finances.value;
    else
        t_finances='';

    if(window.document.recherche_avance.t_innovation && window.document.recherche_avance.t_innovation.checked)
        t_innovation=window.document.recherche_avance.t_innovation.value;
    else
        t_innovation='';

    if(window.document.recherche_avance.t_industriel && window.document.recherche_avance.t_industriel.checked)
        t_industriel=window.document.recherche_avance.t_industriel.value;
    else
        t_industriel='';

    if(window.document.recherche_avance.m_dp && window.document.recherche_avance.m_dp.checked)
        m_dp=window.document.recherche_avance.m_dp.value;
    else
        m_dp='';

    if(window.document.recherche_avance.m_magazine && window.document.recherche_avance.m_magazine.checked)
        m_magazine=window.document.recherche_avance.m_magazine.value;
    else
        m_magazine='';

    dateop=window.document.recherche_avance.dateop.value;
    pageLength=window.document.recherche_avance.pageLength.value;

    date1=window.document.recherche_avance.date1.value;
    date2=window.document.recherche_avance.date2.value;

    window.location = 'index_recherche.php?texte='+escape(texte)+'&m_groupe='+escape(m_groupe)+'&m_cp='+escape(m_cp)+'&t_finances='+escape(t_finances)+'&t_innovation='+escape(t_innovation)+'&t_industriel='+escape(t_industriel)+'&m_dp='+escape(m_dp)+'&m_magazine='+escape(m_magazine)+'&date1='+escape(date1)+'&date2='+escape(date2)+'&dateop='+escape(dateop)+'&pageLength='+escape(pageLength)+'&form=1';
}

var isDOM = (document.getElementById) ? true : false;
var isIE = ((navigator.appName).indexOf("Microsoft")>-1) ? true : false;
var isNS4 = (!document.all && !document.getElementById) ? true : false;
var isNS7 = (!document.all && document.getElementById && !isIE) ? true : false;

function centrerLayer (calqueNom,largeurSite,divSitePosition) //PC = NS 4.7+ et IE 5+ || MAC = NS 4.7+ et IE 5.1+
{
	if(!isIE)
	{
		var divRef = MM_findObj(calqueNom);
		var winLargeur = (document.all) ? document.body.clientWidth : window.innerWidth;
	
		if (isNS7)
		{
//		alert("divRef="+divRef);
//		alert("winLargeur="+winLargeur);
//		alert("divSitePosition="+divSitePosition);
		var posCentre = (winLargeur>largeurSite) ? ((winLargeur - largeurSite)/2)+divSitePosition-(winLargeur-window.document.width)/2: divSitePosition;
//		alert("posCentre="+posCentre);
		}
		else  //utile pour NS4
		{
		var posCentre = (winLargeur>(largeurSite+23)) ? ((winLargeur - largeurSite)/2)+divSitePosition-8: divSitePosition+8;
		}
	
		posCentre = Math.floor(posCentre);
		if (isIE || isNS7)
		divRef.style.left = posCentre+"px";
		else  //utile pour NS4
		divRef.left = posCentre;

//		alert("divRef.style.left="+divRef.style.left);
//		alert("posCentre="+posCentre);
	}
}

function glossaire(word, content)
{
	var myDefinition = "<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr><td bgcolor='#C1C1B9' align='left'><table border='0' cellpadding='0' cellspacing='0'><tr><td width='20' valign='baseline'><img src='../imgs/visu_glossaire02.gif' vspace='2' alt='' /></td><td class='noir11'><b>"+word+"</b></td></tr></table></td></tr><tr><td><img src='../imgs/blank.gif'  width='1' height='9' alt='' /><br /><table border='0' cellpadding='0' cellspacing='0'><tr><td width='20'>&nbsp;</td><td align='left' class='noir11'>"+content+"</td><td width='20'>&nbsp;</td></tr></table><img src='../imgs/blank.gif' width='1' height='9' alt='' /><br /></td></tr></table>";
	return myDefinition;
}









function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//--Changement de style de td
var liste_tab_ouverts = new Array();
function switchbgd(IDnumber,IDclass,sens)
{
//	alert((sens==-1 && liste_tab_ouverts[IDnumber]==false)+"-"+(sens==1 && liste_tab_ouverts[IDnumber]==true));
//	document.all[IDnumber].className = ((sens==-1 && liste_tab_ouverts[IDnumber]==false) || (sens==1 && liste_tab_ouverts[IDnumber]==true)) ? IDclass+"On" : IDclass+"Off";
//	alert(liste_tab_ouverts[IDnumber]);
	if (!liste_tab_ouverts[IDnumber])
	liste_tab_ouverts[IDnumber]=false;

	if (sens==1)
	{
		if (document.all)
		document.all[IDnumber].className = (liste_tab_ouverts[IDnumber]==false) ? IDclass+"On" : IDclass+"Off";
		else
		document.getElementById(IDnumber).className = (liste_tab_ouverts[IDnumber]==false) ? IDclass+"On" : IDclass+"Off";
	}
	else
	{
		if (document.all)
		document.all[IDnumber].className = (liste_tab_ouverts[IDnumber]==false) ? IDclass+"Off" : IDclass+"On" ;
		else
		document.getElementById(IDnumber).className = (liste_tab_ouverts[IDnumber]==false) ? IDclass+"Off" : IDclass+"On" ;
	}
}
//-----------------------------
//--Afficher ou masquer une zone
function afficher_masquer(zone_id)
{
	parametres = afficher_masquer.arguments;
	if (parametres[1])
	{
		for(i=1;i<=parametres[2];i++)
		{
			if (i!==parametres[1])
			{
			liste_tab_ouverts[parametres[4]+i]=!liste_tab_ouverts[parametres[4]+i];

			if (parametres[4] && parametres[5])
			switchbgd(parametres[4]+i,parametres[5],liste_tab_ouverts[parametres[4]+i]);

			if (i==parametres[6])
			liste_tab_ouverts[parametres[4]+i]=true;
			else
			liste_tab_ouverts[parametres[4]+i]=false;

			liste_tab_ouverts[parametres[0]+i]=false;
			MM_findObj(zone_id+i).style.display = 'none';
			}
		}
	zone_id = parametres[0]+parametres[1];
	}

	if (!(parametres[3] && MM_findObj(zone_id).style.display!=='none'))
	{
	liste_tab_ouverts[parametres[4]+parametres[1]]=!liste_tab_ouverts[parametres[4]+parametres[1]];

	liste_tab_ouverts[zone_id]=!liste_tab_ouverts[zone_id];
	MM_findObj(zone_id).style.display = (MM_findObj(zone_id).style.display=='none' || parametres[3]) ? 'block' : 'none';
	}
}



function afficher_masquer_prog(zone_id)
{
	liste_tab_ouverts[zone_id]=!liste_tab_ouverts[zone_id];
	
	if (MM_findObj(zone_id+"_on").style.display=='none'){
		MM_findObj(zone_id+"_on").style.display = 'block';
		MM_findObj(zone_id).style.display = 'none';
	}
	
	for(i=1; i<4; i++){
		if(zone_id!="ttl0"+i && MM_findObj("ttl0"+i)){
			MM_findObj("ttl0"+i+"_on").style.display = 'none';
			MM_findObj("ttl0"+i).style.display = 'block';
		}
	}

}

function masquer_prog(zone_id)
{
	
	for(i=1; i<4; i++){
		if(zone_id!="ttl0"+i && MM_findObj("ttl0"+i)){
			MM_findObj("ttl0"+i+"_on").style.display = 'none';
			MM_findObj("ttl0"+i).style.display = 'block';
		}
	}

}


function calcHeightIframe(ifrmObj)
{
	var x,y;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) // all but Explorer Mac
	{
		y = document.body.scrollHeight;
	}
	else // Explorer Mac;
		 //would also work in Explorer 6 Strict, Mozilla and Safari
	{
		y = document.body.offsetHeight;
	}

	var the_height=ifrmObj.contentWindow.document.body.scrollHeight;//find the height of the internal page
	ifrmObj.height=the_height;//change the height of the iframe
	//alert(ifrmObj.contentWindow.document.body.offsetHeight);
}
