// JavaScript Document
if (!document.all&&!document.getElementById)
getthedate()
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
var ns5 = (document.getElementById && navigator.userAgent.indexOf('Gecko') > -1) ? true: false;
var ie5 = (document.getElementById && navigator.userAgent.indexOf('MSIE') > -1) ? true : false;
var ie4 = (!document.getElementById && document.all) ? true : false;
if (!ie4 && !ie5 && !ns5)
{
	event = "nope"
}

var offset_x = 10;
var offset_y = 20; 
var pre_main;
var pretime_1, pretime_2;
var pre_show = false;
var cur_x, cur_y;
function initiate()
{	
	if (!ie4 && !ie5 && !ns5)
	{
		return;
	}
	pre_main = my_getbyid('preview_main');
	if (pre_main)
	{
		document.onmousemove = set_preview;
	}
}
function do_preview(num)
{	
	if (!pre_main)
	{	
		return;
	}
	if (pretime_1){clearTimeout(pretime_1);}
	if (pretime_2){clearTimeout(pretime_2);}
	pre_show = true;

	if (ie4 || ie5 || ns5)
	{
		var temp = my_getbyid('preview_main');
		var th = temp.innerHTML;
		var wd = (th.length > 100) ? 300 : th.length+25;
		getAjax('preview_main', 'detail.php?id='+num);
		my_show_div(pre_main);
	}

	pretime_1 = setTimeout("my_show_div(pre_main)", 10);
}
function set_preview(e)
{
	cur_x = (ns5) ? e.pageX : event.x+tbody().scrollLeft;
	cur_y = (ns5) ? e.pageY : event.y+tbody().scrollTop;
	var redge = ((ie4 || ie5) && !window.opera) ? tbody().clientWidth-event.clientX-offset_x : window.innerWidth-e.clientX-offset_x-20;
	var bedge = ((ie4 || ie5) && !window.opera) ? tbody().clientHeight-event.clientY-offset_y : window.innerHeight-e.clientY-offset_y-20;
	var ledge = (offset_x < 0) ? offset_x*(-1) : -1000;

	if (redge < pre_main.offsetWidth)
	{
		pre_main.style.left = (ie4 || ie5) ? tbody().scrollLeft+event.clientX-pre_main.offsetWidth+"px" : window.pageXOffset+e.clientX-pre_main.offsetWidth+"px";
	}
	else if (cur_x < ledge)
	{
		pre_main.style.left = "5px";
	}
	else
	{
		pre_main.style.left = cur_x+offset_x+"px";
	}

	if (bedge < pre_main.offsetHeight)
	{
		pre_main.style.top = (ie4 || ie5) ? tbody().scrollTop+event.clientY-pre_main.offsetHeight-offset_y+"px" : window.pageYOffset+e.clientY-pre_main.offsetHeight-offset_y+"px";
	}
	else
	{
		pre_main.style.top = cur_y+offset_y+"px";
	}
}

function hide_preview()
{
	if (!pre_main)
	{
		return;
	}

	pretime_2 = setTimeout("my_hide_div(pre_main)", 10);
	pre_show = false;
}

function tbody()
{
	return (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
}

function my_getbyid(id)
{
	itm = null;
	
	if (document.getElementById)
	{
		itm = document.getElementById(id);
	}
	else if (document.all)
	{
		itm = document.all[id];
	}
	else if (document.layers)
	{
		itm = document.layers[id];
	}
	
	return itm;
}


//==========================================
// Set DIV ID to hide
//==========================================

function my_hide_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "none";
}

//==========================================
// Set DIV ID to show
//==========================================

function my_show_div(itm)
{
	if ( ! itm ) return;
	
	itm.style.display = "";
}
