var References = new Object();
window.addListener(References);
References.regions = new Object();
References.buildings = [];
References.onload = function()
{
 if (document.getElementById)
 {
  this.addBuildings();
 }
};
References.addBuildings = function()
{
 var buildings = document.getElementsByClassName('interactive')[0].getElementsByTagName('a');
 var nrOfBuildings = buildings.length;
 
 for (var i = 0; i < nrOfBuildings; i++)
 {
  var building = new Building(buildings[i]);
  building.setName(typesOfBuildings[i]);
  this.buildings.push(building);
 }
};
var Building = function(link)
{
 this._link = link;
 this._link._obj = this;
 this._regions = [];
 this._headline = document.getElementById('building');
 
 this._img = this._link.getElementsByTagName('img')[0];
 this._outSrc = this._img.src;
 var outID=this._img.id;
 if(document.getElementById(outID+'over')){
     var overIMG=document.getElementById(outID+'over');
     this._overSrc = overIMG.src;
 }else{
 this._overSrc = this._outSrc.replace(/(\.(gif|jpg))/, '_over' + '$1');
 }

 var overImg = new Image();
 overImg.src = this._overSrc;
 
 this._link.onmouseover = this._hilite;
 this._link.onmouseout = this._clear;
};
Building.prototype.setName = function(name)
{
 this._name = name;
};
Building.prototype.addRegion = function(region)
{
 this._regions.push(region);
};
Building.prototype.show = function()
{
 this._link.style.visibility = 'visible';
};
Building.prototype.hide = function()
{
 this._link.style.visibility = 'hidden';
};
Building.prototype._hilite = function()
{
 this._obj._img.src = this._obj._overSrc;
 this._obj._clearHeadline();
 
 var text = document.createTextNode(this._obj._name);
 this._obj._headline.appendChild(text);
};
Building.prototype._clear = function()
{
 this._obj._img.src = this._obj._outSrc;
 this._obj._clearHeadline();
};
Building.prototype._clearHeadline = function()
{
 var headline = this._headline;
 if (headline.childNodes[0])
 {
  headline.removeChild(headline.childNodes[0]);
 }
};
