document.observe('dom:loaded', function () {
	$('contact').hide();
	$('thankyou').hide();
	$$('a[href=#contact]').invoke('observe', 'click', function (event) {
		event.stop();
		Effect.Fade('about', { duration: 0.3 });
		Effect.Appear('contact', { duration: 0.5 });
	});
	$$('input[type=text]', 'textarea').invoke('observe', 'focus', function () {
		if (this.getValue() === this.defaultValue) { this.setValue(''); }
	});
	$$('input[type=text]', 'textarea').invoke('observe', 'blur', function () {
		if (this.getValue().blank()) { this.setValue(this.defaultValue); }
	});
	$$('#contact form').invoke('observe', 'submit', function (event) {
		event.stop();
		this.request();
		this.reset();
		Effect.Fade('contact', { duration: 0.3 });
		Effect.Appear('thankyou', { duration: 0.5 });
		
		(function () {
			Effect.Fade('thankyou', { duration: 0.3 });
			Effect.Appear('about', { duration: 0.5 });
		}).delay(2);
	});
	$$('.grid').each(function (block) {
		var Timer = {
			counter: null,
			start: function (fn) { this.counter = setTimeout(fn, 10); },
			stop: function () {
				if (this.counter !== null) clearInterval(this.counter);
				this.counter = null;
			}
		};
		if (block.down('div.specification')) {
			var paragraph = block.down('div.specification').hide();
			block.observe('mouseover', function () {
				Timer.stop();
				Effect.Appear(paragraph, { to: 0.7, duration: 0.5 });
				// paragraph.show();
			});
			block.observe('mouseout', function () {
				Timer.start(function () {
					Effect.Fade(paragraph, { duration: 0.3 })
				});
			});
		}
	});
});