var reFloat = /^((\d+(\,\d*)?)|((\d*\,)?\d+))$/
var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 28;
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;
//---------------------------------------------
function ValidatorDate(DateToValidate)
//---------------------------------------------
{
	var inDate = DateToValidate;
	var inDay  = inDate.substring(0, inDate.indexOf("/"));
	if(inDay.substring(0,1) == "0" && inDay.length > 1) inDay = inDay.substring(1, inDay.length);

	var inMonth = inDate.substring(inDate.indexOf("/") + 1, inDate.lastIndexOf("/"));
	if(inMonth.substring(0,1) == "0" && inMonth.length > 1) inMonth = inMonth.substring(1, inMonth.length);

	var inYear  = inDate.substring(inDate.lastIndexOf("/") + 1, inDate.length);

	if(!isDate(inYear,inMonth,inDay))
	{
		alert("La date n'est pas une date correcte correcte !");
		return (false);
	}
	return true;
}
//---------------------------------------------
function isDate (year, month, day)
//---------------------------------------------
{
	if(!(isYear(year, false) && isMonth(month, false) && isDay(day, false))) return false;

    var intYear = parseInt(year);
    var intMonth = parseInt(month);
    var intDay = parseInt(day);

    if (intDay > daysInMonth[intMonth]) return false; 

    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;

    return true;
	}

function isYear (s)
	{   
	if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return false;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
	}

function isMonth (s)
	{   
	if (isEmpty(s)) 
       if (isMonth.arguments.length == 1) return false;
       else return (isMonth.arguments[1] == true);
    return isIntegerInRange (s, 1, 12);
	}

function isDay (s)
	{   
	if (isEmpty(s)) 
       if (isDay.arguments.length == 1) return false;
       else return (isDay.arguments[1] == true);   
    return isIntegerInRange (s, 1, 31);
	}

function isEmpty(s)
	{   
	return ((s == null) || (s.length == 0))
	}

function daysInFebruary (year)
{  
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}

function makeArray(n) {
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   	} 
   return this
}

function isIntegerInRange (s, a, b)
{   if (isEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return false;
       else return (isIntegerInRange.arguments[1] == true);

    if (!isInteger(s, false)) return false;

    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}

function isNonnegativeInteger (s)
{   var secondArg = false;

    if (isNonnegativeInteger.arguments.length > 1)
        secondArg = isNonnegativeInteger.arguments[1];

    return (isSignedInteger(s, secondArg)
         && ( (isEmpty(s) && secondArg)  || (parseInt (s) >= 0) ) );
}

function isInteger (s)

{   var i;

    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return false;
       else return (isInteger.arguments[1] == true);

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    return true;
}

function isSignedInteger (s)

{   if (isEmpty(s)) 
       if (isSignedInteger.arguments.length == 1) return false;
       else return (isSignedInteger.arguments[1] == true);

    else {
        var startPos = 0;
        var secondArg = false;

        if (isSignedInteger.arguments.length > 1)
            secondArg = isSignedInteger.arguments[1];

        if ( (s.charAt(0) == "-") || (s.charAt(0) == "+") )
           startPos = 1;    
        return (isInteger(s.substring(startPos, s.length), secondArg))
    }
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isFloat (s)

{   if (isEmpty(s)) 
       if (isFloat.arguments.length == 1) return defaultEmptyOK;
       else return (isFloat.arguments[1] == true);

    return reFloat.test(s)
}

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_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

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 ChangeDivBgr(DivName,Image) { //v3.0
	 DivName.style.backgroundImage = 'url('+ Image +')' ; 
}
function RestoreDivBgr(DivName,Image) { //v3.0
	 DivName.style.backgroundImage = 'url('+ Image +')' ; 
}

function ChangeDivCol(DivName,Color) { //v3.0
	 DivName.style.backgroundColor =  Color ; 
}
function RestoreDivCol(DivName,Color) { //v3.0
	 DivName.style.backgroundColor = Color ; 
}


function WinName(theName) { //v3.0
	 window.document.title = window.document.title + ' - ' + theName; 
}

function scrollnews(cliptop, speed, topedge, leftedge, boxheight, boxwidth, scrollheight) {
	if (document.layers) {
		newsDiv = document.newsScroll;
		newsDiv.clip.top = cliptop;
		newsDiv.clip.bottom = cliptop + boxheight;
		newsDiv.clip.left = 0;
		newsDiv.clip.right = boxwidth + leftedge;
		newsDiv.left = leftedge;
		newsDiv.top = topedge - cliptop;
	}
	else {
		newsDiv = newsScroll.style;
		newsDiv.clip = "rect(" + cliptop + "px " + (boxwidth + leftedge) + "px " + (cliptop + boxheight) + "px 0px)";
		newsDiv.pixelLeft = leftedge;
		newsDiv.pixelTop = topedge - cliptop;
	}
	cliptop = (cliptop + 1) % (scrollheight + boxheight);
	newsDiv.visibility='visible';

	setTimeout("scrollnews(" + cliptop + "," + speed + "," + topedge + "," + leftedge + "," + boxheight + "," + boxwidth + "," + scrollheight + ")",speed );
}

function scrollevent(cliptop, speed, topedge, leftedge, boxheight, boxwidth, scrollheight) {
	if (document.layers) {
		eventDiv = document.eventScroll;
		eventDiv.clip.top = cliptop;
		eventDiv.clip.bottom = cliptop + boxheight;
		eventDiv.clip.left = 0;
		eventDiv.clip.right = boxwidth + leftedge;
		eventDiv.left = leftedge;
		eventDiv.top = topedge - cliptop;
	}
	else {
		eventDiv = eventScroll.style;		
		eventDiv.clip = "rect(" + cliptop + "px " + (boxwidth + leftedge) + "px " + (cliptop + boxheight) + "px 0px)";
		eventDiv.pixelLeft = leftedge;
		eventDiv.pixelTop = topedge - cliptop;
	}
	cliptop = (cliptop + 1) % (scrollheight + boxheight);
	eventDiv.visibility='visible';

	setTimeout("scrollevent(" + cliptop + "," + speed + "," + topedge + "," + leftedge + "," + boxheight + "," + boxwidth + "," + scrollheight + ")",speed );
}
