window.addEvent('domready', function() {	
	
	if (document.getElementById('formulario')) {
		var checkEmail = function(email) {
				var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
				return filter.test(email)
		}
		
		$('formulario').addEvent('submit', function(e){
			if (!$('nome').value || !$('apelido').value || !$('email').value) {
				e.stop();
				alert("Por favor, preencha todos os campos obrigat\u00f3rios! \n(Todos os campos seguidos do caracter '*').");
			} else if(!checkEmail($('email').value)) {
				e.stop();
				alert("Por favor, introduza um email v\u00e1lido!");
			}
		});
	}
	
	if (document.getElementById('rodape_container')) {
		var start_movimento = function(){
			movimento.start({
				'margin-left': [$('rodape_container').getSize().x, -1200]
			});
		}
		var movimento = new Fx.Morph($('rodape'), {
			duration: 30000,
			transition: 'linear',
			onComplete: function(){
				start_movimento();
			}
		});
		start_movimento();
	}

});