
function chart_page_loaded() {
	msg("chart page_loaded");
	top.any_page_loaded(page_id);
	load_chart();
}


function load_chart() {
	img_url = parent.storm_folder + parent.storm_key + "_chart.png"
	document.images["chart"].src = img_url;
}


function write_image_map() {
	str = "";

	x_left = 0;
	
	for (i=0; i<opts.length; i++) {
		opt = opts[i];
		x = opt.x;

		next_i = i+1;
		if ( next_i < opts.length ) {
			next_x = opts[next_i].x;
			x_right = (x + next_x) / 2
		}
		else { x_right = chart_width; }


		str += '<area shape="rect"';
		str += ' coords="' + x_left + ',0,' + x_right + ',100"';
		str += ' href="javascript:view_observation(' + (i+1) + ')"';
		str += ' alt="' + get_option_name(opt) + '"';
		str += '>';

		x_left = x_right;
	}

	document.write(str);
}


function view_observation(p) {
	top.obs.set_option(p-1);
//	hilite_observation(p-1);
}


function hilite_observation(opt) {
	x = opt.x - 9
	y = 59; // dot above line
	// y = 65 // dot on line

	set_hilite_loc(x, y);
}

function set_hilite_loc(x, y) {
	if (document.getElementById) {
		hiliter = document.getElementById("hilite").style;
		hiliter.left = "" + x + "px";
		hiliter.top  = "" + y + "px";
	} else {
		document.hilite.left = x;
		document.hilite.top  = y;
	}
}


function help() {
	set_hilite_loc(0, 200);
	document.images["chart"].src = "img/help/chart.gif";
}


function help_off() {
	load_chart();
	hilite_observation(top.obs.get_option());
}

