function toggle_area(area)
{
  var e = document.getElementById(area);
  e.style.display = e.style.display == 'none' ? '' : 'none';
}
// Element, state (1 = on, 0 = off) , alternate class name
function highlight(el, state, alt_class)
{
	//printd($(e).className);
  the_class = alt_class ? alt_class : "hl_on";
  if(state)
  { 
    el.addClass(the_class);
  } else {
    el.removeClass(the_class);
  }
}

function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}

// Tool Tip info
var tool_tip = [];
function init_tool_tip()
{
	if(!tool_tip['elmt']) // There's no tool tip, create one.
	{
		tool_tip['elmt'] = $('#tool_tip');
		tool_tip['text'] = $('#tool_tip_mid');
		tool_tip['type'] = null; // Mostly for regen, we want to hide it if the regen if full and the type is regen_info
	} 
}

// Do the hovers for the station list stuff on the left
$(function()
{
	$('#station_list .station_info').each( function() {
		$(this).hover(station_info_display, station_info_hide);
		$(this).bind('mousemove', tooltip_info_move);
	});
	
});

function station_info_display()
{
	// The station links inside
	var links = $(this).find('.station_links')[0];
	var desc = $(this).find('.station_desc')[0];
	
	$(links).show();
	tool_tip['text'].html(desc.innerHTML);
	tool_tip['elmt'].show();
	tool_tip['type'] = "regen_info"; // Set this type to regen_info so we can hide it if the regen is full.

}
function station_info_hide(e)
{
	var links = $(this).find('.station_links')[0];
	$(links).hide();
	tool_tip['elmt'].hide()
	tool_tip['type'] = null; // Set this type to null because we're not using it
}
function tooltip_info_move(e)
{
	tool_tip['elmt'].css('top', e.pageY + 10 + "px");
	tool_tip['elmt'].css('left', e.pageX + 10 + "px");
}


