// JavaScript Document

	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 OpenPopupWindow (sURL,w,h) {
      param="top=20,left=20,width=" + w + ",height=" + h + ",toolbar=no,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no";
  	  hWnd=window.open(sURL,"Hwnd",param);
	  hWnd.focus();
    }

  function OpenWindow (WindowID) {
	  document.getElementById(WindowID).style.visibility = "visible" ;
  }

  function CloseWindow (WindowID) {
	  document.getElementById(WindowID).style.visibility = "hidden" ;
  }

// Gestion de la barre de status---- ----------------------------------------------------------------

   function HideStatus(){
     window.status=''
     return true
   }
    if (document.layers) document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
    document.onmouseover=HideStatus
    document.onmouseout=HideStatus
	
    function error () { 
	  return true; 
	}
    window.onerror = error;

    var phrase="                                                               ";
    window.status="";
    transi="";
    var i=0;
    function affiche() {
      if(i>phrase.length-1) {
        window.status="";
        transi="";
        i=0;
      } 
	  else {
        transi=transi+phrase.charAt(i);
        window.status=transi;
        i=i+1;
      }
    }
    setInterval("affiche()",100);

// Gestion du volet de la galerie de photo ----------------------------------------------------------

   function view (photo) {
	 document.getElementById("ViewPhoto").src=photo ;
   }

   function ViewLargePhoto (photo, description) {
     ActiverViewer();
     if (document.all) {
	   document.images.ViewPhoto.style.filter="blendTrans(duration=0.4)" ;
       document.images.ViewPhoto.filters.blendTrans.Apply() ;
       document.images.ViewPhoto.filters.blendTrans.Play() ;
	 }
//   playSound(4); 
	 document.images.ViewPhoto.src=photo;
	 document.getElementById("txtDescription").innerHTML = description;
   }

  var timer1 = null;
  var timer2 = null ;
  var r = -5 ;
  var s = 376 ;
  
  function RentrerViewer() {
	if (r < 381) {
	  document.getElementById("VoletViewer").style.left = r ;
	  timer1 = setTimeout("RentrerViewer()", 1);
	  r=r+4
	}
	else {
	  r=-5 ; 
	  clearTimeout(timer1);
	 }
  }

  function SortirViewer() {
	if (s > -27) {
	  document.getElementById("VoletViewer").style.left = s ;
	  timer2 = setTimeout("SortirViewer()", 1);
	  s=s-4
	}
	else {
	  s=376 ; 
	  clearTimeout(timer2);
	}
  }

  function ActiverViewer() {
	if (parseInt(document.getElementById("VoletViewer").style.left) > 375) {
      playSound(2); 
 	  SortirViewer() ;
   	  document.getElementById("ZoneCdeViewer").innerHTML = "&laquo; <a href='javascript:DesactiverViewer()'>Fermer la galerie de photos</a>" ;
	}
  }

  function DesactiverViewer() {
	if (parseInt(document.getElementById("VoletViewer").style.left) < 0) {
      playSound(2); 
	  RentrerViewer() ;
   	  document.getElementById("ZoneCdeViewer").innerHTML = "&laquo; <a href='javascript:ActiverViewer()'>Ouvrir la galerie de photos</a>" ;
	}
  }
  
  function SurvolVignette(obj) { 
    if(obj && obj.filters[0]) {
     obj.filters[0].apply();
     obj.visibility="visible";
     obj.filters[0].play();
    }
  }

// Gestion des fonctions vidéo Playa ----------------------------------------------------------------

   function ViewVideoFLV (NoVideo,description) {
     PauseMusicDeFond ();
	 if (parseInt(document.getElementById("VoletViewer").style.left) > 0) {
        ActiverViewerVideo();
        LancerLaVideo (NoVideo)
	 }
	 else {
        playSound(5); 
	    play(NoVideo);
	 }
   }
  
   function ViewVideoFLV2 (NoVideo,description) {
     ActiverViewerVideo();
     play(NoVideo);
	 document.getElementById("txtDescription").innerHTML = description ;
   }

// Gestion du volet viewer video (page television.asp) ----------------------------------------------

  function ActiverViewerVideo() {
	if (parseInt(document.getElementById("VoletViewer").style.left) > 375) {
      if (document.all) {
	    document.getElementById("viewerVideoFLVPlayer").style.display ="block"; 
	  }
	  else {
	    MontrerViewerVideoFLVPlayer ();
	  }
 	  document.getElementById("ZoneCdeViewer").innerHTML = "&laquo; <a href='javascript:DesactiverViewerVideo()'>Fermer la galerie de videos</a>" ;
      playSound(2); 
      SortirViewer() ;
	}
  }

  function DesactiverViewerVideo() {
	if (parseInt(document.getElementById("VoletViewer").style.left) < 0) {
	  stop() ;
	  CacherViewerVideoFLVPlayer ();
      playSound(2); 
	  RentrerViewer() ;
   	  document.getElementById("ZoneCdeViewer").innerHTML = "&laquo; <a href='javascript:ActiverViewerVideo()'>Ouvrir la galerie de videos</a>" ;
      InitMusicDeFond ();
	}
  }
  
  var timer20 = null ;
  var timer21 = null ;
  t=0;
  
  function LancerLaVideo (v) {
    if (t<3) {
	  t++
	  timer21 = setTimeout("LancerLaVideo(" + v +")", 600);
	}
	else {
	  t=0;
	  play(v);
	  clearTimeout(timer21);
	}
  }
  
  function CacherViewerVideoFLVPlayer () {
	  document.getElementById("viewerVideoFLVPlayer").style.display ="none";
  }

  function MontrerViewerVideoFLVPlayer () {
    if (t<3) {
	  t++
	  timer20 = setTimeout("MontrerViewerVideoFLVPlayer()", 300);
	}
	else {
	  t=0;
	  document.getElementById("viewerVideoFLVPlayer").style.display ="block";
	  clearTimeout(timer20);
	}
  }

// Gestion des fonctions vidéo Wasp -----------------------------------------------------------------

   function ViewVideoWasp (Video,description) {
     PauseMusicDeFond ();
	 if (parseInt(document.getElementById("VoletViewer").style.left) > 0) {
        ActiverViewerVideo();
	    wasp_load('0809011918',Video,'/mgp/wasp/default-cover.jpg','true');
	 }
	 else {
        playSound(5); 
	    wasp_load('0809011918',Video,'/mgp/wasp/default-cover.jpg','true');
	 }
   }
  
// gestion du mini viewer video wasp --------------------------------------------------------
  
  function Video (Video,Titre) {
    document.getElementById("MiniViewerWasp").style.filter="alpha(opacity=100)" ;
	document.getElementById('MiniViewerWasp').style.visibility = "visible" ;
	document.getElementById('TitreViewerWasp').innerHTML = "&nbsp;" + Titre;
	PauseMusicDeFond ();
    playSound(5); 
	wasp_load('0809011918','/mgp/videos/'+Video,'/mgp/wasp/default-cover.jpg','true');
  }

  function CloseViewerWasp () {
	document.getElementById("MiniViewerWasp").style.visibility = "hidden" ;
    playSound(5); 
	InitMusicDeFond ();
  }

// gestion du mini viewer video Playa -------------------------------------------------------

  function OuvrirViewerVideo () {
    document.getElementById("ViewerVideo").style.filter="alpha(opacity=100)" ;
	document.getElementById("ViewerVideo").style.visibility = "visible" ;
  }

  var timer7 = null ;
  L=0
  function OuvrirViewerVideo2 () {
    if (L<1) {
	  document.getElementById("ViewerVideo").style.opacity=(1) ;
	  document.getElementById("ViewerVideo").style.KhtmlOpacity=(1) ;
	  document.getElementById("ViewerVideo").style.MozOpacity=(1) ;
      document.getElementById("ViewerVideo").style.filter="alpha(opacity=100)" ;
	  document.getElementById("ViewerVideo").style.visibility = "visible" ;
      timer7 = setTimeout("OuvrirViewerVideo2 ()",50) ;
    }
	else {
	  L=0 ;
	  clearTimeout(timer7) ;
	}
  }

  noVideo=0
  titreVideo=""
  d=0
  function AfficherLaVideo () {
    if (d<1) {
      timer7 = setTimeout("AfficherLaVideo ()",400) ;
	  d++
    }
	else {
	  d=0 ;
	  clearTimeout(timer7) ;
      document.getElementById("TitreViewer").innerHTML = "&nbsp;" + titreVideo ;
      play(noVideo) ;
	}
  }
  
  function VoirUneVideo (v,titre) {
    stop() ;
	PauseMusicDeFond ();
    playSound(5); 
	OuvrirViewerVideo2 () ;
	noVideo = v ;
	titreVideo = titre;
	AfficherLaVideo ();
  }

  function FermerViewerVideo () {
    stop() ;
    playSound(5); 
	document.getElementById("ViewerVideo").style.visibility = "hidden" ;
	InitMusicDeFond ();
  }
  
  
// Gestion des fenêtres calendriers --------------------------------------------------

  var timer4 = null ;
  j=0
  
  function OuvrirCalqueCalendrier () {
    if (j<167) {
	  document.getElementById("Calendrier").style.left = 702-j ;
	  document.getElementById("Calendrier").style.top  = 227-j ;
	  document.getElementById("Calendrier").style.width = 2*j;
	  document.getElementById("Calendrier").style.height = 2*j ;
      timer4 = setTimeout("OuvrirCalqueCalendrier ()",1) ;
	  i = i+10
    }
	else {
	  i = 0 ;
	  clearTimeout(timer4) ;
	}
  }
  
  function ActiverCalqueCalendrier1 () {
    if (j<101) {
	  document.getElementById("Calendrier1").style.opacity=(j/100) ;
	  document.getElementById("Calendrier1").style.MozOpacity=(j/100) ;
	  document.getElementById("Calendrier1").style.KhtmlOpacity=(j/100) ;
	  document.getElementById("Calendrier1").style.filter="alpha(opacity="+j+")" ;
	  document.getElementById("Calendrier1").style.visibility = "visible" ;
      timer4 = setTimeout("ActiverCalqueCalendrier1 ()",1) ;
	  j = j+10
    }
	else {
	  j = 0 ;
	  clearTimeout(timer4) ;
	}
  }

  function ActiverCalqueCalendrier2 () {
    if (j<101) {
	  document.getElementById("Calendrier2").style.opacity=(j/100) ;
	  document.getElementById("Calendrier2").style.MozOpacity=(j/100) ;
	  document.getElementById("Calendrier2").style.KhtmlOpacity=(j/100) ;
	  document.getElementById("Calendrier2").style.filter="alpha(opacity="+j+")" ;
	  document.getElementById("Calendrier2").style.visibility = "visible" ;
      timer4 = setTimeout("ActiverCalqueCalendrier2 ()",1) ;
	  j = j+10
    }
	else {
	  j = 0 ;
	  clearTimeout(timer4) ;
	}
  }

  function DesactiverCalquesCalendrier () {
	document.getElementById("Calendrier1").style.visibility = "hidden" ;
	document.getElementById("Calendrier2").style.visibility = "hidden" ;
  }

  function DesactiverCalqueCalendrier1 () {
    playSound(5); 
	document.getElementById("Calendrier1").style.visibility = "hidden" ;
  }

  function DesactiverCalqueCalendrier2 () {
    playSound(5); 
	document.getElementById("Calendrier2").style.visibility = "hidden" ;
  }

// gestion de l'affichage des revues de presse ---------------------------------------------

  var timer30 = null ;
  j=0;

  function ActiverCalqueRevueDePresse () {
    if (j<101) {
	  document.getElementById("WinPressID").style.opacity=(j/100) ;
	  document.getElementById("WinPressID").style.MozOpacity=(j/100) ;
	  document.getElementById("WinPressID").style.KhtmlOpacity=(j/100) ;
	  document.getElementById("WinPressID").style.filter="alpha(opacity="+j+")" ;
	  document.getElementById("WinPressID").style.visibility = "visible" ;
      timer30 = setTimeout("ActiverCalqueRevueDePresse ()",1) ;
	  j = j+5
    }
	else {
	  j = 0 ;
	  clearTimeout(timer30) ;
//    document.getElementById("AffPressID").style.cursor = "url('/mgp/images/loupe-red.cur')"
//	  document.images.IMGPressID.style.cursor = "url('/mgp/images/close.cur')" ;
	}
  }

  function DesactiverCalqueRevueDePresse () {
    playSound(5); 
	document.getElementById("WinPressID").style.visibility = "hidden" ;
  }

  function AfficherRevueDePresse (i,t,l,h) {
    playSound(5); 
	document.images.IMGPressID.src=i ;
//	document.images.IMGPressID.style.filter = "alpha(opacity=70)" ;
    document.getElementById("WinPressID").style.width  = l ;
    document.getElementById("WinPressID").style.height = h ;
	document.getElementById("TitlePressID").innerHTML = "&nbsp;" + t ;
	ActiverCalqueRevueDePresse ();
   }

  function SetPressPicture (p,t) {
    p = "/mgp/images/presse/"+p;
    objImage = new Image();
    objImage.src=p
    objImage.onLoad=OpenPressPopup(objImage.src,t);
  }

  function OpenPressPopup (p,t) {
    playSound(5); 
    document.images.IMGPressID.src=p;
    largCalc = document.images.IMGPressID.width + 25;
	hautCalc = document.images.IMGPressID.height + 35;
	if (hautCalc > 550) { hautCalc = 550; largCalc = largCalc + 10; }
    document.getElementById("WinPressID").style.width  = largCalc ;
    document.getElementById("WinPressID").style.height = hautCalc ;
	document.getElementById("TitlePressID").innerHTML  = "&nbsp;" + t ;
	ActiverCalqueRevueDePresse ();
   }

// gestion de la musique de fond ----------------------------------------------------------

   function InitMusicDeFond () {
     var musique = LireCookie("PlayMusic");
     if (musique == null) {
       Playa.doPlay();
     } 
	 else {
       if (musique == "Oui") Playa.doPlay();
     }
   }

   var m=0;
   var timer60 = null ;
   function InitMusicDeFond2 () {
     if (m<2) {
       timer60 = setTimeout("InitMusicDeFond2 ()",100) ;
	   m=m+1
    }
	else {
	   m=0 ;
	   clearTimeout(timer60) ;
       var musique = LireCookie("PlayMusic");
       if (musique == null) {
         Playa.doPlay();
       } 
	   else {
         if (musique == "Oui") Playa.doPlay();
       }
	}
   }

   function LireMusicDeFond() {
     Playa.doPlay();
	 date=new Date;
     date.setMonth(date.getMonth()+6);
	 EcrireCookie ("PlayMusic","Oui",date,"/");
   }

   function ArreterMusicDeFond() {
     Playa.doStop();
	 date=new Date;
     date.setMonth(date.getMonth()+6);
	 EcrireCookie ("PlayMusic","Non",date,"/");
   }
   
   function PauseMusicDeFond() {
     Playa.doStop();
   }
   

   function EcrireCookie(nom, valeur) {
     var argv=EcrireCookie.arguments;
     var argc=EcrireCookie.arguments.length;
     var expires=(argc > 2) ? argv[2] : null;
     var path=(argc > 3) ? argv[3] : null;
     var domain=(argc > 4) ? argv[4] : null;
     var secure=(argc > 5) ? argv[5] : false;
     document.cookie=nom+"="+escape(valeur)+
       ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
       ((path==null) ? "" : ("; path="+path))+
       ((domain==null) ? "" : ("; domain="+domain))+
       ((secure==true) ? "; secure" : "");
   }


   function getCookieVal(offset) {
     var endstr=document.cookie.indexOf (";", offset);
     if (endstr==-1) endstr=document.cookie.length;
     return unescape(document.cookie.substring(offset, endstr));
   }

   function LireCookie(nom) {
     var arg=nom+"=";
     var alen=arg.length;
     var clen=document.cookie.length;
     var i=0;
     while (i<clen) {
       var j=i+alen;
       if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
       i=document.cookie.indexOf(" ",i)+1;
       if (i==0) break;
     }
     return null;
   }

   function EffaceCookie(nom) {
      date=new Date;
      date.setFullYear(date.getFullYear()-1);
      EcrireCookie(nom,null,date);
   }

// -----------------------------------------------------------------------------------------

   var aySound = new Array();
   aySound[0] = "/mgp/sons/56.au";
   aySound[1] = "/mgp/sons/vs-036.wav";
   aySound[2] = "/mgp/sons/39.au";           // sonorisation volets galerie photos/vidéos
   aySound[3] = "/mgp/sons/52.au";
   aySound[4] = "/mgp/sons/sound2.wav";
   aySound[5] = "/mgp/sons/48.au";           // sonorisation ouverture revue de presse
   aySound[6] = "/mgp/sons/41.au";           // sonorisation fermeture revue de presse

   document.write('<BGSOUND id="auIEContainer">')
   IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
   NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
   ver4 = IE||NS? 1:0;
   onload=auPreload;

  function auPreload() {
     if (!ver4) return;
     if (NS) auEmb = new Layer(0,window);
     else {
       Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
       document.body.insertAdjacentHTML("BeforeEnd",Str);
     }
     var Str = '';
     for (i=0;i<aySound.length;i++)
       Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"
     if (IE) auEmb.innerHTML = Str;
     else {
       auEmb.document.open();
       auEmb.document.write(Str);
       auEmb.document.close();
     }
     auCon = IE? document.all.auIEContainer:auEmb;
     auCon.control = auCtrl;
   }

   function auCtrl(whSound,play) {
     if (IE) this.src = play? aySound[whSound]:'';
     else eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
   }

   function playSound(whSound) { 
     if (window.auCon) auCon.control(whSound,true);
   }

   function stopSound(whSound) { 
    if (window.auCon) auCon.control(whSound,false);
   }

// -----------------------------------------------------------------------------------------
