function DisplayMiniCart(name,style) {
  var cookies=document.cookie;  //read in all cookies
  var start = cookies.indexOf(name + "=");  //set start to beginning of ss_cart cookie
  var cartvalues = "";
  var linecount = 0;
  var start1;
  var end1;
  var tmp;

  // Start Output
  document.write("<div class=\"MiniCart\">\n");

  if (style == "Detail")
  {
    document.write("<table cellspacing=\"0\" cellpadding=\"0\" width=\"130\" bgcolor=\"#D3DBD3\" border=\"1\">\n");
    document.write("<tr>\n");
    document.write("<th colspan=\"3\">");
    document.write("<a href=\"http://www.bonsaiboy.com/cgi-bonsaiboy/sb/order.cgi?storeid=*1a442456109edc27016177cea94a95&function=show\">");
    document.write("<img src=\"http://www.bonsaiboy.com/catalog/media/themesmedia/cart-black.gif\" border=\"0\" name=\"cart\" align=\"top\"> <small>View Shopping Cart</small>");
    document.write("</a></th></tr>");
  }
  else if (style == "Summary")
  {
    document.write("<a href=\"http://www.tahoemountainsports.com/cgi-tahoemountainsports/sb/order.cgi?storeid=*28a5f1b8bd747e463c27fb9748a871081043c6e19b9c&function=show\">");
    document.write("Your Shopping Cart");
    document.write("</a>");
  }
  else
  {
    document.write("<a class=\"MiniCart\" href=\"http://www.tahoemountainsports.com/cgi-tahoemountainsports/sb/order.cgi?storeid=*28a5f1b8bd747e463c27fb9748a871081043c6e19b9c&function=show\">");
    document.write("<img src=\"http://www.tahoemountainsports.com/store/media/themesmedia/cart-white.gif\" border=\"0\" name=\"cart\" align=\"top\">");
    document.write("</a>&nbsp;");
  }

  if (start == -1)  //No cart cookie
  {
    if (style == "Detail")
    {
      document.write("</table>\n");
    }
    else if ((style == "ItemCount") || (style == "Subtotal"))
    {
      document.write("<a href=\"http://www.bonsaiboy.com/cgi-bonsaiboy/sb/order.cgi?storeid=*1a442456109edc27016177cea94a95&function=show\">");
      document.write("0 Items");
      document.write("</a>&nbsp;");
      document.write("</div>\n");
    }
    else
    {
      document.write("</div>\n");
    }      
  }
  else   //cart cookie is present
  {
    start = cookies.indexOf("=", start) +1;  
    var end = cookies.indexOf(";", start);  
    if (end == -1)
    {
      end = cookies.length;
    }
    cartvalues = unescape(cookies.substring(start,end)); //read in just the cookie data

    start = 0;
    while ((start = cartvalues.indexOf("|", start)) != -1)
    {
      start++;
      end = cartvalues.indexOf("|", start);
      if (end != -1)
      {
        linecount++;

/* none of the styles use the number of line items
        if ((linecount == 1) && (style != "Detail"))  // Number of Line Items
        {
          tmp = cartvalues.substring(start,end);
          colon = tmp.indexOf(":", 0);
          if ((style == "ItemCount") || (style == "Subtotal"))
          {
            document.write("<a class=\"MiniCart\" href=\"http://www.bonsaiboy.com/cgi-bonsaiboy/sb/order.cgi?storeid=*1a442456109edc27016177cea94a95&function=show\">");
          }

          if (style == "Summary")
          {
            document.write("<br>Contains <b>");
          } 
          document.write(tmp.substring(colon+1,end - start));
          if (style == "Summary")
          {
            document.write("</b>");
          }
          if ((tmp.substring(colon+1,end - start)) == 1 )
          {
            document.write(" Item");
          }
          else
          {
            document.write(" Items");
          }
          if (style == "ItemCount")
          {
            document.write("</a>");
          } 
          else if (style == "Subtotal")
          {
            document.write(": ");
          } 
          else if (style == "Summary")
          {
            document.write("<br>Sub Total: <b>");
          }
        }
*/

        if ((linecount == 2) && (style != "Detail"))  // Total Quantity of Items
        {
          tmp = cartvalues.substring(start,end);
          colon = tmp.indexOf(":", 0);
          if ((style == "ItemCount") || (style == "Subtotal"))
          {
            document.write("<a href=\"http://www.bonsaiboy.com/cgi-bonsaiboy/sb/order.cgi?storeid=*1a442456109edc27016177cea94a95&function=show\">");
          }

          if (style == "Summary")
          {
            document.write("<br>Contains <b>");
          } 
          document.write(tmp.substring(colon+1,end - start));
          if (style == "Summary")
          {
            document.write("</b>");
          }
          if ((tmp.substring(colon+1,end - start)) == 1 )
          {
            document.write(" Item");
          }
          else
          {
            document.write(" Items");
          }
          if (style == "ItemCount")
          {
            document.write("</a>");
          } 
          else if (style == "Subtotal")
          {
            document.write(": ");
          } 
          else if (style == "Summary")
          {
            document.write("<br>Sub Total: <b>");
          }
        }




        if (linecount == 3)  // Product Subtotal
        {
          if ((style == "Subtotal") || (style == "Summary"))
          {
            tmp = cartvalues.substring(start,end);
            colon = tmp.indexOf(":", 0);
            document.write(tmp.substring(colon+1,end - start));
            if (style == "Summary") 
            {
              document.write("</b>");
            }
            else
            {
            document.write("</a>");
            }
          }
          else if (style == "Detail")
          {
            start1 = start;
            end1 = end;
            document.write("<tr><td><small>Qty</small></td>");
            document.write("<td><small>Product</small></td>");
            document.write("<td><small>Price</small></td></tr>\n");
          }
        }

        if ((linecount > 3) && (style == "Detail"))  // individual products
        {
          tmp = cartvalues.substring(start,end);
          colon = tmp.indexOf(":", 0);
          document.write("<tr>");
          document.write("<td><small>");
          document.write(tmp.substring(0,colon));
          document.write("</small></td><td><small>");
          colon2 = tmp.indexOf(":", colon+1);
          document.write(tmp.substring(colon2+1,end - start));
          document.write("</small></td><td><small>");
          document.write(tmp.substring(colon+1,colon2));
          document.write("</small></td></tr>\n");
        }
        start = end;
      }
      else
        break;
    } // end while loop

    //close minicart HTML
    if (style != "Detail")
    {
      document.write("</div>\n");
    }
    else
    {
      document.write("<tr>");
      document.write("<td colspan=\"2\"><small>Subtotal</small></td>");
      document.write("<td><small>");
      tmp = cartvalues.substring(start1,end1);
      colon = tmp.indexOf(":", 0);
      document.write(tmp.substring(colon+1,end1 - start1));
      document.write("</small></td>");
      document.write("</tr>");
      document.write("</table>\n");
      document.write("</div>\n");
    }
  }
}  




function getref() {
var expDays = 2; // days
var expDate = new Date();
expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
var thevar = "";
var id = GetCookie('id');
//if (id == null || id == "no id") 
if (location.search.length > 1) 
{

var temps1 = location.search.substring(1, location.search.length); 
if (temps1.indexOf ("SSAID") >= 0)
	{
 	var thetempvar = temps1.split("=")
 	id = "SAS-"+thetempvar[1]
	}

//else id = "none";



else {
	 
		if (temps1.indexOf ("PID") >= 0)
		{
		var btemp = temps1.split("&");
	  	 for (var i=0; i < btemp.length; i++)
   			{
 			
   			var ctemp = btemp[i].split("=");
   			if (ctemp[0] == "PID") 
      			id = "CJ-"+ctemp[1];
   			}
		}	

	}



if (id != GetCookie('id')) SetCookie('id', id, expDate, '/', 'bonsaiboy.com');
}

// document.idform.id.value = id;
if (id == null || id == "no id") return "";
else
{//document.write("<br><font size=1>Phone orders: mention this code:</font><font size=2 color=red>");

return id;

}
}


function getCookieVal (offset) {  
var endstr = document.cookie.indexOf (";", offset);  
if (endstr == -1)    
endstr = document.cookie.length;  
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
((path == null) ? "" : ("; path=" + path)) +  
((domain == null) ? "" : ("; domain=" + domain)) +    
((secure == true) ? "; secure" : "");
} 