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
menu_listeners = [];
function menu_addListener(o) {
	menu_listeners[menu_listeners.length] = o;
}

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

function getPageSize(){
	var x,y;
	if (self.innerHeight) // all except Explorer
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	var x1,y1;
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) // all but Explorer Mac
	{
		x1 = document.body.scrollWidth;
		y1 = document.body.scrollHeight;
	}
	else // Explorer Mac;
		 //would also work in Explorer 6 Strict, Mozilla and Safari
	{
		x1 = document.body.offsetWidth;
		y1 = document.body.offsetHeight;
	}
	arrayPageSize = new Array(x,y,x1,y1) 
	return arrayPageSize;
}

function dopasuj_overlay(){
	var OverlayObject = document.getElementById("przeprowadzka_overlay");
	OverlayObject.style.width = arrayPageSize[0] + "px";
	OverlayObject.style.height = arrayPageSize[1] + 'px';
}

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