//These script lines must be included on each product page
var count = eval(getCookie("counter"));
if (count==null){count = 0};
setCookie("counter",count);

// Heinle's function for retrieving a cookie...must include
function getCookie(name){
  var cname = name + "=";               
  var dc = document.cookie;             
  if (dc.length > 0) {              
    begin = dc.indexOf(cname);       
    if (begin != -1) {           
      begin += cname.length;       
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    } 
  }
  return null;
}

// An adaptation of Dorcht's function for setting a cookie...must include
function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) + 
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

function buyProduct(coder,namer,pricer,howbig,taste,shipping,number) {
   count = count + 1;
   setCookie("counter",count);
   var x = taste.selectedIndex;
   if (number == null || number == " ") {number = 1};
   var product = new Array();
   product[0] = coder;
   product[1] = namer;
   product[2] = pricer;   
   product[3] = number;
   product[4] = taste;
   product[5] = howbig;
   product[6] = shipping;
   var together = product.join();
   setCookie("test",together);
   location.href="cart.php";
}

//The script lines and functions above are all required on each product page
