/**
Contains functions and classes for the weather map
*/

function regionClass(){
	this.name = name;
	this.img = img;
}

var wmRegions = new Array("default", "america") //,"africa","westasia","asia");
var defaultRegion = null;
var activeRegion = 0;
var overRegion = 1;


//when mousing over a region on the map
function eventWMover(x){
	var obj = document.getElementById("wmM" + wmRegions[overRegion]);
	//alert("over: set hidden: " + "wmM" + wmRegions[overRegion]);
	obj.style.visibility = "hidden";
	obj = document.getElementById("wmI" + wmRegions[x]);
	//alert("over: set vivible: " + "wmI" + wmRegions[x]);
	obj.style.visibility = "visible";
	overRegion = x;
}

//when mousing out of  a region on the map
function eventWMout(){
	var obj = document.getElementById("wmM" + wmRegions[0]);
	//alert("out: set visible: " + "wmM" + wmRegions[0]);
	obj.style.visibility = "visible";
	obj = document.getElementById("wmI" + wmRegions[overRegion]);
	//alert("out: set hidden: " + "wmI" + wmRegions[overRegion]);
	obj.style.visibility = "hidden";
	overRegion = 0;
}

// changes the visibility for the default(select) region
function eventWMDefault(){
	if (defaultRegion){
		eventWMclick(defaultRegion);
	}
	var obj = document.getElementById("wmI" + wmRegions[activeRegion]);
	obj.style.visibility = "visible";
	obj.style.display = "block";
}

//event fired when the user clicks on the maps
function eventWMclick(x){
	//hide old graphic region
	var obj = document.getElementById("wmI" + wmRegions[activeRegion]);
	obj.style.visibility = "hidden";
	obj.style.display = "none";
	//show new graphic region
	obj = document.getElementById("wmI" + wmRegions[x]);
	if (obj){
		obj.style.visibility = "visible";
		obj.style.display = "block";
	}
	if (activeWMTopic != null){
		eventWMclickTopic(activeWMTopic,x);
	}
	activeRegion = x;
}
	
function eventWMclickTopic(topic,newRegion){
	//hide old
	var obj = document.getElementById("wm_" + activeWMTopic+wmRegions[activeRegion]);
	if (obj){
		obj.style.display = "none";
		obj.style.visibility = "hidden";
	}	
	obj = document.getElementById("wm_" + activeWMTopic);
	if (obj){
		obj.style.display = "none";
		obj.style.visibility = "hidden";
	}	
	if (newRegion == null){
		newRegion = activeRegion;
	}
	obj = document.getElementById("wm_" + topic+wmRegions[newRegion]);
	if (obj){
		obj.style.display = "block";
		obj.style.visibility = "visible";
	}	
	//mark active topic menu
	obj = document.getElementById("wm_" + topic);
	if (obj){
		obj.style.visibility = "visible";
		obj.style.display = "block";
	}	
	activeWMTopic = topic;
}

function initWM(){}

