
function Start(){
  LnCnt=0;
  EditMode=0;
  Header();
  tab=MakeTable('HOURS',MakeHours(),7,3);
  geninfo1+=tab+'</CENTER></BODY></HTML>';
  tab=MakeTable('',DescInfo,9,1);
  geninfo2+=tab+'</CENTER></BODY></HTML>';
  Wcol1(cat[0]);
}

function Header() {
  top.frames[1].document.open();
  top.frames[1].document.write(headpage);
  top.frames[1].document.close();
  parent.mycols.cols="230,280,*";
  Blank2();
  Blank3();
}

function Ginfo() {
  window.parent.col2.document.open();
  window.parent.col2.document.write(geninfo1);
  window.parent.col2.document.close();
  window.parent.col3.document.open();
  window.parent.col3.document.write(geninfo2);
  window.parent.col3.document.close();
}

function Wcol1(count){
  window.parent.col1.document.open();
  window.parent.col1.document.write(headstring);
  window.parent.col1.document.write('<BODY bgcolor="#CEE7FF"><TABLE width=100%>');
  today=new Date();
  datestring=today.toString();
  window.parent.col1.document.write('<tr><font color=green>'+datestring+'</font></tr>');
  thismonth=today.getMonth();
  thisdayom=today.getDate();
//  thismonth=4;
//  thisdayom=25;
  thishour=today.getHours();
  thismin=today.getMinutes();
  thistime=thishour*100+thismin;
  storeclosed1=CivilHolidays(thismonth,thisdayom);
  storeclosed2=JewishHolidays(thismonth,thisdayom);
  storeclosed=Math.max(storeclosed1,storeclosed2);

        switch (storeclosed){
           case 0:
               thisday=today.getDay();
               PrintStoreHours(thisday);
               break;
           case 1:
               break;
           case 2:
               window.parent.col1.document.write('<tr><font color=red>Store is closed today</font></tr>');
        }

  for(i=1;i<count+1;i++) Wdata1(i);
  window.parent.col1.document.write('</table></BODY></HTML>');
  window.parent.col1.document.close();
}

function Wcol1x(){
  window.parent.col1.document.open();
  window.parent.col1.document.write(headstring);
  window.parent.col1.document.write('<BODY bgcolor="#CEE7FF"><TABLE width=100%>');
  today=new Date();
  datestring=today.toString();
  window.parent.col1.document.write('<tr><font color=green>'+datestring+'</font></tr>');
  thismonth=today.getMonth();
  thisdayom=today.getDate();
  thishour=today.getHours();
  storeclosed1=CivilHolidays(thismonth,thisdayom);
  storeclosed2=JewishHolidays(thismonth,thisdayom);
  storeclosed=Math.max(storeclosed1,storeclosed2);

        switch (storeclosed){
           case 0:
               thisday=today.getDay();
               PrintStoreHours(thisday);
               break;
           case 1:
               break;
           case 2:
               window.parent.col1.document.write('<tr><font color=red>Store is closed today</font></tr>');
        }
  window.parent.col1.document.write('</table></BODY></HTML>');
  window.parent.col1.document.close();
}

function Wcol2(index){
  window.parent.col2.document.open();
  window.parent.col2.document.write(headstring);
  window.parent.col2.document.write('<BODY bgcolor="#A9D2F3">');

  sindx=cat[index][2];  
  if (sindx != 0) {
	 text1=cat[index][0];
	 text2=cat[index][1];
	 eindx=cat[index][3];

     tindx=cat[index][4];
     goodtime=1;
     if (tindx != 0) {CheckTime(tindx)};
     if (goodtime == 1) {catcolor="navy"} else {catcolor="red"};

	 var astring='<center><font color="'+catcolor+'">' + text1 + '</font><br><font color="black">'+
     text2 + '</font></center><hr><table>';
     window.parent.col2.document.write(astring);
     for(sub=sindx;sub<eindx+1;sub++) Wdata2(sub,goodtime);
  }
  
  window.parent.col2.document.write('</table></BODY><HTML>');
  window.parent.col2.document.close();
  Blank3();
}


function Wcol3(sub){
  CurrentItem=sub;
  text=item[sub][1];
  if (text=="") {text=item[sub][0];}

  window.parent.col3.document.open();
  window.parent.col3.document.write(headstring);
  window.parent.col3.document.write(bodystring);
  var astring="<font color=blue>"+text+"</font><hr><br>";
  window.parent.col3.document.write(astring);
  
  ProcessOptions(sub);

  window.parent.col3.document.write('</BODY><HTML>');
  window.parent.col3.document.close();
}

function Wdata1(index){
  text=cat[index][0];
  sindx=cat[index][2];
  eindx=cat[index][3];
  if (sindx == 0){
	 astring="<tr><td><DIV onmouseover='parent.hidden.Ginfo()'>";
	 window.parent.col1.document.write(astring);
     window.parent.col1.document.write('<font color="black">'+text+'</font>');
	 window.parent.col1.document.write("</DIV></td></tr><tr><td>&nbsp;</td></tr>");
  } else {
     astring="<tr><td><DIV onmouseover='parent.hidden.Wcol2("+index+")'>";
	 window.parent.col1.document.write(astring);
     tindx=cat[index][4];
     goodtime=1;
     if (tindx != 0) {CheckTime(tindx)};
     if (goodtime == 1) {catcolor="navy"} else {catcolor="silver"};
     window.parent.col1.document.write('<font color="'+catcolor+'">'+text+'</font>');
	 window.parent.col1.document.write("</DIV></td></tr><tr><td>&nbsp;</td></tr>");
  }
}

function Wdata2(sub,goodtime){
  text=item[sub][1];
  if (text=="") {text=item[sub][0];}
  price=GetPPU(item[sub][2],item[sub][3]);

  if (goodtime == 1){
     DIVstring='<DIV onmouseover= "parent.hidden.Wcol3('+sub+')">';
     itemcolor='black'
  } else {
     DIVstring='<DIV>';
     itemcolor='red';
  }

  astring='<tr><td valign="bottom">'+DIVstring;
  window.parent.col2.document.write(astring);
  window.parent.col2.document.write('<font color="'+itemcolor+'">'+text+'</font>');
  window.parent.col2.document.write('</td><td valign="bottom"><font color="'+itemcolor+'">'+
  '&nbsp;&nbsp;&nbsp;' + price + '</font>');
  window.parent.col2.document.write("</DIV></td></tr>");
}

function Blank2(){
  window.parent.col2.document.open();
  window.parent.col2.document.write(blankpage);
  window.parent.col2.document.close();
}

function Blank3(){
  window.parent.col3.document.open();
  window.parent.col3.document.write(blankpage);
  window.parent.col3.document.close();
}

function CivilHolidays(thismonth,thisdayom){
  numhols=civilhol[0];
  for(j=1;j<numhols+1;j++){
     if (civilhol[j][0] == thismonth & civilhol[j][1] == thisdayom){
        if (civilholx[j][1] == 1) {
           window.parent.col1.document.write('<tr><font color=red>'+civilholx[j][0]+'</font></tr>');
        }
        if (civilholx[j][2] == 1){
           PrintShortHours(civilholx[j][3],civilholx[j][4],civilholx[j][5],civilholx[j][6]);
        }
        return civilholx[j][2];
     }
  }
  return 0;
}  

function JewishHolidays(thismonth,thisdayom){
  numhols=jewishol[0];
  for(j=1;j<numhols+1;j++){
     if (jewishol[j][0] == thismonth & jewishol[j][1] == thisdayom){
        if (jewisholx[j][1] == 1) {
           window.parent.col1.document.write('<tr><font color=red>'+jewisholx[j][0]+'</font></tr>');
        }
        if (jewisholx[j][2] == 1){
           PrintShortHours(jewisholx[j][3],jewisholx[j][4],jewisholx[j][5],jewisholx[j][6])
        }
        return jewisholx[j][2];
     }
  }
  return 0;
}

function PrintShortHours(hour1,min1,hour2,min2){
     opentime=GetTime(hour1,min1);
     closetime=GetTime(hour2,min2);
     window.parent.col1.document.write('<tr><font color=red>Hours today '+opentime+' - '+closetime+'</font></tr>');
}

function PrintStoreHours(thisday){
  tday=thisday+1
  if (storehours[tday][0] == null){
     window.parent.col1.document.write('<tr><font color=red>Store is closed on '+dayname[tday]+'</font></tr>');
  } else {
     opentime=GetTime(storehours[tday][0],storehours[tday][1]);
     closetime=GetTime(storehours[tday][2],storehours[tday][3]);
     window.parent.col1.document.write('<tr><font color=red>Hours today '+opentime+' - '+closetime+'</font></tr>');
  }
}

function GetTime(xhour,xminute){
     if ((xhour == 0 || xhour == 24) & xminute == 0) return '12 Midnight';
     if (xhour == 12 & xminute == 0) return '12 Noon';
     if (xminute < 10) xminute='0'+xminute;
     if (xhour < 12) return xhour+':'+xminute+'AM';
     if (xhour == 12) return xhour+':'+xminute+'PM';
     return (xhour-12)+':'+xminute+'PM';
}             


function CheckTime(tindx){
  goodtime=0;
  var numtrip=timeopt[tindx][0];
  for(j=1;j<numtrip+1;j++){
     k=1+(j-1)*3;
     if (thisday == timeopt[tindx][k]){
        if (thistime>=timeopt[tindx][k+1] & thistime<=timeopt[tindx][k+2]){goodtime=1}
     }
  }
}

function ProcessOptions(sub){
  window.parent.col3.document.write(itemform);
  qty(sub);
  numoptions=item[sub][7];
  if (numoptions !=0){
     CurrentOption=1;
     CurrentElement=0;
     for(i=1;i<numoptions+1;i++){
        optnum=item[sub][7+i];
        option=opt[optnum][0];
        numchoice=opt[optnum][1];
        window.parent.col3.document.write('<br><br> ');

        switch (option){
           case 'comment':
               com();
               break;
           case 'yesno':
               yesno();
               break;
           case 'noyes$':
               noyes$();
               break;
           case 'pick1$':
               pick1$();
               break;
        }
     }
  }
  if (EditMode == 0){
     if (LnCnt == 0){
         whichbotton=addbotton;
     } else {
         whichbotton=addbotton+revbotton;
     }
  } else {
     whichbotton=modbotton;
  }
     
  window.parent.col3.document.write('<br><br><br><center>'+whichbotton+'</center>');
  window.parent.col3.document.write('</FORM>');
}

function qty(sub){
  sel='<select name="QTY" id="QTY">';
  window.parent.col3.document.write(sel);
  minqty=item[sub][5];
  maxqty=item[sub][6];
  for(j=minqty;j<maxqty+1;j++){
     optionline='<OPTION value='+j+'>'+j+'</OPTION>';
     window.parent.col3.document.write(optionline);
  }
  window.parent.col3.document.write('</select>');
  if (EditMode==0){
     window.parent.col3.mform.QTY.selectedIndex=0;
  } else {
     window.parent.col3.mform.QTY.selectedIndex=WholePtr;
  }
  qtyname=item[sub][3];
  if (qtyname == 'lbs'){
     numoptions=item[sub][7];
     if (numoptions == 0) return;
     firstopt=item[sub][8];
     if (opt[firstopt][0] != "fraction") return;
     CurrentElement=1;
     numfrac=opt[firstopt][1];     
     name='QF'+sub;
     sel='<select name="fraction" id="fraction">';
     window.parent.col3.document.write(sel);
     for(k=0;k<numfrac;k++){
//        fracval=opt[firstopt][(k+1)*2+1];
        fracname=opt[firstopt][(k+1)*2];
        optionline='<OPTION value="'+k+'">'+fracname+'</OPTION>';
        window.parent.col3.document.write(optionline);
     }
     window.parent.col3.document.write('</select>');
     if (EditMode==0){
        window.parent.col3.mform.fraction.selectedIndex=0;
     } else {
        window.parent.col3.mform.fraction.selectedIndex=FractionPtr;
     }
  }
  window.parent.col3.document.write(' '+qtyname);
}

function ckcharcnt(choice){
  charcnt += choice.length+4;
  if (charcnt > 32) {
     charcnt=0;
     return '<br>';
  } else {
     return '';
  }
}

function com(){
  for(j=1;j<numchoice+1;j++){
     comment=opt[optnum][j*2];
     comcolor=opt[optnum][j*2+1];
     commentline='<font color='+comcolor+'>'+comment+'</font>';
     window.parent.col3.document.write(commentline);
  }
}

function yesno(){
  name='N'+optnum;
  charcnt=0;
  numhold=0;

  if (EditMode ==1){
     CurrentElement+=numchoice;
     optx=oitem[CurrentLine][3+CurrentOption];
     CurrentOption++;
     var type=typeof optx;
     if (type =='object'){
        numhold=optx[0];
     }
  }

  for(j=1;j<numchoice+1;j++){
     choice=opt[optnum][1+j];
     begline=ckcharcnt(choice);

     ckval='checked';
     if (EditMode ==1 & type == 'object'){
        for (m=1;m<numhold+1;m++) {
            k=optx[m];
            if (j == k) {ckval=''}
        }
     }

     checkline='<INPUT TYPE="checkbox" NAME="'+name+'" value="'+choice+'"'+
     ckval+'>'+choice;
     window.parent.col3.document.write(begline+checkline+'&nbsp;&nbsp;');
  }
}

function noyes$(){
  name='N'+optnum;
  charcnt=0;
  numpick=0;

  if (EditMode ==1){
     CurrentElement+=numchoice;
     optx=oitem[CurrentLine][3+CurrentOption];
     CurrentOption++;
     var type=typeof optx;
     if (type =='object'){
        numpick=optx[0];
     }
  }

  for(j=1;j<numchoice+1;j++){
     choice=opt[optnum][j*2];
     begline=ckcharcnt(choice);

     ckval='';
     if (EditMode ==1 & type == 'object'){
        for (m=1;m<numpick+1;m++) {
            k=optx[m];
            if (j == k) {ckval='checked'}
        }
     }

     checkline='<INPUT TYPE="checkbox" NAME="'+name+'" value="'+choice+'"'+
     ckval+'>'+choice;
     window.parent.col3.document.write(begline+checkline+'&nbsp;&nbsp;');
  }
}

function pick1$(){
  name='N'+optnum;

  if (EditMode ==1){
     k=oitem[CurrentLine][3+CurrentOption];
     CurrentOption++;
  }

  if (numchoice>2){
     sel='<select name="'+name+'" id="'+name+'">';
     window.parent.col3.document.write(sel);
     for(j=1;j<numchoice*2+1;j+=2){
        choice=opt[optnum][1+j];
        cost=opt[optnum][2+j];
        optionline='<OPTION value="'+choice+'">'+choice+'</OPTION>';
        window.parent.col3.document.write(optionline);
     }
     window.parent.col3.document.write('</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
     if (EditMode==1){
        CurrentElement++;
        window.parent.col3.mform.elements[CurrentElement].selectedIndex=k;
     }

  } else {
     charcnt=0;
     for(j=1;j<numchoice+1;j++){
        choice=opt[optnum][j*2];
        cost=opt[optnum][j*2+1];
        begline=ckcharcnt(choice);

        if (EditMode==1){CurrentElement++}

        if ((EditMode ==0 & j==1)||(EditMode ==1 & j==k)){ckval=" checked"}
        else {checked=""}

        radioline='<INPUT TYPE="radio" name="'+name+'" value="'+choice+'" '+
        ckval+'>'+choice;
        window.parent.col3.document.write(begline+radioline+'&nbsp;&nbsp;');
     }
  }
}

function GetPPU(amount,units){
  var price,unit;
  price=GetDisplayAmt(amount);
  unit=priceunit[units];
  return price+'/'+unit;
}


function GetDisplayAmt(amount){
  samt=Get2DecimalDisplay(amount);
  return samt;
}

function Get2DecimalDisplay(amount){
  camt=""+Math.round(100.*amount);
  if (camt.length > 1){
     damt=camt.substr(0,camt.length-2)+'.'+camt.substr(camt.length-2,2);
  } else {
     damt='.0'+camt;
  }
  return damt;
}

function DisplayOrder(){
  GetQty();
  if (Qty == 0.){
     alert("\n 0 is an invalid order quantity");
     window.parent.col3.mform.QTY.focus();
  } else {
     window.parent.mycols.cols="230,570,0";
     Wcol1x();
     Blank2();
     SaveOrder();
     ShowOrders();
  }
}

function ReviewOrder(){
  window.parent.mycols.cols="230,570,0";
  Wcol1x();
  Blank2();
  ShowOrders();
}

function GetQty(){
  WholeQty=window.parent.col3.mform.QTY.options
    [window.parent.col3.mform.QTY.selectedIndex].value;
  WholePtr=window.parent.col3.mform.QTY.selectedIndex;
  if (item[CurrentItem][3] == 'lbs'){
     FractionPtr=window.parent.col3.mform.fraction.options
     [window.parent.col3.mform.fraction.selectedIndex].value;
     FractionInd=item[CurrentItem][8];
     Fraction=opt[FractionInd][FractionPtr*2+3]-0.;
     CurrentElement=2;
  } else {
     FractionPtr=0;
     Fraction=0.;
     CurrentElement=1;
  }
  Qty=WholeQty-0.+Fraction;
}

function SaveOrder(){
  if (EditMode == 0){
     LnCnt++;
     oitem[0]=LnCnt;
     SaveLoc=LnCnt;
  } else {
     SaveLoc=EditItem;
     EditMode=0;
  }
  oitem[SaveLoc]=[CurrentItem,WholePtr,FractionPtr,Qty];
  GetOptions();
}

function GetOptions(){
  numoptions=item[CurrentItem][7];
  if (numoptions !=0){
     for(i=1;i<numoptions+1;i++){
        optnum=item[CurrentItem][7+i];
        option=opt[optnum][0];
        numchoice=opt[optnum][1];
 
        switch (option){
           case 'yesno':
               GetYesno();
               break;
           case 'noyes$':
               GetNoyes$();
               break;
           case 'pick1$':
               GetPick1$();
               break;
        }
     }
  }
}

function GetYesno(){
  var stack=[]
  opcnt=0;
  for (j=1;j<numchoice+1;j++){
      k=CurrentElement-1+j;
      e=window.parent.col3.mform.elements[k];
//      etype=e.type;
//      ename=e.name;
//      evalu=e.value;
//      alert("\n j="+j+"\n k="+k+"\n etype="+etype+"\n ename="+ename+"\n evalu="+evalu);
      if (!e.checked){
         opcnt++;
         stack.push(j);
      }
  }
  stack.unshift(opcnt);
  if (opcnt == 0){
     oitem[SaveLoc].push(opcnt);
  } else {
     oitem[SaveLoc].push(stack);
  }
  CurrentElement=k+1;
}

function GetNoyes$(){
  var stack=[]
//  var stack2=new Array();
  opcnt=0;
  for (j=1;j<numchoice+1;j++){
      k=CurrentElement-1+j;
      e=window.parent.col3.mform.elements[k];
//      etype=e.type;
//      ename=e.name;
//      evalu=e.value;
//      alert("\n j="+j+"\n k="+k+"\n etype="+etype+"\n ename="+ename+"\n evalu="+evalu);
      if (e.checked){
         opcnt++;
         stack.push(j);
      }
  }
  stack.unshift(opcnt);
  if (opcnt == 0){
     oitem[SaveLoc].push(opcnt);
  } else {
     oitem[SaveLoc].push(stack);
  }
  CurrentElement=k+1;
}

function GetPick1$(){
   k=CurrentElement;
   e=window.parent.col3.mform.elements[k]
   etype=e.type;
//   ename=e.name;
//   evalu=e.value;
//   alert("\n k="+k+"\n etype="+etype+"\n ename="+ename+"\n evalu="+evalu);

  if (etype != "radio") {
     SelPtr=e.selectedIndex;
     CurrentElement++;
     oitem[SaveLoc].push(SelPtr);
     return;
  }

  for (j=1;j<numchoice+1;j++){
      k=CurrentElement-1+j;
      e=window.parent.col3.mform.elements[k];
      if (e.checked){
         oitem[SaveLoc].push(j);
      }
  }

  CurrentElement=k+1;
}


function ShowOrders(){
  window.parent.col2.document.open();
  window.parent.col2.document.write(headstring+bodystring+orderform+'<table>');
  Tcost=0;
  TxCost=0;
  for(l=1;l<LnCnt+1;l++){
     itemno=oitem[l][0];
     Qty=oitem[l][3];
     Price=item[itemno][2];
     Dprice=GetPPU(Price,item[itemno][3]);
     Cost=Qty*Price;
     Dcost=GetDisplayAmt(Cost);
     Tcost+=Cost;
     TaxCode=item[itemno][4];
     if (TaxCode == 'TX') {TxCost+=Cost}

     Row='<tr>';
     Row+='<td>---</td>';
     Row+='<td align="right">'+Qty+'</td>';
     Row+='<td>'+item[itemno][0]+'</td>';
     Row+='<td>@</td>';
     Row+='<td align="right">'+Dprice+'</td>'
     Row+='<td>=</td>';
     Row+='<td align="right">'+Dcost+'</td>';
     Row+='<td>'+TaxCode+'</td>';
     Row+='<td>'+deletebotton1+l+deletebotton2+'</td>';
     Row+='<td>'+changebotton1+l+changebotton2+'</td>';
     Row+='</tr>';
     window.parent.col2.document.write(Row);
     ShowOptions(l);
  }
  if (TxCost != 0){
     TaxCode='Tax =';
     Dttax=Get2DecimalDisplay(TxCost*StoreTax);
     Ttax=Dttax-0.;
     Dttax='$ '+Dttax;
  } else {
     TaxCode='&nbsp';
     Ttax=0;
     Dttax='&nbsp';
  }
  Total=Tcost+Ttax;
  Dtcost=GetDisplayAmt(Tcost);
  Dtot=Get2DecimalDisplay(Total);

  Row='<tr><td>&nbsp;</td><td>&nbsp;</td><td>Total</td><td>&nbsp;</td><td>&nbsp;</td>'+
  '<td>&nbsp;</td><td align="right">'+Dtcost+'</td><td>'+TaxCode+
  '</td><td align="right">'+Dttax+'</td><td align="right">&nbsp; $ '+Dtot+'</td></tr>';
  window.parent.col2.document.write(Row);
  window.parent.col2.document.write('</table>'+bottonset+'</body></html>');
  window.parent.col2.document.close();
}


function ShowOptions(line){

  x=oitem[line].length-4;
  CurrentOption=1;
  CurrentItem=oitem[line][0];
  numoptions=item[CurrentItem][7];

  if (numoptions !=0){
     for(i=1;i<numoptions+1;i++){
        optnum=item[CurrentItem][7+i];
        option=opt[optnum][0];
        numchoice=opt[optnum][1];
 
        switch (option){
           case 'comment':
               break;
           case 'fraction':
               CurrentOption++;
               break;
           case 'yesno':
               ShowYesno(line,optnum);
               break;
           case 'noyes$':
               ShowNoyes$(line,optnum);
               break;
           case 'pick1$':
               ShowPick1$(line,optnum);
               break;
        }
     }
  }
}

function ShowYesno(line,optnum){
  optx=oitem[line][3+CurrentOption];
  CurrentOption++;
  type=typeof optx;
  if (type=='number'){return}
  numhold=optx[0];

  for (j=1;j<numhold+1;j++){
      k=optx[j];
      optval=opt[optnum][1+k];
      Row='<tr><td>&nbsp;</td><td>&nbsp;</td><td>no '+optval+'</td><td>&nbsp;</td>'+
      '<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>'+
      '<td>&nbsp;</td></tr>';
      window.parent.col2.document.write(Row);
  }
}

function ShowNoyes$(line,optnum){
  optx=oitem[line][3+CurrentOption];
  CurrentOption++;
  type=typeof optx;
  if (type=='number'){return}
  numchosen=optx[0];

  for (j=1;j<numchosen+1;j++){
      k=optx[j];
      choice=opt[optnum][k*2];
      oprice=opt[optnum][k*2+1]*Qty;

      if (oprice == 0){
         doprice='&nbsp;';
         txcode='&nbsp;';   
      } else {
         doprice=GetDisplayAmt(oprice);
         Tcost+=oprice;
         if (TaxCode == 'TX') {TxCost+=oprice} 
         txcode=TaxCode; 
         tindex=choice.indexOf('~');
         if (tindex != -1){choice=choice.slice(0,tindex-1)}     
      }

      Row='<tr><td>&nbsp;</td><td>&nbsp;</td><td>'+choice+'</td><td>&nbsp;</td>'+
      '<td>&nbsp;</td><td>&nbsp;</td><td align="right">'+doprice+'</td><td>'+txcode+
      '</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
      window.parent.col2.document.write(Row);
  }
}

function ShowPick1$(line,optnum){
  k=oitem[line][3+CurrentOption];
  CurrentOption++;
  numopt=opt[optnum][1];
  if (numopt > 2) {k++};
  choice=opt[optnum][2*k];
  oprice=opt[optnum][2*k+1]*Qty;

  if (oprice == 0){
     doprice='&nbsp;';
     txcode='&nbsp;';   
  } else {
     doprice=GetDisplayAmt(oprice);
     Tcost+=oprice;
     if (TaxCode == 'TX') {TxCost+=oprice} 
     txcode=TaxCode;
     tindex=choice.indexOf('~');
     if (tindex != -1){choice=choice.slice(0,tindex-1)}  
  }

  Row='<tr><td>&nbsp;</td><td>&nbsp;</td><td>'+choice+'</td><td>&nbsp;</td>'+
  '<td>&nbsp;</td><td>&nbsp;</td><td align="right">'+doprice+'</td><td>'+txcode+
  '</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
  window.parent.col2.document.write(Row);
}



function DeleteItem(itemno){
  for(l=itemno;l<LnCnt+1;l++){
     oitem[l]=oitem[l+1];
  }
  LnCnt--;
  if (LnCnt == 0){
     ContinueOrder();
  } else {
     Wcol1x();
     ShowOrders();
  }
}

function ChangeItem(itemno){
  CurrentLine=itemno;
  EditMode=1;
  EditItem=itemno;
  window.parent.mycols.cols="230,280,*";
  Blank2();
  Blank3();
  CurrentItem=oitem[itemno][0];
  WholeQty=oitem[itemno][1];
  FractionPtr=oitem[itemno][2];
  Wcol3(CurrentItem);
}

function ContinueOrder(){
  window.parent.mycols.cols="230,280,*";
  Blank2();
  Blank3();
  Wcol1(cat[0]);
}

function CancelOrder(){
  LnCnt=0;
  ContinueOrder();
}

function CompleteOrder(){
}

function MakeTable(cap,arr,rows,cols){
  var tab='<table>';
  if (cap !='') {tab+='<caption>'+cap+'</caption>'}
  for (i=1;i<rows+1;i++){
      tab+='<tr>';
      for (j=0;j<cols;j++){
          if (j==0) {align='left'} else {align='right'}
            if (cols !=1) {
             tab+='<td align="'+align+'">'+arr[i][j]+'</td>';
          } else {
              tab+='<td align="'+align+'">'+arr[i]+'</td>';
          }
      }
      tab+='</tr>';
  }
  tab+='</table>';
  return tab;
}

function MakeHours(){
  var hourtable=new Array();
  for (i=1;i<8;i++){
      opentime=GetTime(storehours[i][0],storehours[i][1]);
      closetime=GetTime(storehours[i][2],storehours[i][3]);
      if (opentime == closetime) {
         opentime='Closed';
         closetime='';
      }
      hourtable[i]=[dayname[i],opentime,closetime]
  }
  return hourtable;
}

