function isValidIsoDate(strDate,intType) 
{	
	// Fonction qui vérifie si la chaine envoyée est une date valide
	// Version 1.0 12 Juin 2000
	// Vérifie pour les formats de date valide suivants :
	// YYYY/MM/DD   YYYY-MM-DD Pour intType = 1
	// MM/JJ/YYYY   MM-JJ-YYYY Pour intType = 2
	// JJ/MM/YYYY   JJ-MM-YYYY Pour intType = 3
	// Erreur  								retourne
	// Pas le bon format de date   		0
	// Si la date est plus vieille         -1
	// Sinon retourne 			1
	
	var strFormat;
	if (intType == "") {intType = "1";}
	
	if (intType == "1"){ strFormat = /^(\d{4})(\/|-)(\d{1,2})\2(\d{1,2})$/;}
	if (intType == "2")	{ strFormat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;}
	if (intType == "3"){ strFormat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;}
	
	var colMatchDate = strDate.match(strFormat); // Format de la date OK?
	
	if (colMatchDate == null)
	{
		// Retourne 0 si ce n'est pas le bon format de date
		return 0;
	}
	// place la date dans les variables
	if (intType == "1"){
		var strMois = colMatchDate[3];
		var strJour = colMatchDate[4];
		var strAnnee = colMatchDate[1];}
	if (intType == "2")	{
		var strMois = colMatchDate[1];
		var strJour = colMatchDate[3];
		var strAnnee = colMatchDate[4];}
	if (intType == "3"){
		var strMois = colMatchDate[3];
		var strJour = colMatchDate[1];
		var strAnnee = colMatchDate[4];}	 
	
	if (strMois < 1 || strMois > 12)
	{ 
		// Vérifie que le mois se situe entre 1 et 12 sinon retourne 0 
		return 0;
	}
	if (strJour < 1 || strJour > 31)
	{
		// Vérifie que le jour se situe entre 1 et 31 sinon retourne 0
		return 0;
	}
	if ((strMois ==4 || strMois ==6 || strMois ==9 || strMois ==11) && strJour ==31)
	{
		// Vérifie les mois n'ayant pas 31 jours sinon retourne 0
		return 0;
	}
	if (strMois == 2)
	{ 
		// Vérifie pour le 29 février
		var blnBissextile = (strAnnee % 4 == 0 && (strAnnee % 100 != 0 || strAnnee % 400 == 0));
		if (strJour > 29 || (strJour == 29 && ! blnBissextile))
		{
			//Si le 29 de février n'existe pas cet année ou si c'est plus que 29 retourne 0
			return 0;
		}
	}
	var strNewDate = new Date()
	
	if ( Date.parse(strMois+"-"+strJour+"-"+strAnnee) < Date.parse((strNewDate.getMonth()+1)+"-"+strNewDate.getDate()+"-"+strNewDate.getFullYear()) )
	{
		return -1;
	}
	if ( Date.parse(strMois+"-"+strJour+"-"+strAnnee) == Date.parse((strNewDate.getMonth()+1)+"-"+strNewDate.getDate()+"-"+strNewDate.getFullYear()) )
	{
		return 2;
	}
	return 1;  //La date est valide
}
function CheckDateType(dtmDateToCheck)
{	 
	var strFormat1 = /^(\d{4})(\/|-)(\d{1,2})\2(\d{1,2})$/;
	var strFormat2 = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
	var strTypeDate;
	var colMatchFormatDate;
	
	colMatchFormatDate = dtmDateToCheck.match(strFormat1)
	if (colMatchFormatDate != null)
	{
		if (isValidIsoDate(dtmDateToCheck,"1") == 0)
		{
			strTypeDate = 0
		}
		else
		{
			strTypeDate = 1
		}
	}
	else
	{
		colMatchFormatDate = dtmDateToCheck.match(strFormat2)
		if (colMatchFormatDate != null)
		{
			if (isValidIsoDate(dtmDateToCheck,"2") == 0)
			{
				if (isValidIsoDate(dtmDateToCheck,"3") == 0)
				{
					strTypeDate = 0
				}
				else
				{
					strTypeDate = 3
				}
			}
			else
			{
				strTypeDate = 2
			}
		}
		else
		{
			strTypeDate = 0
		}
	}
	return strTypeDate;
}

function CompareTwoDate(strFirstDate,strSecondDate)
{
	var strFormat1 = /^(\d{4})(\/|-)(\d{1,2})\2(\d{1,2})$/;
	var strFormat2 = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;	
	var strTypeFirstDate=CheckDateType(strFirstDate);
	var strTypeSecondDate=CheckDateType(strSecondDate);
	var colMatchFormatFirstDate;
	var colMatchFormatSecondDate;
	var strDayFirstDate;
	var strMonthFirstDate;
	var strYearFirstDate;
	var strDaySecondDate;
	var strMonthSecondDate;
	var strYearSecondDate;
	var dtmFirstDate;
	var dtmSecondDate;
	if (strTypeFirstDate == 0 && strTypeSecondDate == 0)
		return 0;
	if (strTypeFirstDate == 0)
		return -1;
	if (strTypeSecondDate == 0)
		return 1;
	if (strTypeFirstDate == 1)
	{
		colMatchFormatFirstDate = strFirstDate.match(strFormat1)
		strMonthFirstDate = colMatchFormatFirstDate[3];
		strDayFirstDate = colMatchFormatFirstDate[4];
		strYearFirstDate = colMatchFormatFirstDate[1];
	}
	else
	{
		colMatchFormatFirstDate = strFirstDate.match(strFormat2)
		if (strTypeFirstDate == 2)
		{
			strMonthFirstDate = colMatchFormatFirstDate[1];
			strDayFirstDate = colMatchFormatFirstDate[3];
			strYearFirstDate = colMatchFormatFirstDate[4];
		}
		else
		{
			strMonthFirstDate = colMatchFormatFirstDate[3];
			strDayFirstDate = colMatchFormatFirstDate[1];
			strYearFirstDate = colMatchFormatFirstDate[4];
		}
	}
	if (strTypeFirstDate == 1)
	{
		colMatchFormatSecondDate = strSecondDate.match(strFormat1)
		strMonthSecondDate = colMatchFormatSecondDate[3];
		strDaySecondDate = colMatchFormatSecondDate[4];
		strYearSecondDate = colMatchFormatSecondDate[1];
	}
	else
	{
		colMatchFormatSecondDate = strSecondDate.match(strFormat2)
		if (strTypeFirstDate == 2)
		{
			strMonthSecondDate = colMatchFormatSecondDate[1];
			strDaySecondDate = colMatchFormatSecondDate[3];
			strYearSecondDate = colMatchFormatSecondDate[4];
		}
		else
		{
			strMonthSecondDate = colMatchFormatSecondDate[3];
			strDaySecondDate = colMatchFormatSecondDate[1];
			strYearSecondDate = colMatchFormatSecondDate[4];
		}
	}
	dtmFirstDate = new Date(strYearFirstDate, (parseInt(strMonthFirstDate) - 1).toString(), strDayFirstDate)
	dtmSecondDate = new Date(strYearSecondDate, (parseInt(strMonthSecondDate) - 1).toString(), strDaySecondDate)

	if (dtmFirstDate < dtmSecondDate)
		return -1;
	else
	{
		if (dtmFirstDate > dtmSecondDate)
			return 1;
		else
			return 0;
	}
}parseInt(strMonthSecondDate) - 1).toString(), strDaySecondDate)

	if (dtmFirstDate < dtmSecondDate)
		return -1;
	else
	{
		if (dtmFirstDate > dtmSecondDate)
			return 1;
		else
			return 0;
	}
}