function openInNewWindowDS(adr, windowName,w,h)
{
    var centerW;
    var centerH;
    var attributes = "width="+(w+10)+",height="+(h+10)+",toolbar=no,menubar=no,location=no,scrollbars=auto,resizable=yes,status=yes";
    
    //var wWindow = window.open("http://www.yahoo.com", "poulpe", "width=300, height=200");
    var wWindow = window.open(adr, windowName, attributes );
    //wWindow = window.open(adr, windowName, "width="+w+",height="+h+",menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0,resizable=1");
    centerW = screen.availWidth/2-w/2;
    centerH = (screen.availHeight-100)/2-h/2;

    wWindow.moveTo(centerW,centerH);
    wWindow.focus();
}
function openInNewWindowDSScroll(adr, windowName,w,h)
{
    var centerW;
    var centerH;
    var attributes = "width="+(w+10)+",height="+(h+10)+",toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=yes";
    
    //var wWindow = window.open("http://www.yahoo.com", "poulpe", "width=300, height=200");
    var wWindow = window.open(adr, windowName, attributes );
    //wWindow = window.open(adr, windowName, "width="+w+",height="+h+",menubar=0,location=0,toolbar=0,personalbar=0,status=0,scrollbars=0,resizable=1");
    centerW = screen.availWidth/2-w/2;
    centerH = (screen.availHeight-100)/2-h/2;

    wWindow.moveTo(centerW,centerH);
    wWindow.focus();
}
function S994_WriteCookie(nom, valeur)
{
  var argv=S994_WriteCookie.arguments;
  var argc=S994_WriteCookie.arguments.length;
  var expires=(argc > 2) ? argv[2] : null;
  var path=(argc > 3) ? argv[3] : null;
  var domain=(argc > 4) ? argv[4] : null;
  var secure=(argc > 5) ? argv[5] : false;
  
  var cookStr = nom+"="+escape(valeur)+
  ((path==null) ? "" : ("; path="+path))+
  ((domain==null) ? "" : ("; domain="+domain))+
  ((secure==true) ? "; secure" : "");
  
  if(expires==null)
  {
   var date=new Date;
   date.setFullYear(date.getFullYear()+1);
   expires = "; expires=" + date.toGMTString();
  }
  
  cookStr = cookStr + expires;
  //alert("cookStr : "+cookStr);
  //alert("expires : "+expires);

  document.cookie= cookStr;
}

function getCookieVal(offset)
{
	var endstr=document.cookie.indexOf (";", offset);
	if (endstr==-1) endstr=document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function LireCookie(nom)
{
	var arg=nom+"=";
	var alen=arg.length;
	var clen=document.cookie.length;
	var i=0;
	while (i<clen)
	{
		var j=i+alen;
		if (document.cookie.substring(i, j)==arg) return getCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if (i==0) break;
	}
	return null;
}
/**********************************************************************/ 
  /*Function name :isDigit(theDigit) */ 
  /*Usage of this function :test for an digit */ 
  /*Input parameter required:thedata=string for test whether is digit */ 
  /*Return value :if is digit,return true */ 
  /* else return false */ 
  /**********************************************************************/ 
  function isDigit(theDigit) 
  { 
    var digitArray = new Array('0','1','2','3','4','5','6','7','8','9'),j; 
    
    for (j = 0; j < digitArray.length; j++) 
    {
      if (theDigit == digitArray[j]) 
      return true 
    } 
    return false 
  } 
  /*************************************************************************/ 
  /*Function name :isPositiveInteger(theString) */ 
  /*Usage of this function :test for an +ve integer */ 
  /*Input parameter required:thedata=string for test whether is +ve integer*/ 
  /*Return value :if is +ve integer,return true */ 
  /* else return false */ 
  /*function require :isDigit */ 
  /*************************************************************************/ 
  function isPositiveInteger(theString) 
  { 
    var theData = new String(theString) 
    
    if (!isDigit(theData.charAt(0)))
    {
      if (!(theData.charAt(0)== '+')){return false;}
    }
    for (var i = 1; i < theData.length; i++)
    {
      if (!isDigit(theData.charAt(i))){return false;} 
    }
    return true; 
  } 
  /**********************************************************************/ 
  /*Function name :isDate(s,f) */ 
  /*Usage of this function :To check s is a valid format */ 
  /*Input parameter required:s=input string */ 
  /* f=input string format */ 
  /* =1,in mm/dd/yyyy format */ 
  /* else in dd/mm/yyyy */ 
  /*Return value :if is a valid date return 1 */ 
  /* else return 0 */ 
  /*Function required :isPositiveInteger() */ 
  /**********************************************************************/ 
  function isDate(s,f) 
  {
    var a1=s.split("/"); 
    var a2=s.split("-"); 
    var e=true; 
    if ((a1.length!=3) && (a2.length!=3)){e=false;} 
    else 
    {
      if (a1.length==3){ var na=a1;}
      if (a2.length==3){ var na=a2;}
      if (isPositiveInteger(na[0]) && isPositiveInteger(na[1]) && isPositiveInteger(na[2])) 
      { 
        if (f==1){var d=na[1],m=na[0];} 
        else{var d=na[0],m=na[1];} 
        
        var y=na[2]; 
        if (((e) && (y<1000)||y.length>4)){e=false}
        if (e) 
        { 
          v=new Date(m+"/"+d+"/"+y); 
          if (v.getMonth()!=m-1){e=false;}
        } 
      } 
      else{e=false;} 
    } 
    return e 
  } 
  
  function checkDate(v) 
  { 
  //var s=v; 
  //if (!isDate(s,0)) //dd/mm/yyyy format 
  //alert("The inputted date value is valid!"); 
  //else 
  //alert("The inputted date value is not valid!"); 
  //return false; 
  return isDate(v,0);
  } 

  
  //la date entrée doit être validée auparavant
  //au format dd/mm/yyyy
  function getDate(strDate)
  {	  
      
      
    year = strDate.substring(6,10);
    month = strDate.substring(3,5);
    day = strDate.substring(0,2);
    
    //alert("day:"+day+" month:"+month+" year:"+year);
    
    if(checkDate(strDate))
    {
      try
      {
        d = new Date();
        d.setDate(day);
        d.setMonth(eval(month)-1);
        d.setFullYear(year); 
        
        //alert("get day:"+d.getDate()+" month:"+d.getMonth()+" year:"+d.getYear());
        
        if(d.getMonth() == eval(month)-1){return d; }
        else {return null;}
      }catch(err){return null;} 
    }
    else{return null;}   
  }
  
  //Return:
  //   0 si date_1=date_2
  //   1 si date_1>date_2
  //  -1 si date_1<date_2	  
  function compare(date_1, date_2)
  {
    diff = date_1.getTime()-date_2.getTime();
    return (diff==0?diff:diff/Math.abs(diff));
  }
  
  // Removes leading whitespaces
  function LTrim( value ) {
          
          var re = /\s*((\S+\s*)*)/;
          return value.replace(re, "$1");
          
  }
  
  // Removes ending whitespaces
  function RTrim( value ) {
          
          var re = /((\s*\S+)*)\s*/;
          return value.replace(re, "$1");
          
  }
  
  // Removes leading and ending whitespaces
  function trim( value ) {
          
          return LTrim(RTrim(value));
          
  }

/**********************************************************************/ 
  /*Function name :isCorrectPwdChar(txt) */ 
  /*Usage of this function :To check valid/invalid char */ 
  /*Input parameter required:s=input string */ 
  /* txt=input string format */ 
  /*Return value :if there is no invalid char return true */ 
  /* else return false */ 
  /**********************************************************************/   
  function isCorrectPwdChar(txt) 
  {
   var invalids = "éèàùïìëêôöçµ´`%£¬§#\°?";

   for(i=0; i<invalids.length; i++) 
   {
    if(txt.indexOf(invalids.charAt(i)) >= 0 ) {return false;}
   }
   return true;
  }