var player;
  function playerReady(obj) {
	 //alert('the videoplayer '+obj['id']+' has been instantiated');
	 player = document.getElementById(obj['id']);
	 player.sendEvent("PLAY","true");
	 player.addModelListener("STATE","finPlayer");
   //lis_video();
  };

function finPlayer(obj) 
  { 
    if(obj.newstate == "COMPLETED")
      {
        $("menu").show();
        if(document.getElementById('intro_video').style.display=='none')
          {
            $$(".clipvideo").each ( Element. hide ) ;
            $("photos").show();
          }
        else
          $("intro_video").hide();   
     }
  };


  function visualise(video)
  {
    //alert(video);
    Element.update("photos", video);
        
  }
  
function afficheMenu(num_vid) {
    $('menu').show();
} 

function afficheClips() {
    $('container_photos').show();
} 

function connectezVous() {

    new Ajax.Updater('container_vostemoignages', '/connectez_vous.php', { method: 'get' });

}

function temoigner() {

    new Ajax.Updater('container_vostemoignages', '/temoignez.php', { method: 'get' });

}

function majTemoignages() {

    new Ajax.Updater('container_vostemoignages', '/vos_temoignages.php', { method: 'get' });

}

function enrTemoignage(){

  var err="";
  //document.FormMessage.action='enr_temoignage.php';
  //
  
  if($F('titre') == "") {
  alert ('le champ titre est obligatoire');
  err= err+ "message \n";
  
  } 
  
  if($F('message') == "") {
  alert ('le champ message est obligatoire');
  err= err+ "message \n";
  
  }
  //
  
  if (err == "") {
  
      $('FormMessage').request({
          onComplete: function (transport) {
          //on efface le formulaire
          Element.update("FormMessage", transport.responseText);
          }
      });
    }

}

function connexionCompteOld() {
  
  new Ajax.Updater('container_vostemoignages', '/connexion_compte.php', { method: 'post' });

}

function connexionCompte(){
  $('formCompte').request({
      onComplete: function (transport) {
      //on efface le formulaire
      Element.update("formCompte","");
      //$$("mess").each(Element.update("mess",""));

      Element.scrollTo("container_vostemoignages");
      Element.update("container_vostemoignages", transport.responseText);
      }
  
  });

}


function inscription() {
  
  new Ajax.Updater('container_vostemoignages', '/inscription.php', { method: 'post' });

}

function enrInscription() {

$('formInscription').request({
      onComplete: function (transport) {
      //on efface le formulaire
      Element.update("formInscription","");
      //$$("mess").each(Element.update("mess",""));

      Element.scrollTo("container_vostemoignages");
      Element.update("container_vostemoignages", transport.responseText);
      }
  
  });


}

function menuHTML(num_vid) {
    
    document.getElementById('BULLESder_GROSSI_thib12').afficheBulle(num_vid);
    $$(".contenus_dynamiques").each ( Element. hide ) ;
    $$(".clipvideo").each ( Element. hide ) ;
    $('container_photos').hide();
    if (num_vid == 0 ) {
      //$('container_photos').show();
      /*
      $('photos').clonePosition($('fond_swf'), { setWidth: false, setHeight:false,offsetLeft: 190, offsetTop: 300 });
      $('pointer').clonePosition($('photos'), { setWidth: false, setHeight:false,offsetLeft:45, offsetTop: 300 });
      */
      $('container_photos').clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 200, offsetTop: 215 });
      $('photos').clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 200, offsetTop: 215 });
      $('pointer').clonePosition($('photos'), { setWidth: false, setHeight:false,offsetLeft:45, offsetTop: 300 });
      $('container_photos').show();
      $('photos').show();
      //timeoutobject = setTimeout("afficheClips()",2700);
    }
    if (num_vid == 2 ) {
      //alert("Les Proches de Patricks");
      
    }
    
    if (num_vid == 4 ) {
      //alert("Vos témoignages");
      //new Ajax.Updater('container_vostemoignages', '/vos_temoignages.php', { method: 'get' });
      //$("container_proches").show();
      
      ///$("container_vostemoignages").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 260, offsetTop: 320 });
      //alert('';)
      //new Effect.Opacity("container_vostemoignages",{duration:2.7, from:0.0, to:1.0 });
      //$("container_vostemoignages").show();
      } 
    
    if (num_vid == 6 ) {
      //alert("Actus");
      new Ajax.Updater('container_actus', '/actus_site2.php', { method: 'get' });
      $("container_actus").show();
      $("container_actus").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 50, offsetTop: 150 });
      
      //new Effect.Opacity("container_actus",{duration:2.7, from:0.0, to:1.0 });
      //document.getElementById('BULLESder_GROSSI_thib12').afficheBulle(num_vid);
    }   
   
    if (num_vid == 3 ) {
      //alert("Apple  à Scénario");
      new Ajax.Updater('container_appel_a_scenario', '/appel_a_scenario.php', { method: 'get' });
      $("container_appel_a_scenario").show();
      $("container_appel_a_scenario").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 182, offsetTop: 637 });
      
    } 
    if (num_vid == 5 ) {
      //alert("0,5g (Le Quizz)");
      new Ajax.Updater('container_quizz', '/quizz_05.php', { method: 'get' ,evalScripts: true});
      $("container_quizz").show();
      //$("container_quizz").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 182, offsetTop: 310 });
      $("container_quizz").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 182, offsetTop: 150 });
    }
    if (num_vid == 1 ) {
      //alert("Aider");
    }
    
   
   //document.getElementById('BULLESder_GROSSI_thib12').afficheBulle(num_vid);
}

var mouseX =0;
var mouseY =0;
var t=0;
function onclick_page(event)
{
  mouseX = event.clientX + document.body.scrollLeft;
  mouseY = event.clientY + document.body.scrollTop;
  //alert('Vous avez cliqué au point de coordonnés: ' + mouseX + ', ' + mouseY );
}

function attente(){
  //affichage des témoignage apres temporisation
  new Effect.Opacity("container_vostemoignages",{duration:3.7, from:0.0, to:1.0 });
  $("container_vostemoignages").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 260, offsetTop: 320 });
  $("container_vostemoignages").show();
  clearTimeout(t);
  //console.debug ('fin de l\'attente');
}

function menuVideo(num_vid) {

 $("menu").show();
 $$(".contenus_dynamiques").each ( Element. hide ) ;
 $$(".clipvideo").each ( Element. hide ) ;
 $('container_photos').hide();
 if (num_vid == 0 ) {
  //alert("Clips");
  /*
  MasqueVideo(0);
  Effect.Grow("photos",{ duration: 2 });
  Effect.Grow("video",{ duration: 2 });
  Effect.Grow("text",{ duration: 2 }); 
  return false;
  */
  //new Effect.Opacity("container_photos",{duration:2.7, from:0.0, to:1.0 });
   //alert('mouseY: ' + mouseY + ' | scrollTop : ' + document.documentElement.scrollTop);
   if(document.documentElement.scrollTop ==0)
    posX = 215;
   else
    posX = 215 + document.documentElement.scrollTop;
   
   var ua = navigator.userAgent.toLowerCase();
  if (ua.indexOf('safari/') != -1){
      //utilisation de safari
      posX = 215 +  document.body.scrollTop;
  }
  
   
   $('container_photos').clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 200, offsetTop:posX });
   $('photos').clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 200, offsetTop: posX });
   $('pointer').clonePosition($('photos'), { setWidth: false, setHeight:false,offsetLeft:45, offsetTop: 300 });
  $('container_photos').show();
  $('photos').show();
 }
if (num_vid == 2 ) {
  //alert("Les Proches de Patricks");
  /*MasqueVideo(2);
  Effect.Grow("video2",{ duration: 2 });
  Effect.Grow("text2",{ duration: 2 }); 
  return false;
  */
  new Ajax.Updater('container_proches', '/proches.php', { method: 'get' });
  //$("container_proches").show();
  $("container_proches").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 50, offsetTop: 150 });
  new Effect.Opacity("container_proches",{duration:2.7, from:0.0, to:1.0 });
}

if (num_vid == 4 ) {
  //alert("Vos témoignages");
  /*MasqueVideo(3);
  Effect.Grow("video3",{ duration: 2 });
  Effect.Grow("text3",{ duration: 2 }); 
  return false;
 */
 new Ajax.Updater('container_vostemoignages', '/vos_temoignages.php', { method: 'get' });
//$("container_proches").show();
 t = window.setTimeout("attente()",3000);
//new Effect.Opacity("container_vostemoignages",{duration:3.7, from:0.0, to:1.0 });
//$("container_vostemoignages").show(); 

} 
if (num_vid == 6 ) {
  
   menuHTML(num_vid);
  /*
  if(document.documentElement.scrollTop ==0)
    posX = 315;
   else
    posX = 315 + document.documentElement.scrollTop;
   
   var ua = navigator.userAgent.toLowerCase();
  if (ua.indexOf('safari/') != -1){
      //utilisation de safari
      posX = 315 +  document.body.scrollTop;
  }
  
  new Ajax.Updater('container_actus', '/actus_site2.php', { method: 'get' });
  $("container_actus").show();
  new Effect.Opacity("container_actus",{duration:2.7, from:0.0, to:1.0 });
  $("container_actus").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 50, offsetTop: posX });
  */
 
}   

if (num_vid == 3 ) {
  //alert("Apple  à Scénario");
  /*MasqueVideo(5);
  Effect.Grow("video5",{ duration: 2 });
  Effect.Grow("text5",{ duration: 2 }); 
  return false;*/
  //alert("Apple  à Scénario");
  //console.debug ('lancement de Apple  à Scénario');
  new Ajax.Updater('container_appel_a_scenario', '/appel_a_scenario.php', { method: 'get' });
  $("container_appel_a_scenario").show();
  $("container_appel_a_scenario").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 182, offsetTop: 637 });
} 
if (num_vid == 5 ) {
  //alert("0,5g (Le Quizz)");
   new Ajax.Updater('container_quizz', '/quizz_05.php', { method: 'get' ,evalScripts: true });
  //$("container_quizz").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 50, offsetTop: 310 });
  //$("container_quizz").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 182, offsetTop: 310 });
  $("container_quizz").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 182, offsetTop: 150 });
  $("container_quizz").show();
}
if (num_vid == 1 ) {
  //alert("Aider");
}



}

function MasqueVideo(id_video) {
  for (i=0;i<=6;i++) {
    if(i != id_video) {
     if ($("video"+i))
      $("video"+i).hide();
     if ($("text"+i)) 
      $("text"+i).hide();
      //alert("video effacée " +i);
      $("photos").hide();
      if(i==0) {
      if ($("video"))
      $("video").hide();
     if ($("text")) 
      $("text").hide();
      
      }
    
    }
      
  
  }
  
}

function afficheIntro(num_vid) {
  
  //alert("intro");
  $("menu").show();
  $('intro_video').clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 300, offsetTop: 200 });
  //$('intro_video').update("<iframe width='580' height='335' src='http://player.oneheartsolutions.com/common/gen_prev_js.php?idv=1164&ide=6&ap=y&ab=n&w=560&h=315&th=1'  frameborder='0' allowfullscreen></iframe>");
  $('intro_video').show();
  //window.frames[0].document.getelementById('example_video_1').play();
  //document.all.introvideo.src="http://player.oneheartsolutions.com/common/gen_prev_js.php?idv=1164&ide=6&ap=y&ab=n&w=560&h=315&th=1";
  //$('introvideo').setAttribute('src','http://player.oneheartsolutions.com/common/gen_prev_js.php?idv=1164&ide=6&ap=y&ab=n&w=560&h=315&th=1');  
  //$('intro_video').update("<iframe width='580' height='335' src='http://player.oneheartsolutions.com/common/gen_prev_js.php?idv=1164&ide=6&ap=y&ab=n&w=560&h=315&th=1'  frameborder='0' allowfullscreen></iframe>");
   //$('intro_video').show();
  //jQuery('#intro_video').html("<iframe width='580' height='335' src='http://player.oneheartsolutions.com/common/gen_prev_js.php?idv=1164&ide=6&ap=y&ab=n&w=560&h=315&th=1'  frameborder='0' allowfullscreen></iframe>");
}

function afficheVideo(num_vid) {

  //MasqueVideo(0);
  $$(".clipvideo").each ( Element. hide ) ;
  //Effect.Grow("video_"+num_vid,{ duration: 2 });
  ////$('bloc_video_'+num_vid).clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 184, offsetTop: 500 });
  //pos_blocX = 330 + document.documentElement.scrollTop;
  pos_blocX = 230 + document.documentElement.scrollTop;
  var ua = navigator.userAgent.toLowerCase();
  if (ua.indexOf('safari/') != -1){
      //utilisation de safari
      pos_blocX = 230 +  document.body.scrollTop;
  }
  if (num_vid == 99)
    $('bloc_video_'+num_vid).clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: -24, offsetTop: pos_blocX });
 if (num_vid == 100)
    $('bloc_video_'+num_vid).clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: -24, offsetTop: pos_blocX -30 });
  if (num_vid == 101)
    $('bloc_video_'+num_vid).clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: -24, offsetTop: pos_blocX -30 });     
  if (num_vid == 102)
    $('bloc_video_'+num_vid).clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: -24, offsetTop: pos_blocX -30 });
  if (num_vid == 103)
    $('bloc_video_'+num_vid).clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: -24, offsetTop: pos_blocX -30 });            
  else if (num_vid < 99)
    {
      $('bloc_video_'+num_vid).clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 184, offsetTop: document.documentElement.scrollTop -185 });
      if (ua.indexOf('safari/') != -1){
      //utilisation de safari
      $('bloc_video_'+num_vid).clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 184, offsetTop: document.body.scrollTop -185 });
    }
    }
  $('bloc_video_'+num_vid).show();
  $('video_'+num_vid).show();
  //console.debug('affiche video_'+num_vid);
  //$('photos').hide();
  //return false;
}
//FONCTIONS POUR LE SWF
function afficheBulle(num_bulle) {
  //lance la f° afficheBulle du Flash
  //document.getElementById('BULLESder_GROSSI_thib12').afficheBulle(num_bulle);
  document.getElementById('BULLESder_GROSSI_thib12').afficheBulle('6');
}



function lireTemoignage(t){
  
  //new Ajax.Updater('container_proches', '/proches_temoignage.php?t='+t, { method: 'get' });
  new Ajax.Updater('container_proches', '/proches.php', { method: 'get' });
  $('container_proches').clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 5, offsetTop: 225 });
  $("container_proches").show();

}


function detailTemoignage(t){
  
  new Ajax.Updater('container_proches', '/proches_temoignage.php?t='+t, { method: 'get' });
  //new Ajax.Updater('container_proches', '/proches.php', { method: 'get' });
  $('container_proches').clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 5, offsetTop: 225 });
  $("container_proches").show();

}

function voirVideoProche(t){
  
  new Ajax.Updater('container_proches', '/proches_video.php?t='+t, { method: 'get' });
  //new Ajax.Updater('container_proches', '/proches.php', { method: 'get' });
  $('container_proches').clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 5, offsetTop: 225 });
  $("container_proches").show();

}


function retourTemoignageProches() {

  new Ajax.Updater('container_proches', '/proches.php', { method: 'get' }); 
  $$(".contenus_dynamiques").each ( Element. hide ) ;
  $$(".clipvideo").each ( Element. hide ) ;
  $('container_photos').hide();
  //alert('retourTemoignageProches2');
  $('container_proches').show();
}

function retourProches() {
  $$(".clipvideo").each ( Element. hide ) ;
  //menuHTML(2);
  //new Ajax.Updater('container_proches', '/proches.php', { method: 'get', evalScripts: true });
   $('container_proches').hide();
   menuHTML(1);
   //alert('retour');
  
}

function retour(r){
  
  alert("retour");

}

function serieSuivante(suiv){
  
  //alert("serieSuivante");

}

function seriePrecedente(prec){
  
  alert("seriePrecedente");

}

function passerIntro(passer) {
  $("menu").show();
}

function voirVideo(vid) {
  //alert("voir Video");
  new Ajax.Updater('container_proches', '/prochesLavideo.php', { method: 'get',evalScripts: true });
  //$("container_proches").show();
  $("container_proches").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: 50, offsetTop: 250 });
  new Effect.Opacity("container_proches",{duration:2.7, from:0.0, to:1.0 });
}

function retourActu() {
  //console.debug("retour Actu");

}

function excluActu() {
  //console.debug("exclu Actu");
  $("container_actus").hide();
  afficheVideo(2);
  $("bloc_video_2").clonePosition($('menu'), { setWidth: false, setHeight:false,offsetLeft: -24, offsetTop: pos_blocX -30 });
}
