var serialnum="0001000192";  

// displays the shopping cart and the number of items and total cost 
// information is stored in a cookie, so this will display 0 items if cookies are not enabled
// strCartItemsDiv is the id of the <div> to contain the text for the number of items:price in cart
// strShoppingCartDiv is the id of the <div> to contain the shopping cart image
function setup_shopping_cart_link(strCartItemsDiv, strShoppingCartDiv)
{
	/**** Mini Cart Subtotal Display ****/
	
	/**** REPLACE THE VALUES IN THESE LINES ****/
	var cartURL="http://www.homesew.com/sc/order.cgi?storeid=*1478cf4c8b2d40a706f4e797&function=show";
	var showCart = true;       // only true or false
	var linkColor = "#000000";  //color for link
	
	/**** DON'T CHANGE ANYTHING BELOW HERE ****/
	var cookies=document.cookie;  //read in all cookies
	var start = cookies.indexOf("ss_cart_" + serialnum + "="); 
	var cartvalues = "";
	var linecount = 0;
	var tmp;

	if (showCart == true)
	{
		document.getElementById(strShoppingCartDiv).innerHTML = "<a href='" + cartURL + "'>"
			+ "<img src='/images/about/sh_cart.jpg' id='imgShoppingCart' width='38' height='26' border='0'></a>";
	}
	
    var strCartItems = "";

	if (start == -1)  //No cart cookie
	{
		strCartItems = "<a href='" + cartURL + "' style='color:" + linkColor + ";'>0 Items</a>";
	}
	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 == 2) // Total Quantity of Items
		  {
			tmp = cartvalues.substring(start,end);
			colon = tmp.indexOf(":", 0);
			strCartItems = "<a href='" + cartURL + "'>" + tmp.substring(colon+1,end - start) + " Item"; 
			if ((tmp.substring(colon+1,end - start)) > 1 )
			{
				strCartItems += "s";
			}
			strCartItems += ": ";
		  }
	
		  if (linecount == 3)  // Product Subtotal
		  {
			tmp = cartvalues.substring(start,end);
			colon = tmp.indexOf(":", 0);
			strCartItems += tmp.substring(colon+1,end - start) + "</a>";
		  }
	
		  start = end;
		}
		else
		  break;
		}
	  } // end while loop
	
	  document.getElementById(strCartItemsDiv).innerHTML = strCartItems;
}


//  displays sign in/register or edit account/sign out depending on if the user is logged in or not
//  strSignInSpan is the id of the <span> to contain the sign in or edit account text
//  strRegisterSpan is the id of the <div> to contain the register or sign out text
function DisplayLogName(strSignInSpan, strRegisterDiv) {
  var cookies=document.cookie;
  var start = cookies.indexOf("ss_reg_" + serialnum + "=");
  var name = "";
  var tmp;
  var signed_in = -1;
  var strSignInText = "";
  var strRegisterText = "";

  if (start != -1) {
    start = cookies.indexOf("=", start) +1;
    var end = cookies.indexOf("|", start);
    if (end != -1) {
      signed_in = cookies.indexOf("|yes", start);
      name = unescape(cookies.substring(start,end-1));
	  if (signed_in != -1)
	  {
		  strSignInText = "<a href='http://www.homesew.com/sc/order.cgi?func=3&storeid=*167fafd8c5399067072eb64f0a&html_reg=html'>View Account</a>";
		  strRegisterText = "<a href='http://www.homesew.com/sc/order.cgi?func=4&storeid=*167fafd8c5399067072eb64f0a&html_reg=html'>Sign Out</a>";
	  }
    }
  }
  if (signed_in == -1) {
	  strSignInText = "<a href='http://www.homesew.com/sc/order.cgi?func=2&storeid=*167fafd8c5399067072eb64f0a&html_reg=html'>Sign In</a>";
	  strRegisterText = "<a href='http://www.homesew.com/sc/order.cgi?func=1&storeid=*167fafd8c5399067072eb64f0a&html_reg=html'>Register</a>";
  }
  document.getElementById(strSignInSpan).innerHTML = strSignInText;
  document.getElementById(strRegisterDiv).innerHTML = strRegisterText;
}

