﻿function new_window(page){
	window.open(page);
}
function demande_conf(numi1,numi2){
	if (confirm("Etes vous certain(e) de vouloir "+numi1)) {
		eval('window.location="'+numi2+'"');
	}
}

/* deb fonctions de diaporama */
	function lance_slideshow(name_div1,name_div2,name_div3,tab_image,tab_lien,tab_text,compteur,sleep,aleatoire){	
		eval("trans"+compteur+" = new Array();");
		eval("fading"+compteur+"=''");
	
		if(aleatoire==1){// aleatoire
			nbimages = tab_image.length;
			var a=Math.floor(nbimages*Math.random());
			var b=1;
			var g=a;
			while(g==a){
				var g=Math.floor(nbimages*Math.random());
			}
			var b = g;
		} else {
			var a = 0;
			var b = 1;
		}
		
		back0 = document.getElementById(name_div1);
		front0 = document.getElementById(name_div2);
		txt0 = document.getElementById(name_div3);	
		
		var taille_w = front0.style.width;
		var taille_h = front0.style.height;
		
		if(tab_lien[a]){
			front0.innerHTML='<a href="'+tab_lien[a]+'"><img src="image/x.gif" width="'+taille_w+'" height="'+taille_h+'" border="0"></a>';
		} else {
			front0.innerHTML='<img src="image/x.gif" width="'+taille_w+'" height="'+taille_h+'" border="0">';
		}
		if(tab_text[a]){
			txt0.innerHTML='<div style="width: '+taille_w+'px;" align="left">'+tab_text[a]+'</div>';
		}
	
		back0.style.backgroundImage = 'url(' + '\'' + tab_image[a] + '\'' + ')';
		front0.style.backgroundImage = 'url(' + '\'' + tab_image[b] + '\'' + ')';	
		setTimeout(function() { fade_loop(a, b,name_div1,name_div2,name_div3,tab_image,tab_lien,tab_text,compteur,sleep,aleatoire); }, sleep * 1000);
	}
	
	function fade_in(a, b,name_div1,name_div2,name_div3,tab_image,tab_lien,tab_text,compteur,sleep,aleatoire) {
		if (eval("trans"+compteur+"["+b+"]") < 100) {
			eval("trans"+compteur+"["+b+"] = trans"+compteur+"["+b+"]+2");
			front0 = document.getElementById(name_div2);
			if (document.all) { front0.filters.alpha.opacity = eval("trans"+compteur+"["+b+"]"); }
			front0.style.MozOpacity = Math.min(parseFloat(front0.style.MozOpacity) + 0.02, 0.99);
			front0.style.opacity = Math.min(parseFloat(front0.style.opacity) + 0.02, 0.99);
	
			if (eval("trans"+compteur+"["+b+"]") == 100) {
				eval("clearInterval(fading"+compteur+")");
				if(aleatoire==1){// aleatoire
					nbimages = tab_image.length;
					var g=b;
					while(g==b){
						var g=Math.floor(nbimages*Math.random());
					}
					var c = g;
				} else {
					var c = b + 1; if (!tab_image[c]) { var c = 0; }
				}
				setTimeout(function() { fade_loop(b, c,name_div1,name_div2,name_div3,tab_image,tab_lien,tab_text,compteur,sleep,aleatoire); }, sleep * 1000);			
			}
		}
	}
	
	function fade_loop(a,b,name_div1,name_div2,name_div3,tab_image,tab_lien,tab_text,compteur,sleep,aleatoire) {
		if(eval("fading"+compteur)){eval("clearInterval(fading"+compteur+");");}
		back0 = document.getElementById(name_div1);
		front0 = document.getElementById(name_div2);
		txt0 = document.getElementById(name_div3);	
		txt0.style.display='none';
		var taille_w = front0.style.width;
		var taille_h = front0.style.height;	
		if(tab_lien[b]){
			front0.innerHTML='<a href="'+tab_lien[b]+'"><img src="image/x.gif" width="'+taille_w+'" height="'+taille_h+'" border="0"></a>';
		} else {
			front0.innerHTML='<img src="image/x.gif" width="'+taille_w+'" height="'+taille_h+'" border="0">';
		}
		if(tab_text[b]){
		//	front0.innerHTML+='<div>'+tab_text[b]+'</div>';
			front0.innerHTML+='<div style="width: '+taille_w+'px;" align="left">'+tab_text[b]+'</div>';
		}
		back0.style.backgroundImage = 'url(' + '\'' + tab_image[a] + '\'' + ')';
		front0.style.backgroundImage = 'url(' + '\'' + tab_image[b] + '\'' + ')';
	
		eval("trans"+compteur+"["+a+"]=0");
		eval("trans"+compteur+"["+b+"]=0");
	
		if (document.all) { front0.filters.alpha.opacity = 0;}
		front0.style.MozOpacity = 0;
		front0.style.opacity = 0;
		gfds = setInterval(function(){fade_in(a,b,name_div1,name_div2,name_div3,tab_image,tab_lien,tab_text,compteur,sleep,aleatoire); }, sleep);
		eval("fading"+compteur+"="+gfds);
	}
/* fin fonctions de diaporama */

/* deb fonctions de planche contact */
	function afficherImage(id,lien,nom_img,m_larg,m_haut,g_larg,g_haut){
		val_txt="";
		val_txt = eval("planche_txt_"+id+"['"+nom_img+"']");
		if (document.images){
			document.images['planche_contact'+id].src = "miniature.php?pic="+lien+"/img_base/planche_contact/"+nom_img+"&w_max="+m_larg+"&h_max="+m_haut;
			var new_lien ="miniature.php?pic=img_base/planche_contact/"+nom_img+"&w_max="+g_larg+"&h_max="+g_haut+"&id_planche_contact="+id+"','"+g_larg+"','"+g_haut+"');";
			document.getElementById('lien_planche_contact'+id).href = new_lien;
			document.getElementById('lien_planche_contact'+id).title = val_txt;
		}
	}
	function popup_diapo(page,largeur,hauteur) {
	  var top=(screen.height-hauteur)/2;
	  var left=(screen.width-largeur)/2;
	  var page = "http://www.flexit.fr/clients/utils/modules/"+page;
	  var options = "menubar=no,scrollbars=yes,statusbar=no";
	  window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
	}
/* fin fonctions de planche contact */

/* deb fonctions de formulaire */
	function MM_validateForm() { //v4.0
	  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
		if (val) { nm=val.name;nm1=val.title;if(nm1!="")nm=nm1; if ((val=val.value)!="") {
		  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) errors+='Le champ '+nm+' doit contenir une adresse email.\n';
		  } else if (test!='R') { num = parseFloat(val);
			if (isNaN(val)) errors+='Le champ '+nm+' doit contenir un nombre.\n';
			if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
			  min=test.substring(8,p); max=test.substring(p+1);
			  if (num<min || max<num) errors+='Le champ '+nm+' doit contenir un nombre entre '+min+' et '+max+'.\n';
		} } } else if (test.charAt(0) == 'R') errors += 'Le champ '+nm+' est requis.\n'; }
	  } if (errors) alert('Erreur(s) rencontrée(s) :\n'+errors);
	  document.MM_returnValue = (errors == '');
	}
/* fin fonctions de formulaire */
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;
}
