// JavaScript Document

<!-- 

// Définition des variable
var divpixel = 0;    // Pixel de départ
var position = 0;    // Position de départ
var numero = 1; 	 // N° du calque actuel
var number = 1;		 // N° du calque actuel

var j=0;			 // Machine à écrite
var i=0;
var texteNE='';

// Fonction rollover
function showhide(calque, action) {
				
	document.getElementById(calque).style.visibility = (action == "show") ? 'visible' : 'hidden';
	
	}
	
	
// Fonctions de déplacement du calque
/*function go_to(num, id) {
	
	window.focus();
		
   // On calcule le point à atteindre en fonction de position précedente
   var objectif = parseInt(position + Number(num*400));
     
   // On verifie si l'on peut se deplacer ou alors qu'on est en bout
   if((0 <= objectif) && ((objectif/400) < eval('maxi_'+id))) {
	   
   // On vérifie que c'est le premier deplacement
   if(divpixel == position) { $("projet-description-"+id).innerHTML = '<img src="img/global/loading.gif" style="vertical-align: middle" /> Chargement du projet'; }
   
   // Si c'est positif, on avance
    if(divpixel > objectif) {
         
         divpixel = (divpixel > (objectif - 10)) ? divpixel-10 : divpixel-1;
      
   // Si c'est négatif, on recule     
      } else if (divpixel < objectif) {
         
         divpixel = (divpixel < (objectif - 10)) ? divpixel+10 : divpixel+1;
      
         
      }
     
   	// Déplacement du calque
     $("projet-exemple-"+id).style.left = -divpixel+'px';
     
     // Si le calque n'est pas a déstination, on relance un déplacement, sinon on note la position
      if(divpixel != objectif) { 
	  
		  // On lance la boucle
		  setTimeout("go_to("+num+",'"+id+"')",1);  
		  
	} else { 
	
		numero += num;					// On définir la variable numero
		position = divpixel;			// On regarde ou on est positionner à la fin
		new Ajax.Updater('projet-description-'+id, 'include/ajax/slider_projet.php', {method: 'get', parameters: 'id='+numero+'&type='+id, asynchronous:false, evalScripts:true});				// On met a jour les infos du site présenté
   		$('projet-precedent-'+id).style.display = (numero > 1) ? 'block' : 'none';	// Precedent
		$('projet-suivant-'+id).style.display = (numero == eval('maxi_'+id)) ? 'none' : 'block';	// Suivant
		
	}
   
    }
}*/

// Deplacement du menu

var pixel = 0;
var move = 1;
var top = 0;
var position_depart = 41;

ie4 = document.all
ns6 = document.getElementById && !document.all
ns4 = document.layers
var pixel = 0;
var move = 1;
var top = 0;
var vitesse = 10;
var margebottom = 180;

function get_top() {

var top;

if (ie4) { top = document.body.scrollTop; }
else if (ns6) { top = window.pageYOffset; }
else if (ns4) { top = eval(window.pageYOffset); }

return top;

}

function move_menu(top) {
	
	if(move == 1) {
	
		if(pixel < top-margebottom) {
			
			pixel += ((top-pixel) > vitesse) ? vitesse : 1;
			
		} else if (pixel > top) {
			
			pixel -= ((pixel-top) > vitesse) ? vitesse : 1;
			
		} else { }
	
	$('perso').setStyle('top: '+pixel+'px');
	//$('perso').innerHTML = 'Pixel : '+pixel+'<br />Top : '+top;
	
	}
		
	setTimeout("move_menu(get_top())",1);

	
}

function move_it() {
	
	move = 1;
	
}

function stop_it() {
	
	move = 0;
	
}

// Effet machine a ecrire dans la bulle
var i = 0;
var tmo = null;
var array = Array();

	function launch_machine(texte) {
		
		$("tete").setStyle('display: block;');
		
		machine_a_ecrire(texte);
	}

	function machine_a_ecrire(texte) {
		
		if(!array[texte]) {
		
		$("bulle").innerHTML = texte.substr(0, i);
	
		if (i < texte.length) { i++; tmo = setTimeout("machine_a_ecrire('"+texte+"')",50); } else { array[texte] = 1; i = 0; clearTimeout(tmo); $("tete").setStyle('display: none;'); }
		
		}
	}
	
	function clearMachine() {
		
			array = Array();
			
			clearTimeout(tmo);
			$("bulle").innerHTML = "";
			$("tete").setStyle('display: none;');
			i = 0;
			
	}
	
// Autoscrolling vers les ancres
Event.observe(window, 'load', function() {
  $$('a[href^=#]:not([href=#])').each(function(element) {
    element.observe('click', function(event) {
      new Effect.ScrollTo(this.hash.substr(1));
      Event.stop(event);
    }.bindAsEventListener(element))
  })
});



//-->  
