/**** pop up *** exemple dans href="javascript:popup('chemin/doc.php',450,380,300,300)" ***/
function popup(page,width,height,top,left)
	{
	window.open(page,'popup','width='+width+',height='+height+',top='+top+',left='+left+',toolbar=1,location=1,directories=1,status=1,menubar=yes,scrollbars=yes,resizable=yes');
	}

/****		Recharge l'url		****/
function rafraichit(lurl){
	window.opener.location.href=lurl;
}

/* ************  BACK OFFICE  ************ */

function verifDocForm(){
	if(document.getElementById('id_titre').options.selectedIndex>0){
		document.oForm.submit();
	}else{
		alert("Vous n'avez pas séléctionné le titre du document");
	}
}



// suppression de fichier pour la gestion de documentation

function convertListe(){	

	// listes documents à supprimer
	
	if(document.baForm.fichiers_assoc.options.length!=0){

		document.baForm.fichiers_assoc.name = "fichiers_assoc[]";	// je modifie l'ID  de la liste pour que PHP traite cette dernière comme un tableau
	
	}
	
	document.baForm.submit();

}

// fin

function envoiMiForm(){
	if(document.miForm.id_doc.value!=""){
		document.miForm.submit();
	}
}

function verif_titreForm(lequel){							// centre de documentation : les titres
	
	if(lequel=='ajout'){
	
		if(document.oForm.id_theme.options.selectedIndex>0){
			if(document.oForm.titre_doc.value!=''){
				if(document.oForm.titre_dossier.value!=''){
					if(document.oForm.type[0].checked == true || document.oForm.type[1].checked == true || document.oForm.type[2].checked == true)
						{
						if(document.oForm.papier[0].checked == true || document.oForm.papier[1].checked == true)
							{

							if(document.oForm.papier[0].checked == true && document.oForm.prix.value =='')
								{
								alert("Vous devez préciser le montant au format (1.00) et non (1,00).");
								}
							else
								{
								document.oForm.submit();
								}
							if(document.oForm.papier[1].checked == true)
								{
								document.oForm.submit();
								}
							}
						else
							{
							alert("Ce document a-il un format physique ?");
							}
						}
					else
						{
						alert("Cochez un type de document");
						}
				}else{
					alert("Saisissez un titre de dossier");
				}
			}else{
				alert("Saisissez un titre de document");
			}
		}else{
			alert("Sélectionner un thème");
		}
		
	}else if(lequel=='modif'){
	
		if(document.baForm.id_theme.options.selectedIndex>0){
			if(document.baForm.titre_doc.value!=''){
				if(document.baForm.papier[0].checked == true || document.baForm.papier[1].checked == true){
					document.baForm.submit();
				}else{
					alert("Ces documents sont-ils disponibles au format papier ou VHS");
				}
			}else{
				alert("Saisissez un titre de document");
			}
		}else{
			alert("Sélectionner un thème");
		}
	
	}
	
}



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;
}

function allerVers(ancre){
	document.location.href='#'+ancre;
}

function verifMailForm(nbre){
	var ok=0;
	if(document.aForm.email.value!=""){
	
		if(nbre>1){
			for(i=0;i<nbre;i++){
				if(document.aForm.groupe_id[i].checked == true){
					document.aForm.submit();
					ok=1;
					break;
				}
			}
		}
		
		if(nbre==1){
			if(document.aForm.groupe_id.checked == true){
				document.aForm.submit();
				ok=1;
			}
		}
		
		if(ok==0){
			alert("Vous devez cocher groupe");
		}
		
	}else{
		alert("Vous devez saisir un email");
	}
}


function groupeTest(){
	if(document.oForm.groupe.value!=""){
		document.oForm.submit();
	}else{
		alert("Vous devez saisir le nom d'un groupe");
	}
}


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 rafraichit(lurl){
	window.opener.location.href=lurl;
}

/* *************************************** */

function popuplettre(page,width,height,top,left){
	window.open(page,'popuplettre','width='+width+',height='+height+',top='+top+',left='+left+',toolbar=no,scrollbars=no,menubar=no,location=no,resizable=no,directories=no');
}
function popuplettreancien(page,width,height,top,left){
	window.open(page,'popuplettre','width='+width+',height='+height+',top='+top+',left='+left+',toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=no,directories=no');
}

function popupprint(idrub,idsrub,idssrub,iprint){
	window.open('print.php?idrub='+idrub+'&idsrub='+idsrub+'&idssrub='+idssrub+'&iprint'+iprint+'','impression','width=800,height=650,top=0,left=0,toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=yes,directories=no');
}

function popuprub(page,nom,width,height,top,left){
	window.open(page,nom,'width='+width+',height='+height+',top='+top+',left='+left+',toolbar=no,scrollbars=yes,menubar=no,location=no,resizable=yes,directories=no');
}

// Dans boite à outils : documentation technique
function changeliste(){
	document.choixtheme.submit(); 
}


/* FONCTIONS DREAMWEAVER */


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_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_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_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);

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 transmettre(url){
	window.opener.location.href=url;
}