/* $Id$ */
var ag_div = null;
var loc_div = null;
var trees_div = null;
var date_div = null;
var beq_div = null;

//
// locate the divs for text
//
function get_text_areas() {
	if ( !ag_div ) ag_div = document.getElementById('vf_agency');
	if ( !trees_div ) trees_div = document.getElementById('vf_trees');
	if ( !loc_div ) loc_div = document.getElementById('vf_location');
	if ( !date_div ) date_div = document.getElementById('vf_plant_date');
	if ( !beq_div ) beq_div = document.getElementById('vf_bequest');
}

//
// mouse over property
//
function vforestOver(mk) {
	get_text_areas();
	var obj = eval(mk.info);
	mk.setImage('/images/our_forest/cross_icon_hover.gif');
	if ( ag_div ) ag_div.innerHTML = obj.Agency;
	if ( trees_div ) trees_div.innerHTML = obj.Planted;
	if ( loc_div ) loc_div.innerHTML = obj.Location+'<br />'+obj.Area;
	if ( date_div ) date_div.innerHTML = obj.PlantDate;
	if ( beq_div ) beq_div.innerHTML = obj.Bequest;
}

//
// mouse moving out of property
//
function vforestOut(mk) {
	get_text_areas();
	mk.setImage('/images/our_forest/cross_icon.gif');
	if ( ag_div ) ag_div.innerHTML = '';
	if ( trees_div ) trees_div.innerHTML = '';
	if ( loc_div ) loc_div.innerHTML = '';
	if ( date_div ) date_div.innerHTML = '';
	if ( beq_div ) beq_div.innerHTML = '';
}

//
// external zoom in and out buttons
//
function vforestZoomIn() {
	if ( g_map && maxzoom ) {
		var zm = g_map.getZoom();
		if ( zm < maxzoom ) g_map.setZoom(zm+1);
	}
}

function vforestZoomOut() {
	if ( g_map ) {
		var zm = g_map.getZoom();
		g_map.setZoom(zm-1);
	}
}

var info_div = null;
var pic_div = null;
var def_pic = null;
var active = null;
var inClick = 0;

function get_htext_areas() {
	if ( !info_div ) info_div = document.getElementById('tree_facts');
	if ( !pic_div ) pic_div = document.getElementById('tree_pic');
}

//
// mouse over property: heritage trees
//
function hTreesClick(mk) {
	var obj = eval(mk.info);
	if ( !asynch_r ) asynch_r = new Rwin();
	t_div = asynch_r.open_div('htInfo','vis');
	asynch_r.wrap('Heritage Tree',10,document.documentElement.scrollTop+20);
	asynch_r.set_html('Loading....');
	asynch_r.add_timer();
	asynch_r.asynch('tree_info','hTreeInfoDisplay',obj.nSiteID);
	if ( active ) {
		var aobj = eval(active.info);
		active.setImage('/images/'+aobj.Icon);
	}
	mk.setImage('/images/heritage_trees/maple-leaf-gold.gif');
	active = mk;
}

//
// display the contents returned by asynch request
//
function hTreeInfoDisplay(json) {
	if ( asynch_r ) {
		asynch_r.set_title(json.Title);
		if ( json.Error ) asynch_r.set_html(json.Error);
		else asynch_r.set_html(json.Content);
	}
}


