// JavaScript Document

// ----------------------------------------------------------------------------

global = new Object();

function init(){
}

function mouseOver(id){
	url='/images/area/'+ res.prefs.list[id].abbrev +'.gif';
	document.getElementById('areaimg').src=url;
}
function mouseOut(){
	$('areaimg').src = '/images/area/area00.gif';
}

function display_c21_links() {
	var elm = $('prefs_selector');
	var ary = new Array();
	ary.push($('area_items_block'));
	ary.push($('area_neighbor_block'));
	ary.push($('area_shops_block'));
	if (0 == elm.selectedIndex) {
	   ary.each(function(item) {
	       if (item != null) {
    	       item.hide();
    	   }
	   });
	} else {
	   ary.each(function(item) {
	       if (item != null) {
    	       item.show();
    	   }
	   });
	}
}

function choice(pref_code) {
	global.prefs.select_pref_by_value(pref_code);
	display_c21_links();
}

function makeOptionsFromPrefs(opts) {
	var index = 0;
	$H(res.prefs.list).each(function(value) {
		pref = value.value;
		opts[index] = new Option(pref.name, pref.code);
		index++;
	});
}

function init_html() {
//	$('content').style.display = 'block';
	if (document.cookie == '') {
		$('visible-content').style.display = 'none';
		$('noscript-warning').style.display = 'block';
		return;
	}
	var selector = $('prefs_selector');
	makeOptionsFromPrefs(selector.options);
	$H(res.prefs.list).each(function(value) {
		pref = value.value;
		var code = pref.code;
		if (0 < code) {
			var elm = $('area_' + code);
			if (elm != null) {
				elm.onclick = function() {
					choice(code);
				};
				elm.onmouseover = function() {
					mouseOver(code);
				};
				elm.onmouseout = function() {
					mouseOut();
				};
				elm['alt'] = pref.name;
			}
		}
	});
	if (global.pref_code) {
		global.prefs.select_pref_by_value(global.pref_code, global.city_code);
	}
}
