maxHistory = 20;

function show_history(product_id,product_name)
{
  if (product_name != '相关商品不存在')
  {
     history_show = "<Table width=232 style=\"font-size:8pt;\"><TBODY><TR bgcolor=\"#ffffff\" height=28>";

     history_show = history_show + "<TD width=232><img src=\"./Image/index_88.gif\"></img><a href='http://www.1b2g.com/price_compare.php?product_id=" + product_id + "'>" + product_name + "</a></TD>";

     history_cookie = "_1b2g_id_" + product_id + "_1b2g_name_" + product_name;
     history_num = 1;

     old_history = GetCookie('history_cookie'); 

     var history_arg = new Array();
     var item = new Array();

     if (old_history != null)
     {
        history_arg = old_history.split("_1b2g_id_");

        for (i=1; i<=maxHistory; i++)
        {
            if(history_arg[i] != null)
            {
               item = history_arg[i].split("_1b2g_name_");

               if (item[0] != product_id)
               {
                   if (history_num % 2 == 0)
                   {
                      history_show = history_show + "</TR><TR bgcolor=\"#ffffff\" height=28>";
                   }
                   else
                   {
                      history_show = history_show + "</TR><TR bgcolor=\"#f0f0f0\" height=28>";
                   }

                   history_show = history_show + "<TD width=232><img src=\"./Image/index_88.gif\"></img><a href='http://www.1b2g.com/price_compare.php?product_id=" + item[0] + "'>" + item[1] + "</a></TD>";
                   history_cookie = history_cookie + "_1b2g_id_" + item[0] + "_1b2g_name_" + item[1];

                   history_num ++;

                   if (history_num >= maxHistory)
                   {
                      break;
                   }
               }
            }
            else
            {
                break;
            }
        }
     }

     var expdays = 365;
     var expires = expdays*24*60*60;

     SetCookie('history_cookie',history_cookie,expires);

     if (history_num % 2 != 0)
     {
        history_show = history_show + "<TD width=360>&nbsp;</TD>";
     }

     history_show += "</TR></TBODY></TABLE>";

     document.getElementById("show_history").innerHTML = history_show;
  }
}
