
// Function to allow for function run on certain events, eg; pageload
function addEvent(obj, evType, fn)
{ 
	if (obj.addEventListener)
	{ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} 
	else if (obj.attachEvent)
	{ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} 
	else 
	{ return false; } 
}

// function to monitor use input around the county map.
function getcounty()
{
	try {
		// upon page load, hide all layers.
		var clearAll = document.getElementById('mapshopslist').getElementsByTagName('div');
		for(var x=0; x<clearAll.length; x++)
		{
			/*if(clearAll[x].id != "pnl_cork") { */ clearAll[x].style.display = "none"; //}
		}
		
		var sfEls = document.getElementById("test").getElementsByTagName("area");
		var getSpan = document.getElementById('mapcounty');
		for (var i=0; i<sfEls.length; i++) 
		{
			sfEls[i].onmouseover=function() 
			{ 
				this.className+=" sfhover"; 
				/*this.style.backgroundColor='#CCCCCC';*/
				getSpan.innerHTML = this.id.charAt(0).toUpperCase() + this.id.substring(1, this.id.length);
				// Pull in the ID & capitalise the first letter
			}
			sfEls[i].onmouseout=function() 
			{ 
				this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); 
				getSpan.innerHTML = "Select county";
			}
			sfEls[i].onclick=function()
			{
				for(var x=0; x<clearAll.length; x++)
				{ if(clearAll[x].id != this.id) { clearAll[x].style.display = "none"; }	}

				document.getElementById("pnl_" + this.id).style.display = "block";
			}

		}// end for
		
		
	} //end try
	catch(e) {}

}

function formHandler()
{
	var elem = document.getElementById('county_form');
	var URL = elem.options[elem.selectedIndex].value;
	
	var clearAll = document.getElementById('mapshopslist').getElementsByTagName('div');
	for(var x=0; x<clearAll.length; x++)
	{ 
		if(clearAll[x].id != URL) { clearAll[x].style.display = "none"; }
	}
	if(URL != "null") { document.getElementById("pnl_" + URL).style.display = "block"; }
	//window.location.href = URL;
}

addEvent(window, 'load', getcounty);