
window.addEvent('domready', function() {
	function validateForm(thisForm) {
		valid = true;
		var required = new Array("name","email","message");
		for (i = 0; i < required.length; i++) {
			var fade = new Fx.Styles('c_'+required[i]+'_l', 'color', {duration:250});
			if ($('c_'+required[i]).value == "") {
				fade.start({'color':'#e00'});
				valid = false;
			} else {
				fade.start({'color':'#fff'});
			}
		}
		if (valid) {
			var val = document.createElement('input'); val.type = "hidden";
			val.name = "val"; val.value = "";
			thisForm.appendChild(val);
		}
		return valid;
	}

	$('contactForm').addEvent('submit', function(e) {
		new Event(e).stop();
		if (validateForm($('contactForm'))) {
			fadeOut('contactForm');
			$('contactForm').style.display = 'none'; $('result').style.display='block';
//			setTimeout("$('contactForm').style.display = 'none';$('result').style.display='block';", 1000);
			$('result').style.opacity = 0; $('result').style.filter = "alpha(opacity=0)";
			$('log_res').empty().addClass('ajax-loading');
			this.send({
				update: $('result'),
				onComplete: function() {
					$('result').addClass('ajax-result');
					$('log_res').removeClass('ajax-loading').innerHTML='&nbsp;';
					fadeIn('result');
				}
			});
		}
	});
});