function init() {
	if (!document.getElementsByTagName || !document.getElementById) return;
	
	// Attach sign up box events
	addEvent(document.getElementById('signupemail'), 'focus', wipeEmailBox, false);
	addEvent(document.getElementById('signupform'), 'submit', checkEmail, false);
	
	// Hunt down popup links
	var as, popfun;
	as=document.getElementsByTagName('a');
	for (var i=0; i<as.length; i++) {
		if(as[i].target && as[i].target=='popup') {			
			var width = as[i].getAttribute('popwidth') ? as[i].getAttribute('popwidth') : 500;
			var height = as[i].getAttribute('popheight') ? as[i].getAttribute('popheight') : 350;
			var left = (screen.width - width) / 3;
			var top = (screen.height - height) / 3;
			var windowAttributes = 'width='+width+',height='+height+',left='+left+',top='+top+',scrollbars=yes,location=no,toolbar=no, resizable=yes';
			
			popfun=function(){
				var theWindow = window.open(this.href,this.target,windowAttributes);
				theWindow.focus();
				return false;
			}
			
			as[i].onclick=popfun;
		}
	}
}

function wipeEmailBox() {
	var textbox = document.getElementById('signupemail');
	if(textbox.value == 'Your email') {
		textbox.value = '';
	}
}

function checkEmail(e) {
	var textbox = document.getElementById('signupemail');
	if (textbox.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi)) {
		return true;
	} else {
		alert('Please type your email address into the box.');
		if (e && e.preventDefault)
			e.preventDefault();
		return false;
	}
}


addEvent(window, 'load', init, false);

function addEvent(elm, evType, fn, useCapture) {
	// cross-browser event handling for IE5+, NS6 and Mozilla
	// By Scott Andrew
	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent) {
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	} else {
		elm['on' + evType] = fn;
	}
}