var mapsrc;
function showCountry(e) {

	var id = this.id;
	if (!id) {
		elm = e.relatedTarget || e.toElement;
		id = elm.id;
	}

	var mapsrc = '/image/map/' + id + '.gif';
	document.getElementById('activeCounty').src = mapsrc;
	document.getElementById('activeCounty').alt = mapsrc;
}

function selectCountry(id) {
	//alert (id);
	mapsrc = document.getElementById('activeCounty').src;
	newmapsrc = '/image/map/' + id + '.gif';
	document.getElementById('activeCounty').src = newmapsrc;
	document.getElementById('activeCounty').alt = newmapsrc;
}

function resetCountry(oldmapsrc) {
	var undefined;
	
	if(oldmapsrc == undefined){
		oldmapsrc = mapsrc;
	}
	document.getElementById('activeCounty').src = oldmapsrc;
}

function addMouseOverForMap() {
	var maplinks = getElementsByClassName('mapMouseOver', 'a');
	var mapsrc = document.getElementById('activeCounty').src;
	for(i=0; i<maplinks.length; i++) {
		addEventHandler(maplinks[i], 'mouseover', showCountry );
		addEventHandler(maplinks[i], 'mouseout', function(e){resetCountry(mapsrc)} );
	}
}

function addMouseOverForIMGMap() {
	var imgmaplinks = getElementsByClassName('imgmapMouseOver', 'area');
	var mapsrc = document.getElementById('activeCounty').src;
	for(i=0; i<imgmaplinks.length; i++) {
		var  str = imgmaplinks[i].toString();
		if(str.indexOf("=") != -1){
			//str = str.substring((str.length-2));
			str = str.substring((str.indexOf("=")+1));
			alert (str);

		}
//		addEventHandler(imgmaplinks[i], 'mouseover', function (e){ selectCountry("L"+str)} );
		imgmaplinks[i].onmouseover = function (e){ selectCountry("L"+str)};
		addEventHandler(imgmaplinks[i], 'mouseout', function(e){resetCountry(mapsrc)} );
	}
}

