/**** Mini Cart Detail Display ****/

/**** REPLACE THE VALUES IN THESE LINES ****/
var serialnum="0001126666";
var cartURL="http://www.mlcswoodworking.com/cgi-mlcswoodworking/sb/order.cgi?storeid=*105ba24ebb07a8c0eee4&function=show";
var textColor="black";
var backgroundColor="transparent";
var showCart="yes";       // only "yes" or "no"
var cartColor="black";    // only "black" or "white"
var textAlign="center";     // only "left" "right" or "center"

/**** DON'T CHANGE ANYTHING BELOW HERE ****/

var linkColor=textColor;
var cookies=document.cookie;  //read in all cookies
var start = cookies.indexOf("ss_cart_" + serialnum + "="); 
var cartvalues = "";
var linecount = 0;
var start1;
var end1;
var tmp;

// Start Output
document.write("<div style=\"color:" + textColor + ";");
document.write("background-color:" + backgroundColor + ";");
document.write("text-align:" + textAlign + ";");
document.write("font-family: Verdana, Arial, Helvetica, sans-serif;");
document.write("font-size: 8pt;");
document.write("\">\n");

document.write("<table>\n");
document.write("<tr>\n");
document.write("<th colspan=\"3\" align=\"center\">");

if (showCart == "yes")
{
  document.write("<a href=\"");
  document.write(cartURL + "\"");
  document.write(">");
  document.write("<img src=\"http://www.mlcswoodworking.com/shopsite_sc/store/html/media/themesmedia/cart-" + cartColor + ".gif\" border=\"0\" align=\"top\">");
  document.write("</a> ");
}

document.write("<a href=\"" + cartURL + "\" style=\"color:" + linkColor + "\">");
document.write("Your Shopping Cart--Click to View");
document.write("</a>");

document.write("</th></tr>");

if (start == -1)  //No cart cookie
{
  document.write("</table>\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++;

      if (linecount == 3)  // Product Subtotal
      {
        start1 = start;
        end1 = end;
        document.write("<tr><th style=\"text-decoration: underline;\">Qty</th>");
        document.write("<th align=\"center\" style=\"text-decoration: underline;\">Product</th>");
        document.write("<th align=\"center\" style=\"text-decoration: underline;\">Price</th></tr>\n");
      }

      if (linecount > 3)  // individual products
      {
        tmp = cartvalues.substring(start,end);
        colon = tmp.indexOf(":", 0);
        document.write("<tr>");
        document.write("<td>");
        document.write(tmp.substring(0,colon));
        document.write("</td><td>");
        colon2 = tmp.indexOf(":", colon+1);
        document.write(tmp.substring(colon2+1,end - start));
        document.write("</td><td align=\"right\">");
        document.write(tmp.substring(colon+1,colon2));
        document.write("</td></tr>\n");
      }

      start = end;
    }
    else
    {
      break;
    }
  } // end while loop

  //close minicart HTML
  document.write("<tr>");
  document.write("<td colspan=\"2\" align=\"right\" style=\"color:#006666;font-weight:bold; border:1px solid gray; background-color:#FFF;\">Subtotal</td>");
  document.write("<td align=\"right\" style=\"color:#006666;font-weight:bold; border:1px solid gray; background-color:#FFF;\">");
  tmp = cartvalues.substring(start1,end1);
  colon = tmp.indexOf(":", 0);
  document.write(tmp.substring(colon+1,end1 - start1));
  document.write("</td>");
  document.write("</tr>");
  document.write("</table>\n");
}
document.write("</div>\n");