//Verification email

function check ()
{
	if (document.patate.i_mail.value == "")	// vérif de l'adresse email
		{
		alert("Merci de saisir votre adresse email.")
		return false;
		}
	if (document.patate.i_mail.value != "" && Verifier_email(document.patate.i_mail.value) == false)	// vérif de  la structure l'adresse email
		{
		alert("Merci de saisir une adresse email valide.")
		return false;
		}
	return true;	
}	

			
function visibilite(thingId)
{
	var target1;
	var target2;
	var target3;
	target1 = document.getElementById("id4") ;
	target2 = document.getElementById("id2") ;
	target3 = document.getElementById("id3") ;
	if (thingId == "id4"){
		if (target1.style.display == "none")
		{
			document.image1.src = "images/digitalDay_onglet_presentation_actif.png";// grande image
			document.image1.width = 223;
			document.image1.height = 70;
			document.image2.src = "images/digitalDay_onglet_temoignage.png";// petite image
			document.image2.width = 201;
			document.image2.height = 70;
			document.image3.src = "images/digitalDay_onglet_edition.png";// petite image
			document.image3.width = 201;
			document.image3.height = 70;
			target1.style.display = "" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
		}			
	}else if (thingId == "id2"){
		if (target2.style.display == "none")
		{
			document.image2.src = "images/digitalDay_onglet_temoignage_actif.png";// grande image
			document.image2.width = 223;
			document.image2.height = 70;
			document.image3.src = "images/digitalDay_onglet_edition.png";// petite image
			document.image3.width = 201;
			document.image3.height = 70;
			document.image1.src = "images/digitalDay_onglet_presentation.png";// grande image
			document.image1.width = 201;
			document.image1.height = 70;	
			target1.style.display = "none" ;
			target2.style.display = "" ;
			target3.style.display = "none" ;
		}			
	}else if (thingId == "id3"){			
		if (target3.style.display == "none")
		{
			document.image3.src = "images/digitalDay_onglet_edition_actif.png";// grande image
			document.image3.width = 223;
			document.image3.height = 70;
			document.image2.src = "images/digitalDay_onglet_temoignage.png";// petite image
			document.image2.width = 201;
			document.image2.height = 70;
			document.image1.src = "images/digitalDay_onglet_presentation.png";// grande image
			document.image1.width = 201;
			document.image1.height = 70;
			target1.style.display = "none" ;
			target2.style.display = "none" ;
			target3.style.display = "" ;
		}
	}	
	
}


function oubli(thingId)
{
	var target1;
	var target2;
	target1 = document.getElementById("lignedej") ;
	target2 = document.getElementById("lignedej2") ;
	if (thingId == "lignedej2"){
		if (target2.style.display == "none")
		{
			target2.style.display = "" ;
			target1.style.display = "none" ;
		}			
	}else if (thingId == "lignedej"){
		if (target1.style.display == "none")
		{
			target2.style.display = "none" ;
			target1.style.display = "" ;
		}			
	}
}

var blob = 0;

function temoignages(plop)
{
	var target1;
	var target2;
	var target3;
	var target4;
	var target5;
	var target6;
	var target7;
	var target8;
	var target9;
	target1 = document.getElementById("id21") ;
	target2 = document.getElementById("id22") ;
	target3 = document.getElementById("id23") ;
	target4 = document.getElementById("id24") ;
	target5 = document.getElementById("id25") ;
	target6 = document.getElementById("id26") ;
	target7 = document.getElementById("id27") ;
	target8 = document.getElementById("id28") ;
	target9 = document.getElementById("id29") ;
	
	if (blob == 0 &&  plop == 0 )
	{
		blob = 9;
	}
	if (blob != 0 &&  plop == 0 )
	{
		blob = blob - 1;
	}
	if (plop == 1 && blob != 9)
	{
		blob = blob + 1;
	}
	if	(plop == 1 && blob == 9)
	{	
		blob = 0;
	}
	if (blob == 0){
		if (target1.style.display == "none")
		{
			target1.style.display = "" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
			target7.style.display = "none" ;
			target8.style.display = "none" ;
			target9.style.display = "none" ;
		}			
	}else if (blob == 1){
		if (target2.style.display == "none")
		{
			target1.style.display = "none" ;
			target2.style.display = "" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
			target7.style.display = "none" ;
			target8.style.display = "none" ;
			target9.style.display = "none" ;
		}			
	}else if (blob == 2){			
		if (target3.style.display == "none")
		{
			target1.style.display = "none" ;
			target2.style.display = "none" ;
			target3.style.display = "" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
			target7.style.display = "none" ;
			target8.style.display = "none" ;
			target9.style.display = "none" ;
		}
	}
	else if (blob == 3	){			
		if (target4.style.display == "none")
		{
			target1.style.display = "none" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
			target4.style.display = "" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
			target7.style.display = "none" ;
			target8.style.display = "none" ;
			target9.style.display = "none" ;
		}
	}
	else if (blob == 4	){			
		if (target5.style.display == "none")
		{
			target1.style.display = "none" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "" ;
			target6.style.display = "none" ;
			target7.style.display = "none" ;
			target8.style.display = "none" ;
			target9.style.display = "none" ;
		}
	}	
	else if (blob == 5	){			
		if (target6.style.display == "none")
		{
			target1.style.display = "none" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "" ;
			target7.style.display = "none" ;
			target8.style.display = "none" ;
			target9.style.display = "none" ;
		}
	}	
	else if (blob == 6	){			
		if (target7.style.display == "none")
		{
			target1.style.display = "none" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
			target7.style.display = "" ;
			target8.style.display = "none" ;
			target9.style.display = "none" ;
		}
	}	
	else if (blob == 7	){			
		if (target8.style.display == "none")
		{
			target1.style.display = "none" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
			target7.style.display = "none" ;
			target8.style.display = "" ;
			target9.style.display = "none" ;
		}
	}
	else if (blob == 8	){			
		if (target9.style.display == "none")
		{
			target1.style.display = "none" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
			target7.style.display = "none" ;
			target8.style.display = "none" ;
			target9.style.display = "" ;
		}
	}		
	
}

//Function vérification d'email
function Verifier_email(email)
{
	var place = email.indexOf("@",1);
	var point = email.indexOf(".",place+2);
	if ((place > -1)&&(email.length >2)&&(point > 1))
		{
		return(true);
		}
	else
		{
		return(false);
		}
}


function Verifier_Numero_fixe(num_tel)
{
	// Definition du motif a matcher
	var regex = new RegExp(/^(01|02|03|04|05|06|08|09)[0-9]{8}/gi);
	// Definition de la variable booleene match
	var match = false;
	// Test sur le motif
	if(regex.test(num_tel))
	{
	match = true;
	}
	else
	{
	match = false;
	}
	// On renvoie match
	return match;
}

function retour(){

	var target1;
	var target2;
	var target3;
	var target4;
	var target5;
	var target6;
	target1 = document.getElementById("id4") ;
	target2 = document.getElementById("id2") ;
	target3 = document.getElementById("id3") ;
	target4 = document.getElementById("id4") ;
	target5 = document.getElementById("id5") ;
	target6 = document.getElementById("id6") ;
	if (document.tdddform.u_nsocie.value == "")
	{
		if (document.tdddform.u_socie.value != '')
		{
			target1.style.display = "" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
		}
		else
		{
			alert('Merci de choissir une société');
		}	
	}		
	else
	{
		if (document.tdddform.u_socie.value != '')
		{
			target1.style.display = "" ;
			target2.style.display = "none" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
		}
		else
		{
			target1.style.display = "none" ;
			target2.style.display = "" ;
			target3.style.display = "none" ;
			target4.style.display = "none" ;
			target5.style.display = "none" ;
			target6.style.display = "none" ;
		}
	}
}	


//Fonction de vérification de société
function validation()
{
var verif;
verif = true;

	if (document.tdddform.u_nom.value == "")
		{
		alert("Merci de rentrer votre nom.")
		verif = false;
		}
	if (document.tdddform.u_pnom.value == "")
		{
		alert("Merci de préciser votre prénom.")
		verif =false;
		}
	if (document.tdddform.u_mail.value == "")
		{
		alert("Merci de saisir votre adresse email.")
		verif = false;
		}
	if (document.tdddform.u_mail.value != "" && Verifier_email(document.tdddform.u_mail.value) == false)
		{
		alert("Merci de saisir une adresse email valide.")
		verif = false;
		}
	if (document.tdddform.u_password.value == "" )
		{
		alert("Merci de saisir un mot de passe.")
		verif = false;
		}	
	if (document.tdddform.c_password.value == "" )
		{
		alert("Merci de confirmer le mot de passe.")
		verif = false;
		}	
	if (document.tdddform.c_password.value != document.tdddform.u_password.value )
		{
		alert("Les mots de passes ne correspondent pas.")
		verif = false;
		}			
	if (document.tdddform.u_tel.value != "" && Verifier_Numero_fixe(document.tdddform.u_tel.value) == false)
		{
		alert("Merci de saisir un N° de téléphone valide.")
		verif =false;
		}
	if (document.tdddform.u_soc.value == "" )
		{
		alert("Merci de saisir votre société.")
		verif = false;
		}
	if (document.tdddform.u_fonct.value == "" )
		{
		alert("Merci de saisir votre fonction.")
		verif = false;
		}	
	if (document.tdddform.u_type.value == "" )
		{
		alert("Merci de saisir votre type.")
		verif = false;
		}			
		
	if (verif == true)
	{
		return true;
	}
	else
	{
		return false;
	}
}

//Carousel


// Definir la vitesse slideShowSpeed en millisecondes
var slideShowSpeed = 7000

// La durée de crossfade en secondes)
var crossFadeDuration = 2

//images
var Pic = new Array() 
Pic[0] = 'images/test9.jpg'
Pic[1] = 'images/test3.jpg'
Pic[2] = 'images/test4.jpg'
Pic[3] = 'images/test1.jpg'
Pic[4] = 'images/test2.jpg'

var t
var j = 0
var p = Pic.length



var preLoad = new Array()
for (i = 0; i < p; i++){

   preLoad[i] = new Image()
   preLoad[i].src = Pic[i]

}



function runSlideShow(){

   if (document.all){

      document.images.SlideShow.style.filter="blendTrans(duration=2)"

      document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"

      document.images.SlideShow.filters.blendTrans.Apply()      

   }

   document.images.SlideShow.src = preLoad[j].src

   if (document.all){

      document.images.SlideShow.filters.blendTrans.Play()

   }

   j = j + 1

   if (j > (p-1)) j=0

   t = setTimeout('runSlideShow()', slideShowSpeed)

}

function Verifier_Numero_fixe(num_tel)
{
	// Definition du motif a matcher
	var regex = new RegExp(/^(01|02|03|04|05|06|08|09)[0-9]{8}/gi);
	// Definition de la variable booleene match
	var match = false;
	// Test sur le motif
	if(regex.test(num_tel))
	{
	match = true;
	}
	else
	{
	match = false;
	}
	// On renvoie match
	return match;
}

//Popup pour récupérer l'email
//Pop up twitter
function pop_it() 
{
   window.open("include/recup.php", "popup", "height=170,width=400,menubar='no',toolbar='no',location='no',status='no',scrollbars='no'");
}


//Deja inscrit
//------------------
function ShowForm(){
  var Obj;
  //-- on affiche le fond
  Obj = document.getElementById('D_FOND');
  if( Obj){
    with( Obj.style){
      position="absolute";
      display="";
      left = "0px";
      top  = "0px";
      zIndex= 10;
    }
  }
  //-- on affiche le formulaire
  Obj = document.getElementById('D_FORM');
  if( Obj){
    with( Obj.style){
      position="absolute";
      display="";

    }
    Obj.focus();
  }
}
//-----------------
function HideForm(){
  var Obj;
  Obj = document.getElementById('D_FORM');
  //-- on masque le formulaire
  if( Obj){
    with( Obj.style){
      display="none";
    }
  }
  //-- on masque le fond  
  Obj = document.getElementById('D_FOND');
  if( Obj){
    with( Obj.style){
      display="none";
    }
  }
   Obj = document.getElementById('lignedej2');
  if( Obj){
    with( Obj.style){
      display="none";
    }
  }
  Obj = document.getElementById('lignedej');
  if( Obj){
    with( Obj.style){
      display="";
    }
  }
  
}



//Ajax verification password
function writediv(texte)
     {
     document.getElementById('incorrect').innerHTML = texte;
     }
	 
//Ajax verification password
function writediv2(texte)
     {
     document.getElementById('incorrect2').innerHTML = texte;
     }	 
	 

function verifpass()
     {
	 
		verif = false;
		pass=document.session.password.value;
		mail=document.session.mail.value;
		
		texte = file('include/verif.php?mail='+escape(mail)+'&pass='+escape(pass))
          if(texte == 1)
               verif = true;
			 // alert("OK");
          else if(texte == 2)
             writediv('<span style="color:red;font-size:10px"><b>Adresse email ou mot de passe incorrect!!!</b></span>');
          //alert("NOK");
		 else
         writediv('');

			   
	if (verif == true)
	{
		return true;
	}
	else
	{
		return false;
	}
			   
			   
     }
	 
function verifmail()
     {
	
		verif = false;
		mail=document.pass.mail.value;
		 //alert("include/verifmail.php?mail="+escape(mail));
		texte = file('include/verifmail.php?mail='+escape(mail))
          if(texte == 1)
               verif = true;
			  //alert("OK");
          else if(texte == 2)
             writediv2('<span style="color:red;font-size:10px"><b>Adresse email incorrect!!!</b></span>');
			//alert("NOK");
		 else
         writediv('');

			   
	if (verif == true)
	{
		return true;
	}
	else
	{
		return false;
	}
			   		   
    }	 


function file(fichier)
     {
     if(window.XMLHttpRequest) // FIREFOX
          xhr_object = new XMLHttpRequest();
     else if(window.ActiveXObject) // IE
          xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
     else
          return(false);
     xhr_object.open("GET", fichier, false);
     xhr_object.send(null);
     if(xhr_object.readyState == 4) return(xhr_object.responseText);
     else return(false);
     }




