networkbar = {
	'menu' : null,
	'img' : null,
	'imgover' : null,
	'timeout' : null,
	
	'preload' : function() {
		if(this.img != null && this.imgover != null) return;
		
		this.img = new Image(200, 20);
		this.img.src = 'http://static.gameparty.net/sitegfx/networkbar/item_normal.gif';
		this.imgover = new Image(200, 20);
		this.imgover.src = 'http://static.gameparty.net/sitegfx/networkbar/item_over.gif';
	},
	
	'init' : function() {
		if(this.menu != null) return;
		
		this.preload();
		
		this.menu = document.getElementById('networkmenu');
		
		var nodes = this.menu.getElementsByTagName('A');
		for(i = 0; i < nodes.length; i++) {
			nodes[i].onmouseover = function() { networkbar.itemMouseOver(this); };
			nodes[i].onmouseout = function() { networkbar.itemMouseOut(this); };
			
			this.itemMouseOut(nodes[i]);
		}
		
		this.menu.onmouseover = function() { networkbar.stopTimeout(); }
		this.menu.onmouseout = function() { networkbar.startTimeout(); }
	},
	
	'setPosition' : function() {
		var el = document.getElementById('networkbutton');
		var left = el.offsetLeft + 0; var top = el.offsetTop + el.height;
		while((el=el.offsetParent) != null) {
			left += el.offsetLeft;
			top += el.offsetTop;
		}
		this.menu.style.top = top+'px';
		this.menu.style.left = left+'px';
	},
	
	'show' : function() {
		this.init();
		this.setPosition();
		this.onShowMenu();
		this.stopTimeout();
		this.menu.style.display = "block";
	},
	
	'hide' : function() {
		this.menu.style.display = "none";
		this.onHideMenu();
	},
	
	'startTimeout' : function() {
		this.stopTimeout();
		this.timeout = setTimeout('networkbar.hide();', 500);
	},
	
	'stopTimeout' : function() {
		if(this.timeout != null) {
			clearTimeout(this.timeout);
			this.timeout = null;
		}
	},
	
	'itemMouseOver' : function(el) {
		el.style.background = 'url("'+this.imgover.src+'")';
	},
	
	'itemMouseOut' : function(el) {
		el.style.backgroundImage = 'url(\''+this.img.src+'\')';
	},
	
	// override these methods to hide / show flash banners to circumvent buggy IE
	'onShowMenu' : function() {
		this.hideTag('object');
		this.hideTag('select');
	},
	
	'onHideMenu' : function() {
		this.showTag('object');
		this.showTag('select');
	},
	
	'showTag' : function(tag) {
		var el = document.getElementsByTagName(tag);
		for(var i = 0; i < el.length; i++) {
			el[i].style.visibility = 'visible';
		}
	},
	
	'hideTag' : function(tag) {
		var el = document.getElementsByTagName(tag);
		for(var i = 0; i < el.length; i++) {
			el[i].style.visibility = 'hidden';
		}
	}
}

networkbar.preload();