function emailcheck(f) {
	if (f.email.value.search(/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)==-1) {
		alert('Please enter a valid email address.');
		return false;
	}
	return true;
}
function fb_share(u) {
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

// Sitewide DomReady
window.addEvent('domready', function() {
	// Navigation
	var nav = new sfNav(
		$$('#navigation > ul li a'), 
		$$('#navigation .subnav'), 
		{
			offsetElement: $('navigation')
		}
	);

	// Search
	/*
	if ($('searchq').get('value')=='') $('searchq').set('value', 'search our site');
	$('searchq').addEvent('blur', function() {
		if (this.get('value')=='') this.set('value', 'search our site');
	});
	$('searchq').addEvent('focus', function() {
		if (this.get('value')=='search our site') this.set('value', '');
	});
	$('searchnow').addEvent('mouseover', function() {
		$('search').setStyle('backgroundPosition', 'left bottom');
	});
	$('searchnow').addEvent('mouseout', function() {
		$('search').setStyle('backgroundPosition', 'left top');
	});
	$('search').addEvent('submit', function(e) {
		e = new Event(e);
		if ($('searchq').get('value')=='' || $('searchq').get('value')=='search our site') e.stop();
	});
	*/

	// Subscribe
	if ($chk($('footer_email'))) {
		if ($('footer_email').get('value')=='') $('footer_email').set('value', 'enter your email');
		$('footer_email').addEvent('blur', function() {
			if (this.get('value')=='') this.set('value', 'enter your email');
		});
		$('footer_email').addEvent('focus', function() {
			if (this.get('value')=='enter your email') this.set('value', '');
		});
	}
	if ($chk($('sidebar_email'))) {
		if ($('sidebar_email').get('value')=='') $('sisdebar_email').set('value', 'enter your email');
		$('sidebar_email').addEvent('blur', function() {
			if (this.get('value')=='') this.set('value', 'enter your email');
		});
		$('sidebar_email').addEvent('focus', function() {
			if (this.get('value')=='enter your email') this.set('value', '');
		});
	}
});

var sfOverlay = new Class({
	Implements: Options,
	fx: Class.empty,
	status: 'off',
	options: {
		duration: 600,
		opacity: 0.75
	},
	initialize: function(options) {
		this.setOptions(options);
		if (!$chk($('overlay'))) {
			// setup overlay
			var ovl = new Element('div');
			ovl.id = 'overlay';
			ovl.setStyles({
				background: 'black',
				position: 'absolute',
				left: 0,
				top: 0,
				width: '100%',
				zIndex: 9999
			});
			ovl.setStyle('height', document.body.getScrollSize().y);
			ovl.addEvent('click', this.off.bind(this));
			document.body.adopt(ovl);
			this.fx = new Fx.Tween(ovl, {
				duration: this.options.duration
			});
			this.fx.set('opacity', 0);
		}
	},
	stopwheel: function(e) {
		e.stop();
	},
	stopkey: function(e) {
		if (e.key=='up' || e.key=='down' || e.key=='left' || e.key=='right') e.stop();
	},
	on: function() {
		if (this.status!='on') {
			window.addEvent('mousewheel', this.stopwheel);
			window.addEvent('keydown', this.stopkey);
			this.fx.start('opacity', this.options.opacity);
			this.status = 'on';
		}
	},
	off: function() {
		window.removeEvent('mousewheel', this.stopwheel);
		window.removeEvent('keydown', this.stopkey);
		this.fx.start('opacity', 0);
		this.status = 'off';
	}
});