<!--
item_ID="00212";
item_Name="AT%26T%20Globalyst%20Series";
item_Description=" ";
item_SKU="CB1220-2.4HG";
item_Promo="0";
item_Price="172.70";
item_Unit="";
item_Taxable="3";
item_Shipping="0.00%200.00%200.00%200.00%200%200"
item_Weight="480";
item_Model="CB1220-2.4HG";
//VARIABLES FOR GLOBAL USE
no_of_order_pages = 200; //the number of possible product pages selected for ordering  
//====== Cookie functions =================================
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return 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;
}
//-------- Array function compatible with NS 2.0x, 3.0x and MSIE
function makeArray(n) 
{
   this.length = n;
   for (var i = 1; i <= n; i++)
   { 
     this[i] = 0;
   }
   return this;
}
function addtoCookieArray(cookieName, info)
{
    var tmpString=GetCookie(cookieName);
    if(GetCookie(cookieName) !=null)
    {
      tmpString = GetCookie(cookieName) + info + ":";
      //append to the current cookie values
      document.cookie = cookieName + "=" + tmpString;
    }
    else
    {
      tmpString = info + ":";
      document.cookie = cookieName + "=" + tmpString;
// alert("cookieNo:"+cookieName + "=" + tmpString);
    }
}
/* this defines an array for holding the user configuration
cookie contents when parsed out. Increase the count if you need to store more
but do not forget that the limitation is 4096 bytes */
// this parses the info stored in the config cookie into the array
function parseIt(cookieName, array) 
{
 config=GetCookie(cookieName);
 config+="";           // make it a string if it was not before
 var y = 1;
while(config.indexOf(":") >= 0) 
 {
   var pos = config.indexOf(":");
   if (pos==0)
     array[y]="";
   else
     array[y]=unescape(config.substring(0,pos));
   y++;
   config=config.substring(pos+1,config.length);
 }
 return y-1;
}
// return -1 if total # of elements in array exceed max limit
// return 0 if element is not found in the array
// return array index if element is found in the array
function posInArray(cookieName, element)
{
 var tmp_array = new makeArray(no_of_order_pages);
 total_count=parseIt(cookieName, tmp_array);

 if (total_count >= no_of_order_pages)
   return -1;

 for (i=1; i<=total_count; i++)
 {
  if (tmp_array[i]==element)
   return i;
 }
 return 0;
}
// This modifies the value of the n-th element in the array stored in cookie.
// For integer arrays, it will perform addition to existing value.
// For string arrays, it will perform concatenation.
function addValueInArray(cookieName, index, element)
{
 var tmp_array = new makeArray(no_of_order_pages);
 total_count=parseIt(cookieName, tmp_array);
 tmp_array[index] = eval(tmp_array[index]) + eval(element);
 tmp_array[index] = RoundQty( tmp_array[index] );
 if (tmp_array[index] > 9999.99) return 0;
 // remove existing cookie
 document.cookie = cookieName + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
 // convert from array to cookie
 for (i=1; i<=total_count; i++)
     addtoCookieArray(cookieName, tmp_array[i]);
 return tmp_array[index];
}
// check if input is an integer and it is greater than 0
function isInt(elm)
{
    var elmstr = "" + elm;
    if (elmstr == "")
        return false;
    for (var i = 0; i < elmstr.length; i++)
    {
        if (elmstr.charAt(i) < "0" || elmstr.charAt(i) > "9")
            { return false; }
    }
    return true;
}
function RoundQty(elm)
{
    var elmstr = "" + elm;
    if (elmstr == "")
        return 0;
    DotExist=0;
    DigitAfterDecimal=0;
    for (var i = 0; i < elmstr.length; i++)
    {
        if (elmstr.charAt(i) < "0" || elmstr.charAt(i) > "9") { 
            if ((elmstr.charAt(i) == ".")&&(DotExist == 0))
                DotExist = 1;
            else
                return 0; 
        }
        else if (DotExist == 1){
            if (DigitAfterDecimal < 2)
                DigitAfterDecimal = DigitAfterDecimal + 1 ;
            else {
                if (elmstr.charAt(i)>="5"){
     var sTmp100 = elmstr.substring(0, i-3) + elmstr.substring(i-2, i);
     nTmp = Number( sTmp100 ) ;
     nTmp = nTmp + 1;
           var sTmp = "" + nTmp;
     if (sTmp.length < 2)
   sTmp = sTmp.substring(0, sTmp.length - 2) + ".0" + sTmp.substring(sTmp.length - 2, sTmp.length );
     else
   sTmp = sTmp.substring(0, sTmp.length - 2) + "." + sTmp.substring(sTmp.length - 2, sTmp.length );
                   return sTmp ;
                }
                else               
                   return Number( elmstr.substring(0, i) );
            }
        }       
    }
    return elm;
}
// check for valid quantity and prompt user if there is an error
// if valid is okay, update the hidden variable used by the basket buttons.
function updateQuantity()
{
// If quantity is valid, then go on to add stuff to cookie
  Qty=RoundQty(document.buynow.quantity.value);
  if (Qty >=10000 || Qty==0 || document.buynow.quantity.value==0)
  {
    alert ("Please enter a valid number that is greater than 0.01 and less than 9999.99!");
    document.buynow.quantity.value = document.buynow.quan.value;
    return;
  }
  document.buynow.quan.value = Qty;
  document.buynow.quantity.value = Qty;
}
function addtoBasket(productID, productName, productDescription, productSKU, productPromo,
 productPrice, productUnit, productQuantity, productTaxable, productShipping, productWeight, productModel) {
  // test if browser supports cookie
  document.cookie = "testcookie=mytestvalue";
  if (GetCookie("testcookie")!="mytestvalue")
  {
    alert("\nNO COOKIE SUPPORT\n \nYou will not be able to use the shopping basket without cookie support.\n \nFor more information on Cookie Support and turning it on please see your Browsers help section.\n \nYou can purchase this item without cookie support by selecting the Express Lane button ");
    return;
  }
  // if product already in shopping basket
  search_index = posInArray("productID", productID);
if (search_index==-1)
{
   alert("The shopping basket is full. No more items can be added.");
   return;
}
  if (search_index!=0)
  {
 total_quantity=addValueInArray("quantity", search_index, productQuantity);
  }
  else
  {
      addtoCookieArray("productID", productID);
      addtoCookieArray("product", productName);
      addtoCookieArray("description", productDescription);
      addtoCookieArray("sku", productSKU);
      addtoCookieArray("promotion", productPromo);
      addtoCookieArray("price", productPrice);
      addtoCookieArray("unit", productUnit);
      addtoCookieArray("quantity", productQuantity);
      addtoCookieArray("taxable", productTaxable);
      addtoCookieArray("shipping", productShipping);
      addtoCookieArray("weight", productWeight);
      addtoCookieArray("model", productModel);
      total_quantity=productQuantity;
  }
if (total_quantity == 0)
  {
      alert(productQuantity + " " + unescape(productName) + "s " + "cannot be added to your shopping basket.\n\n REASON:\n The maximium number of these items that can be added to your basket is 9999.99");
  }
  else if(productQuantity == 1)
  {
      alert(productQuantity + " " + unescape(productName) + " " + "has been added to your shopping basket.\n\nAltogether, you have "+
 total_quantity + " of these items in your basket.");
  }
  else
  {
      alert(productQuantity + " " + unescape(productName) + "s " + "have been added to your shopping basket.\n\nAltogether, you have "+
 total_quantity + " of these items in your basket.");
   }
}

function addtoBasketnew(productID, productName, productDescription, productSKU, productPromo,
 productPrice, productUnit, productQuantity, productTaxable, productShipping, productWeight, productModel) {
  // test if browser supports cookie
  document.cookie = "testcookie=mytestvalue";
  if (GetCookie("testcookie")!="mytestvalue")
  {
    alert("\nNO COOKIE SUPPORT\n \nYou will not be able to use the shopping basket without cookie support.\n \nFor more information on Cookie Support and turning it on please see your Browsers help section.\n \nYou can purchase this item without cookie support by selecting the Express Lane button ");
    return;
  }
  // if product already in shopping basket
  search_index = posInArray("productID", productID);
if (search_index==-1)
{
   alert("The shopping basket is full. No more items can be added.");
   return;
}
  if (search_index!=0)
  {
 total_quantity=addValueInArray("quantity", search_index, productQuantity);
  }
  else
  {
      addtoCookieArray("productID", productID);
      addtoCookieArray("product", productName);
      addtoCookieArray("description", productDescription);
      addtoCookieArray("sku", productSKU);
      addtoCookieArray("promotion", productPromo);
      addtoCookieArray("price", productPrice);
      addtoCookieArray("unit", productUnit);
      addtoCookieArray("quantity", productQuantity);
      addtoCookieArray("taxable", productTaxable);
      addtoCookieArray("shipping", productShipping);
      addtoCookieArray("weight", productWeight);
      addtoCookieArray("model", productModel);
      total_quantity=productQuantity;
  }
if (total_quantity == 0)
  {
      alert(productQuantity + " " + unescape(productName) + "s " + "cannot be added to your shopping basket.\n\n REASON:\n The maximium number of these items that can be added to your basket is 9999.99");
  }
  else if(productQuantity == 1)
  {
      alert(productQuantity + " " + unescape(productName) + " " + "has been added to your shopping basket.\n\nAltogether, you have "+
 total_quantity + " of these items in your basket.");
  }
  else
  {
      alert(productQuantity + " " + unescape(productName) + "s " + "have been added to your shopping basket.\n\nAltogether, you have "+
 total_quantity + " of these items in your basket.");
   }
   return false;
}

//-->

