window.addEvent('domready', function() {

	$$('.message').each(function(el) {
		el.set('slide', { duration: 800, transition: Fx.Transitions.Back.easeOut });
		el.slide('hide');
		(function(){ el.slide('toggle'); }).delay(300);
		(function(){ el.slide('toggle'); }).delay(20000);
	});
	//the first one doesn't have any padding... some day with css3 this wouldn't be nessessary
	var mainH2 = $$('#main h2');
	if( mainH2.length > 0 ) { mainH2[0].setStyle('padding-top',0); }

	$$('a.layout-1').addEvent('click', function(e){ e.stop(); });
	$$('#layout_1 p img::only-child').setStyle('margin-top', -5);
	$$('#layout_1 td h3:first-child').setStyle('padding-top', 0)
});

window.addEvent('load', function() {
	var tooTall = 200;
	$$('div.imgs').each(function(cont) {
		var maxHeight = 0;
		contElms = cont.getElements('strong img');
		contElms.each(function(el) {
			var size = el.getSize();
			if(size.y > tooTall) { el.set('height', tooTall); }
			maxHeight = Math.max(maxHeight, size.y).limit(120,tooTall);
		})
		contElms.each(function(el) {
			var size = el.getSize();
			var diff = (maxHeight - size.y) / 2;
			el.setStyles({
				marginTop: diff + 'px',
				marginBottom: diff + 'px'
			});

		});
	});

});

function setScroll() { Cookie.write('scrolled_y', window.getScrollTop()); }

function restoreScroll() {
	//scroll restoration
	var scrolled_y = Cookie.read('scrolled_y');
	if ( scrolled_y > 0 ) { window.scrollTo(0,scrolled_y); Cookie.dispose('scrolled_y'); }
}

window.addEvent('domready', function() {
	if( $$('#nav').length > 0 ) {
		var myMenu1 = new MenuMatic({duration: 1000, matchWidthMode: true, tweakInitial: {x: 1, y: 3}, effect: 'fade' });
	}
	if( $$('#sidenav').length > 0 ) {
		var myMenu2 = new MenuMatic({id: 'sidenav', subMenusContainerId: 'subMenusContainer2', orientation: 'vertical', duration: 500, effect: 'fade', tweakInitial: {x: 0, y: 3} });
	}
});