function addCustom(Sku, Qty, Desc, Price){

  if(arguments.length > 4)
  {
     Sku = Sku + "-";
     for(i = 4; i < arguments.length-1; i++)
     {
          if(arguments[i].selectedIndex == 0)
          {
            alert("You must select required product option(s) before placing item in shopping cart!");
            return;
          }
          else if(arguments[arguments.length-1].value == "")
          {
               if(!confirm("Press \"OK\" if you are sure that you do NOT want to add a custom message?"))
               	return;
          }
          
          Sku = Sku + "f" + arguments[i].selectedIndex;
     }
     for(i = 4; i < arguments.length-1; i++) arguments[i].selectedIndex = 0;
  }

  Add(Sku, Qty, Desc, Price, arguments[arguments.length-1].value);
}

function addOptions(Sku, Qty, Desc, Price){

  if(arguments.length > 4){
  
     //Sku = Sku + "-";
     for(i = 4; i < arguments.length; i++){

         if(arguments[i].selectedIndex == 0){
            alert("You must select required product option(s) before placing item in shopping cart!");
            return;
         }
         else{
           if(Sku.length > 0) Sku = Sku + "-";
           Sku = Sku + arguments[i][arguments[i].selectedIndex].value;
         }
     }
     for(i = 4; i < arguments.length; i++) arguments[i].selectedIndex = 0;
  }
  Add(Sku, Qty, Desc, Price);
}

function Add(Sku,Qty,Name,Price){

  var offset;
  var endstr;
  var Order;
  var CurrQty;
  var CookieData;
  var AllCookies = "";

  CookieData = new String(unescape(document.cookie));
  AllCookies = CookieData.split(";");

  if(AllCookies[0].indexOf("Order=Empty", 0) != -1) AllCookies[0] = "";
  else if(AllCookies[0].indexOf("Order=", 0) != -1) AllCookies[0] = AllCookies[0].substring(AllCookies[0].indexOf("=", 0)+1, AllCookies[0].length);

  if(AllCookies[1]){
     if(AllCookies[1].indexOf("Custom=Empty", 0) != -1) AllCookies[1] = "";
     else if(AllCookies[1].indexOf("Custom=", 0) != -1) AllCookies[1] = AllCookies[1].substring(AllCookies[1].indexOf("=", 0)+1, AllCookies[1].length);
  }
  else AllCookies[1] = "";

  offset = AllCookies[0].indexOf(Sku, 0);

  if(offset == -1){
     document.cookie = "Order=" + escape(AllCookies[0] + Sku + "~" + Qty + "~" + Name + "~" + Price + "|");
     if(arguments.length > 4) document.cookie = "Custom=" + escape(AllCookies[1] + Sku + "~" + arguments[4] + "|");
     else if(AllCookies[1] == "") document.cookie = "Custom=Empty";
  }
  else{
     offset = AllCookies[0].indexOf(Sku, 0);
     endstr = AllCookies[0].indexOf("~", offset) + 1;
     Order = AllCookies[0].substring(0, endstr);
     offset = endstr;
     endstr = AllCookies[0].indexOf("~", offset);
     CurrQty = AllCookies[0].substring(offset, endstr);
     offset = endstr;
     CurrQty = parseInt(CurrQty) + Qty;
     document.cookie = "Order=" + escape(Order + CurrQty + AllCookies[0].substring(offset, AllCookies[0].length));
  }

  if(document.cookie == "")
     alert("You have cookies disabled in your browser, to use this shopping cart you must be able to accept cookies.\nIf you prefer you can fax or email your order. (WARNING: Do not include credit card information in an email,\nwe will contact you to complete your order)");
  else
     document.location="showcart.html"
}