function tempCookie(theName__,theValue__)
{
  if ((theNmae != null) && (theValue__ != null))
  {
    document.cookie = theName__ + "="+theValue__;
    return true;
  }
  return false;
}
function setCookie(theName__,theValue__,theDay__, thePath__)
{
  if ((theName__ != null) && (theValue__ != null))
  {
    var expDay__ = "Wed, 01 Jan 2020 18:56:35 GMT";
    if (theDay__ != null)
    {
      theDay__ = eval(theDay__);
      var setDay = new Date();
      setDay.setTime(setDay.getTime()+(theDay__*1000*60*60*24));
      expDay__ = setDay.toGMTString();
    }
    document.cookie = theName__ + "="+escape(theValue__)+";expires="+expDay__+";path=/";
    return true;
  }
  return false;
}
function deleteCookie(theName__)
{
  document.cookie = theName__ + "=;expires=Thu,01-Jan-70 00:00:01 GMT";
  return true;
}
function getCookie(theName__)
{
  theName__ += "=";
  theCookie__ = document.cookie+";";
  start__ = theCookie__.indexOf(theName__);
  if (start__ != -1)
  {
    end__ = theCookie__.indexOf(";",start__);
    return unescape(theCookie__.substring(start__+theName__.length,end__));
  }
  return false;
}

function itemIndex()
{
  var item_index = getCookie("graniph.com.item_remember");
  var id = document.forms['cart'].elements['_item_id'].value;
  if (!item_index)
  {
    item_index = "1:" + id;
  }
  else
  {
    var a = item_index.split(";");
    var b = [];
    for (var i = 0; i < a.length; i++)
    {
      if (b.length < 15 && a[i].split(":")[1] != id)
      {
        b[b.length] = (i + 2) + ":" + a[i].split(":")[1];
      }
    }
    item_index = b.join(";");
    item_index = "1:" + id + ";" + item_index;
    item_index = item_index.replace(/^\;|\;$|/g, "").replace("\;+", ";");
  }
  setCookie("graniph.com.item_remember", item_index);
  return true;
}

itemIndex();

