hrcolor='CFDfE2';

function showthumbtable() {
  tnnumperrow=4; tnnumperpage=24;
  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 width="95%" border="0" align="center">');
  j=startat;
  while (j<nextstart) {
//  showtnnamerow();
    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="3" color="#800000">');
        document.write(requote(c[i][namecol]));
//        document.write(c[i][colOf('manufacturer')]+': '+requote(c[i][namecol]));
        document.write('</font></b>');
        document.write('<br><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#800000">'+requote(c[i][colOf('desc')])+'</font>');
        document.write('</td>');
      }
    }
    document.write('</tr>');
//  showtnimgrow();
    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('itemID')]+'.jpg" border="0" ');
       // }
        if (tnimagewidth>0) {
          document.write('width='+tnimagewidth);
        }
        document.write('></a><br><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#800000">'+c[i][colOf('wax')]+'</font></td>');
      }
    }
    document.write('</tr>');
/*
//  showtnlinkrow();


    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]+'">');
        document.write('<font size=1>view details ...</font></a></td>');
      }
    }
    document.write('</tr>');
*/


/*
//  showtnpricerow();


    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('$'+USD(c[i][colOf('price')]));
        document.write('$'+c[i][colOf('price')]);
        document.write('</font></b>');
        document.write('</td>');
      }
    }
    document.write('</tr>');
*/

/*
//  showtnbuttonrow();
    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="javascript:buy1(');
        document.write("'"+c[i][skucol]+"'");
        document.write(');">');
        document.write('<a href="'+itemhtm+'?'+c[i][skucol]+'">');
        document.write('<b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">');
        document.write('Select Sizes');
*/

/*
//instock example
        if ((colOf('instock')>=0)&&(Number(c[i][colOf('instock')])<Number(1))) { document.write('Out of Stock');}
        else {document.write('Buy 1 Now!');}
*/
/*
//end instock example
        document.write('</font></b>');
        document.write('</a></td>');
      }

    }
    document.write('</tr>');
*/
//  showtnspacerrow();
    document.write('<tr><td colspan='+tnnumperrow+' height=2><font size=1><hr color="#'+hrcolor+'"></font></td></tr>');
    j=Number(j)+Number(tnnumperrow);
  }
  document.write('</table></center>');
}
//e8f8ff
selectrgb='231,247,255';

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;
selectrgb="194,204,240";
  document.write('<form><small><select size=6 onChange="'+action+'('+isorts+',this.selectedIndex-1);"  style="background-color: rgb('+selectrgb+'); color: rgb(63,63,255); font-family: verdana, helvetica bold; font-style: bold; text-decoration: none">')
  document.write('<option selected>'+label);
  for (i=0;i<allf3.length;++i) {
    document.write('<option');
//    document.write('>'+requote(allf3[i]));

    document.write('>'+allf3[i]);
  }
  document.write('</select></small>');
  document.write('</form>');
}

function hexify(astr) {
  astr=replaceString(' ','+',astr);
  astr=replaceString(':','%3A',astr);
  astr=replaceString(';','%3B',astr);
  astr=replaceString('"','%22',astr);
  astr=replaceString("'","%27",astr);
  astr=replaceString("&","%26",astr);
  astr=replaceString("@","%40",astr);
  astr=replaceString("|","%7C",astr);
  return astr;
}

function unspace(astr) {
  astr=replaceString('+',' ',astr);
  astr=replaceString('%26','&',astr);
  astr=replaceString('%7C','|',astr);
  return astr;
}


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

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>=" ") {
    for (var ik=0; ik<fullS.length; ik++) {
      if (fullS>=" ") {
        if (fullS.substring(ik,ik+oldS.length) == oldS) {
          fullS = fullS.substring(0,ik)+newS+fullS.substring(ik+oldS.length,fullS.length);
        }
      }
    }
    return fullS;
  }
}

function unhex(val) {
  val=replaceString('%25','%',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 alertEmpty() {
  alert('Please enter a word, phrase, or partial word to search.');
}


function newqs() {
  newq="?";
  newq+="file="+file;
  newq+="&delimiter="+delimiter;
  newq+="&template="+template;
  newq+="&ssi="+ssi;
  newq+="&fields="+fields;
  newq+="&search="+search;
  return newq;
}

function gonext(infound) {
  path2go="http://www327.pair.com/cgi-bin/cgiwrap/pscan/nesearch.pl"+oldqs;
  document.location=path2go+'&nextstart='+infound;
}

function makebacknext(isback,isspace,ismore){
  numleft=Number(numfound)-Number(lastseen);
  backto=Number(startat)-Number(forcount);
  if (Number(startat)>1) {document.write('<a href="javascript:gonext('+backto+');">'+isback+'</a>');}
  if ((Number(startat)>1)||(Number(numleft)>0)) {document.write(isspace);}
  if (Number(numleft)>0) {document.write('<a href="javascript:gonext('+nextstart+');">'+ismore+'</a>');}
}

function recall() {
  document.location=path2cgi+newqs();
}

function go2item(isort,iallf3) {
//note sfieldnames read from sortnames[isort]
  sfieldnames=sortnames[isort];
  if (iallf3>=0) {sfor=sorts[isort][iallf3];}
//  go2search(sfieldnames,sfor);
//alert(isort+iallf3+sfor);
  sfor=replaceString(" ","",sfor);
  document.location=domain+"item.htm?"+sfor.toLowerCase();
}

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

function getAWfromqs() {
  AW='';
  qs=window.location.search;
  iscat=1;
  if (qs.length>1) {
    qs=qs.substring(1,qs.length);
    qsargs=qs.split('&');
    AWs=qsargs[0].split('=');
    AW=AWs[1];
  }
}

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

reviewpage="review.html";

function writeBack2cookie() {
  days2x = 1;
  xdate = new Date();
  xdate.setTime(xdate.getTime()+days2x*(86400*1000));
  xdate.toGMTString();
  c1=document.location;
  document.cookie = 'DR='+c1+'; expires='+xdate+';path=/';
}

function newqs() {
  newq="?";
  newq+="file="+file;
  newq+="&delimiter="+delimiter;
  newq+="&template="+template;
  newq+="&ssi="+ssi;
  newq+="&fields="+fields;
  newq+="&search="+search;
  return newq;
}

function recall() {
  document.location=path2cgi+newqs();
}

selectrgb='255,255,221';


