/*
 * global loader
 */

var Loader = {
	initialized: 0,
	stack: [],
	/**
	 * push function on stack
	 */
	push: function(funct) {
		this.stack.push(funct);
	},

	/**
	 * execute functions stored in stack
	 */
	start: function() {
		if (this.initialized == 0) {
			for (var i=0; i<this.stack.length; i++) {
				this.stack[i]();
				this.stack[i] = null;
			}
			this.stack = [];
		}
		this.initialized += 1;
	}
}

var True = true;
var False = false;

function readMap() {
	var map, mapbg, i;
	mapbg = document.getElementById('ImgCountrySelect');
	if(mapbg) {
		//mapbg.src = "http://webarchive.nationalarchives.gov.uk/20081105144808/http://www.envirowise.gov.uk/images/spacer.gif";

		map = document.getElementsByTagName('area');
		if (document.getElementById('map-links')) {
			linkColor = document.getElementById('map-links').getElementsByTagName('a');
		};
		
		if (document.getElementById('MapCountry')) {
			linkColor = document.getElementById('MapCountry').getElementsByTagName('a');
		};

		for(i=0;i<map.length;i++) {
			map[i].onmouseover=function() { change(this); };
			map[i].onmouseout=function() { change(this); };
		}

		for(i=0;i<linkColor.length;i++) {
			linkColor[i].onmouseover=function() { change(this,1); };
			linkColor[i].onmouseout=function() { change(this,1); };
		}
	}
}

Loader.push(function(){ readMap(); });


function change(o,linked) {
	var mapbg, id;
	id = o.id;

	mapbg = document.getElementById('ImgCountrySelect');

	if (linked == 1) {
		id = 'map' + id.substring(4,8);
		if (id == 'map-cym') id = 'map-wal';
	}

	if(id == mapbg.className) {
		mapbg.className='map-off';
		document.getElementById('link' +id.substring(3,7)).style.color = "#6f6352";
		if (id == 'map-wal') document.getElementById('link-cym').style.color = "#6f6352";
	}
	else {
		mapbg.className=id;
		document.getElementById('link' +id.substring(3,7)).style.color = "#d9c90a";
		if (id == 'map-wal') document.getElementById('link-cym').style.color = "#d9c90a";
	}
}

function linklight(act) {
	var mapsw, id;
	
}


function flashActivation() {
	
}

// global onload function
var _init = function() {
	Loader.start();
}

window.onload = function() {
	_init();
}

var state = 'block'; 

function showhide(layer_ref) { 

if (state == 'block') { 
state = 'none'; 
} 
else { 
state = 'block'; 
} 
if (document.all) { //IS IE 4 or 5 (or 6 beta) 
eval( "document.all." + layer_ref + ".style.display = state"); 
} 
if (document.layers) { //IS NETSCAPE 4 or below 
document.layers[layer_ref].display = state; 
} 
if (document.getElementById &&!document.all) { 
hza = document.getElementById(layer_ref); 
hza.style.display = state; 
} 
} 


