// NebuCart - The JavaScript Shopping Cart
//
// Copyright 1999-2006 all rights reserved.

// None of this script may be redistributed or sold
// without the authors express consent.
// Violations of copyright will be prosecuted.

// If you would like to use NebuCart,
// email us at admin@javascriptcart.com
// or visit http://www.javascriptcart.com

// ********************************************
// NebuCart Engine                           *
// ********************************************
// DO NOT CHANGE ANYTHING BELOW THIS LINE!    *
// ********************************************

var Cart         = new Array();
var tmpArray     = new Array();
var shopperArray = new Array();
var shipeeArray  = new Array();
var shipDesc     = '';
var cardDesc     = '';
var cardName     = '';
var cardNo       = '';
var cardMonth    = '';
var cardYear     = '';
var postAction   = '';
var orderID      = '';
var delim        = '|';
var taxRate      = 0;
var cartVersion  = 2.5;

function CartItem(RECREATE, prodID, qty, desc, price, opt, limit){
 if(RECREATE){
  this.prodID = prodID;
  this.qty    = qty;
  this.price  = price;
  this.desc   = desc;
  this.limit  = limit;
  this.opt    = opt;
 } else {
  this.prodID = prodID;
  this.qty    = qty;
  this.price  = getValue(prodID,'price');
  this.desc   = getValue(prodID,'desc');
  this.limit  = getValue(prodID,'limit');
  this.opt    = getOptions(prodID,'opt');
  tmpXtra     = getOptionCosts(prodID,'opt');
  if(tmpXtra != 0){
   this.price = Number(this.price) + Number(tmpXtra);
  }
 }
}
function AddItem(ItemNo){
 var madeChange    = false;
 var alreadyExists = false;
 var newItem       = false;
 var verb          = 'has';
 var Qty           = getValue(ItemNo,'');
 if(!Number(Qty) || Qty.indexOf('.') != -1){
  alert('Please enter a whole\nnumerical value for item quantity.');
  clear(ItemNo);
  focus(ItemNo);
 } else {
  Qty = parseInt(Qty);
  if(Cart.length > 0){
   for(i=0; i < Cart.length; i++){
    if(Cart[i].prodID == ItemNo){

     var newOption = getOptions(ItemNo,'opt');
     if(newOption != Cart[i].opt){
      madeChange = false;
      alreadyExists = false;
     } else if(Cart[i].qty != Qty){
      ChangeQty(i,Qty);
      madeChange = true;
      alreadyExists = true;
      break;
     } else {
      alreadyExists = true;
      alert('Item ' + Cart[i].prodID + ', (' + Cart[i].desc + ')\nalready exists in your cart.');
      break;
     }
    }
   }
   if(!madeChange && !alreadyExists){
    newItem = true;
   }
  } else {
   newItem = true;
  }
  if(newItem){
   Cart[Cart.length] = new CartItem(false,ItemNo,Qty);
   if(Qty > Number(Cart[Cart.length - 1].limit) && Cart[Cart.length - 1].limit != ''){
    alert('You may only order up to ' + Cart[Cart.length - 1].limit + ' of\n' + Cart[Cart.length - 1].desc + ' per order.\nQuantity will be changed to limit.');
    ChangeQty(Cart.length - 1,Cart[Cart.length - 1].limit);
   }
   if(supressCart){
    alert('Item ' + Cart[Cart.length - 1].prodID + ', (' + Cart[Cart.length - 1].desc + ')\nhas been added to your cart.');
    cartToCookie();
   } else {
    displayCart();
   }
  }
 }
}
function UpdateItems(numItems){
 for(itmC = 0; itmC < numItems; itmC++){
  oldQty = Cart[itmC].qty;
  newQty = getValue(Cart[itmC].prodID,String(itmC));
  if(newQty <= 0 || String(newQty).trim() == '' || !Number(newQty)){
   Cart[itmC].qty = 0;
  } else if(newQty != oldQty){
   if(Cart[itmC].limit == '' || newQty <= Cart[itmC].limit){
    Cart[itmC].qty = parseInt(newQty);
   } else {
    Cart[itmC].qty = Cart[itmC].limit;
   }
  }
 }
 DeleteItems();
}
function DeleteItems(){
 var deletedItem;
 for(i=0; i < Cart.length; i++){
  if(Cart[i].qty > 0){
   tmpArray[tmpArray.length] = Cart[i];
  }
 }
  Cart = new Array();
 for(i=0; i < tmpArray.length; i++){
  Cart[i] = tmpArray[i];
 }
 tmpArray = new Array();
 if(supressCart && String(location).indexOf(cartPage) == -1){
  cartToCookie();
 } else {
  displayCart();
 }
}
function ChangeQty(arrayNum, newQty){
 var OK = false;
 var underLimit = true;
 if(newQty > Number(Cart[arrayNum].limit) && Cart[arrayNum].limit != ''){
  alert('You may not order more than ' + Cart[arrayNum].limit + '\nof these during a session.\nYour quantity will be changed\nto the maximum amount.');
  Cart[arrayNum].qty = Cart[arrayNum].limit;
 } else {
  Cart[arrayNum].qty = newQty;
 }

 if(supressCart && String(location).indexOf(cartPage) == -1){
  cartToCookie();
  alert('Item ' + Cart[arrayNum].prodID + ', (' + Cart[arrayNum].desc + ')\nhas been updated in your cart.');
 } else {
  displayCart();
 }
}
function getOptions(itemID, valType){
 var retStr = '';
 retStr     = getValue(itemID, valType);
 for(optCount = 0; optCount < 20; optCount ++){
  optName = valType + String(optCount + 1);
  tmpStr  = getValue(itemID, optName);
  if(tmpStr != ''){
   if(retStr == ''){
    retStr = tmpStr;
   } else {
    retStr += ', ' + tmpStr;
   }
  }
 }
 allOpt = retStr.split(',');
 retStr = '';
 for(optCount = 0; optCount < allOpt.length; optCount ++){
  tmpStr = allOpt[optCount].split(delim);
  if(retStr == ''){
   retStr = tmpStr[0];
  } else {
   retStr += ', ' + tmpStr[0];
  }
 }
 return retStr;
}
function getOptionCosts(itemID,valType){
 var retStr = '';
 retStr     = getValue(itemID, valType);
 for(optCount = 0; optCount < 20; optCount ++){
  optName = valType + String(optCount + 1);
  tmpStr  = getValue(itemID, optName);
  if(tmpStr != ''){
   if(retStr == ''){
    retStr = tmpStr;
   } else {
    retStr += ', ' + tmpStr;
   }
  }
 }
 allOpt = retStr.split(',');
 retStr = '';
 for(optCount = 0; optCount < allOpt.length; optCount ++){
  tmpStr = allOpt[optCount].split(delim);
  if(retStr == ''){
   retStr  = (tmpStr[1]) ? Number(tmpStr[1]) : 0;
  } else {
   retStr += (tmpStr[1]) ? Number(tmpStr[1]) : 0;
  }
 }
 return retStr;
}
function DeleteCart(){
 if(confirm('Are you sure you want\nto clear the entire Shopping Cart?')){
  Cart = new Array();
  displayCart();
 }
}
function displayCart(){
 cartToCookie();
 document.location = cartPage;
}
function getShipDetails(){
 var shipSel     = document.NC_form.ship_option;
 var shipDetails = shipSel.options[shipSel.selectedIndex].value;
 shipDetails     = shipDetails.split(delim);
 shipDesc        = shipDetails[0];
 shipAmt         = shipDetails[1];
 shipPerItem     = shipDetails[2];
}
function getSelectedRadio(radioGroup){
 for(i = 0; i < radioGroup.length; i ++){
  if(radioGroup[i].checked){
   return i;
  }
 }
 return 0;
}
function fillShopperForm(){
 shopperArray = getCookieVal(myStoreName + '_b');
 if(shopperArray == null || shopperArray == ''){
   shopperArray = new Array();
 }
 shipeeArray = getCookieVal(myStoreName + '_r');
 if(shipeeArray == null || shipeeArray == ''){
   shipeeArray = new Array();
 }
 if(shopperArray.length > 0){
  if(shopperArray[0] != ''){
   document.NC_form.fname.value = shopperArray[0];
  }
  if(shopperArray[1] != ''){
   document.NC_form.lname.value = shopperArray[1];
  }
  if(shopperArray[2] != ''){
   document.NC_form.email.value = shopperArray[2];
  }
  if(shopperArray[3] != ''){
   document.NC_form.add1.value = shopperArray[3];
  }
  if(shopperArray[4] != ''){
   document.NC_form.add2.value = shopperArray[4];
  }
  if(shopperArray[5] != ''){
   document.NC_form.city.value = shopperArray[5];
  }
  if(shopperArray[6] != ''){ setupStateSel('state',shopperArray[6]); }
  if(shopperArray[7] != ''){
   document.NC_form.zip.value = shopperArray[7];
  }

  if(shopperArray[8] != ''){ setupCountrySel('country',shopperArray[8]); }
  if(shopperArray[9] != ''){
   document.NC_form.phone.value = shopperArray[9];
  }
 }
 if(shipeeArray.length > 0 && shipeeArray[0] != ''){
  document.NC_form.diffShip.checked = true;
  if(shipeeArray[0] != ''){
   document.NC_form.Sfname.value = shipeeArray[0];
  }
  if(shipeeArray[1] != ''){
   document.NC_form.Slname.value = shipeeArray[1];
  }
  if(shipeeArray[2] != ''){
   document.NC_form.Semail.value = shipeeArray[2];
  }
  if(shipeeArray[3] != ''){
   document.NC_form.Sadd1.value = shipeeArray[3];
  }
  if(shipeeArray[4] != ''){
   document.NC_form.Sadd2.value = shipeeArray[4];
  }
  if(shipeeArray[5] != ''){
   document.NC_form.Scity.value = shipeeArray[5];
  }
  if(shipeeArray[6] != ''){ setupStateSel('Sstate',shipeeArray[6]); }
  if(shipeeArray[7] != ''){
   document.NC_form.Szip.value = shipeeArray[7];
  }
  if(shopperArray[8] != ''){ setupCountrySel('Scountry',shipeeArray[8]); }
 }
 if(useDiscount && !discountByQty && discountArray.length > 0){
  document.NC_form.Discount.value = getCookieVal(myStoreName + '_d');
 }
}
function Validate(orderOption, secureWin){
if (Cart.length == 0) return alert(cartEmptyText)
 var AllOk       = true;
 var tmpPhone    = '';
 var phoneChar   = new Array('-','(',')',' ','.');
 var goodChar    = true;
 shopperArray[0] = getValue('fname','');
 shopperArray[1] = getValue('lname','');
 shopperArray[2] = getValue('email','');
 shopperArray[3] = getValue('add1','');
 shopperArray[4] = getValue('add2','');
 shopperArray[5] = getValue('city','');
 shopperArray[6] = getValue('state','');
 shopperArray[7] = getValue('zip','');
 shopperArray[8] = getValue('country','');
 shopperArray[9] = getValue('phone','');
 if(shopperArray[6].indexOf('-- Select') != -1){
  shopperArray[6] = '';
 }
 for(w = 0; w < shopperArray.length; w++){
  shopperArray[w] = shopperArray[w].trim();
 }
 if(getAltShipping){
  if(getValue('Sfname','') != '' &&
     getValue('Slname','') != '' &&
     getValue('Semail','') != '' &&
     getValue('Sadd1','')  != '' &&
     getValue('Scity','')  != '' &&
     getValue('Sstate','') != '' &&
     getValue('Szip','')   != ''){
     document.NC_form.diffShip.checked = true;
  }
  if(document.NC_form.diffShip.checked){
   shipeeArray[0] = getValue('Sfname','');
   shipeeArray[1] = getValue('Slname','');
   shipeeArray[2] = getValue('Semail','');
   shipeeArray[3] = getValue('Sadd1','');
   shipeeArray[4] = getValue('Sadd2','');
   shipeeArray[5] = getValue('Scity','');
   shipeeArray[6] = getValue('Sstate','');
   shipeeArray[7] = getValue('Szip','');
   shipeeArray[8] = getValue('Scountry','');
   if(shipeeArray[6].indexOf('-- Select') != -1){
    shipeeArray[6] = '';
   }
   for(w = 0; w < shipeeArray.length; w++){
    shipeeArray[w] = shipeeArray[w].trim();
   }
  } else {
   shippeeArray = new Array();
   killCookie(myStoreName + '_r');
  }
 } else {
   shippeeArray = new Array();
   killCookie(myStoreName + '_r');
 }
 if(shopperArray[0] == '' && AllOk){
  alert('Please fill out the "First Name" field');
  focus('fname');
  AllOk = false;
 }
 if(shopperArray[1] == '' && AllOk){
  alert('Please fill out the "Last Name" field');
  focus('lname');
  AllOk = false;
 }
 if(AllOk){
  if(shopperArray[2] == ''){
   alert('Please fill out the "Email" field');
   focus('email');
   AllOk = false;
  } else {
   if(shopperArray[2].indexOf('@') == -1){
    alert('Please enter a valid Email address.');
    focus('email');
    AllOk = false;
   }
  }
 }
 if(shopperArray[3] == '' && AllOk){
  alert('Please fill out the "Address" field');
  focus('add1');
  AllOk = false;
 }
 if(shopperArray[5] == '' && AllOk){
  alert('Please fill out the "City" field');
  focus('city');
  AllOk = false;
 }
 if(shopperArray[8].toLowerCase() == 'us' ||
    shopperArray[8].toLowerCase() == 'ca'){
  if(shopperArray[6] == '' && AllOk){
   alert('Please fill out the "State/Provice" field');
   focus('state');
   AllOk = false;
  }
  if(shopperArray[7] == '' && AllOk){
   alert('Please fill out the "Postal Code" field');
   focus('zip');
   AllOk = false;
  }
 }
 if(shopperArray[8] == '' && AllOk){
  alert('Please select your country.');
  focus('country');
  AllOk = false;
 }
 if(shopperArray[9] == '' && AllOk){
  if(shopperArray[9] == ''){
   alert('Please fill out the "Phone Number" field');
   focus('phone');
   AllOk = false;
  } else {
   for(i = 0; i < shoppArray[9].length; i ++){
    for(j = 0; j < phoneChar.length; j ++){
     if(shopperArray[9].charAt(i) != phoneChar[j]){
      goodChar = true;
     } else {
      goodChar = false;
     }
    }
    if(goodChar){
     tmpPhone = tmpPhone + shopperArray[9].charAt(i);
    }
   }
   if(!Number(tmpPhone)){
    alert('Please enter a valid Phone number');
    focus('phone');
    allOk = false;
   }
  }
 }
 if(getAltShipping){
  if(document.NC_form.diffShip.checked){
   if(shipeeArray[0] == '' && AllOk){
    alert('Please fill out the "Shipping First Name" field');
    focus('Sfname');
    AllOk = false;
   }
   if(shipeeArray[1] == '' && AllOk){
    alert('Please fill out the "Shipping Last Name" field');
    focus('Slname');
    AllOk = false;
   }
   if(shipeeArray[2] == '' && AllOk){
    alert('Please fill out the "Shipping Email" field');
    focus('Semail');
    AllOk = false;
   }
   if(shipeeArray[3] == '' && AllOk){
    alert('Please fill out the "Shipping Address" field');
    focus('Sadd1');
    AllOk = false;
   }
   if(shipeeArray[5] == '' && AllOk){
    alert('Please fill out the "Shipping City" field');
    focus('Scity');
    AllOk = false;
   }
   if(shipeeArray[8].toLowerCase() == 'us' ||
      shipeeArray[8].toLowerCase() == 'ca'){
    if((shipeeArray[6] == '' || shipeeArray[6].indexOf('-- Select') != -1) && AllOk){
     alert('Please fill out the "Shipping State/Province" field');
     focus('Sstate');
     AllOk = false;
    }
    if(shipeeArray[7] == '' && AllOk){
     alert('Please fill out the "Shipping Postal Code" field');
     focus('Szip');
     AllOk = false;
    }
   }
   if((shipeeArray[8] == '' || shipeeArray[8].indexOf('-- Select') != -1) && AllOk){
    alert('Please select your shipping country.');
    focus('Scountry');
    AllOk = false;
   }
  }
 }
 if(AllOk){
  setCookie(myStoreName + '_b',shopperArray.join(delim),eval(customerTime),cookiePath,unsecureDomain);
  if(shipeeArray.length > 0){
   setCookie(myStoreName + '_r',shipeeArray.join(delim),null,cookiePath,unsecureDomain);
  }
  if(useDiscount && !discountByQty && discountArray.length > 0){
   setCookie(myStoreName + '_d',document.NC_form.Discount.value,null,cookiePath,unsecureDomain);
  }
  routeToPayment(orderOption, secureWin);
 }
}
function calcDiscount(){
 if(useDiscount && discountArray.length > 0){
  if(discountByQty){
   for(dCount = 0; dCount < discountArray.length; dCount++){
    tmpA = discountArray[dCount].split(delim);
    if(totalQty >= tmpA[0] && totalQty <= tmpA[1]){
     return (totalCost * tmpA[2]);
    }
   }
  } else {
   discountCode = getCookieVal(myStoreName + '_d');
   for(dCount = 0; dCount < discountArray.length; dCount++){
    tmpA = discountArray[dCount].split(delim);
    if(discountCode.toLowerCase() == tmpA[0].toLowerCase()){
     return (totalCost * tmpA[1]);
    }
   }
  }
 }
 return 0;
}
function calcTax(){
 var t          = 0;
 var tmpCost    = (taxShipping && Number(SnH)) ? (totalCost + Number(SnH)) : totalCost;
 var taxAddress = new Array();
 if(taxOnShipAddress && shipeeArray.length > 0){
  taxAddress = shipeeArray;
 } else {
  taxAddress = shopperArray;
 }

 if(alwaysTax){
  t = taxRateArray[0] * tmpCost;
  taxRate = taxRateArray[0];
 } else if(taxOnState && taxAddress.length > 0){
  for(tCount = 0; tCount < taxStateArray.length; tCount ++){
   if (taxAddress[6].toLowerCase() == taxStateArray[tCount].toLowerCase()){
    if(taxRateArray[tCount]){
     t = taxRateArray[tCount] * tmpCost;
     taxRate = taxRateArray[tCount];
    } else if(taxRateArray[0]){
     t = taxRateArray[0] * tmpCost;
     taxRate = taxRateArray[0];
    }
    break;
   }
  }
 } else if(taxOnZipCode && taxAddress.length > 0){
  for(tCount = 0; tCount < taxZipCodeArray.length; tCount ++){
   if (taxAddress[7].toLowerCase() == taxZipCodeArray[tCount].toLowerCase()){
    if(taxRateArray[tCount]){
     t = taxRateArray[tCount] * tmpCost;
     taxRate = taxRateArray[tCount];
    } else if(taxRateArray[0]){
     t = taxRateArray[0] * tmpCost;
     taxRate = taxRateArray[0];
    }
    break;
   }
  }
 } else if(taxOnCountry && taxAddress.length > 0){
  for(tCount = 0; tCount < taxCountryArray.length; tCount ++){//Bug: Changed taxStateArray to taxCountryArray
   if (taxAddress[8].toLowerCase() == taxCountryArray[tCount].toLowerCase()){
    if(taxRateArray[tCount]){
     t = taxRateArray[tCount] * tmpCost;
     taxRate = taxRateArray[tCount];
    } else if(taxRateArray[0]){
     t = taxRateArray[0] * tmpCost;
     taxRate = taxRateArray[0];
    }
    break;
   }
  }
 }
 return t;
}
function calcShipping(){
 if(!shipPercent && !shipPerItem && !useShipRules && !useShipOptions){
  return shipAmt;
 }
 if(!shipPercent && shipPerItem && !useShipRules && !useShipOptions){
  return (shipAmt * totalQty);
 }
 if(shipPercent && !shipPerItem && !useShipRules && !useShipOptions){
  return (shipAmt * totalCost);
 }
 if(!useShipRules && useShipOptions){
   if(shipPerItem){
     return (shipAmt * totalQty);
   } else {
     return shipAmt;
   }
 }
 if(useShipRules && !useShipOptions){
  return getShipRule(totalCost,totalQty);
 }
 return 0;
}
function buildOrderID(){
 tmpDate  = new Date();
 orderID  = String(tmpDate.getFullYear());
 orderID += ((tmpDate.getMonth() + 1) < 10)? '0' + (tmpDate.getMonth() + 1) : (tmpDate.getMonth() + 1);
 orderID += (tmpDate.getDate()        < 10)? '0' + tmpDate.getDate()        : tmpDate.getDate();
 orderID += (tmpDate.getHours()       < 10)? '0' + tmpDate.getHours()       : tmpDate.getHours();
 orderID += (tmpDate.getMinutes()     < 10)? '0' + tmpDate.getMinutes()     : tmpDate.getMinutes();
 orderID += (tmpDate.getSeconds()     < 10)? '0' + tmpDate.getSeconds()     : tmpDate.getSeconds();
 orderID += shopperArray[0].charAt(0).toUpperCase();
 orderID += shopperArray[1].charAt(0).toUpperCase();
 return orderID;
}
function routeToPayment(orderOption, secureWin){
 var s = '';
 if(useShipOptions){
  getShipDetails();
 }
 killCookie(myStoreName + '_sd');
 killCookie(myStoreName + '_sa');
 killCookie(myStoreName + '_sp');
 setCookie(myStoreName  + '_sd',shipDesc   ,eval(cartTime),cookiePath,unsecureDomain);
 setCookie(myStoreName  + '_sa',shipAmt    ,eval(cartTime),cookiePath,unsecureDomain);
 setCookie(myStoreName  + '_sp',shipPerItem,eval(cartTime),cookiePath,unsecureDomain);
 if(orderOption == '' || orderOption == null){
  document.location = COprintVerify;
 } else {
  if(secureWin && securePath != ''){
   if(securePath.charAt(securePath.length-1) != '/'){
    securePath += '/';
   }
   var securePost;
   var prodID = new Array();
   var qty    = new Array();
   var price  = new Array();
   var desc   = new Array();
   var opt    = new Array();
   var limit  = new Array();
   for(i = 0; i < Cart.length; i ++){
    prodID[i] = Cart[i].prodID;
    qty[i]    = Cart[i].qty;
    price[i]  = Cart[i].price;
    desc[i]   = Cart[i].desc;
    opt[i]    = Cart[i].opt;
    limit[i]  = Cart[i].limit;
   }
   securePost  =  securePath + orderOption + '?';
   s +=  'NC_A=' + shopperArray.join(delim);
   s += '&NC_B=' + shipeeArray.join(delim);
   s += '&NC_C=' + shipDesc;
   s += '&NC_D=' + shipAmt;
   s += '&NC_E=' + shipPerItem;
   s += '&NC_F=' + shipPercent;
   s += '&NC_G=' + useShipOptions;
   s += '&NC_H=' + useShipRules;
   s += '&NC_J=' + prodID.join(delim);
   s += '&NC_K=' + qty.join(delim);
   s += '&NC_L=' + price.join(delim);
   s += '&NC_M=' + opt.join(delim);
   s += '&NC_N=' + desc.join(delim);
   s += '&NC_O=' + limit.join(delim);
   s += '&NC_P=' + getCookieVal(myStoreName + '_d');
   s  = encrypt(s);
   securePost += s;
   if(secureBreakFrames){
    window.location = securePost;
   } else {
    parent.document.location = securePost;
   }
  } else {
   document.location = orderOption;
  }
 }
}
function cartToCookie(){
 for (cc = 0; cc < 10000; cc++){
  cookieVal = getCookieVal(myStoreName + '_i' + cc);
  if(cookieVal != '' && cookieVal != null){
   killCookie(myStoreName + '_i' + cc);
  } else {
   break;
  }
 }
 if(Cart.length > 0){
  for(cc = 0; cc < Cart.length; cc++){
   itemContents  = '';
   itemContents += Cart[cc].prodID + delim;
   itemContents += Cart[cc].qty    + delim;
   itemContents += Cart[cc].desc   + delim;
   itemContents += Cart[cc].price  + delim;
   itemContents += Cart[cc].opt    + delim;
   itemContents += Cart[cc].limit  + delim;
   setCookie(myStoreName + '_i' + cc,itemContents,eval(cartTime),cookiePath,unsecureDomain);
  }
 }
}
function cookieToCart(){
 shopperArray = getCookieVal(myStoreName + '_b');
 if(shopperArray == null || shopperArray == ''){
   shopperArray = new Array();
 }
 shipeeArray = getCookieVal(myStoreName + '_r');
 if(shipeeArray == null || shipeeArray == ''){
   shipeeArray = new Array();
 }
 shipDesc = getCookieVal(myStoreName + '_sd');
 tmpShipAmt = getCookieVal(myStoreName + '_sa');
 if(tmpShipAmt != null && tmpShipAmt != ''){
  shipAmt = tmpShipAmt;
 }
 tmpShipPerItem = getCookieVal(myStoreName + '_sp');
 if(tmpShipPerItem != null && tmpShipPerItem != ''){
  tmpShipPerItem = (tmpShipPerItem == 'true') ? true : false;
  shipPerItem    = tmpShipPerItem;
 }
 if(shipPercent || useShipRules){
  shipPerItem = false;
 }
 for (cc = 0; cc < 10000; cc++){
  cookieVal = getCookieVal(myStoreName + '_i' + cc);
  if(cookieVal != '' && cookieVal != null){
   itemVal  = getCookieVal(myStoreName + '_i' + cc);
   Cart[cc] = new CartItem(true,itemVal[0],itemVal[1],itemVal[2],itemVal[3],itemVal[4],itemVal[5]);
  } else {
   break;
  }
 }
}
function PreAddItem(ItemNo,SubFld,DefV,Msg){
 ID = String(ItemNo + SubFld);
 fldVal = getValue(ID,'');
 if(fldVal != DefV){
  AddItem(ItemNo);
 } else {
  alert(Msg);
 }
}