var displayed = false;
var displayed_data;

var clicked = 0;
var last_panel = 0;
var last_hl = 0;
var current_panel = 0;

function hide_previous(){
	if(last_hl < 22){
		swap('spot_'+last_hl,'../maps/images/spot.gif');
	}

	last_name = "name_"+last_hl;
	m_hide(last_name);
}

/*
// hide EVERYTHING...
	for (var i = 1; i < 22; i++) {
		if (i < 10){
			num_str = "0"+i;
		}
		swap('spot_'+num_str,'../maps/images/spot.gif');
		this_flag = "name_"+num_str;
		m_hide(this_flag);
	}	
*/


function map_hide(){
	clicked = 0;

// hide this panel...
	this_data = "map_"+last_panel;
	m_hide(this_data);

// hide last map location...
// but only if it isn't a region!
	if (last_panel < 22){
		swap('spot_'+last_panel,'../maps/images/spot.gif');
	}
	this_spot = "name_"+last_panel;
	m_hide(this_spot);
}


function map_show(this_object){


// handle an open panel...
	if (clicked == 1){
		map_hide();
	}

// show this new panel...
	clicked = 1;

// display this panel...
	current_panel = this_object;
	this_data = "map_"+this_object;
	m_show(this_data);
	last_panel = this_object;
	
// highlight this map location...
// but only if it isn't a region!
	if (this_object < 22){
		swap('spot_'+this_object,'../maps/images/spot_over.gif');
	}
	this_spot = "name_"+this_object;
	m_show(this_spot);


}

function map_over(this_object){
// unhighlight previous
	if (last_hl != 0){
		hide_previous();
	}

// only show name tags when the panel is closed...
	if (clicked != 1){
		swap('spot_'+this_object,'../maps/images/spot_over.gif');

		this_spot = "name_"+this_object;
		m_show(this_spot);

		last_hl = this_object;

	} else {
		if (current_panel != this_object){
// hide the current panel's highlight spot and flag
// make sure it wasn't a region!
			if (current_panel < 22){
				swap('spot_'+current_panel,'../maps/images/spot.gif');
			}
			this_spot = "name_"+current_panel;
			m_hide(this_spot);

// display new spot and flag
			swap('spot_'+this_object,'../maps/images/spot_over.gif');

			this_spot = "name_"+this_object;
			m_show(this_spot);

			last_hl = this_object;
		}	
	}
}

function rgn_over(this_object){
// unhighlight previous
	if (last_hl != 0){
		hide_previous();
	}

// only show name tags when the panel is closed...
	if (clicked != 1){
		this_spot = "name_"+this_object;
		m_show(this_spot);
		last_hl = this_object;

	} else {
		if (current_panel != this_object){
// hide the current panel's highlight spot and flag
// make sure it wasn't a region!
			if (current_panel < 22){
				swap('spot_'+current_panel,'../maps/images/spot.gif');
			}
			this_spot = "name_"+current_panel;
			m_hide(this_spot);

// display new flag (for a region)
			this_spot = "name_"+this_object;
			m_show(this_spot);

			last_hl = this_object;
		}	
	}
}





function map_out(this_object){
// only hide name tags when the panel is closed...
	if (clicked != 1){
		swap('spot_'+this_object,'../maps/images/spot.gif');

		this_spot = "name_"+this_object;
		m_hide(this_spot);

	} else {
		if (current_panel != this_object){
			swap('spot_'+this_object,'../maps/images/spot.gif');

			this_spot = "name_"+this_object;
			m_hide(this_spot);
	
// re-highlight current map location...
// but only if it isn't a region!
			if (current_panel < 22){
				swap('spot_'+current_panel,'../maps/images/spot_over.gif');
			}
			this_spot = "name_"+current_panel;
			m_show(this_spot);
		}
	}
}

function rgn_out(this_object){
// only hide name tags when the panel is closed...
	if (clicked != 1){
		this_spot = "name_"+this_object;
		m_hide(this_spot);

	} else {
		if (current_panel != this_object){
			this_spot = "name_"+this_object;
			m_hide(this_spot);
	
// re-highlight current map location...
// but only if it isn't a region!
			if (current_panel < 22){
				swap('spot_'+current_panel,'../maps/images/spot_over.gif');
			}
			this_spot = "name_"+current_panel;
			m_show(this_spot);
		}
	}
}



function sf_map_init(){
	return true;
}


function m_show(this_object){
//alert(this_object);
	if (document.getElementById && document.getElementById(this_object) != null){
//		node = document.getElementById(displayed_object).style.visibility='hidden';
		node = document.getElementById(this_object).style.visibility='visible';
		node = document.getElementById(this_object).style.display='block';

	} else if (document.layers && document.layers[this_object] != null){
//		document.layers[displayed_object].visibility = 'hidden';
		document.layers[this_object].visibility = 'visible';
		document.layers[this_object].display = 'block';

	} else if (document.all){
//		document.all[displayed_object].style.visibility = 'hidden';
		document.all[this_object].style.visibility = 'visible';
		document.all[this_object].style.display = 'block';

	}

	displayed_object = this_object;
}


function m_hide(this_object){
//alert(this_object);
	if (document.getElementById && document.getElementById(displayed_object) != null){
		node = document.getElementById(this_object).style.visibility='hidden';
//		node = document.getElementById(this_object).style.display='none';

	} else if (document.layers && document.layers[displayed_object] != null){
		document.layers[this_object].visibility = 'hidden';
//		document.layers[this_object].display = 'none';

	} else if (document.all){
		document.all[this_object].style.visibility = 'hidden';
//		document.all[this_object].style.display = 'none';

	}

	displayed_object = this_object;
}



/*
function show(id) {
	if (document.getElementById) {
		document.getElementById(id).style.visibility="visible";
		if (navigator.userAgent.indexOf('MSIE') == -1 || navigator.userAgent.indexOf('Mac') == -1) {
			document.getElementById(id).style.left="0px";
		}
	} else if (document.all) {
		document.all[id].style.display="block";
	} else if (document.layers) {
//
	}
} 

function hide(id) {
	if (document.getElementById) {
		document.getElementById(id).style.visibility="hidden";
	} else if (document.all) {
		document.all[id].style.display="none";
	} else if (document.layers) {
	;
	}
}
*/
