    window.onload=menu_left;

var Engine = {
    detect: function() {
      var UA = navigator.userAgent;
      this.isKHTML = /Konqueror|Safari|KHTML/.test(UA);
      this.isGecko = (/Gecko/.test(UA) && !this.isKHTML);
      this.isOpera = /Opera/.test(UA);
      this.isMSIE  = (/MSIE/.test(UA) && !this.isOpera);
      this.isMSIE7 = this.isMSIE && !(/MSIE 6\./.test(UA) && !this.isOpera);
    }
}

Engine.detect();


function getInt(n) {
    // returns always an integer
    n = parseInt(n);
    if (isNaN(n)) return 0;
    return n;
}
/*
 * Position class
 */
function Position(x, y) {
    this.x = parseFloat(x);
    this.y = parseFloat(y);
    return this;
}

Position.prototype.toString = function() {
    return this.x + "," + this.y;
}

function getElementPosition(elem) {
    // returns a Position with the position of the element
    var x = 0;
    var y = 0;
    if (elem.offsetParent) {
        // use .offsetLeft for most browsers
        var e = elem;
        while (e) {
            if (Engine.isMSIE) {
                if (Engine.isMac) {
                    // IE for Mac extraspecial
                    if (e.offsetParent.tagName == "BODY") {
                        x += e.clientLeft;
                        y += e.clientTop;
                        break;
                    }
                } else {
                    // special for IE
                    if ((e.tagName != "TABLE") && (e.tagName != "BODY")) {
                        x += e.clientLeft;
                        y += e.clientTop;
                    }
                }
            }
            x += e.offsetLeft;
            y += e.offsetTop;
            e = e.offsetParent;
        }
    } else if (defined(elem.x)) {
        // use .x for other (which?)
        x = elem.x;
        y = elem.y;
    } else if (defined(elem.pageX)) {
        // use pageX for N4
        x = elem.pageX;
        y = elem.pageY;
    } else {
        alert("unable to get position of "+elem+" (id:"+elem.id+")");
    }
    return new Position(getInt(x), getInt(y));
}



function init_menu_atmb(lang)
{
 //entreprise = Element.getDimensions('menuEntreprise-content');
 tunnel     = Element.getDimensions('menuTunnel-content');
 autoroute  = Element.getDimensions('menuAutoroute-content');
 preparez   = Element.getDimensions('menuPreparez-content');
 presse     = Element.getDimensions('menuPresse-content');
 tourisme   = Element.getDimensions('menuTourisme-content');


  //////////////////////////////////// IE
  if (Engine.isMSIE) {
      if (lang=='fr') {

      }
  }

  //////////////////////////////////// IE7
  if (Engine.isMSIE7) {


  }
  //////////////////////////////////// FIREFOX
  else {
      e = Element.getDimensions('menuEntreprise-content');

      }
}



	function AjaxGetTourismeInfoBox(id_article, lang)
   {
//		var url = '?page=inc-atmb-tourisme-infobox';		
//      var pars = 'id_article='+id_article+'&lang='+lang;		
 		var url = '/inc-atmb-tourisme-infobox/'+lang+'/-/-/?id_article='+id_article;	
        var pars = 'tme=ee';
        //alert(url+pars);
	    //alert(url+pars);
    
        Ajax.Responders.register({
          onCreate: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount>0)
              Effect.Appear('jobAjaxMainContent',{duration:0.2,queue:'end'});
          },
          onComplete: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount==0)
              Effect.Fade('jobAjaxMainContent',{duration:0.2,queue:'end'});
          }
        });
	   
       var myAjax = new Ajax.Updater
       ( 
        {success: 'right_content-tourisme-ajax'}, 
        url,
        { method: 'get', parameters: pars }
        );        
	}
    

	function AjaxGetUrl(noeud, lang, content)
   {
		var url = '?page=inc-atmb-ajax';		
        var pars = 'id_rubrique='+noeud+'&lang='+lang+'&content='+content;		
	    //alert(url+pars);
	   //alert(url+pars);
	   
        Ajax.Responders.register({
          onCreate: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount>0)
              Effect.Appear('jobAjaxMainContent',{duration:0.2,queue:'end'});
          },
          onComplete: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount==0)
              Effect.Fade('jobAjaxMainContent',{duration:0.2,queue:'end'});
          }
        });
	   
       var myAjax = new Ajax.Updater
       ( 
        {success: 'main_content'}, 
        url,
        { method: 'get', parameters: pars }
        );        
	}
    
    
	function AjaxRefreshPath(noeud, lang)
   {
		var url = '?page=inc-atmb-path';		
        var pars ;
		
        pars = 'id_rubrique='+noeud+'&lang='+lang;
	    //alert(url+pars);
	    //alert(url+pars);
	   
        Ajax.Responders.register({
          onCreate: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount>0)
              Effect.Appear('jobAjaxMainContent',{duration:0.2,queue:'end'});
          },
          onComplete: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount==0)
              Effect.Fade('jobAjaxMainContent',{duration:0.2,queue:'end'});
          }
        });
	   
       var myAjax = new Ajax.Updater
       ( 
        {success: 'main-path-content'}, 
        url,
        { method: 'get', parameters: pars }
        );        
	}

	function AjaxRefreshInfoBox(noeud, lang)
   {
		var url = '?page=inc-atmb-content-right';		
        var pars ;
		
        pars = 'id_rubrique='+noeud+'&lang='+lang;
	    //alert(url+pars);
	    //alert(url+pars);
	   
        Ajax.Responders.register({
          onCreate: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount>0)
              Effect.Appear('jobAjaxMainContent',{duration:0.2,queue:'end'});
          },
          onComplete: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount==0)
              Effect.Fade('jobAjaxMainContent',{duration:0.2,queue:'end'});
          }
        });
	   
       var myAjax = new Ajax.Updater
       ( 
        {success: 'info-box'}, 
        url,
        { method: 'get', parameters: pars }
        );        
	}



   function AjaxGetSearch(lang, recherche)
   {
		var url = 'atmb/inc-ajax-recherche.php';
		
        var pars = 'recherche='+recherche+'&lang='+lang;		
       
	   //alert(url+pars);
	   
        Ajax.Responders.register({
          onCreate: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount>0)
              Effect.Appear('jobAjaxMainContent',{duration:0.2,queue:'end'});
          },
          onComplete: function() {
            if($('jobAjaxMainContent') && Ajax.activeRequestCount==0)
              Effect.Fade('jobAjaxMainContent',{duration:0.2,queue:'end'});
          }
        });
	   
       var myAjax = new Ajax.Updater
       ( 
        {success: 'search-content-result'}, 
        url,
        { method: 'get', parameters: pars }
        );        
	}

  function menu_left(id, noeud, lang, content)/* id:Number */ {
  	// deselectionne tout

    for (var i = 1; i<=10; i++) {
  		if ($('dd_smenu'+i)) {$('dd_smenu'+i).style.display='none';}
  		if ($('dt_smenu'+i)) {$('dt_smenu'+i).className='';}
  	}
  	// selectionne 
    if ($('dd_smenu'+id)) {
    $('dd_smenu'+id).style.display='block';

    //new Effect.BlindDown($('dd_smenu'+id));

      $('dt_smenu'+id).className='selected';      
    for(var j=1; j<=10; j++) {if($('dd_'+id+'_li_'+j)) {$('dd_'+id+'_li_'+j).className='';};}     
      if ($('dd_'+id+'_li_1')){
      $('dd_'+id+'_li_1').className='current';
      //new Effect.Highlight('dd_'+id+'_li_1');
      }
    }
    
    //rafraichissement main_content
    //alert('noeud='+noeud+ ',lang='+lang+',content='+ content);

	
	//?page=atmb&content=preparez&id_rubrique=9&lang=fr
    if ( noeud==55 && content=='preparez') {
        window.location='?page=atmb&content=preparez&id_rubrique=9&lang='+lang;	
	} 
    //?page=atmb&content=autoroute&id_rubrique=8&lang=fr
    else if ( noeud==30 && content=='autoroute') {
        //alert('Webtrafic');
        //AjaxGetUrl(130, lang, 'autoroute');
        window.location='?page=atmb&content=autoroute&id_rubrique=130&lang='+lang;
    } else {

        AjaxGetUrl(noeud, lang, content);
        AjaxRefreshPath(noeud, lang);
        AjaxRefreshInfoBox(noeud, lang);//rafraichissement info_box
    }

    
    //AjaxGetInfoBox(noeud, lang);

}



//--------------------------------------------
// déclaration des calques et de leur position
// 1 = Entreprise
// 2 = Tunnel du Mont Blanc
// 3 = L'Autoroute Blanche
// 4 = Préparez votre voyage
// 5 = Tourisme
// 6 = Espace presse
// 7 = Flash Info
//--------------------------------------------
var tblCalques = ['', 'menuEntreprise', 'menuTunnel', 'menuAutoroute', 'menuPreparez', 'menuTourisme', 'menuPresse', 'cFlash'];
var tblPosX = [0, 0, 0, 0, 0, 0, 0, 0];
var tblPosXfilet = [0, 8, 121, 263, 381, 510, 574, -1];
var timerMasqueCalque;		// timer utilisé pour masque les calques après un certain délai
var delaiMasquage = 2000; 	// délai après lequel les calques des menus sont effacés 

//------------------------------------------------------------------------------------------
// on fait en sorte qu'à chaque redimensionnement de fenêtre, les calques de menu s'effacent
//------------------------------------------------------------------------------------------
function MM_reloadPage(lang) {
	if (lang == 'en') {
		tblPosX = [0, 0, 0, 0, 0, 0, 0, 0];
		tblPosXfilet = [0, 8, 121, 263, 385, 516, 574, -1];
	}
	else if (lang == 'it') {
		tblPosX = [0, 0, 0, 0, 0, 0, 0, 0];
		tblPosXfilet = [0, 8, 121, 263, 385, 510, 574, -1];
	}
	
    //positionnement selon navigateur !!!
    
    
	if (!document.MM_init) {
		// si on est sous NS6
		if (navigator.vendor) {
			if (navigator.vendor.toLowerCase().indexOf('netscape6') != -1)
				document.MM_navig = 'ns6';
			// sinon on considère qu'on est sous NS7 ayant les même propriétés que IE5
			else
				document.MM_navig = 'ie5';
		}

		// Si on est sous IE5+ ou NS7+
		else if (document.getElementById)
			document.MM_navig = 'ie5';

		// Si on est sous IE4
		else if ((document.all)&&(!document.getElementById))
			document.MM_navig = 'ie4';
		
		// Si on est sous NS4.x
		else if (document.layers)
			document.MM_navig = 'ns4';

		if (document.MM_navig == 'ns6')
			document.MM_pgW = document.width;
		else if (document.body.clientWidth)
			document.MM_pgW = document.body.clientWidth;
		else
			document.MM_pgW = window.innerWidth;

		document.MM_init = true;
		//onresize = MM_reloadPage;
		
		afficheFlash();
		statusATMB();
	}
	
	else {
		if (document.MM_navig == 'ns6') {
			if (document.MM_pgW != document.width)
				MasqueTous();
		}
		else if (document.body.clientWidth) {
			if (document.MM_pgW != document.body.clientWidth)
				MasqueTous();
		}
		else (window.innerWidth != document.MM_pgW)
			MasqueTous();
			
		afficheFlash();
	}
}

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; }
}

//------------------------------------------------------------------
// Exemple: AfficheCalque(1);
//------------------------------------------------------------------
function AfficheCalque(num) {
	MasqueTous();
	// largeur du tableau de la page
	wlarg_tab = 1003;	
	wdecalage = 0;

	// Nom du calque à afficher
	nom = tblCalques[num];
	nomFilet = nom + "Filet";
	
	// largeur de la fenêtre du navigateur
	// si on est sous NS6
	if (document.MM_navig == 'ns6')
		wlarg_nav = document.width;

	// Si on est sous IE4, IE5 ou NS7
	else if (document.body.clientWidth)
		wlarg_nav = document.body.clientWidth;

	// Si on est sous NS4.x ou N7+
	else 
		wlarg_nav = window.innerWidth;		

	// position des calques menu
	wleft_menu = Math.round((wlarg_nav-wlarg_tab)/2) - wdecalage + tblPosX[num];
	wleft_menu_Filet = Math.round((wlarg_nav-wlarg_tab)/2) - wdecalage + tblPosXfilet[num];

	// Si on est sous IE5 ou NS6
	if (document.MM_navig == 'ie5' || document.MM_navig == 'ns6') {
		document.getElementById(nom).style.left = wleft_menu;
		document.getElementById(nom).style.visibility = 'visible';	
		if (num != 7) {
			document.getElementById(nomFilet).style.left = wleft_menu_Filet;
			document.getElementById(nomFilet).style.visibility = 'visible';		
		}
	}

	// Si on est sous IE4
	if (document.MM_navig == 'ie4')	{
		document.all[nom].style.left = wleft_menu;
		document.all[nom].style.visibility = 'visible';
		if (num != 7) {
			document.all[nomFilet].style.left = wleft_menu_Filet;
			document.all[nomFilet].style.visibility = 'visible';
		}
	}
	
	// Si on est sous NS4.x
	if (document.MM_navig == 'ns4') {
		document.layers[nom].left = wleft_menu;
		document.layers[nom].visibility = 'visible';		
		if (num != 7) {
			document.layers[nomFilet].left = wleft_menu_Filet;
			document.layers[nomFilet].visibility = 'visible';		
		}
	}
}

//------------------------------------------------------------------
// Exemple 1: MasqueCalque(1)    --> masque le calque 1 immédiatement
// Exemple 2: MasqueCalque(1, 2) --> masque le calque 1 après un délai de 2 secondes
//------------------------------------------------------------------
function MasqueCalque(num, delai) {
	if (delai)
		timerMasqueCalque = setTimeout('MasqueCalque(' + num + ')', delaiMasquage);
	else {
		MM_showHideLayers(tblCalques[num],'','hide');
		if (num != 7)
			MM_showHideLayers(tblCalques[num]+'Filet','','hide');
	}
}

function MasqueTous() {
	stopMasqueCalque();
	for(i=1;i<7;i++)
		MasqueCalque(i);
}

function stopMasqueCalque() {
	clearTimeout(timerMasqueCalque);
}

// fonction d'affichage du module Flash Infos dans le bandeau supérieur sur la HP
function afficheFlash() {
	if (MM_findObj('cFlash')) {
			AfficheCalque(7);
	}
}


function go_impression(page)
	{
	//window.open('/atmb/atmb_impression.php?page='+page, 'impression', 'width=100, height=100, top=3000, left=3000');
	//var Win = window.open('/atmb/atmb_impression.php?page='+page, 'impression');
    window.open('/atmb/atmb_impression.php?page='+page, 'impression');
    //Win.print();
    //setTimeout('Win.close();', 1000);

	}
	
function impression()
	{
	    self.print();
	    //setTimeout('self.close();', 1000);
	}
	
function go_ami(page,lang)
	{
	window.open('?page=atmb_email_ami_popup&'+'&url='+page+'&lang='+lang,'popup','scrollbars=yes,width=575,height=600');
	}
	
function go_popup_parent(page, rub, art, lang)
	{
	top.window.opener.location.href = 'atmb_'+page+'.php?id_rubrique='+rub+'&id_article='+art+'&lang='+lang;
	self.close();
	}
	
function statusATMB() {
	// window.status = 'Bienvenue sur atmb.net';
	// setTimeout('statusATMB()', 50);
}

function popup(url, titre, largeur, hauteur, scroll)
  {
  //lancement de popup (utilisé pour atmb_concours_accueil_popup.php)
window.open(url, titre, 'width=' + largeur + ', height=' + hauteur + ', scrollbars=' + scroll);
}


function AfficheInfo(num,left)
	{
	// Masque ttes les infos
	MasqueInfoTout();

	// largeur du tableau de la page
	wlarg_tab = 773;	
	wdecalage = 0;

	// Nom du calque à afficher
	nom = 'info' + num;
	
	// largeur de la fenêtre du navigateur
	// Si on est sous IE5 ou NS6
	if (document.getElementById)
		{
		wlarg_nav = document.body.clientWidth;
		}

	// Si on est sous IE4
	if ((document.all)&&(!document.getElementById))
		{
		wlarg_nav = document.body.clientWidth;
		}
	
	// Si on est sous NS4.x
	if (document.layers)
		{
		wlarg_nav = window.innerWidth		
		}

	wleft_info = left + Math.round((wlarg_nav-wlarg_tab)/2);

	// Si on est sous IE5 ou NS6
	if (document.getElementById)
		{
		document.getElementById(nom).style.left = wleft_info;
		document.getElementById(nom).style.visibility = 'visible';		
		}

	// Si on est sous IE4
	if ((document.all)&&(!document.getElementById))
		{
		document.all[nom].style.left = wleft_info;
		document.all[nom].style.visibility = 'visible';
		}
	
	// Si on est sous NS4.x
	if (document.layers)
		{
		document.layers[nom].left = wleft_info;
		document.layers[nom].visibility = 'visible';		
		}

}

function MasqueInfo(nom) {
	// Si on est sous IE5 ou NS6
	if (document.getElementById)
		{
		document.getElementById(nom).style.visibility = 'hidden';		
		}
	// Si on est sous IE4
	if ((document.all)&&(!document.getElementById))
		{
		document.all[nom].style.visibility = 'hidden';
		}
	// Si on est sous NS4.x
	if (document.layers)
		{
		document.layers[nom].visibility = 'hidden';		
		}
}

function MasqueInfoTout() {
	for(i=1;i<=4;i++)
		{
		wnom = "info" + i;
		MasqueInfo(wnom);
		}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}





