//  c[ic]=new Array('sku','category','product','price','description','color','size','logo','logocolor','subcategory','subsubcategory','desc2','desc3','XXL','XXXL','cat0text','cat1text','cat2text');
//  c[ic]=new Array('itemID','cat1','label','price','desc1','opt1','opt2','opt3','opt4','cat2','cat3','desc2','desc3','price2','price3','cat0text','cat1text','cat2text','opt1costs','opt2costs','opt3costs','opt4costs','qty','minorder');

//**********      GENERAL    ******************************
function initcatalog() {
  catlength=c.length;
}

function initpages() {
  getispecs();
//  initspecs();
  initthumbs();
  inititem();
  initreview();
}

function initspecs() {
//  specs=new Array();
//  for (i=c.length-1;i>=catlength;--i) {
//    specs[i-catlength]=c.pop();
//document.write(i,specs[i-catlength]);
//  }
  getispecs();
}

function getispecs() {
  ispecs=0;
  for (i=3;i<specs.length;++i) {
    if ((specs[i][specscolOf('store')]==store)&&
        (specs[i][specscolOf('section')]==section)&&
        (specs[i][specscolOf('category')]==category)) {
      ispecs=i;
//      reviewpage='http://'+specs[ispecs][specscolOf('domain')]+'/'+specs[ispecs][specscolOf('reviewhtm')];
reviewpage=specs[ispecs][specscolOf('reviewhtm')];
      goreview='document.location=reviewpage;';
    }
  }
}

function specscolOf(name) {
   icol=-1;jcol=0;
   while ((icol==-1)&&(jcol<specs[0].length)) {
     if (specs[0][jcol].indexOf(name)==0) {icol=jcol;}
     ++jcol;
   }
   return icol;
}

function colOf(name) {
   icol=-1;jcol=0;
   while ((icol==-1)&&(jcol<c[0].length)) {
     if (c[0][jcol].indexOf(name)==0) {icol=jcol;}
     ++jcol;
   }
   return icol;
}

function replaceString(oldS,newS,fullS) {
  if (oldS>=" ") {
      if (fullS>=" ") {
    for (var ik=0; ik<fullS.length; ik++) {
        if (fullS.substring(ik,ik+oldS.length) == oldS) {
          fullS = fullS.substring(0,ik)+newS+fullS.substring(ik+oldS.length,fullS.length);
        }
      }
    }
    return fullS;
  }
}

function unspace(astr) {
  astr=replaceString(' ','+',astr);
  astr=replaceString(':','%3A',astr);
  astr=replaceString(';','%3B',astr);
  astr=replaceString('&','%26',astr);
  return astr;
}

function unhex(val) {
  val=replaceString('%20',' ',val);
  val=replaceString('+',' ',val);
  val=replaceString('%3A',':',val);
  val=replaceString('%3B',';',val);
  val=replaceString('%22','"',val);
  val=replaceString("%27","'",val);
  val=replaceString('%26','&',val);
  val=replaceString('%0D%0A','<br>',val);
  val=replaceString('%7C','|',val);
  val=replaceString('%40','@',val);
  return val;
}

function hexify(astr) {
  astr=replaceString(' ','+',astr);
  astr=replaceString(':','%3A',astr);
  astr=replaceString(';','%3B',astr);
  astr=replaceString('"','%22',astr);
  astr=replaceString("'","%27",astr);
  return astr;
}

function requote(val) {
  val=replaceString('%22','"',val);
  val=replaceString("%27","'",val);
  return val;
}

function rebreak(val) {
  val=replaceString('%0D%0A','<br>',val);
  return val;
}

function capitalize(astring) {
  cap1=astring.substring(0,1);
  Astring=cap1.toUpperCase()+astring.substring(1,astring.length);
  return Astring;
}

function USD(anumber) {
  pennies=String(Math.round(100*Number(anumber)));
  astring=pennies.substring(0,pennies.length-2)+"."+pennies.substring(pennies.length-2,pennies.length);
  if (anumber==0) {astring="0.00";}
  return astring;
}

function search(fields,forstring) {
  sfieldlist=fields.split('|');
//document.write(fields,forstring,sfieldlist,sfieldlist.length,c.length,sfieldlist[0].toLowerCase(),forstring.toLowerCase());
  for (j=1;j<c.length;++j) {
//document.write(j);
    keep=0;
    for (i=0;i<sfieldlist.length;++i) {
//document.write(forstring,sfieldlist[i],c[j][colOf(sfieldlist[i])]+'<br>');
      if (
//(c[j][colOf('use')]=='1')&& (c[i][colOf(user)]>' ') &&
        (c[j][colOf(sfieldlist[i])].toLowerCase().indexOf(forstring.toLowerCase())>-1)) {keep=1;}
    }
    if (keep==1) {tnlist[tnlist.length]=j;}
  }
//  tnnumperpage=0;
}

function makefieldselect(field,label,action) {
  allf=new Array();
  for (i=1;i<c.length;++i) {
      allf[allf.length]=c[i][colOf(field)].split('^');
  }
  allf2=new Array();
  for (fi=0;fi<allf.length;++fi) {
    for (fi2=0;fi2<allf[fi].length;++fi2) {
      allf2[allf2.length]=allf[fi][fi2];
    }
  }
  allf2.sort();
  allf3=new Array();
  allf3[0]=allf2[0];
  for (fi=1;fi<allf2.length;++fi) {
    if (allf2[fi]!=allf2[fi-1]) {
      allf3[allf3.length]=allf2[fi];
    }
  }
  sorts[++isorts]=new Array();;
  sorts[isorts]=allf3;
  sortnames[isorts]=field;
  sfieldnames=field;
  document.write('<form><small><select onChange="'+action+'('+isorts+',this.selectedIndex-1);">');
  document.write('<option>'+label);
  for (i=0;i<allf3.length;++i) {
    document.write('<option');
    document.write('>'+requote(allf3[i]));
  }
  document.write('</select></small>');
  document.write('</form>');
}

function go2category(isort,iallf3) {
  if (iallf3>=0) {document.location="category.htm?"+unspace(sorts[isort][iallf3]);}
}

function go2search(sfields,sfor) {
var sfields,sfor;
//  if (sfor>=" ") {
document.location="category.htm?search^0^"+sfields+"^"+unspace(sfor);
//}
}

function select2search(isort,iallf3) {
//note sfieldnames read from sortnames[isort]
  sfieldnames=sortnames[isort];
  if (iallf3>=0) {sfor=sorts[isort][iallf3];}
  go2search(sfieldnames,sfor);
}

function searchfields(formattext,sfnames) {
  document.write('<form name="searchform">'+formattext);
//  document.write('<input type=hidden name=n value="'+fnames+'">');
newloc='category.htm?search^0^'+sfnames+'^';
  document.write('<input type=text size=15 value="" onChange="');
  document.write("newloc+=this.value;");
  document.write('document.location=newloc;');
  document.write('">');
//document.write("'"+sfnames+"'");
//document.write(',this.value);">');
  document.write('<input type=button value=Go onClick="document.location=newloc;">');
//document.write("'"+sfnames+"'");
//document.write(',this.value);">');
  document.write('</form>');
//document.write("'"+sfnames+"'");
//?search^0^manufacturer^kk
}

//*****************     COOKIES   ***************************

function read2orders()
{
  orders=new Array();
  c0="";
  if(document.cookie) {
    ci = document.cookie.indexOf(cn);
    if (ci>-1) {
      c0=document.cookie.substring(ci,document.cookie.length);
      mark=c0.indexOf(';');if (mark<0) {mark=c0.length;}
      c0=c0.substring(0,mark);
      mark=c0.indexOf('=');if (mark<0) {mark=0;}
      c0=c0.substring(mark+1,c0.length);
      args=c0.split("^");
      for (i=0;i<args.length-1;++i)
      {
        if (args[i].length>1) {orders[i]=args[i].split(":");}
      }
    }
  }
}

function writeorders2cookie() {
  c1="";
  for (i=0;i<orders.length;++i) {
    if (orders[i][1]>0) {
      for (j=0;j<orders[i].length-1;++j) {c1+=orders[i][j]+":";}
      c1+=orders[i][orders[i].length-1]+"^";
    }
  }
  write2cookie(c1);
}

function write2cookie(c1) {
  days2x = 2;
  xdate = new Date();
  xdate.setTime(xdate.getTime()+(days2x*86400*1000));
  expires = xdate.toGMTString();
  cookie=cn+'='+c1+';expires='+expires+';path=/';
  document.cookie = cookie;
}

function readTaxShip()
{
  c0="";
  notax=0;outofarea=0;nextday=0;
  if(document.cookie) {
    ci = document.cookie.indexOf('TS');
    if (ci>-1) {
      c0=document.cookie.substring(ci,document.cookie.length);
      mark=c0.indexOf(';');if (mark<0) {mark=c0.length;}
      c0=c0.substring(0,mark);
      mark=c0.indexOf('=');if (mark<0) {mark=0;}
      c0=c0.substring(mark+1,c0.length);
      args=c0.split("^");
      notax=args[0];outofarea=args[1];nextday=args[2];
    }
  }
}

function writeTaxShip2cookie() {
  days2x = 2;
  xdate = new Date();
  c1=notax+'^'+outofarea+'^'+nextday;
  xdate.setTime(xdate.getTime()+(days2x*86400*1000));
  expires = xdate.toGMTString();
  cookie='TS='+c1+';expires='+expires+';path=/';
  document.cookie = cookie;
}

function readPID()
{
//the contents of PID are variable, and may require parsing at the application level
  c0="";
  PID='';
  if(document.cookie) {
    ci = document.cookie.indexOf('PID');
    if (ci>-1) {
      c0=document.cookie.substring(ci,document.cookie.length);
      mark=c0.indexOf(';');if (mark<0) {mark=c0.length;}
      c0=c0.substring(0,mark);
      mark=c0.indexOf('=');if (mark<0) {mark=0;}
      c0=c0.substring(mark+1,c0.length);
//      args=c0.split("^");
//      notax=args[0];outofarea=args[1];nextday=args[2];
      PID=c0;
    }
  }
}

function writePID2cookie() {
//the contents of PID are variable, and may require parsing at the application level
  days2x = 2;
  xdate = new Date();
  c1=PID;
  xdate.setTime(xdate.getTime()+(days2x*86400*1000));
  expires = xdate.toGMTString();
  cookie='PID='+c1+';expires='+expires+';path=/';
  document.cookie = cookie;
}

function addfullsku() {
  newic=c.length;
  c[newic]=new Array();
  for (jcol=0;jcol<c[isic].length;++jcol) {
    c[newic][jcol]=c[isic][jcol];
  }
  c[newic][colOf('use')]=' ';
  c[newic][colOf(itemIDname)]+=thisorder[(2+getioptionslist('M_or_W'))];
  c[newic][colOf(itemIDname)]+=thisorder[(2+getioptionslist('size'))];
  isic=newic;
  issku=c[newic][colOf(itemIDname)];
//thisorder[(2+getioptionslist(varname))]=val;
}


function add2orders() {
//  addfullsku();
  errormsg=checkoptionsERRORS(issku);
  if (errormsg>"") {alert("Please select options for: "+errormsg);}
  else {
    isorder=orders.length;
    for (i=0;i<orders.length;++i) {
      if (issku==orders[i][0]) {isorder=i;}
    }
    orders[isorder]=thisorder;
    writeorders2cookie();
//instock example
    if (colOf('instock')>0) {c[isic][colOf('instock')]-=thisorder[1];}
    document.location="review.htm";
  }
}

function buy1(ansku) {
  issku=ansku;
  thisorder[0]=issku;
  thisorder[1]=1;
  errormsg=checkoptionsERRORS(issku);
  if (errormsg>"") {thisorder[1]=0;document.location=itemhtm+"?"+issku;}
  else {add2orders('');}
}

function checkoptionsERRORS(ansku) {

  issku=ansku;
  optionsERRORS="";
  for (i=1;i<c.length;++i) {if (c[i][colOf(itemIDname)]==issku) {isic=i;}}

  for (i=0;i<optionslist.length;++i) {
if (optionslist[i]>' ') {
    if (c[isic][colOf(optionslist[i])]<=' ') {setNA(optionslist[i]);}
    else {
      if (c[isic][colOf(optionslist[i])].indexOf('^')<0) {setsingle(optionslist[i]);}
      else {
        isselect=0;
        for (j=0;j<selectlist;++j) {
          if (optionslist[i]==selectlist[j]) {isselect=1;}
        }
        if (((isselect==0)&&(thisorder[2+i]==" ")) ||
           ((isselect==1)&&(thisorder[2+i]==0))) {
          if (optionsERRORS>"") {optionsERRORS+=" & ";}
          optionsERRORS+=optionslist[i];
        }
      }
    }
}
  } return optionsERRORS;
}





function orderQTY(anitemID,qty) {
  read2orders();
  thisorder[0]=anitemID;
  thisorder[1]=qty;
  isorder=orders.length;
  for (i=0;i<orders.length;++i) {
    if (anitemID==orders[i][0]) {isorder=i;}
  }
  orders[isorder]=thisorder;
  writeorders2cookie();
}

function go2review() {document.location="review.htm";}

function inputQTY(anitemID) {
// adds qty input and order button
  qty=0;
  for (i=0;i<orders.length;++i) {
    if (anitemID==orders[i][0]) {qty=orders[i][1];}
  }
  document.write('<input value='+qty+' size=3 >');
//onChange="orderQTY('+anitemID+',this.value);"
  document.write('<input type=button value="Add to Cart" onClick="go2review();">');
}

function addGC2orders(ansku) {
  issku=ansku;
  for (i=1;i<c.length;++i) {if (c[i][colOf(itemIDname)]==issku) {isic=i;}}
  isorder=orders.length;
  for (i=0;i<orders.length;++i) {
    if (isic==orders[i][0]) {isorder=i;}
  }
  orders[isorder]=new Array(issku,1);
  for (i=0;i<optionslist.length;++i) {orders[2+i]=' ';}
  writeorders2cookie();
  document.location="review.htm";
}

function set1order() {
  isorder=0;
  for (i=0;i<orders.length;++i) {
    if (issku==orders[i][0]) {
      isorder=i;
      isqty=orders[isorder][1];
/*issize=orders[isorder][2];
      iscolor=orders[isorder][3];islogo=orders[isorder][4];islogocolor=orders[isorder][5];
      istext=orders[isorder][6];
*/
      for (j=0;j<orders[isorder].length;++j) {thisorder[j]=orders[isorder][j];}
    }
  }
}

function buyamericart() {
document.write('<form method="POST" action="http://www.cartserver.com/sc/cart.cgi">');
//  <p align="center"><input border="0" src="../images/buyme.jpg" name="I1" type="image" width="60" height="17"></p>
document.write('<input type="hidden" name="item" value="'+americartID+'^'+issku+'^'+c[isic][itemnamecol]+'; '+c[isic][colOf('desc')]+'^$'+c[isic][itempricecol]+'^1">');
document.write('<input type="submit" value="Order">&nbsp;&nbsp;');
document.write('<input TYPE="button" VALUE="Review Order" onClick="viewButton();">&nbsp;&nbsp;');
showbackbutton();
document.write('</form>');
}

/* View basket */
function viewButton() {
americartid="a-7790";
formaction="http://www.cartserver.com/sc/cart.cgi"
document.location=formaction+'?item='+americartid;
//document.write('<form method="POST" action='+formaction+'><input type="hidden" name="item" value="'+americartid+'"><p><input src="images/view.gif" name="view" alt="Review Order" type="image" border="0"></form>');
}

//***********    END COOKIES   ***************************
//**********     END GENERAL    ******************************
//**********      CATEGORY    ******************************

function initthumbs() {
ispage=specs[ispecs][specscolOf('ispage')];
categoryname=specs[ispecs][specscolOf('categoryname')];
categorytext=specs[ispecs][specscolOf('categorytext')];
itemIDname=specs[ispecs][specscolOf('itemIDname')];
itemname=specs[ispecs][specscolOf('itemname')];
itemnameplace=specs[ispecs][specscolOf('itemnameplace')];
itemnamestyle=specs[ispecs][specscolOf('itemnamestyle')];
itemnamefont=specs[ispecs][specscolOf('itemnamefont')];
itemnamesize=specs[ispecs][specscolOf('itemnamesize')];
itemnamecolor=specs[ispecs][specscolOf('itemnamecolor')];
itemnamebold=specs[ispecs][specscolOf('itemnamebold')];
itemnameitalic=specs[ispecs][specscolOf('itemnameitalic')];
tntablewidth=specs[ispecs][specscolOf('tntablewidth')];
tncellpadding=specs[ispecs][specscolOf('tncellpadding')];
tncellspacing=specs[ispecs][specscolOf('tncellspacing')];
tnborder=specs[ispecs][specscolOf('tnborder')];
tncellcolor=specs[ispecs][specscolOf('tncellcolor')];
tncellvalign=specs[ispecs][specscolOf('tncellvalign')];
tnnumperrow=specs[ispecs][specscolOf('tnnumperrow')];
tnnumperpage=Number(specs[ispecs][specscolOf('tnnumperpage')]);
tncellwidth=specs[ispecs][specscolOf('tncellwidth')];
tnpath=specs[ispecs][specscolOf('tnpath')];
tnext=specs[ispecs][specscolOf('tnext')];
tntype=specs[ispecs][specscolOf('tntype')];
tnimagewidth=specs[ispecs][specscolOf('tnimagewidth')];

  getthumbcols();getcategoryfromqs();

if (specs[ispecs][specscolOf('itemhtm')].indexOf('.htm')>0) {
  itemhtm='http://'+specs[ispecs][specscolOf('domain')]+'/'+specs[ispecs][specscolOf('itemhtm')];
} else {
  itemhtm='http://'+specs[ispecs][specscolOf('domain')]+'/'+specs[ispecs][specscolOf('section')]+'/'+ispage+'.htm';
}
//  reviewpage='http://'+specs[ispecs][specscolOf('domain')]+'/'+specs[ispecs][specscolOf('reviewhtm')];
reviewpage=specs[ispecs][specscolOf('reviewhtm')];
  goreview='document.location=reviewpage;';
}

function getthumbcols() {
  categorycol=colOf(categoryname);
  if (categorytext!="") {categorytextcol=colOf(categorytext);}
  skucol=colOf(itemIDname);
  namecol=colOf(itemname);
}

function getcategoryfromqs() {
  startat=0;sfields='nofields';sfor='nofor';
  pathparts=document.URL.split('?');
  qs=window.location.search;
  if (qs.length>1) {
    qs=replaceString('%5E','^',qs);
    qs=replaceString('+',' ',qs);
    qs=replaceString('%20',' ',qs);
    qs=qs.substring(1,qs.length);
    ispage=qs;
category=ispage;
    if (qs.indexOf('^')>0) {
      qss=qs.split('^');ispage=qss[0];startat=Number(qss[1]);
      if (ispage=='search') {sfields=qss[2];sfor=qss[3];}
    }
  }
}

function showcategoryname() {document.write(requote(ispage));}

function showcategorytext() {
  if (categorytext!="") {
    categorytextfound="";
    for (i=1;i<c.length;++i) {
      if ((c[i][categorycol]==ispage)&&(c[i][categorytextcol]>" ")) {
        categorytextfound=c[i][categorytextcol];
      }
    }
    document.write(requote(categorytextfound));
  }
}

function writeitemname() {
  if (itemnamebold="YES") {document.write('<b>');}
  if (itemnameitalic="YES") {document.write('<i>');}
  document.write(requote(c[i][namecol]));
  if (itemnameitalic="YES") {document.write('</i>');}
  if (itemnamebold="YES") {document.write('</b>');}
}

function placeitemname(place) {
  if (place=="above") {
    if (itemnamestyle=="YES") {document.write(requote(c[i][namecol])+'<br>');}
    else {
      document.write('<font face="'+itemnamefont+'" size='+itemnamesize+' color="'+itemnamecolor+'">');
      writeitemname();
      document.write('</font><br><br>');
    }
  }
  if (place=="below") {
    if (itemnamestyle=="YES") {document.write('<br>'+requote(c[i][namecol]));}
    else {
      document.write('<br><font face="'+itemnamefont+'" size='+itemnamesize+' color="'+itemnamecolor+'">');
      writeitemname();
      document.write('</font>');
    }
  }
}

function maketnlist(){
  tnlist=new Array();
//document.write(ispage);
  if (ispage=='search') {search(sfields,sfor);}
  else {
    for (i=1;i<c.length;++i) {
      cats=c[i][categorycol].split('^');
      for (icat=0;icat<cats.length;++icat) {
        if (cats[icat]==ispage) {
          tnlist[tnlist.length]=i;
        }
      }
    }
  }
}

function showthumbnails() {
  maketnlist();
  if (tnnumperpage==0) {nextstart=tnlist.length;}
  else {nextstart=startat+tnnumperpage;if (nextstart>=tnlist.length){nextstart=tnlist.length}}
  numleft=tnlist.length-nextstart;
  numdrawn=0;
  if (tncellwidth=="even") {percentwide=Math.floor(100/tnnumperrow);}
  document.write('<center><table border="'+tnborder+'" cellpadding="'+tncellpadding+'" cellspacing="'+tncellspacing+'"');
  if (tntablewidth!="") {document.write(' width="'+tntablewidth+'"');}
  document.write('><tr>');
  for (j=startat;j<nextstart;++j) {
      i=tnlist[j];
      if (numdrawn==0) {document.write('<tr>');}
      ++numdrawn;
      document.write('<td  bgcolor="'+tncellcolor+'" align="center" valign="'+tncellvalign+'" ');
      if (tncellwidth=="even") {document.write('width="'+percentwide+'%"');}
      if (Number(tncellwidth)>0) {document.write('width="'+tncellwidth+'"');}
      document.write('><a href="'+itemhtm+'?'+c[i][skucol]+'" class="itemname">');
      if (itemnameplace=="above") {placeitemname(itemnameplace);}
      if (colOf('thumbnail')>=0) {
        document.write('<img src="'+tnpath+c[i][colOf('thumbnail')]+'" border="0" ');
      } else {
        document.write('<img src="'+c[i][skucol]+tnext+'.'+tntype+'" border="0" ');
      }
      if (tnimagewidth>0) {
        document.write('width='+tnimagewidth);
      }
      document.write('></a>');
      if (itemnameplace=="below") {placeitemname(itemnameplace);}
      document.write('</td>');
      if (numdrawn % tnnumperrow ==0) {document.write('</tr><tr>');}
  }
  document.write('</tr></table></center>');
}

function showelaxthumbnails() {
  maketnlist();
  if (tnnumperpage==0) {nextstart=tnlist.length;}
  else {nextstart=startat+tnnumperpage;if (nextstart>=tnlist.length){nextstart=tnlist.length}}
//document.write('tnlist='+tnlist.length+'; tnnumperpage='+tnnumperpage+'; startat='+startat+'; nextstart='+nextstart+'; tnnumperrow='+tnnumperrow);
  numleft=tnlist.length-nextstart;
  numdrawn=0;
  if (tncellwidth=="even") {percentwide=Math.floor(100/tnnumperrow);}
  document.write('<center><table width="95%" border="0" align="center">');

  j=startat;
  while (j<nextstart) {

//  showelaxtnimgrow();
    document.write('<tr>');
    for (k=0;k<tnnumperrow;++k) {
      if (j+k<nextstart) {
        i=tnlist[j+k];
        document.write('<td width="'+percentwide+'%" align=center valign=center>');
        document.write('<a href="'+itemhtm+'?'+c[i][skucol]+'">');
        if (colOf('thumbnail')>=0) {
          document.write('<img src="'+tnpath+c[i][colOf('thumbnail')]+'" border="0" ');
        }
        if (tnimagewidth>0) {
          document.write('width='+tnimagewidth);
        }
        document.write('></a></td>');
      }
    }
    document.write('</tr>');

//  showelaxtnnamerow();
    document.write('<tr>');
    for (k=0;k<tnnumperrow;++k) {
      if (j+k<nextstart) {
        i=tnlist[j+k];
        document.write('<td align=center valign=center>');
        document.write('<b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">');
        document.write(c[i][colOf('manufacturer')]+': '+requote(c[i][namecol]));
        document.write('</font></b>');
        document.write('</td>');
      }
    }
    document.write('</tr>');


//  showelaxtnbuttonrow();
    document.write('<tr>');
    for (k=0;k<tnnumperrow;++k) {
      if (j+k<nextstart) {
        i=tnlist[j+k];
        document.write('<td align=center valign=center>');
        document.write('<a href="'+itemhtm+'?'+c[i][skucol]+'">');
        document.write('<b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">');
//instock example
        if ((colOf('instock')>=0)&&(Number(c[i][colOf('instock')])<Number(1))) { document.write('Out of Stock');}
        else {document.write('Buy Now!');}
//end instock example
        document.write('</font></b>');
        document.write('</a></td>');
      }
    }
    document.write('</tr>');

//  showelaxtnspacerrow();
    document.write('<tr><td colspan=3 height=2><font size=1><hr color="#a0a0ff"></font></td></tr>');

    j=Number(j)+Number(tnnumperrow);
  }
  document.write('</table></center>');

/*
  for (j=startat;j<nextstart;++j) {
      i=tnlist[j];
      if (numdrawn==0) {document.write('<tr>');}
      ++numdrawn;
      document.write('<td  bgcolor="'+tncellcolor+'" align="center" valign="'+tncellvalign+'" ');
      if (tncellwidth=="even") {document.write('width="'+percentwide+'%"');}
      if (Number(tncellwidth)>0) {document.write('width="'+tncellwidth+'"');}
      document.write('><a href="'+itemhtm+'?'+c[i][skucol]+'" class="itemname">');
      if (itemnameplace=="above") {placeitemname(itemnameplace);}
      if (colOf('thumbnail')>=0) {
        document.write('<img src="'+tnpath+c[i][colOf('thumbnail')]+'" border="0" ');
      } else {
        document.write('<img src="'+c[i][skucol]+tnext+'.'+tntype+'" border="0" ');
      }
      if (tnimagewidth>0) {
        document.write('width='+tnimagewidth);
      }
      document.write('></a>');
      if (itemnameplace=="below") {placeitemname(itemnameplace);}
      document.write('</td>');
      if (numdrawn % tnnumperrow ==0) {document.write('</tr><tr>');}
  }
  document.write('</tr></table></center>');
*/
}

function showTSthumbnails() {
  maketnlist();
  if (tnnumperpage==0) {nextstart=tnlist.length;}
  else {nextstart=startat+tnnumperpage;if (nextstart>=tnlist.length){nextstart=tnlist.length}}
  numleft=tnlist.length-nextstart;
  numdrawn=0;
  if (tncellwidth=="even") {percentwide=Math.floor(100/tnnumperrow);}
  document.write('<center><table border="'+tnborder+'" cellpadding="'+tncellpadding+'" cellspacing="'+tncellspacing+'"');
  if (tntablewidth!="") {document.write(' width="'+tntablewidth+'"');}
  document.write('><tr>');
  for (j=startat;j<nextstart;++j) {
      i=tnlist[j];
      if (numdrawn==0) {document.write('<tr>');}
      ++numdrawn;
      document.write('<td  bgcolor="'+tncellcolor+'" align="center" valign="'+tncellvalign+'" ');
      if (tncellwidth=="even") {document.write('width="'+percentwide+'%"');}
      if (Number(tncellwidth)>0) {document.write('width="'+tncellwidth+'"');}
      document.write('>');
      document.write('<table border="0" cellpadding="0" cellspacing="0" width="100%">');
      document.write('<tr>');
      document.write('<td width="100%" height="120"><p align="center">');
      document.write('<a href="'+itemhtm+'?'+c[i][skucol]+'" class="itemname">');
      document.write('<img src="'+c[i][skucol]+tnext+'.'+tntype+'" border="0" ');
      if (tnimagewidth>0) {
        document.write('width='+tnimagewidth);
      }
      document.write('></a>');
      document.write('</td>');
      document.write('</tr>');
      document.write('<tr>');
      document.write('<td width="100%" bgcolor="#6666FF" height="17" align="center">');
      document.write('<font size="2" face="Arial, Helvetica, sans-serif">');
      document.write('<a href="'+itemhtm+'?'+c[i][skucol]+'" class="itemname">');
      document.write('click to order</a></font>');
      document.write('</td>');
      document.write('</tr>');
      document.write('</table>');

      document.write('</td>');
      if (numdrawn % tnnumperrow ==0) {document.write('</tr><tr>');}
  }
  document.write('</tr></table></center>');
}

function maketnbacknext(isback,isspace,ismore){
  backtn=startat-tnnumperpage;
  if (startat>0) {document.write('<a href="javascript:gonexttn('+backtn+');">'+isback+'</a>');}
  if ((startat>0)||(numleft>0)) {document.write(isspace);}
  if (numleft>0) {document.write('<a href="javascript:gonexttn('+nextstart+');">'+ismore+'</a>');}
}

function gonexttn(nexttn) {
  nextargs=ispage+'^'+nexttn;
  if (ispage=='search') {nextargs+='^'+sfields+'^'+sfor;}
  document.location=pathparts[0]+'?'+nextargs;
}
//**********     END CATEGORY    ******************************
//***************   ITEMS     ******************************

function getioptionslist(optname) {
  isol=-1;
  for (iol=0;iol<optionslist.length;++iol) {
    if (optname==optionslist[iol]) {isol=iol;}
  }
  return isol;
}

function inititem() {
itemdefault=specs[ispecs][specscolOf('itemdefault')];
itemname=specs[ispecs][specscolOf('itemname')];
itemimagepath=specs[ispecs][specscolOf('itemimagepath')];
itemimagetype=specs[ispecs][specscolOf('itemimagetype')];
itemimagewidth=specs[ispecs][specscolOf('itemimagewidth')];
itemdesc=specs[ispecs][specscolOf('itemdesc')];
itemprice=specs[ispecs][specscolOf('itemprice')];
optionslist=new Array();
optionslistitems=specs[ispecs][specscolOf('optionslist')].split('^');
for (i=0;i<optionslistitems.length;++i) {
  if (optionslistitems[i]>"") {optionslist[i]=optionslistitems[i];}
}
selectlist=new Array();
selectlistitems=specs[ispecs][specscolOf('selectlist')].split('^');
for (i=0;i<selectlistitems.length;++i) {
  if (selectlistitems[i]>"") {selectlist[i]=selectlistitems[i];}
}
americartID=specs[ispecs][specscolOf('americartID')];
//reviewhtm='http://'+specs[ispecs][specscolOf('domain')]+'/'+specs[ispecs][specscolOf('reviewhtm')];
reviewhtm=specs[ispecs][specscolOf('reviewhtm')];
//reviewpage='http://'+specs[ispecs][specscolOf('domain')]+'/'+specs[ispecs][specscolOf('reviewhtm')];
reviewpage=specs[ispecs][specscolOf('reviewhtm')];
goreview='document.location=reviewpage;';

  initthisorder();
  getitemfromqs();
  for (i=1;i<c.length;++i) {if (c[i][colOf(itemIDname)]==issku) {isic=i;}}
  setitemcols();
  read2orders();
  set1order();
}

function initthisorder() {
  thisorder=new Array(itemdefault,1);
  for (i=0;i<optionslist.length;++i) {
    isselect=0;
    for (j=0;j<selectlist.length;++j) {
      if (optionslist[i]==selectlist[j]) {isselect=1;}
    }
    if (isselect==0) {thisorder[thisorder.length]=" ";} else {thisorder[thisorder.length]=0;}
  }
}

function getitemfromqs() {
  qs=window.location.search;
  issku=itemdefault;
  if (qs.length>1) {
    qs=qs.substring(1,qs.length);
    qsargs=qs.split("^");
//    issku=qsargs[0];
    isitem=0;
for (i=1;i<c.length;++i) {if (c[i][colOf(itemIDname)]==qsargs[0]) {isitem=1;issku=qsargs[0];}}
    if (isitem==1){for (i=0;i<qsargs.length;++i) {thisorder[i]=qsargs[i];}}
}}

function setitemcols() {
  itemnamecol=colOf(itemname);
  itemdesccol=colOf(itemdesc);
  itempricecol=colOf(itemprice);
}

function showitemcolOf(anic,colName) {document.write(rebreak(requote(c[anic][colOf(colName)])));}
function showitemcol(colName) {document.write(requote(rebreak(c[isic][colOf(colName)])));}
function showitemname() {document.write(requote(c[isic][itemnamecol]));}
function showitemimage() {
  if (colOf('image')>0) {
    document.write('<IMG SRC="'+itemimagepath+c[isic][colOf('image')]+'"');
  } else {
    document.write('<IMG SRC="'+itemimagepath+issku+'.'+itemimagetype+'"');
  }
  if (itemimagewidth>0) {document.write(' width='+itemimagewidth);}
  document.write('>');
}
function showitemdesc() {document.write(requote(c[isic][itemdesccol]));}

function showitemprice() {
  if (c[isic][itempricecol]>'a') {document.write('varies by '+c[isic][itempricecol]);}
  else {document.write(USD(c[isic][itempricecol]));}
/*  if (Number(c[isic][colOf(user)])==Number(1.0)) {thisprice=c[isic][itempricecol];}
  if (Number(c[isic][colOf(user)])<Number(1.0)) {thisprice=Number(c[isic][colOf('oldprice')])*Number(c[isic][colOf(user)]);}
  if (Number(c[isic][colOf(user)])>Number(1.0)) {thisprice=Number(c[isic][colOf(user)]);}
  if (user=='guest') {document.write('<a href="javascript:NAwindow();">NA</a>');}
  else {document.write(USD(thisprice));}
*/
}

function NAwindow() {
  alert("Please contact Wynns to set up an Institutional Account.");
}

function checkqty(aqty) {
  if ((colOf('instock')>0)&&(Number(c[isic][colOf('instock')])<Number(aqty))){
    msg='Sorry, we only have '+c[isic][colOf('instock')]+' in stock at this time. Please select a smaller quantity.';
    alert(msg);
  }
  else {thisorder[1]=aqty;}
}


function checkqty2(aqty,anic,iord) {
  if ((colOf('instock')>0)&&(Number(c[anic][colOf('instock')])<Number(aqty))){
    thisstock=c[anic][colOf('instock')];
    msg='Sorry, we only have '+thisstock+' in stock at this time. Please select a smaller quantity.';
    alert(msg);
  }
  else {orders[iord][1]=aqty;writeorders2cookie();}
}



function showitemqty() {
//instock example
  if ((colOf('instock')>0)&&(Number(c[isic][colOf('instock')]))<Number(1)){
    document.write('Out Of Stock');}
  else {
    document.write('<INPUT TYPE="TEXT" VALUE="'+thisorder[1]+'" size=4 onChange="checkqty(this.value);">');
  }
}

function showsizeqty(anitem) {
}

function showitemsku() {document.write(issku);}
function getoptiontext(varname,tlen) {document.write('<input size='+tlen+' onChange="thisorder['+(2+getioptionslist(varname))+']=this.value;">');}

function makeradio(varname,val,ischecked) {
 document.write('<input type=radio name="'+varname+'" value="'+val+'" onChange="thisorder['+(2+getioptionslist(varname))+']=this.value;"');
 if (ischecked==1) {document.write(' checked');thisorder[(2+getioptionslist(varname))]=val;}
 document.write('>');
}

function makeselect(option,optionlabel) {
  opts=c[isic][colOf(option)].split('^');
  isol=getioptionslist(option);
  document.write('<select onChange="thisorder['+(2+isol)+']=this.selectedIndex;">');
  document.write('<option>'+optionlabel);
  for (i=0;i<opts.length;++i) {
    document.write('<option');
    if ((opts.length==1)||(i==(thisorder[2+isol]-1))) {document.write(' selected');}
    document.write('>'+requote(opts[i]));
  }
  document.write('</select>');
}

function makeicoptionQTYs(anic,anoption) {
  read2orders();
  anitemID=c[anic][skucol];
  isorder=-1; oldQTY=0;
  for (ios=0;ios<orders.length;++ios) {
    if ((anitemID==orders[ios][0])&&(aniot==orders[ios][2+isol])) {isorder=ios;}
  }
  if (isorder>=0){oldQTY=orders[isorder][1];}
  opts=c[anic][colOf(anoption)].split('^');
  isol=getioptionslist(anoption);
  for (iopt=0;iopt<opts.length;++iopt) {
    document.write('<input size=3 value=oldQTY onChange="seticoptionQTYs('+anic+','+anoption+','+iopt+','+this.value+');"> '+requote(opts[ipt]));
  }
}

function seticoptionQTYs(anic,anoption,aniopt,aQTY) {
  opts=c[isic][colOf(option)].split('^');
  isol=getioptionslist(option);
  anitemID=c[anic][skucol];
  read2orders();
  thisorder[0]=anitemID;
  thisorder[1]=qty;
  thisorder[2+isol]=aniopt;
  isorder=orders.length;
  for (i=0;i<orders.length;++i) {
    if ((anitemID==orders[i][0])&&(aniot==orders[i][2+isol])) {isorder=i;}
  }
  orders[isorder]=thisorder;
  writeorders2cookie();
}

function setNA(option) {
  opts=c[isic][colOf(option)].split('^');
  isol=getioptionslist(option);
  thisorder[(2+isol)]='NA';
}

function setsingle(option) {
  opts=c[isic][colOf(option)].split('^');
  isol=getioptionslist(option);
  thisorder[(2+isol)]=c[isic][colOf(option)];
}

function showoptionimages(optname,numperrow,optionimagepath,optionimagetype,optionimagewidth) {
  numperrow=4;numshown=0;
  opts=c[isic][colOf(optname)].split('^');
  if (opts.length>1) {
    document.write('<table cellpadding=5 cellspacing=0 bgcolor="white">');
    for (iopt=0;iopt<opts.length;++iopt) {
      if (numshown % numperrow == 0) {document.write('<tr><td><center>');}
      command="javascript:setoption('"+optname+"',"+(iopt+1)+");"
      document.write('<a href="'+command+'">');
      document.write('<img src="'+optionimagepath+opts[iopt]+'.'+optionimagetype+'" border=0');
      if (optionimagewidth>0) {document.write(' width='+optionimagewidth);}
      document.write('></a>');
      ++numshown;
      if (numshown % numperrow == 0) {document.write('</center></td></tr>');}
    }
    document.write('</table>');
  }
}

function setoption(optname,iopt) {
  for (i=0;i<orders.length;++i) {
    if (issku==orders[i][0]) {orders[i][2+getioptionslist(optname)]=iopt;writeorders2cookie();}
  }
  thisorder[2+getioptionslist(optname)]=iopt;
  qs="?";
  for (i=0;i<thisorder.length-1;++i) {qs+=thisorder[i]+"^";} qs+=thisorder[thisorder.length-1];
  document.location=itemhtm+qs;
}

//*************     END ITEMS    ******************************
//***************     REVIEW     ******************************

function initreview() {
  row_color1=specs[ispecs][specscolOf('row_color1')];
  row_color2=specs[ispecs][specscolOf('row_color2')];
  recalc_button=specs[ispecs][specscolOf('recalc_button')];
  checkout_button=specs[ispecs][specscolOf('checkout_button')];
  back_button=specs[ispecs][specscolOf('back_button')];
  reviewtabletag=specs[ispecs][specscolOf('reviewtabletag')];
  rtopfont=specs[ispecs][specscolOf('rtopfont')];
  r1font=specs[ispecs][specscolOf('r1font')];
  r2font=specs[ispecs][specscolOf('r2font')];
  subtotalfont=specs[ispecs][specscolOf('subtotalfont')];
  shippingfont=specs[ispecs][specscolOf('shippingfont')];
  totalfont=specs[ispecs][specscolOf('totalfont')];
  totalcellcolor=specs[ispecs][specscolOf('totalcellcolor')];
  path2checkout=specs[ispecs][specscolOf('path2checkout')];
  user=parent.user;
}

function checkNoTax() {
 document.write('<input type=checkbox onClick="notax='+Number(Number(notax)+1)%2+';writeTaxShip2cookie();'+goreview+'"');
 if (notax==0) {document.write(' checked');}
 document.write('>');
}

function checkOutOfArea() {
 document.write('<input type=checkbox onClick="outofarea='+(outofarea+1)%2+';writeTaxShip2cookie();"');
 if (outofarea==1) {document.write(' checked');}
 document.write('>');
}

function checkNextDay() {
 document.write('<input type=checkbox onClick="nextday='+(nextday+1)%2+';writeTaxShip2cookie();"');
 if (nextday==1) {document.write(' checked');}
 document.write('>');
}

function appendoptions2desc(iorder) {
//  category=c[isic][categorycol];
//  getispecs();issku=c[isic][skucol];
//document.write(iorder,isic,category,ispecs+'<br>');
//  if (ispecs==0) {category='default'; getispecs();}
//  inititem();issku=c[isic][skucol];
  for (iopt=0;iopt<optionslist.length;++iopt) {
    descadded=0;
if (optionslist[iopt]>' ') {
    for (isel=0;isel<selectlist.length;++isel) {
      if (optionslist[iopt]==selectlist[isel]) {
        opts=c[isic][colOf(optionslist[iopt])].split('^');
        optval=opts[(orders[iorder][2+iopt]-1)];
//document.write(issku,isic,optionslist,selectlist,opts,optval);
if ((selectlist[isel]=='size')&&(c[isic][itempricecol]=='size')) {
  price=optval.substring(optval.indexOf('$')+1,optval.length);
  optval=optval.substring(0,optval.indexOf('/$'));
}
        if (optval>'') {
        desc+="; "+optionslist[iopt]+"-"+optval;
        descadded=1;
        }
      }
}
    }
if (optionslist[iopt]>' ') {
    if (descadded==0) {desc+="; "+optionslist[iopt]+"-"+orders[iorder][2+iopt];}
} else {desc+="; "}
  }
}

function writereviewline(i) {
  ++iseen;
  isic=0;
  issku=orders[i][0];
  for (ic=1;ic<c.length;++ic) {
    if (issku==c[ic][colOf(itemIDname)]) {isic=ic;}
//     document.write(issku,isic,c[ic][colOf(itemIDname)]);
  }
  qty=Number(orders[i][1]);
//i+';'+isic+';'+orders.length+';'+
  desc=requote(c[isic][itemnamecol]);
//  if (c[isic][colOf('desc')]>" ") {desc+='; '+requote(c[isic][colOf('desc')]);}
// size/price exceptions
  price=0;
  if ((c[isic][itempricecol]>" ")&&(c[isic][itempricecol]!="size"))
    {price=Number(c[isic][itempricecol]);}

//multiuser exceptions
/*  if (Number(c[isic][colOf(user)])==Number(1.0)) {thisprice=c[isic][itempricecol];}
  if (Number(c[isic][colOf(user)])<Number(1.0)) {thisprice=Number(c[isic][colOf('oldprice')])*Number(c[isic][colOf(user)]);}
  if (Number(c[isic][colOf(user)])>Number(1.0)) {thisprice=Number(c[isic][colOf(user)]);}
  if (user=='guest') {thisprice=0;}
  price=thisprice;
*/

    appendoptions2desc(i);


  totalqty+=Number(qty);
  desc2=unspace(desc);
  orderstring+=issku+":"+qty+":"+USD(price)+":"+desc2+"^";
  itemsub=(qty*price); subtotal+=itemsub;
  if (iseen % 2 == 0) {rc=row_color1;rf=r1font;} else {rc=row_color2;rf=r2font;}

  document.write('<tr><td bgcolor='+rc+'>'+rf+'&nbsp;'+issku+'&nbsp;</td><td bgcolor='+rc+'>'+rf+'&nbsp;'+requote(desc)+'&nbsp;</td><td bgcolor='+rc+' valign=middle>'+rf);
  document.write('<br><form><input value='+qty+' size=2 onChange="checkqty2(this.value,'+isic+','+i+');"></form>');
  document.write('</td><td bgcolor='+rc+' align=right>'+rf+'$'+USD(price)+'</td><td bgcolor='+rc+' align=right>'+rf+'$'+USD(itemsub)+'</td></tr>');
}

function showrecalculatebutton() {
  if (orders.length>0) {
        if (recalc_button>" ") {
      document.write('<form><input type=image src="'+recalc_button+'" onClick='+goreview+'></form>');
    } else {
      document.write('<form><input type=button value="Recalculate" onClick='+goreview+'></form>');
    }
  }
}

function go2checkout() {
//GUEST exception
  if (user=='guest') {alert('Please contact Wynns to set up an Institutional Account.');}
else {
  read2orders();writeorders2cookie();read2orders();
  if (orders.length==0) {document.location="review.htm";}
  else {
    now=new Date();invoice_num=Math.floor((now.valueOf()/1000)+(100*total));
    qs="invoice_num="+invoice_num+"&data="+orderstring+"&amt="+USD(total);
    if (top.user>' ') {qs+="&user="+top.user;}
    if (salestax>0) {qs+="&salestax="+salestax;}
    if (outofarea>0) {qs+="&outofarea="+outofarea;}
    if (nextday>0) {qs+="&nextday="+nextday;}
    window.open(path2checkout+'?'+qs);
  }
}
}

function showcheckoutbutton() {
  if (orders.length>0) {
    now=new Date();invoice_num="HC"+Math.floor((now.valueOf()/1000)+(100*total));
    qs="invoice_num="+invoice_num+"&data="+orderstring+"&amt="+USD(total)+"&user="+top.user;
    gocheckout='window.open("'+path2checkout+'?'+qs+'")';
    if (checkout_button>" ") {
      document.write('<form><input type=image src="'+checkout_button+'" onClick="go2checkout();"></form>');
    } else {
      document.write('<form><input type=button value="Checkout" onClick="go2checkout();"></form>');
    }
  }
}

function showbackbutton() {
/*  if (back_button>" ") {
    document.write('<form><input type=image src="'+back_button+'" onClick="history.go(-1);"></form>');
  } else {
*/
    document.write('<input type=button value="Back" onClick="history.go(-1);">');
//  }
}

function addbuttons4review() {
  document.write('<table><tr>');
  document.write('<td>');
  showrecalculatebutton();
  document.write('</td>');
  document.write('<td>');
  showcheckoutbutton();
  document.write('</td>');
  document.write('<td>');
  showbackbutton();
  document.write('</td>');
  document.write('</tr></table>');
}


function showorder() {
//UNFINISHED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//  orders[isorder]=new Array(isic,isqty,issize,iscolor,islogo,islogocolor,istext);
//  c[ic]=new Array('category[10,1]','sku[10,1]','product[10,1]','price[10,1]','XXL[10,1]','XXXL[10,1]','description[10,1]','color[10,1]','size[10,1]','logo[10,1]','logocolor[10,1]');
  read2orders();
  readTaxShip();
  if (orders.length==0) {document.write('There are no items in your shopping cart.');}
  else {
    setitemcols();
    iseen=0; subtotal=0;
    orderstring="";
    totalqty=0;
    rc=row_color1;
    document.write(reviewtabletag);
    document.write('<tr><td bgcolor='+rc+' align=left>'+rtopfont+'SKU</td><td bgcolor='+rc+' align=center>'+rtopfont+'Description</td><td bgcolor='+rc+' align=left>'+rtopfont+'Qty</td><td bgcolor='+rc+' align=right>'+rtopfont+'&nbsp;each&nbsp;</td><td bgcolor='+rc+' align=right>'+rtopfont+'&nbsp;subtotal&nbsp;</td></tr>');
    for (i01=0;i01<orders.length;++i01) {
//      document.write(orders,orders.length,orders[i01]+'<br>');
      writereviewline(i01);
    }
    calculateShipping();
    calculateSalesTax();
    document.write('<tr><td colspan=4 align=right>'+subtotalfont+'Subtotal:&nbsp;</td><td align=right>'+subtotalfont+'$'+USD(subtotal)+'</td></tr>');total=subtotal;
//    if (salestax>0) {
document.write('<tr><td colspan=4 align=right>');
      checkNoTax();document.write(shippingfont+'Vermont residents only - Sales Tax 5%:&nbsp;</td><td align=right>'+shippingfont+'$'+USD(salestax)+'</td></tr>');total+=salestax;
//}
    document.write('<tr><td colspan=4 align=right>'+shippingfont+'Shipping:&nbsp;</td><td align=right>'+shippingfont+'$'+USD(shipping)+'</td></tr>');total+=shipping;
    document.write('<tr><td colspan=4 align=right>'+totalfont+'Total:&nbsp;</td><td bgcolor="'+totalcellcolor+'" align=right>'+totalfont+'$'+USD(total)+'</td></tr>');
    document.write('</table></form>');
  }
}

/*
function calculateSalesTax() {
  salestax=0;
  rate=0;
  if ((store=='gsc')&&(notax==0)) {rate=0.05;}
  salestax=Number(subtotal)*Number(rate);
}
*/

function calculateShipping() {
shipping=0;

if (store=='kinetic') {shipping=0.085*Number(subtotal);}

if (store=='elax'){
/*
$ 1-$25 $4.99
$26-$50 $5.99
$51-$100 $7.49
$101-$150 $8.49
$151-$200 $9.49
$201-$250 $10.49
Over $250 $15.00
*/
  if (Number(subtotal)>Number(250)) {shipping=15;}
  else {if (Number(subtotal)>Number(200)) {shipping=10.49;}
    else {if (Number(subtotal)>Number(150)) {shipping=9.49;}
      else {if (Number(subtotal)>Number(100)) {shipping=8.49;}
        else {if (Number(subtotal)>Number(50)) {shipping=7.49;}
          else {if (Number(subtotal)>Number(25)) {shipping=5.99;}
            else {if (Number(subtotal)>Number(0)) {shipping=4.99;}
            }
          }
        }
      }
    }
  }
}

if (store=='gsc'){
0-10-1
10-19-2
19.01-25-5
25.01-75-7.5
/*
0 to $25.00  $5.00
$25.01 to $75.00  $7.50
Over $75.00  $10.00
Over $100.00  $12.50
Out of the Continent   $20.00
Next Day Delivery   Add $20.00
*/
  if (Number(subtotal)>Number(100)) {shipping=12.50;}
  else {if (Number(subtotal)>Number(75)) {shipping=10;}
    else {if (Number(subtotal)>Number(25)) {shipping=7.50;}
      else {if (Number(subtotal)>Number(19)) {shipping=5;}
        else {if (Number(subtotal)>Number(10)) {shipping=2;}
          else {if (Number(subtotal)>Number(0)) {shipping=1;}
          }
        }
      }
    }
  }
  if (qs.indexOf('outofarea')>0) {shipping=Number(shipping)+Number(20);}
  if (qs.indexOf('nextday')>0) {shipping=Number(shipping)+Number(20);}
}

//  shipping=6+(Math.round(10*subtotal)/100);
//shipping=Math.round(297+(198*totalqty))/100;
//shipping=0;
}


//**********      END REVIEW    ******************************
//***************   CATALOG     ******************************

c=new Array(); ic=-1;

cn = "version0.1";

thisorder=new Array(); theseorders=new Array(); sorts=new Array(); sortnames=new Array(); isorts=-1;
user=parent.user;


//************   END CATALOG     ******************************


