
var Checker={
	templates:{
		'it':new Template('Il campo "#{title}" sembra non essere corretto.'),
		'en':new Template('The field "#{title}" seems to be not correct.'),
		'de':new Template('Auffangen "#{title}" scheint, falsch zu sein.')
	},
	checks:{
		'email':/^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/,
	},
	check_form:function(){
		for(i in this.checks){
			el=$(i);
			if(!this.checks[i].test(el.value)){
				el.focus();
				alert(this.templates[$('lang').value].evaluate({'title':el.name}));
				return false;
			}
		}
		return true;
	}
};
input_focus=function(){
	this.style.backgroundColor='#fff6f1';
	this.style.color='#fb8f23';
};
input_blur=function(){
	this.style.backgroundColor='#f1faff';
	this.style.color='#3499cc';
};
Event.observe(window,'load',function(){
	inputs=$('contatti').getElementsByTagName('input');
	inputs[inputs.length]=$('contatti').getElementsByTagName('textarea')[0];
	for(i=0; i<inputs.length+1;i++){
		Event.observe(inputs[i],'focus',input_focus.bindAsEventListener(inputs[i]));
		Event.observe(inputs[i],'blur',input_blur.bindAsEventListener(inputs[i]));
	}
	inputs[0].focus();
	Event.observe('send','click',function(){
		if(Checker.check_form())$('contatti').submit();
	});
});