
function rollover_accueil(rub){
	document.getElementById(rub).style.display='';
}

function rollout_accueil(rub){
	document.getElementById(rub).style.display='none';
}

function change_Check_Value(){
	if(document.oForm.fiscal_check.checked==true){
		document.oForm.fiscal.value='true';
	}
	if(document.oForm.social_check.checked==true){
		document.oForm.social.value='true';
	}
	if(document.oForm.frais_check.checked==true){
		document.oForm.frais.value='true';
	}
	if(document.oForm.newsletter_check.checked==true){
		document.oForm.newsletter.value='true';
	}
}




var checkmail = /^[\w\-]+(\.[\w\-]+)*@[\w\-]+(\.[\w\-]+)*\.[\w\-]{2,}$/;

function verifMail(email) {
    verif=checkmail.test(email)
    if(verif){
		return true;
	}else{
		return false;
	}
}


function verif_Contact_Form(){
	var email=document.oForm.email.value;
	
	if(document.oForm.prenom.value!=""){
		if(document.oForm.nom.value!=""){
			if(document.oForm.societe.value!=""){
				if(document.oForm.fonction.value!=""){
					if(document.oForm.ligne_directe.value!=""){
						if(email!=""){
							if(!verifMail(email)) {
								alert("Votre adresse email est invalide");
								return false; 
							}else{
								return true; 	// Submit
							}
						}else{
							alert("Vous n'avez pas saisi votre adresse email");
							return false; 
						}
					}else{
						alert("Vous n'avez pas saisi le numéro de votre ligne directe");
						return false; 
					}
				}else{
					alert("Vous n'avez pas saisi votre fonction");
					return false; 
				}
			}else{
				alert("Vous n'avez pas saisi le nom de votre société");
				return false; 
			}
		}else{
			alert("Vous n'avez pas saisi votre nom");
			return false; 
		}
	}else{
		alert("Vous n'avez pas saisi votre prénom");
		return false; 
	}
}

function verif_Recom_Form(){

	var email=document.recForm.email.value;
	
	var mails=document.recForm.mails.value;
	liste_email = mails.split(";");
	var nb=liste_email.length;
	
	if(document.recForm.prenommail.value!=""){
		if(document.recForm.nommail.value!=""){
	
			if(email!=""){
				if(verifMail(email)){
					if(mails!=""){
						for(i=0;i<nb;i++){	// on parcoure la liste des adresses "destinataire" saisies
							if(verifMail(liste_email[i])) {
								//alert(liste_email[i]);
								return true; 	// Submit
							}else{
								alert("Une des adresses email saisie dans le champs destinataires est invalide");
								return false;
							}
						}
					}else{
						alert("Vous n'avez pas saisi l'email du destinataire");
						return false;
					}
						
				}else{
					alert("Votre email est invalide");
					return false;
				}
		
			}else{
				alert("Vous n'avez pas saisi votre email");
				return false;
			}
			
		}else{
			alert("Vous n'avez pas saisi votre nom");
			return false;
		}
	}else{
		alert("Vous n'avez pas saisi votre prénom");
		return false;
	}

}


/* *******************************************************************/
/* ********************      ADMINISTRATION      *********************/
/* *******************************************************************/


// Ce n'est pas tout a fait de l'AJAX : Asynchronous JavaScript And XML , mais juste de l'utilisation de XmlHttpRequest car il n'y a pas de XML
// Sert à retourner des données de la base sans recharger la page

function getXhr(){
	var xhr = null;
	if(window.XMLHttpRequest){ // Firefox et autres
		xhr = new XMLHttpRequest();
	}else if(window.ActiveXObject){ // Internet Explorer
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP"); // ICI
		} catch (e) {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}else{ // XMLHttpRequest non supporté par le navigateur
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		xhr = false;
	}
	return xhr
}

function changeColorOver(id){
	document.getElementById('cellule'+id).style.background='#456b8f';
	document.getElementById('link'+id).style.color="#d4dfea";
}

function changeColorOut(id){
	document.getElementById('cellule'+id).style.background='#d4dfea';
	document.getElementById('link'+id).style.color="#456b8f";
}

function AfficheSousMenu(id){
	document.getElementById('sousmenu'+id).style.visibility='visible';
	for (i=1; i<7; i++){
		if (i!=id){
			document.getElementById('sousmenu'+i).style.visibility='hidden';
		}
	}
}

function CacheSousMenu(id){
	document.getElementById('sousmenu'+id).style.visibility='hidden';
}

function CacheToutSousMenu(){
	for (i=1; i<7; i++){
		document.getElementById('sousmenu'+i).style.visibility='hidden';
	}
}


function confirm(page,width,height){
	window.open(page,'confirmation','width='+width+',height='+height+',top='+screen.height/2+',left='+screen.width/4+',toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=no,directories=no');
}

function rafraichir(lurl){
	window.opener.location.href=lurl;
}

function refresh(lurl){
	window.opener.location.href=lurl;
}

function popupprint(rub){
	window.open('print.php?rub='+rub+'','impression','width=730,height=600,top=150,left=150,toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=yes,directories=no');
}

/* ********************************* ACTUALITES ******************************* */


function chargeImages(){
		document.aForm.action='contenu/actualites/listes/charge_image.php?action=1';
		document.aForm.target='upload_target';
		document.aForm.submit();
}

function stopUpload(success,mess){
		document.getElementById('mess_upload').innerHTML = mess;
		document.getElementById('file').innerHTML ='<input type="file" name="le_fichier1" style="width:300px">';
		return true; 
}




function supp_Images(id_acco_form){
	
		var xhr = getXhr();
		
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				leselect = xhr.responseText;
				if(leselect==1){
					document.getElementById('mess_upload').innerHTML = "Le fichier a bien été supprimé.";
					document.getElementById('lien_vers_fichier').style.display = "none";
				}else{
					document.getElementById('mess_upload').innerHTML = "Le fichier n'a pu être supprimé.";
				}
			}
		}
	
		xhr.open("POST","contenu/actualites/listes/charge_image.php?action=2",true);
		
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		
		xhr.send("id_acco_form="+id_acco_form);
}






function rempli_menu_doc_actu(id_type,lequel){
	
		var xhr = getXhr();
		
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				leselect = xhr.responseText;
				document.getElementById('contenant_id_doc'+lequel).innerHTML = leselect;
				
			}
		}
	
		xhr.open("POST","contenu/actualites/listes/generation_menu_doc.php",true);
		
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		
		xhr.send("id_type="+id_type+"&lequel="+lequel);
}

function rempli_champ_url(lequel){
	
		var xhr = getXhr();
		
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				url = xhr.responseText;
				document.getElementById('lien'+lequel).value=url;
			}
		}
	
		xhr.open("POST","contenu/actualites/listes/generation_url.php",true);
		
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		
		id_doc=document.getElementById('id_doc'+lequel).value;
		
		xhr.send("id_doc="+id_doc+"&lequel="+lequel);
}



function afficheLigneFormulaire(){
	if(document.getElementById('type_actu').options.selectedIndex==1){
		
		document.getElementById('ligne_espace').style.display='';
		
		document.getElementById('ligne_libelle1').style.display='';
		document.getElementById('ligne_libelle2').style.display='none';
		
	
		document.getElementById('ligne_choix1').style.display='none';
		document.getElementById('ligne_type_doc1').style.display='none';
		document.getElementById('ligne_doc1').style.display='none';
		document.getElementById('ligne_lien1').style.display='';
		
		document.getElementById('ligne_choix2').style.display='none';
		document.getElementById('ligne_type_doc2').style.display='none';
		document.getElementById('ligne_doc2').style.display='none';
		document.getElementById('ligne_lien2').style.display='none';
		
		
		document.getElementById('ligne_details').style.display='none';
		
		
	}else if(document.getElementById('type_actu').options.selectedIndex==2){
		
		document.getElementById('ligne_espace').style.display='';
		
		document.getElementById('ligne_libelle1').style.display='';
		
		document.getElementById('ligne_choix1').style.display='';
		document.getElementById('ligne_lien1').style.display='';
		document.getElementById('ligne_libelle2').style.display='';
		document.getElementById('ligne_choix2').style.display='';
		document.getElementById('ligne_lien2').style.display='';
		
		document.getElementById('ligne_details').style.display='none';
	
	}else if(document.getElementById('type_actu').options.selectedIndex==3){

		document.getElementById('ligne_espace').style.display='';
		
		document.getElementById('ligne_libelle1').style.display='';
		document.getElementById('ligne_libelle2').style.display='none';
		
	
		document.getElementById('ligne_choix1').style.display='none';
		document.getElementById('ligne_type_doc1').style.display='none';
		document.getElementById('ligne_doc1').style.display='none';
		document.getElementById('ligne_lien1').style.display='none';
		
		document.getElementById('ligne_choix2').style.display='none';
		document.getElementById('ligne_type_doc2').style.display='none';
		document.getElementById('ligne_doc2').style.display='none';
		document.getElementById('ligne_lien2').style.display='none';
		
		
		document.getElementById('ligne_details').style.display='';
		
	}else if(document.getElementById('type_actu').options.selectedIndex==4){
		
		document.getElementById('ligne_espace').style.display='none';
		
		document.getElementById('ligne_libelle1').style.display='none';
		document.getElementById('ligne_libelle2').style.display='none';
		
	
		document.getElementById('ligne_choix1').style.display='none';
		document.getElementById('ligne_type_doc1').style.display='none';
		document.getElementById('ligne_doc1').style.display='none';
		document.getElementById('ligne_lien1').style.display='none';
		
		document.getElementById('ligne_choix2').style.display='none';
		document.getElementById('ligne_type_doc2').style.display='none';
		document.getElementById('ligne_doc2').style.display='none';
		document.getElementById('ligne_lien2').style.display='none';
		
		
		document.getElementById('ligne_details').style.display='none';
	
	}
}

function afficheValueFormulaire(){
	if(document.getElementById('type_actu').options.selectedIndex==1){
		
		document.getElementById('libelle_lien1').value='';
		document.getElementById('libelle_lien2').value='';
		
	
		document.oForm.choix1[0].checked=true;
		document.oForm.type1.checked=0;
		//document.oForm.type1[0].checked=0;
		//document.oForm.type1[1].checked=0;
		//document.oForm.type1[2].checked=0;
		//document.oForm.type1[3].checked=0;
		document.getElementById('id_doc1').selectedIndex=0;
		document.getElementById('lien1').value='';
		
		document.oForm.choix2[0].checked=true;
		document.oForm.type2.checked=0;
		//document.oForm.type2[0].checked=0;
		//document.oForm.type2[1].checked=0;
		//document.oForm.type2[2].checked=0;
		//document.oForm.type2[3].checked=0;
		document.getElementById('id_doc2').selectedIndex=0;
		document.getElementById('lien2').value='';
		
		document.getElementById('details_actu1').value='';
		document.getElementById('details_actu2').value='';
		
	}else if(document.getElementById('type_actu').options.selectedIndex==2){
		
		document.getElementById('libelle_lien1').value='';
		document.getElementById('lien1').value='';
		
		document.getElementById('details_actu1').value='';
		document.getElementById('details_actu2').value='';
	
	}else if(document.getElementById('type_actu').options.selectedIndex==3){

		document.getElementById('ligne_espace').style.display='';
		
		document.getElementById('ligne_libelle1').style.display='';
		document.getElementById('libelle_lien1').value='Lire la suite';
		document.getElementById('libelle_lien2').value='';
		
	
		document.oForm.choix1[0].checked=true;
		document.oForm.type1.checked=0;
		//document.oForm.type1[1].checked=0;
		//document.oForm.type1[2].checked=0;
		//document.oForm.type1[3].checked=0;
		document.getElementById('id_doc1').selectedIndex=0;
		document.getElementById('lien1').value='';
		
		document.oForm.choix2[0].checked=true;
		document.oForm.type2.checked=0;
		//document.oForm.type2[0].checked=0;
		//document.oForm.type2[1].checked=0;
		//document.oForm.type2[2].checked=0;
		//document.oForm.type2[3].checked=0;
		document.getElementById('id_doc2').selectedIndex=0;
		document.getElementById('lien2').value='';
		
	}else if(document.getElementById('type_actu').options.selectedIndex==4){
		
		document.getElementById('libelle_lien1').value='';
		document.getElementById('libelle_lien2').value='';
		
	
		document.oForm.choix1[0].checked=true;
		document.oForm.type1.checked=0;
		//document.oForm.type1[0].checked=0;
		//document.oForm.type1[1].checked=0;
		//document.oForm.type1[2].checked=0;
		//document.oForm.type1[3].checked=0;
		document.getElementById('id_doc1').selectedIndex=0;
		document.getElementById('lien1').value='';
		
		document.oForm.choix2[0].checked=true;
		document.oForm.type2.checked=0;
		//document.oForm.type2[0].checked=0;
		//document.oForm.type2[1].checked=0;
		//document.oForm.type2[2].checked=0;
		//document.oForm.type2[3].checked=0;
		document.getElementById('id_doc2').selectedIndex=0;
		document.getElementById('lien2').value='';
		
		document.getElementById('details_actu1').value='';
		document.getElementById('details_actu2').value='';
	
	}
}

function suppLigneFormulaire(lequel){

	if(lequel==1){
		document.oForm.type1.checked=0;
		//document.oForm.type1[0].checked=0;
		//document.oForm.type1[1].checked=0;
		//document.oForm.type1[2].checked=0;
		//document.oForm.type1[3].checked=0;
		document.getElementById('ligne_type_doc1').style.display='none';
		document.getElementById('id_doc1').selectedIndex=0;
		document.getElementById('ligne_doc1').style.display='none';
		document.getElementById('lien1').value='';
	}else if(lequel==2){
		document.oForm.type2.checked=0;
		//document.oForm.type2[0].checked=0;
		//document.oForm.type2[1].checked=0;
		//document.oForm.type2[2].checked=0;
		//document.oForm.type2[3].checked=0;
		document.getElementById('ligne_type_doc2').style.display='none';
		document.getElementById('id_doc2').selectedIndex=0;
		document.getElementById('ligne_doc2').style.display='none';
		document.getElementById('lien2').value='';
	}

}

function verifFormActu(){

	if(document.oForm.date_debut.value!=""){
		if(document.oForm.date_fin.value!=""){
			if(document.getElementById('type_actu').selectedIndex!=0){
					if(document.oForm.titre_actu.value!=""){
					
						if(document.getElementById('type_actu').selectedIndex==1){
						
							if(document.oForm.libelle_lien1.value!=""){
								if(document.oForm.lien1.value!=""){
									document.oForm.submit();
								}else{
									alert("Vous n'avez pas saisi le lien 1");
								}
							}else{
								alert("Vous n'avez pas saisi le libellé du lien 1");
							}
							
						}else if(document.getElementById('type_actu').selectedIndex==2){
						
							if(document.oForm.libelle_lien1.value!=""){
								if(document.oForm.lien1.value!=""){
									document.oForm.submit();
								}else{
									alert("Vous n'avez pas saisi le lien 1");
								}
							}else{
								alert("Vous n'avez pas saisi le libellé du lien 1");
							}
							
						}else if(document.getElementById('type_actu').selectedIndex==3){
						
							if(document.oForm.libelle_lien1.value!=""){
								if(tinyMCE.getContent("details_actu1")!=""){
									if(tinyMCE.getContent("details_actu2")!=""){
										document.oForm.submit();
									}else{
										alert("Vous n'avez pas saisi le détail de la colonne de droite de l'actualité");
									}
								}else{
									alert("Vous n'avez pas saisi le détail de la colonne de gauche de l'actualité");
								}
							}else{
								alert("Vous n'avez pas saisi le libellé du lien 1");
							}
							
						}else if(document.getElementById('type_actu').selectedIndex==4){
							document.oForm.submit();
						}
						
					}else{
						alert("Vous n'avez pas sélectionné le titre de l'actualité");
					}
			}else{
				alert("Vous n'avez pas sélectionné le type d'actualité");
			}
		}else{
			alert("Vous n'avez pas saisi le champ date de fin d'édition");
		}	
	}else{
		alert("Vous n'avez pas saisi le champ date de début d'édition");		
	}

}



/* *************************************************** DOCUMENTATION ********************************************** */

function verifDoc(nbre){
	var coche='non';

	if(document.oForm.titre_doc.value!=""){
		if(nbre>1){
			for(i=0;i<nbre;i++){
				if(document.oForm.type[i].checked==true){
					coche='oui';
				}
			}
		}else{
			if(document.oForm.type.checked==true){
				coche='oui';
			}
		}
		
		if(coche=='oui'){
			document.oForm.submit();
		}else{
			alert("Vous n'avez pas cochez le thème du document");
		}
		
	}else{
		alert("Vous n'avez pas saisi le titre du document");
	}
}

function rempli_menu_doc(id_type){
	
		var xhr = getXhr();
		
		xhr.onreadystatechange = function(){
			if(xhr.readyState == 4 && xhr.status == 200){
				leselect = xhr.responseText;
				
				/*
					if(document.all){	//IE
					
						document.getElementById('contenant_id_doc').innerHTML = leselect;
					
					}else{	// DOM
					
						// pour vider le contenu de "contenant_id_doc"
						while(document.getElementById('contenant_id_doc').firstChild) document.getElementById('contenant_id_doc').removeChild(document.getElementById('contenant_id_doc').firstChild);
		
						
						// pour créer le menu déroulant
						var unSelect = document.createElement("select");
						unSelect.setAttribute("onchange","document.miForm.submit();");
						unSelect.setAttribute("name","id_doc");
						unSelect.setAttribute("id","id_doc");
						
						// gérer les options dynamiquement en AJAX : à FAIRE
						var oOption1 = document.createElement("option");
						oOption1.value = "5";
						oOption1.text = "Sélectionnez le fichier à modifier";
						
						var oOption2 = document.createElement("option");
						oOption2.value = "1";
						oOption2.text = "unTexte";
					

						unSelect.appendChild(oOption1);
						unSelect.appendChild(oOption2);
						document.getElementById('contenant_id_doc').appendChild(unSelect);
						
				}
				
				*/
				
				document.getElementById('contenant_id_doc').innerHTML = leselect;
				
			}
		}
	
		xhr.open("POST","contenu/doc_tech/listes/generation_menu_doc.php",true);
		
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		
		xhr.send("id_type="+id_type);
}

function alimenteChamp(){
	document.baForm.lequeltheme.value=document.baForm.idtheme.options[document.baForm.idtheme.selectedIndex].text;
	i=document.baForm.idtheme.options[document.baForm.idtheme.selectedIndex].value;
}



/* *************************************************** REFERENCES ********************************************** */

function verifFormRef(){

	if(document.oForm.type_ref.value!=""){
		if(document.oForm.titre_ref.value!=""){
			if(tinyMCE.getContent("details_ref")!=""){
				document.oForm.submit();
			}else{
				alert('Vous n\'avez pas saisi le texte lié à la référence');
			}
		}else{
			alert('Vous n\'avez pas saisi le titre de la référence');
		}
	}else{
		alert('Vous n\'avez pas saisi le type de la référence');
	}
}

/* *******************************************************************/
/* ****************      FONCTIONS DREAMWEAVER      ******************/
/* *******************************************************************/


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
