window.addEvent('load', function() {
	/* Slideshow needs to be called in load event for webkit to work out heights properly */
	if($defined($$('.gallery')[0])) {
		$$('.gallery').each(function(e) {
			new Gallery({galleryTarget:e});
		});
	}
});

window.addEvent('domready', function() {
	if($defined($$('.overlay')[0])) {
		new OverlaySlide();
	}

	$$('#menu>ul>li').each(function(e) {
		e.addEvents({
			'mouseenter': function() {
				e.addClass('over');
			},
			'mouseleave': function() {
				e.removeClass('over');
			}
		});
	});

	var searchText = $$('#search .text').get('rel');
	if($$('#search .text').get('value') == '') $$('#search .text').set('value',searchText);
	$$('#search .text').addEvents({
		'focus': function() {
			if(this.get('value') == searchText) this.set('value','');
		},
		'blur': function() {
			if(this.get('value') == '') this.set('value',searchText);
		}
	});

	var FBMorphs = new Array();

	if($$('#footer_blocks .block').length > 0) {
		$$('#footer_blocks .block').each(function(e,i) {
			FBMorphs[i] = new Fx.Morph(e, {duration:'150',link:'chain',transition:Fx.Transitions.Sine.easeIn});
			e.addEvents({
				'mouseenter':function() { FBMorphs[i].clearChain(); FBMorphs[i].start({ 'margin-top': [0, -136], 'height': [44, 180] }); },
				'mouseleave':function() { FBMorphs[i].start({ 'margin-top': [-136, 0], 'height': [180, 44] }); }
			});
		});
	}
});