/*Fonction "Ce que nos clients disent de nous"*/
$(document).ready(function(){

	$(".diaporama").diaporama({
		animationSpeed: "slow",
		delay:5
	});

});
/*Fonction "Ce que nos clients disent de nous"*/

/*Fonction "Ils nous font confiance"*/
$(function(){
			$('#slides').slides({
				preload: false,
				preloadImage: 'img/loading.gif',
				play: 2000,
				pause: 5000,
				hoverPause: true
			});
		});
/*Fin fonction "Ils nous font confiance"*/


/*Debut fonction Afficher Solution*/
function afficher(n) {
       var id;
       switch(n) {
          case 1 : id = "instant_survey"; break;
          case 2 : id = "sms_survey"; break;
          case 3 : id = "auto_info"; break;
          case 4 : id = "mqos"; break;
          case 5 : id = "plus"; break;
          }
       document.getElementById('instant_survey').style.display = "none";
       document.getElementById('sms_survey').style.display = "none";
       document.getElementById('auto_info').style.display = "none";
       document.getElementById('mqos').style.display = "none";
       document.getElementById('plus').style.display = "none";       
       document.getElementById(id).style.display = "block";
       }
/*Fin fonction Afficher Solution*/

/*Debut fonction Etat Solution*/
function actifs(n) {
       var id;
       switch(n) {
          case 1 : id = "is_actif"; break;
          case 2 : id = "sms_actif"; break;
          case 3 : id = "auto_actif"; break;
          case 4 : id = "mqos_actif"; break;
          }
       document.getElementById('is_actif').style.opacity = "0.5";
       document.getElementById('sms_actif').style.opacity = "0.5";
       document.getElementById('auto_actif').style.opacity = "0.5";
       document.getElementById('mqos_actif').style.opacity = "0.5";      
       document.getElementById(id).style.opacity = "1.0";
     }
/*Fin fonction Etat Solution*/

/*Debut fonction Etat Solution IE*/
function actifsie(n) {
       var id;
       switch(n) {
          case 1 : id = "is_actif"; break;
          case 2 : id = "sms_actif"; break;
          case 3 : id = "auto_actif"; break;
          case 4 : id = "mqos_actif"; break;
          }
       document.getElementById('is_actif').style.filter = "alpha(opacity=50)";
       document.getElementById('sms_actif').style.filter = "alpha(opacity=50)";
       document.getElementById('auto_actif').style.filter = "alpha(opacity=50)";
       document.getElementById('mqos_actif').style.filter = "alpha(opacity=50)";      
       document.getElementById(id).style.filter = "alpha(opacity=100)";
     }
/*Fin fonction Etat Solution IE*/

/*Fonction bandeau Accès Clients*/
function derouler_clients(n){
	var id;
	switch(n){
		case 1 :id="menu_clients"; break;
	}

	document.getElementById('menu_clients').style.display="none";
	document.getElementById(id).style.display="block";	
}

function fermer_clients(m){
	var id;
	switch(m){
		case 1 :id="menu_clients"; break;
	}

	document.getElementById('menu_clients').style.display="block";
	document.getElementById(id).style.display="none";	
}
/*Fin fonction Accès Clients*/


/*Debut fonction Carrousel Home*/
var carrousel = {
    
    nbSlide : 0,
    nbCurrent : 1,
    elemCurrent : null,
    elem : null,
    timer : null,
    
    init : function(elem){
        this.nbSlide = elem.find(".slide").length;
        
        // Initialisation du carrousel
        this.elem=elem;
        elem.find(".slide").hide();
        elem.find(".slide:first").show();
        this.elemCurrent = elem.find(".slide:first");
        
        // On cré le timer
        carrousel.play();
    },
    
    gotoSlide : function(num){
        if(num==this.nbCurrent){ return false; }
        
        /* Animation en fadeIn/fadeOut */
        this.elemCurrent.fadeOut();
        this.elem.find("#slide"+num).fadeIn();
        
        /* Animation en slide 
        var sens = 1;
        if(num<this.nbCurrent){ sens = -1;}
        var cssDeb = { "left" : sens*this.elem.width() };
        var cssFin = { "left" : -sens*this.elem.width() };
        this.elem.find("#slide"+num).show().css(cssDeb);
        this.elem.find("#slide"+num).animate({"top":0,"left":0},500);
        this.elemCurrent.animate(cssFin,500);
     
        /*
        Animation Titre + Fadein/Out sur la div visu
        
        this.elemCurrent.find(".visu").fadeOut();
        this.elem.find("#slide"+num).show();
        this.elem.find("#slide"+num+" .visu").hide().fadeIn();
        var titleHeight = this.elemCurrent.find(".title").height();
        this.elemCurrent.find(".title").animate({"bottom": -titleHeight},500);
        this.elem.find("#slide"+num+" .title").css("bottom",-titleHeight).animate({"bottom": 0},500);
        */
		
        
        
        this.elem.find(".navigation span").removeClass("active");
        this.elem.find(".navigation span:eq("+(num-1)+")").addClass("active");
        this.nbCurrent = num;
        this.elemCurrent = this.elem.find("#slide"+num);
    },
    
    next : function(){
        var num  = this.nbCurrent+1;
        if(num  >this.nbSlide){
            num  = 1;
        }
        this.gotoSlide(num);
    },
    prev : function(){
        var num  = this.nbCurrent-1;
        if(num< 1){
            num= this.nbSlide;
        }
        this.gotoSlide(num);
    },
    play : function(){
        window.clearInterval(carrousel.timer);
        carrousel.timer = window.setInterval("carrousel.next()",4000);
    }

}

$(function(){
    carrousel.init($("#carrousel"));
});
/*Fin fonction carrousel Home*/


/*Debut fonction Confiance*/
var confiance = {
    
    nbsSlide : 0,
    nbsCurrent : 1,
    eleCurrent : null,
    ele : null,
    time: null,
    
    inite : function(ele){
        this.nbsSlide = ele.find(".slide_c").length;
        
        // Initialisation du carrousel
        this.ele=ele;
        ele.find(".slide_c").hide();
        ele.find(".slide_c:first").show();
        this.eleCurrent = ele.find(".slide_c:first");
        
        // On cré le timer
        confiance.playe();
    },
    
    gotoSlides : function(nu){
        if(nu==this.nbsCurrent){ return false; }
        
        /* Animation en slide*/
        var sense = 1;
        if(nu<this.nbsCurrent){ sense = -1;}
        var cssDeb = { "left" : sense*this.ele.width() };
        var cssFin = { "left" : -sense*this.ele.width() };
        this.ele.find("#slides"+nu).show().css(cssDeb);
        this.ele.find("#slides"+nu).animate({"top":22,"left":60},500);
        this.eleCurrent.animate(cssFin,500);
     
        this.ele.find(".navigation_c span").removeClass("active");
        this.ele.find(".navigation_c span:eq("+(nu-1)+")").addClass("active");
        this.nbsCurrent = nu;
        this.eleCurrent = this.ele.find("#slides"+nu);
    },
    
    nexte : function(){
        var nu = this.nbsCurrent+1;
        if(nu  >this.nbsSlide){
            nu  = 1;
        }
        this.gotoSlides(nu);
    },
    preve : function(){
        var nu  = this.nbsCurrent-1;
        if(nu< 1){
            nu= this.nbsSlide;
        }
        this.gotoSlides(nu);
    },
    playe: function(){
        window.clearInterval(confiance.time);
        confiance.time = window.setInterval("confiance.nexte()",4000);
    }

}

$(function(){
    confiance.inite($("#bloc_confiance"));
});
/*Fin fonction Confiance*/

