//topic preview by pukapuka
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
var the_div;
var show_type;

function get_div(div_id)
{
	if (ns4)
	{
		the_div = document.layers[div_id];
	}
	else if (ns6)
	{
		the_div = document.getElementById(div_id).style;
	}
	else if (ie4)
	{
		the_div = document.all[div_id].style;
	}

	return the_div;
}

function show_div(div_id, stype)
{
	get_div(div_id);
	show_type = stype;
	if (ns4)
	{
		document.captureEvents(Event.MOUSEMOVE);
	}
	document.onmousemove = get_mouse;
	the_div.visibility = "visible";
	the_div.display = "";
}

function hide_div(div_id)
{
	get_div(div_id);
	the_div.visibility = "hidden";
	the_div.display = "none";
}

function get_mouse(e)
{
	var x = (ns4 || ns6) ? e.pageX : event.x + document.body.scrollLeft;
	var y = (ns4 || ns6) ? e.pageY : event.y+ document.body.scrollTop;
	if (show_type == 'topic')
	{
		the_div.left = x - 50;
	}
	else if (show_type == 'last_post')
	{
		the_div.left = x - 130;
	}
	the_div.top = y + 20;
}

function write_preview_topic(topic_div_id, topic_preview)
{
	document.writeln('<div id="' + topic_div_id + '" style="position: absolute; visibility: hidden; display: none;"><table class="forumline" width="400px"><tr><td class="preview">' + topic_preview + '</td></tr></table></div>');
}

function write_preview_last_post(u_last_post, last_post_div_id, last_post_img, last_post_preview)
{
	document.writeln('<a href="' + u_last_post + '" onMouseOver="show_div(\'' + last_post_div_id + '\', \'last_post\');" onMouseOut="hide_div(\'' + last_post_div_id + '\');">' + last_post_img + '</a>');
	document.writeln('<div id="' + last_post_div_id + '" style="position: absolute; visibility: hidden; display: none;"><table class="forumline" width="300px"><tr><td class="preview">' + last_post_preview + '</td></tr></table></div>'); 
}

