/**
 * @author jfdesgagne
 */
var Contact = new Class({
    fValidator:null, 
	table:null,
	
    initialize: function(){
		this.fValidator = new fValidator("form_contact", {
			"onValidClass": this,
			"language": lang,
			"onValidFunction": "submitForm"
		});
		$('phone1').addEvent('keyup', this.phoneChangeHandler);
		$('phone2').addEvent('keyup', this.phoneChangeHandler);
    },
	
	phoneChangeHandler:function(event) {
		if ((event.code > 47 && event.code < 58) || (event.code > 95 && event.code < 106)) {
			if (event.target.get('value').length == 3) {
				var nextField = $(this.id.substr(0, this.id.length-1)+(Number(this.id.substr(this.id.length-1, 1))+1));
					nextField.focus();
					nextField.select();				
			}
		}
	},
	
	submitForm:function() {
		$('form_contact').submit();
	}
	
});


