Event.observe(window, 'load', function() {
	
	if(!$('iw_user')){
		return;
	}
	
    var valid = new Validation('iw_user', {
        immediate : true,
        stopOnFirst:true
    });

    Validation.addAllThese([
        ['validate-password', 'Enter password between 4 and 15 characters.', {
        //pattern: new RegExp("\\+$","gi"),
        minLength : 4,
        maxLength : 15
        }],
        ['validate-cgu', 'You must agree the terms and conditions.', function (v,elm) {
				var p = elm.parentNode;
				var options = p.getElementsByTagName('INPUT');
				return $A(options).any(function(elm) {
					return $F(elm);
				});
		}],
	    ['validate-email', 'Please enter a valid email address.', function(v){
			return !Validation.get('IsEmpty').test(v);
	    }],
        ['validate-selection-genre', 'Please select your gender.', function(v,elm){
			return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
	    }],
	    /*['validate-pays', 'Merci de sélectionner votre pays.', function(v,elm){
			return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
	    }],*/
        ['validate-origine', 'Please select your origin.', function(v,elm) {
            return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
        }],
        ['validate-cp', 'Please enter a valid post code.', function (v) {
            return !Validation.get('IsEmpty').test(v);
        }],
        ['validation-pseudo', 'Please enter a username with 4 to 12 characters.', function(v){
		return !Validation.get('IsEmpty').test(v);
        //minLength : 4
        }],
	    ['validate-birthay', 'Please enter your date of birth.', function(v,elm){
			return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
	    }]
    ]);

 });



