//**********************************************************
//fonctions estEmail teste si le champ est de la forme email: 
// entrée : une chaîne
// sortie : si la chaîne correspond au critère
function estEmail(ch) {
	 return(ch.replace(/[\-\w]+[\.\-\w]*@[\-\w]+\.[\-\w]+[\.\-\w]*/, '*')=="*")
}

//**********************************************************
//fonction estSaisi teste la présence d'au moins un 
//caractère non vide
// entrée : une chaîne
// sortie : true si ch est saisie: ch non nulle et s'il y a au moins un caractère non blanc
function estSaisi(ch) {
	return (ch.length>0&&ch.replace(/[\s ]/gi,"").length>0) ;
}


//**********************************************************
//fonction LimiteCar = tronque un textarea source à max caractères
// entrée : 
//		testvalue : une chaîne de caractères
//		howmany   : la taille max, à tronquer
// sortie :
//		aucune, testvalue est modifiée !
//		
function LimiteCar(testvalue, howmany) {
   if (testvalue.value.length>howmany)  {
	alert("Vous avez atteint la limite de "+ howmany +" caractères,\nLe texte va être tronqué.");
//	alert("You have reach the limit of "+ howmany +" letters,\nThe text is truncated.");
	testvalue.value=testvalue.value.substring (0, howmany);
   }
}


//**********************************************************
//fonction testvide = controle champ tout à blanc ou vide 
//utilisation & retour identique à l'ancienne fonction
// entrée : 
//		testvalue : une chaîne de caractères
//		howmany   : la taille max de cette chaîne (gardé pour compatibilité)
// sortie :
//		true  si la chaine est totalement vide ou pleine de caractères blancs
//		false sinon
function testvide(testvalue, howmany) {
	return (testvalue.replace(/[\s]/gi, "").length>0);
}


//**********************************************************
function testnum(testvalue, howmany) {
	return (testvalue=="" || testvalue==testvalue.replace(/[^0-9 .\s]/g, "#"));
}

/* Teste une adresse email de la forme générique mot[.mot]*@mot.mot[.mot]*
 * ou mot est composé de A-Za-z0-9 et du caractère underscore _
 * renvoie true si l'adresse est correcte, false sinon
 */
function ValidEmail(sEmail) {
  return(sEmail.replace(/\w+[\.\w]*@\w+\.\w+[\.\w]*/, '*')=="*")
}

//**********************************************************
function testdate(testvalue) 
{
var erreur=0;
var aaaa,mm,jj,aa;//pour tester, après décope de testvalue
var mois=new Array(31,29,31,30,31,30,31,31,30,31,30,31);//nb de jour par mois janvier<=>mois[0]
	
	//teste si la date est composée de chiffres et de /
	if( testvalue.replace(/[0-9\/]/g, "").length==0 ) {
		aa=Math.ceil(testvalue.substring(8,10));
		aaaa=Math.ceil(testvalue.substring(6,10));
		mm=Math.ceil(testvalue.substring(3,5));
		jj=Math.ceil(testvalue.substring(0,2));
	
		//teste l'année entre 1930 et 2029
		if(aaaa>=1930 && aaaa<=2029) {
	
			//teste mois
			if(mm>=1 && mm<=12) {
	
				//teste année bissextile et mois de février
				if (Math.ceil(aa/4)!=(aa/4) && mm==2 && jj==29)
					return false;//jour du mois de février incorrect
	
				//teste mois par mois le 31
				if(jj>mois[mm-1])
					return false;//jour incorrect
	
			}else return false//mois incorrect
	
		}else return false;//année incorrecte
		
	}else return false;//caractère incorrect
	
	return true;
}

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_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 pop1() {
		var wind=window.open("e-alliance/inscription.asp", "Siplast", "0,0,left=100,top=50,0,scrollbars=yes,0,width=590,height=450");
		wind.opener=self;
	}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function OuvrePlan() {
		var wind=window.open("/plan.html", "Plan", "0,0,left=100,top=50,0,scrollbars=yes,0,width=735,height=650");
		wind.opener=self;
	}
	
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function trackEvent(URL, TITLE){
	// On fait appel à la fonction WebTrends
		dcsMultiTrack('DCS.dcsuri', URL, 'WT.ti', TITLE);
}

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 popAide(theURL) {	
			  window.open(theURL);	
}

function popAide1(url) {
	var wind=window.open(url, "Aide", "left=0,top=0,scrollbars=yes,width=600,height=400,status=yes,resizable=yes");
	wind.opener=self;
	wind.focus();
}

function popAide2(url) {	
		this.location.href=url;
}


function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0;
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;
	this.mac=this.agent.indexOf("Mac")>-1;
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
	return this;
}
var bw=lib_bwcheck();





