tabNomImage = new Array ("../images/interface/dp_o_en.png","../images/interface/dp_o_fr.png");
nbImages = tabNomImage.length

dessin = new Array(nbImages)
	
for ( remplissage = 0 ; remplissage <= nbImages ; remplissage++ )
{
	dessin[remplissage] = new Image()
	dessin[remplissage].src = tabNomImage[remplissage]
}
	
affCalque=false;
offsetHor = 0;
offsetVert = 0;
vitesseDiaporama = 5000; // Vitesse du diaporama
dureeTransition = 1; // Durée de la transition

/* Déclaration */
preChargement = new Array()
NumImgAff = new Array();
nbImgTotal = new Array();
IdTimeOut = new Array();

/* Declaration et Init supplémentaire */
for (cpt_diapo = 1 ; cpt_diapo <= nb_diaporama ; cpt_diapo++)
{
	NumImgAff[cpt_diapo] = 0;
	nbImgTotal[cpt_diapo] = tabImg[cpt_diapo].length;
	preChargement[cpt_diapo] = new Array()
	
	for (cpt = 0; cpt < nbImgTotal[cpt_diapo] ; cpt++)
	{
		preChargement[cpt_diapo][cpt] = new Image()
		preChargement[cpt_diapo][cpt].src = emplacement + tabImg[cpt_diapo][cpt]
	}
}

/*****************************************/
/*             LES FONCTIONS             */
/*****************************************/

function nomId(id)
{
	return document.getElementById(id);
}

function move(e)
{
	if(affCalque)
	{
		var position_souris;
		
		// Si la bulle est visible, on calcul en temps reel sa position ideale
    	if (navigator.appName!="Microsoft Internet Explorer")
    	{
    		// Si on est pas sous IE
    		position_souris_x = e.pageX;
    		position_souris_y = e.pageY;
    	}
    	else
    	{
    		position_souris_x = window.event.x;
    		position_souris_y = window.event.y + document.body.scrollTop;
    	}
    	    	
    	nomId("curseur").style.left = position_souris_x + 5 + offsetHor;
    	nomId("curseur").style.top = position_souris_y + 10 + offsetVert;
  	}
}

function montrerCalque(diaporama,posHor,posVert)
{
	var positionImg
	
	if(affCalque==false)
	{
		/* Gestion de la position */

  		if (posHor == "droite") offsetHor = 5;
  		else offsetHor = -445 ;
  		
  		if (posVert == "bas") offsetVert = 0;
  		else offsetVert = -300-20;
  		
  		/* Gestion de l'affichage */
  		positionImg = NumImgAff[diaporama] - 1;
  		if (NumImgAff[diaporama] == 0) { positionImg = tabImg[diaporama].length-1 };
  	
  		nomId("zoom").src = emplacement + "zoom_" + tabImg[diaporama][positionImg] // Si il est cacher (la verif n'est qu'une securité) on le rend visible.
  		nomId("curseur").style.display="block"; // Si il est cacher (la verif n'est qu'une securité) on le rend visible.
  		affCalque=true;
  	}
}

function afficher_pdf(nom_fichier)
{

	chemin = "../ressources/revues/" + nom_fichier;
	window.open(chemin,"doc_pdf","resizable=yes,status=yes,toolbar=no,menubar=no,location=no");

}

function cacherCalque()
{
	if(affCalque==true)
	{
		nomId("curseur").style.display="none"; // Si la bulle etais visible on la cache
		nomId("zoom").src = emplacement + "blanc.png" // Si il est cacher (la verif n'est qu'une securité) on le rend visible.
		affCalque=false;
	}
}

function demarrerDiaporama(numero)
{
	var nom_diaporama;
	var NumImgAff_ec;
	
	nom_diaporama = "diaporama_" + numero
	NumImgAff_ec = NumImgAff[numero];

	if (navigator.appName!="Microsoft Internet Explorer")
    {
    	// Si on est pas sous IE
		nomId(nom_diaporama).src = preChargement[numero][NumImgAff_ec].src
    }
    else
    {
    	nomId(nom_diaporama).style.filter="blendTrans(dureeTransition)"
		nomId(nom_diaporama).filters.blendTrans.Apply() 
		nomId(nom_diaporama).src = preChargement[numero][NumImgAff_ec].src
		nomId(nom_diaporama).filters.blendTrans.Play()
    }	
	
	NumImgAff[numero] = NumImgAff[numero] + 1;
	if ( NumImgAff[numero] > (nbImgTotal[numero]-1) ) NumImgAff[numero] = 0;
	IdTimeOut[numero] = setTimeout('demarrerDiaporama('+numero+')', vitesseDiaporama)
}

/* position e la souris */
document.onmousemove=move;

function initialiser()
{
	valeur = document.getElementById("texte_3-1").clientHeight;
	document.getElementById("separation").style.height=valeur-15;

	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-12, imgName.length) == "ARRONDIE.PNG")
	      {
	         var imgID = (img.id) ? "id='" + img.id + "' " : ""
	         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         var imgStyle = "display:inline-block;" + img.style.cssText 
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
	         img.outerHTML = strNewHTML
	         i = i-1
	      }
	   }
	}

	for ( cpt_diaporama = 0 ; cpt_diaporama < nb_diaporama ; cpt_diaporama++)
		demarrerDiaporama(cpt_diaporama+1);

}

function initialiser_fenetre()
{
	var arVersion = navigator.appVersion.split("MSIE")
	var version = parseFloat(arVersion[1])

	if ((version >= 5.5) && (document.body.filters)) 
	{
	   for(var i=0; i<document.images.length; i++)
	   {
	      var img = document.images[i]
	      var imgName = img.src.toUpperCase()
	      if (imgName.substring(imgName.length-12, imgName.length) == "ARRONDIE.PNG")
	      {
	         var imgID = (img.id) ? "id='" + img.id + "' " : ""
	         var imgClass = (img.className) ? "class='" + img.className + "' " : ""
	         var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
	         var imgStyle = "display:inline-block;" + img.style.cssText 
	         if (img.align == "left") imgStyle = "float:left;" + imgStyle
	         if (img.align == "right") imgStyle = "float:right;" + imgStyle
	         if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
	         var strNewHTML = "<span " + imgID + imgClass + imgTitle
	         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
	         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
	         img.outerHTML = strNewHTML
	         i = i-1
	      }
	   }
	}

	for ( cpt_diaporama = 0 ; cpt_diaporama < nb_diaporama ; cpt_diaporama++)
		demarrerDiaporama(cpt_diaporama+1);

}

function valider_renseignements()
{
	erreur_champs = false;
	msg_erreur = "";
	
	if ( document.formulaire_contact.nomprenom.value == "" ) { msg_erreur += "\n- Nom et prénom"; erreur_champs = true; }
	if ( document.formulaire_contact.adresse.value == "" ) { msg_erreur += "\n- Adresse"; erreur_champs = true; }
	if ( document.formulaire_contact.code_postal.value == "" ) { msg_erreur += "\n- Code postal"; erreur_champs = true; }
	if ( document.formulaire_contact.ville.value == "" ) { msg_erreur += "\n- Ville"; erreur_champs = true; }
	if ( document.formulaire_contact.telephone.value == "" ) { msg_erreur += "\n- Téléphone"; erreur_champs = true; }
	if ( document.formulaire_contact.email.value == "" ) { msg_erreur += "\n- Email"; erreur_champs = true; }
	if ( document.formulaire_contact.sujet.value == "" ) { msg_erreur += "\n- Sujet de votre demande"; erreur_champs = true; }
	
	if ( erreur_champs == true ) alert("Merci de remplir le(s) champ(s) :" + msg_erreur);
	else { if( confirm("Passer à l'étape suivante de l'envoi ?") )
	{
		// Verrouiller les informations
		document.formulaire_contact.nomprenom.disabled = true; 
		document.formulaire_contact.adresse.disabled = true; 
		document.formulaire_contact.code_postal.disabled = true; 
		document.formulaire_contact.ville.disabled = true; 
		document.formulaire_contact.telephone.disabled = true; 
		document.formulaire_contact.email.disabled = true; 
		document.formulaire_contact.sujet.disabled = true; 
	
		//Affichage du sondage
		document.getElementById('fenetre').style.display="block"; }
	}
		
}

function valider_contact()
{
		// Dévérouiller les informations
		document.formulaire_contact.nomprenom.disabled = false; 
		document.formulaire_contact.adresse.disabled = false; 
		document.formulaire_contact.code_postal.disabled = false; 
		document.formulaire_contact.ville.disabled = false; 
		document.formulaire_contact.telephone.disabled = false; 
		document.formulaire_contact.email.disabled = false; 
		document.formulaire_contact.sujet.disabled = false; 
	
		//Valider
		document.formulaire_contact.submit();		
}

function voir_actualite(num_actualite)
{
	document.formulaire_actualite.id_actualite.value=num_actualite;
	document.formulaire_actualite.submit();
}

function info_mail_envoye()
{
	alert("Vos informations ont été envoyées, merci");
}

function ouvrir_fenetre(page,hauteur)
{
	// width : 466 IE 
	fenetre = page.substr(0, (page.length-4));
	window.open(page,fenetre,"height="+hauteur+",width=500,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no");
}

function changerPage_actualite(aller_page)
{
	document.formulaire_actualite.page_ec_actu.value=aller_page
	document.formulaire_actualite.submit();
}

function changerPage_revue(aller_page)
{
	document.formulaire_revue.page_ec_revue.value=aller_page
	document.formulaire_revue.submit();
}
