var state_list;
function initMap() {
	var _map = document.getElementById("map");
	if (_map) {
		createMap(_map);
	}
}

function createMap(_map) {
	state_list = document.getElementById("map-hover").getElementsByTagName("li");
	var _areas = _map.getElementsByTagName("area");
		for (i = 0; i < _areas.length; i ++) {
			if (_areas[i].alt) {
				var _node = document.getElementById(_areas[i].alt);
				if (_node) {
					_areas[i]._node = _node;
					_areas[i].onmouseover = function() {
                        // Need to submit location from the onmouseover if it's an ios otherwise user has to click on the area twice
                        if (isios) {
                            iosSubmitLocation(this.className);
                        }
						if (this._node.className.indexOf("activestate") == -1) {
							this._node.className += " activestate";
						}
					}
					_areas[i].onmouseout = function() {
						this._node.className = this._node.className.replace("activestate", "");
					}
				}
			}
		}
}
if (window.addEventListener){
	window.addEventListener("load", initMap, false);
}
else if (window.attachEvent){
	window.attachEvent("onload", initMap);
}

function iosSubmitLocation(location) {
    document.countryForm.dropSelect.value=location;
    document.countryForm.btn_submit.click(true);
}
