var Headquarters = Class.create();
Headquarters.prototype = {
	initialize : function() {

		this.mapObj = $('headquarterMap');
		this.mapWrapObj = $('headquarterMapWrap');

		this.mapAreaArr = $A(this.mapObj.getElementsByTagName('area'));
		this.mapAreaArr.each(this.setupAreas.bind(this));

	},

	setupAreas : function(areaObj) {
		Event.observe(areaObj, 'mouseover', this.show.bindAsEventListener(this), false);

		id = areaObj.alt;
		layerObj = $('headquarterLayer_' + id);

		Event.observe(layerObj, 'mouseout', this.hideAll.bindAsEventListener(this), false);

	},

	show : function(ev){
		Event.stop(ev);
		var areaObj = Event.findElement(ev, 'area');
		
		id = areaObj.alt;
		layerObj = $('headquarterLayer_' + id);
		Element.show(layerObj);
	},
	
	hideAll : function(ev){
		Event.stop(ev);
		
		this.layerArr = $A(this.mapWrapObj.getElementsByTagName('div'));
		this.layerArr.each(this.hide.bind(this));
	},

	hide : function(layerObj){
		if(layerObj.className == 'headquarterLayer'){
			layerObj.hide();
		}
	}

}

Event.observe(window,'load', function(){new Headquarters()}, false);
