function SaveTrail(id,name,img,cookie,size)
{
  var path = "";
  var path = GetCookie(cookie);
  if (path == null)
    path = "";

  var elem;
  if (id && name)
  {
    elem = id + "|" + escape(name) + "|" + img;
  }
  else
  {
    elem = id;
  }
  path = RemoveStr(path,elem);
  var trail = path.split(",");
  var l = trail.push( elem );
  while ( trail.length > 0 && trail[0] == "" )
  {
    trail.shift();
    l = trail.length;
  }
  while ( l > parseInt(size) )
  {
    trail.shift();
    l = trail.length;
  }
  
  path = trail.toString();
  // make it expire in one day
  var dt = new Date();
  dt.setTime(dt.getTime() + 24 * 60 * 60 * 1000);
  SetCookie(cookie, path, dt);
}

function ShowFullTrail(type)
{
    var ck = (type == "Items" ? "Path" : "Section");

    var path = GetCookie(ck);
    if (path == null)
      path = "";

  var trail = path.split(",");
  while ( trail.length > 0 && trail[0] == "" )
  {
    trail.shift();
    l = trail.length;
  }

  if ( trail.length > 0 )
  {
    var columns = 2;
    var NewRow = true;
    var InRow = false;
    var colwid = 5 / columns;
    
    document.write("<div id=recenthistory>");
    document.write("<label>" + "</label>");
    document.write("<table border=0 width=450 cellpadding=0 cellspacing=3>");
    var j = 1;
    for ( i = trail.length - 1; i >= 0; i-- )
    {
        if (NewRow)
        {
            document.write("<tr valign=top>");
            NewRow = false;
            InRow = true;
        }
        elem = trail[i].split("|");
        if ( elem[0].length > 0 )
        {
            document.write("<td width=" + colwid + "%><table border=0 cellpadding=0 cellspacing=2><tr><td align=center width=50%>");
            if (elem[2].length > 0)
            {
                document.write ( "<img border=0 align=absmiddle src=" + elem[2] + ">&nbsp;" );
            }
            document.write("<br>");
            document.write( "<a href=" + elem[0] + ".html>" + unescape(elem[1].replace(/`/gi, "'").replace(/%26%2396%3B/gi,"'")) + "</a><br>");
            document.write("</td></tr></table></td>");
        }
        if (j % columns == 0)
        {
            document.write("</tr>");
            NewRow = true;
            InRow = false;
        }
        j++;
    }
    if (InRow)
        document.write("</tr>");
    document.write("</table></div>");
  }
}

