//<script>
var SEP_VALR = "#";
var ERROR_MESSAGE_PLACE_HOLDER = "[ErrorMessagePlaceHolder]";
var ERROR_MESSAGE_CSS_CLASS_PLACE_HOLDER = "[ErrorMessageCssClassPlaceHolder]";

var Page_DSFValidationVer = "2";
var Page_IsValid = true;  
var Page_BlockSubmit = false;

// On affiche le validateur ou non, selon qu'il est en erreur ou non
function ValidatorUpdateDisplay(val)
{
	var display = dsf_getAttribute( val, "display" );

    if (typeof(display) == "string")
    {
        if (display == "None")
        {
            return;
        }
        
        if (display == "Dynamic")
        {
            val.style.display = val.isvalid ? "none" : "inline";
            return;
        }
    }
    val.style.visibility = val.isvalid ? "hidden" : "visible";
    
    //var controlBackground = dsf_getAttribute(val, "controlbackground");
    //controlBackground
    //originalbackcolor
/*    if (typeof(controlToValidate) == "string")
    {
        ValidatorHookupControl(GetById(controlToValidate), val);
    }        */
}

// Si un validateur est en erreur alors la page n'est plus valide
function ValidatorUpdateIsValid()
{
	var i;
    for (i = 0; i < Page_Validators.length; i++)
    {
        if (!Page_Validators[i].isvalid)
        {
            Page_IsValid = false;
            return;
        }
	}
	Page_IsValid = true;
}

function ValidatorHookupControlID(controlID, val)
{
    if (typeof(controlID) != "string")
        return;
        
    var ctrl = GetById(controlID);
    
    if (typeof(ctrl) != "undefined")
    {
        ValidatorHookupControl(ctrl, val);
    }
    else
    {
        val.isvalid = true;
        val.enabled = false;
    }
}

// Associer une fonction javascript au validateur
function ValidatorHookupControl(control, val)
{
    if (control)
    {
        if (typeof (control.tagName) == "undefined" && typeof (control.length) == "number")
        {
            var i;

            for (i = 0; i < control.length; i++)
            {
                var inner = control[i];

                if (typeof (inner.value) == "string")
                {
                    ValidatorHookupControl(inner, val);
                }
            }
            return;
        }
        else if (control.tagName != "INPUT" && control.tagName != "TEXTAREA" && control.tagName.substring(0, 1) != "S")
        {
            var i;

            for (i = 0; i < control.childNodes.length; i++)
            {
                if (control.childNodes[i].nodeType == 1)
                {
                    ValidatorHookupControl(control.children[i], val);
                }
            }
            return;
        }
        else
        {
            if (typeof (control.Validators) == "undefined")
            {
                control.Validators = new Array;
                var ev;
                if (control.type == "radio")
                {
                    ev = control.onclick;
                }
                else
                {
                    ev = control.onchange;
                }
                if (typeof (ev) == "function")
                {
                    ev = ev.toString();
                    ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}"));
                }
                else
                {
                    ev = "";
                }

                // on ajouter la fonction de validation
                ev = "ValidatorOnChange('" + control.id + "'); " + ev;

                // on s'assure que s'il y a une fonction de formattage, ce sera la
                // premiere executee.
                //var regEx = new RegExp('FormatControlValue\(.*\)\;');
                //var matches = regEx.exec(ev);

                //if( matches != null && matches[0] != null && matches[0].length > 0 )
                //{
                //	ev = ev.replace( matches[0], "" );
                //	ev = matches[0] + ev;
                //}

                var func = new Function(ev);

                if (control.type == "radio")
                {
                    control.onclick = func;
                }
                else
                {
                    control.onchange = func;
                }
            }
            control.Validators[control.Validators.length] = val;

            control.controlvalider = false;
        }
    }
}

// On test tous les validateurs de la page pour voir si la page est valide
function Page_ClientValidate()
{
    var i;
    for (i = 0; i < Page_Validators.length; i++)
    {
        ValidatorValidate(Page_Validators[i]);
    }
    ValidatorUpdateBackColor(Page_Validators);
    ValidatorUpdateIsValid();
    
    ValidationSummary();
    Page_BlockSubmit = !Page_IsValid;
    //Vider le contenu du message warning lorqu'on a un message de validation de la page
    if (Page_BlockSubmit){
	   var value = GetById("ctl00_ContenuPrincipal_MessageErreurUsrCtrl_SumMessagesWarning");
	   if( typeof(value) != "undefined" && value != null ){
	      value.innerHTML = "";
	      value.style.visibility = "hidden";
	   }
	 }
    return Page_IsValid;
}

// Support for CausesValidation property
function ValidatorCommonOnSubmit()
{
    var returnValue =  !Page_BlockSubmit;
    Page_BlockSubmit = false;
    return returnValue;
}

// Le controle a change, verifier s'il est en erreur
// Si oui, afficher un message d'erreur
function ValidatorOnChange(controlID)
{
	var tempo = "";
    var cont = GetById(controlID);
    var vals = cont.Validators;
    
    var i;
    var validateurEnErreurID = -1;
 
	cont.isValid = true;
 
    for (i = 0; i < vals.length; i++)
    {
        ValidatorValidate(vals[i]);
        
        if(! vals[i].isvalid)
        {
			cont.isValid = false;
        
			if( validateurEnErreurID < 0 )
			{
				validateurEnErreurID = i;
			}
        }
    }
        
    ValidatorUpdateBackColor(vals);
    ValidatorUpdateIsValid();
    //ValidationSummary();
    
	// Afficher DIV avec le message d'erreur
    if( validateurEnErreurID >= 0 )
    {
		// On met un timeout ici, mais je ne sais pas vraiment pourquoi
		// on dirait qu'il faut un delai pour etre capable d'afficher le popup des erreurs
    	window.setTimeout("ShowError( '" + dsf_getAttribute( vals[validateurEnErreurID], "id" ) + "' );", 200);
    	//ShowError( dsf_getAttribute( vals[validateurEnErreurID], "id" ) );
	}
	/*
	else
	{
		HideError();
	}
	*/
	
	return Page_IsValid;
}

function ShowError(ValidateurEnErreurID)
{
	var vValidateurEnErreur = GetById(ValidateurEnErreurID);
	
	var controlToValidate = dsf_getAttribute( vValidateurEnErreur, "controltovalidate" );
	
	// Focus sur le control en erreur
	SetFocus( controlToValidate );
	
	//Permet de valider si le tableau existe deja
	if (typeof(Page_MessageErreur) == "undefined") 
        return;
	
	var vCtrl = GetById( controlToValidate );
	
	// nouvelle fonction pour l'event OnBlur pour cacher le message d'erreur
	// on doit garder tout evenement deja existant sur le onblur
	var ev;
	ev = vCtrl.onblur;
	
    if (typeof(ev) == "function" )
    {
        ev = ev.toString();
        ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}"));
    }
    else
    {
        ev = "";
    }
    
    var func = new Function("HideError( this ); " + ev);
    
	vCtrl.onblur = func;
            
	var divErreur = Page_MessageErreur[0];//GetById("divErreur");
	//On obtient la TD qui doit recevoir le texte de la definition
	var tdErreurTexte = Page_MessageErreur[1];//GetById("TdErreurTexte");
	var TblErreurId = Page_MessageErreur[2];
	if (vCtrl==null || divErreur==null || tdErreurTexte==null)
		return;
	
	//Assigner le texte de la definition a la TD
	tdErreurTexte.innerHTML = dsf_getAttribute( vValidateurEnErreur, "errormessage" );

	// On veut positionner le message d'erreur tout juste sous le controle en erreur
	topVal = getElemTop( vCtrl ) + getElemHeight( vCtrl ) + 5
	leftVal = getElemLeft( vCtrl )

	//Obtenir le style de la DIV
	divErreurStyle = divErreur.style;
	divErreurStyle.top = topVal; // Positions the element from the top
	divErreurStyle.left = leftVal; // Positions the element from the left
	divErreurStyle.visibility = "visible"; // Makes the element visable 
	
	// On cache les select potentiellement sous les DIV...
	scanSelectForClip(TblErreurId,vCtrl)
}

// Cacher le message d'erreur
function HideError( vControl )
{
	// enlever l'evenement HideError du onblur, mais garder tout evenement qui
	// etait la precedement
	
	ev = vControl.onblur;
	
    if (typeof(ev) == "function" )
    {
        ev = ev.toString();
        ev = ev.substring(ev.indexOf("{") + 1, ev.lastIndexOf("}"));
    }
    else
    {
        ev = "";
    }
    
    var func = new Function( ev.replace( "HideError( this ); ", "" ) );
    
	vControl.onblur = func;
	
	//Permet de valider si le tableau existe deja
	if (typeof(Page_MessageErreur) == "undefined") 
        return;
	//On obtient le style de la DIV servant a afficher la definition sous forme de PopUp
	var divErreur = Page_MessageErreur[0];
	if (divErreur.style == null)
		return;
	divErreur.style.visibility = "hidden";
	AfficherSelect(Page_MessageErreur[2].id);
}

// on verifie si un validateur est en erreur
function ValidatorValidate(val)
{
    val.isvalid = true;

    if( val.enabled != false )
    {
		if( typeof( val.evalfunc ) == "function" )
		{
			val.isvalid = val.evalfunc(val);
		}
    }
    ValidatorUpdateDisplay(val);
}

// initialisation des validateurs de la page
function ValidatorOnLoad()
{
    if (typeof(Page_Validators) == "undefined")
        return;

    var i, val;
    for (i = 0; i < Page_Validators.length; i++)
    {
        val = Page_Validators[i];
        
        var evalFunction = dsf_getAttribute(val, "evaluationfunction");

        if( typeof(evalFunction) == "string" && evalFunction.length > 0 )
        {
            eval("val.evalfunc = " + evalFunction + ";");
        }
        var isValidAttribute = dsf_getAttribute(val, "isvalid");
        if (typeof(isValidAttribute) == "string")
        {
            if (isValidAttribute == "False")
            {
                val.isvalid = false;                                
                Page_IsValid = false;
            } 
            else
            {
                val.isvalid = true;
            }
        }
        else
        {
            val.isvalid = true;
        }
        
        var enabledAttribute = dsf_getAttribute(val, "enabled");
        if (typeof(enabledAttribute) == "string")
        {
            if (enabledAttribute == "False")
            {
                val.enabled = false;
            } 
            else
            {
                val.enabled = true;
            }
        }
        else
        {
            val.enabled = true;
        }
        
        var controlToValidate = dsf_getAttribute(val, "controltovalidate");
        var controlToCompare = dsf_getAttribute(val, "controltocompare");
        
        if( typeof(controlToValidate) == "string" && controlToValidate.length > 0 )
        {
			ValidatorHookupControlID(controlToValidate, val);
        }
        if (typeof(controlToCompare) == "string" && controlToCompare.length > 0)
        {
			if (controlToCompare != "")
            {
				ValidatorHookupControlID(controlToCompare, val);
            }
        }  
    }
    Page_ValidationActive = true;
    
    // c'est serait pour que le sommaire se genere cote-client seulement
    // meme lors de validation cote-serveur
    //if( !Page_IsValid )
	 //  ValidationSummary();
	   
}

// Evaluer si un validateur ExpressionReguliere est en erreur
function RegularExpressionValidatorEvaluateIsValid(val)
{
    var value = GetControlValueById(dsf_getAttribute(val, "controltovalidate"));
    
    if (value == "")
        return true;        
    var rx = new RegExp(dsf_getAttribute(val, "validationexpression"));
    
    var matches = rx.exec(value);
    return (matches != null && value == matches[0]);
}

// ???
function ValidatorTrim(s)
{
    //var m = s.match(/^\s*(.*\S)\s*$/);
    var m = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
    return (m == null) ? "" : m[1];
}

// Evaluer si un validateur Required est en erreur
function RequiredFieldValidatorEvaluateIsValid(val)
{
    return (ValidatorTrim(GetControlValueById(dsf_getAttribute(val, "controltovalidate"))) != ValidatorTrim(dsf_getAttribute(val, "initialvalue")));
}

// Evaluer si un validateur Custom est en erreur
function CustomValidatorEvaluateIsValid(val)
{
	var controlToValidate = dsf_getAttribute(val, "controltovalidate");
	var blankValidate = dsf_getAttribute(val, "blankvalidation");
    var value = "";

    if (typeof(controlToValidate) == "string")
    {
		if( controlToValidate != "" )
		{
			value = GetControlValueById(controlToValidate);

			if (ValidatorTrim(value).length == 0 && blankValidate=="False")
			{
				return true;
			}
		}
		
    }

    var args = { Value:value, IsValid:true };
    var func_str = dsf_getAttribute(val, "clientvalidationfunction");

    if (typeof(func_str) == "string")
    {
		if (func_str != "")
		{
			eval(func_str + "(val, args) ;");
		}
    }
    return args.IsValid;
}

// Convert a String to a particular DataType
function ValidatorConvert(op, dataType, val)
{
	var m;
	
	if( op == null )
		return null;
		
    function GetFullYear(year)
    {
        return (year + parseInt(val.century)) - ((year < dsf_getAttribute( val, "cutoffyear" )) ? 0 : 100);
    }
    
    var num, cleanInput, m, exp;
    if (dataType == "Integer")
    {
		// enlever le separateur groupe de millier
		var control = GetById(dsf_getAttribute(val, "controltovalidate") );
		var thousandCharacter = dsf_getAttribute(control, "thousandseparator");

		// enlever les espaces qui auraient pu etre mis par le specialtypevalidator
		op = RemoveWhiteSpace(op, thousandCharacter)
		
        exp = /^\s*[-\+]?\d+\s*$/;
        if (op.match(exp) == null) 
            return null;
        num = parseInt(op, 10);
        return (isNaN(num) ? null : num);
    }
    else if(dataType == "Double")
    {
		// enlever le separateur groupe de millier
		var control = GetById(dsf_getAttribute(val, "controltovalidate") );
		var thousandCharacter = dsf_getAttribute(control, "thousandseparator");
		// enlever les espaces qui auraient pu etre mis par le specialtypevalidator
		op = RemoveWhiteSpace(op, thousandCharacter)

        exp = new RegExp("^\\s*([-\\+])?(\\d+)?(\\" + dsf_getAttribute( val, "decimalchar" ) + "(\\d+))?\\s*$");
        m = op.match(exp);
        if (m == null)
            return null;
        if (typeof(m[1]) == "undefined")
			m[1] = "";
		if (typeof(m[2]) == "undefined")
			m[2] = "";
		if (typeof(m[4]) == "undefined")
			m[4] = "";
		cleanInput = m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4];
        num = parseFloat(cleanInput);
        return (isNaN(num) ? null : num);            
    } 
    else if (dataType == "Currency")
    {
		// enlever le separateur groupe de millier
		var control = GetById(dsf_getAttribute(val, "controltovalidate") );
		var thousandCharacter = dsf_getAttribute(control, "thousandseparator");

		// enlever le signe de $
		op = op.replace("$", "");
		
		// enlever les espaces qui auraient pu etre mis par le specialtypevalidator
		op = RemoveWhiteSpace(op, thousandCharacter)

		
        exp = new RegExp("^\\s*([-\\+])?(((\\d+)\\" + dsf_getAttribute( val, "groupchar" ) + ")*)(\\d+)"
                        + ((val.digits > 0) ? "(\\" + dsf_getAttribute( val, "decimalchar" ) + "(\\d{1," + dsf_getAttribute( val, "digits" ) + "}))?" : "")
                        + "\\s*$");
        m = op.match(exp);
        if (m == null)
            return null;
        if (typeof(m[2]) == "undefined")
			m[2] = "";
		if (typeof(m[5]) == "undefined")
			m[5] = "";	
		if (typeof(m[7]) == "undefined")
			m[7] = "";
        var intermed = m[2] + m[5] ;
        cleanInput = m[1] + intermed.replace(new RegExp("(\\" + dsf_getAttribute( val, "groupchar" ) + ")", "g"), "") + ((dsf_getAttribute( val, "digits" ) > 0) ? "." + m[7] : 0);
        num = parseFloat(cleanInput);
        return (isNaN(num) ? null : num);            
    }
    else if (dataType == "Date")
    {
        var yearFirstExp = new RegExp("^\\s*((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})\\s*$");
        m = op.match(yearFirstExp);
        var day, month, year;
        if (typeof(m[1]) == "undefined")
			m[1] = "";
        if (typeof(m[2]) == "undefined")
			m[2] = "";
		if (typeof(m[3]) == "undefined")
			m[3] = "";
		if (typeof(m[5]) == "undefined")
			m[5] = "";
		if (typeof(m[6]) == "undefined")
			m[6] = "";
			
        if (m != null && (m[2].length == 4 || val.dateorder == "ymd"))
        {
            day = m[6];
            month = m[5];
            year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10))
        }
        else
        {
            if (val.dateorder == "ymd")
            {
                return null;		
            }						
            var yearLastExp = new RegExp("^\\s*(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))\\s*$");
            m = op.match(yearLastExp);
            if (m == null)
            {
                return null;
            }
            if (val.dateorder == "mdy")
            {
                day = m[3];
                month = m[1];
            }
            else
            {
                day = m[1];
                month = m[3];
            }
            year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10))
        }
        month -= 1;
        var date = new Date(year, month, day);
        return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()) ? date.valueOf() : null;
    }
    else
    {
        return op.toString();
    }
}

function RemoveWhiteSpace(field, thousandCharacter)
{
	do
	{
		field = field.replace(thousandCharacter, "");
	}
	while (field.indexOf(thousandCharacter) != -1)
	
	do
	{
		field = field.replace(" ", "");
	}
	while (field.indexOf(" ") != -1)
	
	return field;
}

// Comparer deux String selon un type et une condition de comparaison donnees
function ValidatorCompare(operand1, operand2, operator, val) {
    var dataType = dsf_getAttribute( val, "type" );
    var op1, op2;
    
    op1 = ValidatorConvert(operand1, dataType, val);

    if (op1 == null)
        return false;    
        
    if (operator == "DataTypeCheck")
        return true;

	if( operand2 == null || typeof(operand2) == "undefined" || operand2 == "" )
		return true;

	op2 = ValidatorConvert(operand2, dataType, val);

    if( op2 == null )
        return false;
        
    switch (operator)
    {
        case "NotEqual":
            return (op1 != op2);
        case "GreaterThan":
			return (op1 > op2);
        case "GreaterThanEqual":
			return (op1 >= op2);
        case "LessThan":
			return (op1 < op2);
        case "LessThanEqual":
			return (op1 <= op2);
        default:
            return (op1 == op2);            
    }
}

// Evaluer si un validateur Compare est en erreur
function CompareValidatorEvaluateIsValid(val)
{
	var controlId = dsf_getAttribute(val, "controltovalidate");
	if( controlId == null )
    {
		return true;
	}
	else
	{
		if( ! ( typeof(controlId) == "string" ) )
			return true;
	}
        
    var value = GetControlValueById(controlId);
    
    if( ValidatorTrim(value).length == 0 )
        return true;
        
    var compareTo = "";
    var compareCtrl = dsf_getAttribute(val, "controltocompare");
    var useControlToCompare = false;
    
    if( compareCtrl != null )
    {
        if (typeof(compareCtrl) == "string")
        {
		    if (compareCtrl != "")
		        useControlToCompare = true;
        }
    }
    
    if (!useControlToCompare)
    {
        var ctrl_literal = dsf_getAttribute(val, "valuetocompare");
        if( typeof(ctrl_literal) == "string" )
        {
            compareTo = ctrl_literal;
         }
    }
    else
    {
        compareTo = GetControlValueById( dsf_getAttribute(val, "controltocompare") );
    }
    
    var operator = dsf_getAttribute( val, "operator" );
    return ValidatorCompare(value, compareTo, operator, val);
}

function RangeValidatorEvaluateIsValid(val)
{
    var value = GetControlValueById(dsf_getAttribute( val, "controltovalidate" ) );
	if (ValidatorTrim(value).length == 0) 
		return true;
		
	return ( ValidatorCompare( value, dsf_getAttribute( val, "minimumvalue" ), "GreaterThanEqual", val ) &&
				ValidatorCompare( value, dsf_getAttribute( val, "maximumvalue" ), "LessThanEqual", val ) );
}

// Si le validateur est en erreur, on met le controle en erreur en jaune
function ValidatorUpdateBackColor(vals)
{
    var i;
	var control;
	
	for (i = 0; i < vals.length; i++)
	{
		if (vals[i].enabled)
		{
			control = GetById(dsf_getAttribute( vals[i], "controlbackcolor" ));
			if( control != null && typeof(control) != "undefined" )
			{
				control.controlvalider = false;
			}
		}
	}
	
    for (i = 0; i < vals.length; i++)
    {
		if (vals[i].enabled != "False" )
		{
			var controlBackColor = dsf_getAttribute( vals[i], "controlbackcolor" );
			
			control = GetById(controlBackColor);
			
			if( control != null && typeof(control) != "undefined" )
			{
				var controlDay = GetById( controlBackColor + "__Day" );
				var controlMonth = GetById( controlBackColor + "__Month" );
				var controlYear = GetById( controlBackColor + "__Year" );
				
				// DatePicker seulement
				if( controlDay != null && controlDay != "undefined"
					&& controlMonth != null && controlMonth != "undefined"
					&& controlYear != null && controlYear != "undefined" )
				{
					if (!vals[i].isvalid)
					{
						controlDay.style.backgroundColor = BackColorError;
						controlMonth.style.backgroundColor = BackColorError;
						controlYear.style.backgroundColor = BackColorError;
					} 
					else
					{
						if (control.controlvalider == false)
						{
							var originalBackColor = "white"; //dsf_getAttribute( control, "originalbackcolor" );
							controlDay.style.backgroundColor = originalBackColor;
							controlMonth.style.backgroundColor = originalBackColor;
							controlYear.style.backgroundColor = originalBackColor;
						}
					}				
				}
				else // tous les autres controles
				{
				    if (!control.disabled)
				    {
				        if (!vals[i].isvalid)
				        {
				            control.style.backgroundColor = BackColorError;
				        }
				        else
				        {
				            if (control.controlvalider == false)
				            {
				                control.style.backgroundColor = dsf_getAttribute(control, "originalbackcolor");
				            }
				        }
				    }
				}
				control.controlvalider = true;
			}
		}
		
		//alert(control.controlvalider);
	}
	
}

// Affichage du sommaire des erreurs de la page
function ValidationSummary()
{
    if (typeof(Page_ValidationSummaries) == "undefined") 
        return;

    var summary, sums, s;
    for (sums = 0; sums < Page_ValidationSummaries.length; sums++)
    {
        summary = Page_ValidationSummaries[sums];
        
        //alert("9 : " + GetById("Textbox1").value);
        //summary.style.visibility = "hidden";
        //summary.style.display = "none";
        //alert("10 : " + GetById("Textbox1").value);
    
        if (Page_IsValid)
        {
			// Si on utilise le style 'summary.style.display = "none";'
			// au lieu visibility ca cree un bug dans Netscape
			if (summary != null)
			summary.style.visibility = "hidden";
        }
        else
        {
            if (dsf_getAttribute( summary, "showsummary" ) != "False")
            {
                summary.style.display = "";
                
                // Les CSS a appliquer
                var CssClassHeaderImage = dsf_getAttribute( summary, "CssClassHeaderImage" );
                var CssClassHeaderTdImage = dsf_getAttribute( summary, "CssClassHeaderTdImage" );
                var CssClassHeaderTdText = dsf_getAttribute( summary, "CssClassHeaderTdText" );
                var CssClassTable = dsf_getAttribute( summary, "CssClassTable" );
                var CssClassTdMessages = dsf_getAttribute( summary, "CssClassTdMessages" );
                var CssClassMessageList = dsf_getAttribute( summary, "CssClassMessageList" );
                var CssClassMessageHyperLink = dsf_getAttribute( summary, "CssClassMessageHyperLink" );
                
                // pour ne pas que ça écrive 'null' dans l'attribut 'class'
                if( typeof(CssClassHeaderImage) == "undefined" || CssClassHeaderImage == null )
                {
					CssClassHeaderImage = "";
                }
                if( typeof(CssClassHeaderTdImage) == "undefined" || CssClassHeaderTdImage == null )
                {
					CssClassHeaderTdImage = "";
                }
                if( typeof(CssClassHeaderTdText) == "undefined" || CssClassHeaderTdText == null )
                {
					CssClassHeaderTdText = "";
                }
                if( typeof(CssClassTable) == "undefined" || CssClassTable == null )
                {
					CssClassTable = "";
                }
                if( typeof(CssClassTdMessages) == "undefined" || CssClassTdMessages == null )
                {
					CssClassTdMessages = "";
                }
                if( typeof(CssClassMessageList) == "undefined" || CssClassMessageList == null )
                {
					CssClassMessageList = "";
                }
                if( typeof(CssClassMessageHyperLink) == "undefined" || CssClassMessageHyperLink == null )
                {
					CssClassMessageHyperLink = "";
                }
                // fin vérification class = null
                
                if (typeof(summary.displaymode) != "string")
                {
                    summary.displaymode = "BulletList";
                }
                
                switch (summary.displaymode)
                {
                    case "List":
                        headerSep = "<br>";
                        first = "";
                        pre = "";
                        post = "<br>";
                        finalTag = "";
                        break;
                    case "BulletList":
                    default: 
                        headerSep = "";
                        first = "<ul class=\"" + CssClassMessageList + "\">";
                        pre = "<li>";
                        post = "</li>";
                        finalTag = "</ul>";
                        break;
                    case "SingleParagraph":
                        headerSep = " ";
                        first = "";
                        pre = "";
                        post = " ";
                        finalTag = "<br>";
                        break;
                }
                var ErrorImageUrl = dsf_getAttribute( summary, "ErrorImageUrl" );
                                          
                var coreBegin = "<table class=\"" +  CssClassTable + "\">";
                var tagImage = "";
                
				if( typeof(ErrorImageUrl) != "string"
					|| ErrorImageUrl == "" )
				{
					tagImage = "";
				}
				else
				{
					tagImage = "<img src=\"" + ErrorImageUrl + "\" class=\"" + CssClassHeaderImage + "\">";
				}
				
				var headerBegin = "<tr><td class=\"" + CssClassHeaderTdImage + "\">" + tagImage + "</td><td class=\"" + CssClassHeaderTdText + "\">";
				var headerEnd = "</td></tr>";
				var coreIntermediate = "<tr><td colspan=\"2\" class=\"" + CssClassTdMessages + "\">";
				var coreEnd = "</td></tr></table>";
                
                var s = "";
                
                s += coreBegin;
                              
                headerText = dsf_getAttribute(summary, "headertext");
                headerText = (headerText != null) ? headerText : "";
                
                if( headerText != "" || tagImage != "" )
                {
                    s += headerBegin + headerText + headerEnd + headerSep;
                }
                			
                s += coreIntermediate + first;
                
                for (i=0; i<Page_Validators.length; i++)
                {
					var errorSummary = dsf_getAttribute(Page_Validators[i], "errorsummary");
					var errorMessage = dsf_getAttribute(Page_Validators[i], "errormessage");
					
                    if (!Page_Validators[i].isvalid )
                    {
						if( typeof(errorSummary) == "string"
							&& typeof(errorMessage) == "string"
							&& errorSummary != ""
							&& errorMessage != "" )
						{
							var errorMessageText = errorSummary.replace( ERROR_MESSAGE_PLACE_HOLDER, errorMessage );
							errorMessageText = errorMessageText.replace( ERROR_MESSAGE_CSS_CLASS_PLACE_HOLDER, CssClassMessageHyperLink );
							s += pre + errorMessageText + post;
						}
                    }
                } 
                
                s += finalTag + coreEnd;
                summary.innerHTML = s;
                window.scrollTo(0,0);
                
				summary.style.visibility = "visible";
				summary.style.display = "inline";
            }
            
            var showmessagebox = dsf_getAttribute( summary, "showmessagebox" );
            if( showmessagebox == "True" )
            {
                s = "";
                var headerText = dsf_getAttribute( summary, "headertext" );
                if (typeof(headerText) == "string")
                {
                    s += headerText + "<BR>";
                }
                for (i=0; i<Page_Validators.length; i++)
                {
					var errorMessage = dsf_getAttribute( Page_Validators[i], "errormessage" );
                    if (!Page_Validators[i].isvalid && typeof(errorMessage) == "string")
                    {
                        switch (summary.displaymode)
                        {
                            case "List":
                                s += errorMessage + "<BR>";
                                break;
                            case "BulletList":
                            default: 
                                s += "  - " + errorMessage + "<BR>";
                                break;
                            case "SingleParagraph":
                                s += errorMessage + " ";
                                break;
                        }
                    }
                }
                
                span = document.createElement("SPAN");
                span.innerHTML = s;
                
                
                if( span.innerText != null 
					&& span.innerText != "undefined"
					&& typeof( span.innerText ) == "string" )
				{
					s = span.innerText;
				}
				
                alert(s);
            }
        }
    }
}

// Appelle par ValidatorValidate
function SpecialTypeValidatorEvaluateIsValid(val)
{
	var controlToValidate = GetById(dsf_getAttribute(val, "controltovalidate"));
	var validationExpression = dsf_getAttribute(val, "validationexpression");
	var formatType = dsf_getAttribute(val, "formattype");
	var charactersAllowed = dsf_getAttribute(val, "allowedcharacters");

	if (controlToValidate.value == "")
	{
		return true;
	}
	
	var thousandCharacter = dsf_getAttribute(controlToValidate, "thousandseparator");
	controlToValidate.value = RemoveWhiteSpace(controlToValidate.value, thousandCharacter);
	
	var strValue = RemoveGoodChars(controlToValidate.value, charactersAllowed);

	var rx = new RegExp(validationExpression);
	var matches = rx.exec(strValue);

	var result = (matches != null && strValue == matches[0]);

	if( result && formatType == "NAS" )
	{
		return SSNValidation( strValue );
	}
	else if( result && formatType == "DateOperational" )
	{
		var allowedCharacters = dsf_getAttribute(val, "allowedcharacters");

		var cleanValue = RemoveGoodChars(controlToValidate.value, allowedCharacters);

		var currentYear = cleanValue.substring(0, 4);
		var currentMonth = cleanValue.substring(4, 6);
		var currentDay = cleanValue.substring(6, 8);
		
		// si on a le 29 fevrier, verifier qu'on a bien une annee bissextile
		if( currentMonth == "02" && currentDay > 28 )
		{
			if( currentYear % 4 != 0 || (currentYear % 100 == 0 && currentYear % 400 != 0 ) )
			{
				result = false;				
			}			
		}
		return result;
	}
	else
	{
		return result;
	}
	//return RegularExpressionValidation(ctrl, validationExpression, formatType, charactersAllowed);
}
