function popupIsOpen() {
	return (typeof(popupWin) == 'object') && popupWin.open && !popupWin.closed;
}

function popup(o, width, height) {
	if(popupIsOpen() && (popupWin.type != 'standard')) popupWin.close();
	popupWin = window.open(o.href, "edelman_popup",'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height);
	popupWin.focus();
	popupWin.type = 'standard';
	return false;
}

function accessible_popup() {
	var d = document;
	if(d.getElementsByTagName && d.getElementById) {
         var anchors = d.getElementsByTagName('A');
		 for (i = 0; i < anchors.length; i++) {
		 	var an = anchors[i];
			var relSplit = an.rel.split("|");
			if(relSplit[0] == "popup") {
				an.onclick = function() {
					// relSplit[1] & relSplit[2] are undefined in popup
					var tmp = this.rel.split("|");
					popup(this, tmp[1], tmp[2]);
					return false;
				}
			}
		}
	}
}

function popupPortfolio(o) {
	if(popupIsOpen() && (popupWin.type != 'portfolio')) popupWin.close();
	popupWin = window.open(o.href, "edelman_popup",'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=490');
	popupWin.focus();
	popupWin.type = 'portfolio';
	return false;
}
popupTimeline = popupPortfolio;

function popup_noscroll(o, width, height) {
	if(popupIsOpen() && (popupWin.type != 'noscroll')) popupWin.close();
	popupWin = window.open(o.href, "edelman_popup",'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height);
	popupWin.focus();
	popupWin.type = 'noscroll';
	return false;
}

function submitSearch() {
	var s = document.getElementById("in").value;
	if(s.length < 3) return;
	document.search.submit();
}
	
// basic window.onload broadcaster
_listeners = [];
function addListener(o) {
	_listeners[_listeners.length] = o;
}

function broadcastMessage(msg) {
	for(var i = 0; i < _listeners.length; i++) {
		_listeners[i][msg]();
	}
}

window.onload = function() {
	broadcastMessage('onload');
}