﻿
var form_to_check = Class.create(Validate,{

	initialize: function($super, options){
		$super();
		this.reqire_fields = {};
		this.reqire_fields.presence_of = {};
		this.in_form = 'the_form';
		this.btn_submit = $('btn_submit');
		if(this.btn_submit) {
			this.btn_submit.observe('click', function (_ev){
				_ev.stop();
				
				var telReg = /^[0-9]{10}$/;
				
				this.reqire_fields.format_of = {};
				
				this.reqire_fields.format_of = {
					telephone					:	{use: telReg, message: 'Un numero de telephone est composé de 10 chiffres.'}
				};
				
				this.check_form();
			}.bind(this));
		}
	}
});


var form_to_check2 = Class.create(Validate,{

	initialize: function($super, options){
		$super();
		this.reqire_fields = {};
		this.reqire_fields.presence_of = {};
		this.in_form = 'the_form';
		this.btn_submit = $('btn_rdv_submit');
		if(this.btn_submit) {
			this.btn_submit.observe('click', function (_ev){
				_ev.stop();
				
				var telReg = /^[0-9]{10}$/;
				
				this.reqire_fields.format_of = {};
				this.reqire_fields.format_date_fr_of = {};
							
				this.reqire_fields.format_of = {
					telephone						:	{use: telReg, message: 'Un numero de telephone est composé de 10 chiffres.'}
				};
				
				this.reqire_fields.format_date_fr_of = {
					dateRappel					:		{message: 'Indiquez la date à laquelle vous souhaitez être rappelé.'}
				};
				
						
				this.check_form();
			}.bind(this));
		}
	}
});

Event.observe(window, 'load', function(){
	form_to_check1 = new form_to_check();
	form_to_check2 = new form_to_check2();
});