var oldmousemove;
var mainmousemove;

function collapseTable(id)
{
	var det=document.getElementById('TBLDETAILS'+id);
	var inf=document.getElementById('TBLINFO'+id);
	var img=document.getElementById('TBLIMG'+id);
	
	var tables=new Array();
	var t=getCookie("TBL").split("/");
	for(var i=0;i < t.length;i++)
	{
		var p=t[i].split("-");
		tables[parseInt(p[0])]=p[1];
	}
	
	if(det.style.visibility == 'hidden')
	{
		det.style.visibility='visible';
		det.style.position='';
		
		inf.style.visibility='hidden';
		inf.style.position='absolute';
		
		img.src='images/tri_down.gif';
		tables[id]='O';
	}
	else
	{
		det.style.visibility='hidden';
		det.style.position='absolute';

		inf.style.visibility='visible';
		inf.style.position='';
		
		img.src='images/tri_up.gif';
		tables[id]='C';
	}
	
	var s="";
	for(var i=0;i < tables.length;i++)
	{
		if(tables[i] == null || tables[i] == undefined)
			continue;
		if(s != "")
			s+="/";
		s+=i+"-"+tables[i];
	}
	setCookie("TBL",s,300,"/");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return "";
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function setCookie(name,value,days,path)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	if(path == null)
		path="/";
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path="+path;
}

function help_move(e)
{
	try
	{
		if(document.getElementById != null)
		{
			myhelp=document.getElementById("help1");
			imyhelp=document.getElementById("ihelp1");
		}
		else
		{
			myhelp= eval("document.help1");
			imyhelp= eval("document.ihelp1");
		}
	
		if (!e) var e = window.event;
		if(e.pageX != null)
			{
				mx=e.pageX-75;
				my=e.pageY+20;
			}
		else
			{
				mx=e.x-75;
				my=e.y+20;
			}
		if (navigator.userAgent.indexOf('MSIE') != -1)
			{
				mx += document.body.scrollLeft;
				my += document.body.scrollTop;
			}
		if(mx < 0)
			mx=0;
			
		if(mx+160 >= document.body.clientWidth)
			mx=document.body.clientWidth-160;
	
		if(myhelp.style != null)
			{
				myhelp.style.top=my;
				myhelp.style.left=mx;
				imyhelp.style.top=my;
				imyhelp.style.left=mx;
				//myhelp.style.visibility="visible";
			}
		else
			{
				myhelp.top=my;
				myhelp.left=mx;
				imyhelp.top=my;
				imyhelp.left=mx;
				//myhelp.visibility="visible";
			}
	}
	catch(ex)
	{
	}
}

function show_help_box(e,msg)
{
	try
	{
		if(document.getElementById != null)
		{
			myhelp=document.getElementById("help1");
			imyhelp=document.getElementById("ihelp1");
		}
		else
		{
			myhelp= eval("document.help1");
			imyhelp= eval("document.ihelp1");
		}
	
		if(e.pageX != null)
			{
				mx=e.pageX-75;
				my=e.pageY+20;
			}
		else
			{
				mx=e.x-75;
				my=e.y+20;
			}
		if (navigator.userAgent.indexOf('MSIE') != -1)
			{
				mx += document.body.scrollLeft;
				my += document.body.scrollTop;
			}
		if(mx < 0)
			mx=0;
			
		if(mx+160 >= document.body.clientWidth)
			mx=document.body.clientWidth-160;		
			
		if(document.width != null && document.width > 200 && (mx+200) > document.width)
			mx=document.width-200;
		else if(window.top.document.body  != null && window.top.document.body.clientWidth  > 200 && (mx+200) > window.top.document.body.clientWidth)
			mx=window.top.document.body.clientWidth-200;
			
		if(myhelp.innerHTML != null)
			myhelp.innerHTML=msg;
		else
			{
				myhelp.document.write(msg);
				myhelp.document.close();
			}
		imyhelp.style.height = myhelp.offsetHeight;
		
		if(myhelp.style != null)
			{
				myhelp.style.top=my;
				myhelp.style.left=mx;
				myhelp.style.visibility="visible";
				imyhelp.style.top=my;
				imyhelp.style.left=mx;
				imyhelp.style.visibility="visible";
			}
		else
			{
				myhelp.top=my;
				myhelp.left=mx;
				myhelp.visibility="visible";
				imyhelp.top=my;
				imyhelp.left=mx;
				imyhelp.visibility="visible";
			}
		if(document.onmousemove != help_move)
		{
			oldmousemove=document.onmousemove;
			document.onmousemove=help_move;
		}
	}
	catch(ex)
	{
	}
}
function hide_help_box()
{
	try
	{
		if(document.getElementById != null)
		{
			myhelp=document.getElementById("help1");
			imyhelp=document.getElementById("ihelp1");
		}
		else
		{
			myhelp= eval("document.help1");
			imyhelp= eval("document.ihelp1");
		}
		
		if(myhelp.style != null)
			{
				myhelp.style.top=0;
				myhelp.style.left=0;
				imyhelp.style.left=-200;
				myhelp.style.visibility="hidden";
				imyhelp.style.visibility="hidden";
			}
		else
			{
				myhelp.top=0;
				myhelp.left=0;
				imyhelp.left=-200;
				myhelp.visibility="hidden";
				imyhelp.visibility="hidden";
			}
		document.onmousemove=oldmousemove;
	}
	catch(ex)
	{
	}
}

