cities = [];

window.onload = function(){
	CreatePoints();
}

var CreatePoints = function(){
	var els = document.getElementsByTagName('dt');
	for(var i = 0;i < els.length;i++){
		cities.push(new CityPoints(els[i]));
	}
}

var CityPoints = function(pointEl){
	this.el = document.getElementById(pointEl.id + 'Desc');
	this.top = parseInt(pointEl.style.top);
	this.left = parseInt(pointEl.style.left);
	this.tmOut = '';
	this.el.style.display = 'block';
	var child = this.el.firstChild;
	    child = child.firstChild;
	this.offset = child.offsetWidth;
	this.el.style.display = 'none';
	pointEl.thisObj = this;
	this.el.thisObj = this;
	pointEl.onmouseover = this.ShowDescription;
	pointEl.onmouseout = this.HideDescription;
	this.el.onmouseover = this.ShowDescription;
	this.el.onmouseout = this.HideDescription;
}

lastCaller = '';
lastDescription = '';

CityPoints.prototype = {
	
	ShowDescription : function(event){
		var thisObj = this.thisObj;
		thisObj.el.style.display = 'block';
		thisObj.el.style.top = (thisObj.top-30) + 'px';
		thisObj.el.style.left = (thisObj.left - (thisObj.offset / 2.2)) + 'px';
		thisObj._MoveDecor();
		if(!window.event){
			thisObj.caller = event.target;
		}else{
			thisObj.caller = window.event.srcElement;
		}
		if(lastCaller != '' && lastDescription != thisObj.el && lastCaller.id != thisObj.caller.id){
			lastDescription.style.display = 'none';
		}
		if (thisObj.caller.nodeName == 'NOBR' || thisObj.caller.nodeName == 'DIV') {
			clearTimeout(thisObj.tmOut);
		}
		lastCaller = thisObj.caller;
		lastDescription = thisObj.el;
	},
	
	HideDescription: function(){
		var thisObj = this.thisObj;
		if (thisObj.caller.nodeName != 'NOBR') {
			thisObj.tmOut = setTimeout(function(){
				thisObj.el.style.display = 'none';
			}, 1500);
		}else{
				thisObj.el.style.display = 'none';
		}
	},

	_MoveDecor : function(){
		var thisObj = this.thisObj;
		var els = this.el.getElementsByTagName('div');
		for(var i = 0;i < els.length;i++){
			if(els[i].className == 'popupTop' || els[i].className == 'popupBot' ){
				els[i].style.left = (this.offset / 2 - 10) + 'px';
			}
		}
	}
}


function showCity(cityId)
{
	var el = document.getElementById(cityId+'Desc');
	for(var i = 0;i < cities.length;i++){
	if(cities[i].el.id == el.id){
		el.style.top = (cities[i].top - 30) + 'px';
		el.style.left = (cities[i].left - (cities[i].offset / 2.2)) + 'px';
		cities[i]._MoveDecor();
		}
	}
	el.style.display = 'block';	
	el.parentNode.style.zIndex = '100';
}

function hideCity(cityId)
{
	var el = document.getElementById(cityId+'Desc');
	el.style.display = 'none';
	el.parentNode.style.zIndex = '0';
}









