
// Add the additional 'advanced' VTypes
Ext.apply(Ext.form.VTypes, {
    daterange : function(val, field) {
        var date = field.parseDate(val);

        if(!date){
            return;
        }
        if (field.startDateField && (!this.dateRangeMax || (date.getTime() != this.dateRangeMax.getTime()))) {
            var start = Ext.getCmp(field.startDateField);
            start.setMaxValue(date);
            start.validate();
            this.dateRangeMax = date;
        } 
        else if (field.endDateField && (!this.dateRangeMin || (date.getTime() != this.dateRangeMin.getTime()))) {
            var end = Ext.getCmp(field.endDateField);
            end.setMinValue(date);
            end.validate();
            this.dateRangeMin = date;
        }
        /*
         * Always return true since we're only using this vtype to set the
         * min/max allowed values (these are tested for after the vtype test)
         */
        return true;
    },

    password : function(val, field) {
        if (field.initialPassField) {
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },

    passwordText : 'Les mots de passe ne correspondent pas',
	
	
    mailcfrm : function(val, field) {
        if (field.initialEmailField) {
            var mail = Ext.getCmp(field.initialEmailField);
            return (val == mail.getValue());
        }
        return true;
    },

    emailText : 'Les champs email et email de confirmation ne correspondent pas'
	
	
});


Ext.apply(Ext.form.VTypes, {
	/*****************************************************************
	DESCRIPTION: Validates that a string contains only valid numbers.
	PARAMETERS:
	strValue - String to be tested for validity
	RETURNS:
	True if valid, otherwise false.
	******************************************************************/
	'numeric': function(){
	var objRegExp = /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
	return function(strValue){
	//check for numeric characters
	return objRegExp.test(strValue);
	}
	}(),
	'numericText': 'Only numbers are allowed',
	
	
	/*****************************************************************
	DESCRIPTION: Validates image file.
	******************************************************************/
	'imagefile': function(){
	return function(v){
	v = v.replace(/^\s|\s$/g, ""); //trims string
	if (v.match(/([^\/\\]+)\.(bmp|gif|png|jpg|jpeg)$/i) )
	return true;
	else
	return false;
	}
	}(),
	'imagefileText' : 'Must be a valid image file: GIF, JPG, BMP, PNG'
	
});

