

function copyright() {
  var lastmod = document.lastModified;
  document.write('<img src="/cgi-sys/Count.cgi?df=kimssush.dat|display=Date|timezone=GMT-0500|dformat=MMDDYY|ft=2|md=6|frgb=217;217;217|dd=D|srgb=255;0;0|prgb=0;0;0" alt="[Date]">');
  document.write('<img src="/cgi-sys/Count.cgi?df=kimssush.dat|display=Clock|timezone=GMT-0500|tformat=12|ft=2|md=6|frgb=217;217;217|dd=D|srgb=255;0;0|prgb=0;0;0" alt="[Clock]"> ');
  document.writeln('<img src="/cgi-sys/Count.cgi?df=kimssush.dat|display=Counter|ft=2|md=6|frgb=217;217;217|dd=D|srgb=255;0;0|prgb=0;0;0" alt="[Counter]"><br>');
  if (lastmod == 0)
    {
      document.writeln("&copy 2006 Nouri Data Systems Last Modified Date: Unknown");
    }
  else
    {
      document.writeln(" &copy 2006 Nouri Data Systems  - Last Modified Date: " + lastmod);
    }
}

function copyright_st() {
  var lastmod = document.lastModified;
  if (lastmod == 0)
    {
      window.status=" Copyright 2006 Nouri Data Systems  - Last Modified Date: Unknown";
    }
  else
    {
      window.status=" Copyright 2006 Nouri Data Systems  - Last Modified Date: " + lastmod;
    }
}

function check_loc() {
// if (top.location == "http://www.kims-sushi.com/")
//   top.location="http://www.kims-sushi.com/default2.html";
// if (top.location == "http://www.kims-chinese.com/")
//   top.location="http://www.kims-chinese.com/default.html";
}



function show_pic_win(url,height,width) {
  var picwin = window.open(''+url,'picwin', 'toolbar=0, location=0, directories=0, status=0, menubar=0,' + 
                ' titlebar=0, scrollbars=0, resizable=0, width=' + width 
                  + ', height=' + height + ', top=100, left=100');
  picwin.focus( );
  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName=="Netscape") {
      picwin.outerWidth=w;
      picwin.outerHeight=h;
    }
    else picwin.resizeTo(w,h);
  }
}


function showPic(image, caption, height, width) {
  height = height + 80;
  width = width + 30;
  var win = window.open("", 'showPic', "height=" + height + ",width=" + width);
  win.focus();
  var text = "";
  text += "<HTML><HEAD><TITLE>Alert</TITLE></HEAD><BODY BGCOLOR='#ffffff'>";
  text += "<img src=" + image + "><br>";
  text += " <CENTER><FONT face='Arial,sans-serif' size=6 color=black>";
  text += caption + "</FONT></CENTER> </BODY></HTML>";
  win.document.write(text);
  win.document.close();
  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName=="Netscape") {
      win.outerWidth=width;
      win.outerHeight=height;
    }
  else win.resizeTo(width,height);
  }
}








function xx_addToOrder(theItem, theSize, thePrice) {
  var win = window.open("", 'kims_dishes');
  win.focus( ); 
  var text = "";
  text += "<HTML><HEAD><TITLE>add an Order</TITLE>\n<link rel=stylesheet href=kims-look.css type=text/css>\n</HEAD>";
  text += '\n<BODY BGCOLOR="#d9d9d9">\n<SCRIPT LANGUAGE="JavaScript" src="js/util.js"></script>';
  text += '\n<form  name=mainform method=POST action="">\n<TABLE valign=top width=500 border="0" cellpadding="2" cellspacing="2" justify="center">';
  text += '\n<TR><TD class=orderitem width=25> QTY </TD> \n    <TD class=orderitem width=300> Description </TD>';
  text += '\n    <TD class=item width=70> Size </TD> \n    <TD class=orderitem width=80> Price</TD>\n</TR>';
  text += "\n<TR><TD><input type=text name=qty size=5 maxsize=5 value=1></TD> \n    <TD class=orderitem>"+theItem+"</TD>";
  text += "\n    <TD class=orderitem>" + theSize + "</TD>\n    <TD class=orderitem>" + thePrice + "</TD>\n</TR>";
  text += "\n<TR><TD colspan=2> Special Instructions: <textarea name=notes cols=30 rows=2></textarea></TD>";
  text += "\n    <TD><input type=button name=b_add onClick='appendOrder(qty.value, \"" + theItem + "\", \"";
  text += theSize + "\", \"" + thePrice + "\", notes.value)' value='Add'></TD>";
  text += "\n    <TD><input type=button name=b_cancel onClick='history.back()'  value='Cancel'></TD>";
  text += '</TR>\n</TABLE> \n<script language="JavaScript"> \n <!-- \n document.mainform.qty.focus();\n document.mainform.qty.value=1; //--> \n </script>\n';
  text += " </FORM></BODY></HTML>";
  win.document.write(text);
  win.document.close();

}






function appendOrder(theQty, theItem, theSize, thePrice, theNotes) {
  var astr = theQty + "|" + theItem + "|" + theSize + "|" + thePrice + "|" + theNotes + "]";
  var headerStr = readHeader();
  var header = headerStr.split("|");
  var itemcount = header[0];
  var subtotal = header[1];
  var tax = header[2];
  var delivery = header[3];
  var total = header[4];
  var ordernotes = header[5];
  itemcount = eval( itemcount) + eval(theQty);
  subtotal = eval(subtotal) + eval(theQty * thePrice);
  tax = eval(subtotal * .08375);
  var adj1 = tax % .05;
  var adjustment = eval(adj1 > .025) ?  eval(.05 - adj1) : eval(-1*adj1);
  tax += adjustment;
  if (eval(subtotal+tax)<8 & eval(subtotal) > 0) {
   delivery = 8-eval(subtotal+tax); 
  } else {
    delivery = 0; 
  }
  total = eval(subtotal + tax + delivery);
  var text1 = "     Items: " + itemcount;  
  text1 +=    "\n  SubTotal: " + formatCurrency(subtotal);
  text1 +=    "\n       Tax: " + formatCurrency(tax);
  text1 +=    "\n  Delivery: " + formatCurrency(delivery);
  text1 +=    "\n     Total: " + formatCurrency(total);
  top.kimsMenu.order.title=text1;
  writeHeader(itemcount + "|"+ subtotal + "|" + tax + "|" + delivery + "|" + total + "|" + ordernotes);
  top.kims_banner.vars.value += astr;
  history.back();
  // showOrder(); 
}
  
function resetorderitem() {

  
}  



 

  
function showOrder() {
  width=682;
  height=564;
  var orders = new String(top.kims_banner.vars.value);
  var recs = orders.split("]");
  var header = recs[0].split("|");
  var rcount = recs.length-2;
  var subtotal = 0, tax = 0, delivery = 0, total = 0;
  var order_note = header[5];
  var win = window.open("", 'kims_dishes', "height=" + height + " width="+width + " scrollbars=1");
  win.focus( );
  var text = "";
  text += "<HTML> <HEAD> <TITLE> Customer Order </TITLE>";
  text += "<style type='text/css'> \n <!-- \n body { margin-left:5px; margin-top:5px; }\n--> \n</style>";
  text += "</HEAD> <BODY BGCOLOR='#d7d7d7'>";
  text += '<TABLE width=500 border="0" cellpadding="0" cellspacing="0" justify="center"> <TR> <TD > ';
  text += "<CENTER> Kim's Chinese & Sushi Takeout <BR> 3712 East Tremont Ave. <BR> Bronx, New York  10465<BR> ";
  text += "(718) 239-3335 / (718) 239-2225 <BR><BR></TD></TR> </TABLE>";
  text += '<BR><FORM method=GET action=""><TABLE width=640 border="0" cellpadding="0" cellspacing="0" justify="center">';
  text += "<TR> <TD colspan=4> <H1> <center> Your Order </center> </H1> </TD> </TR>";
  text += "<TR> <TD width='5%'>Qty</TD> <TD width='75%'>Item / Special Instructions</TD> <TD width='10%'> Size </TD> <TD width='10%'>Price</TD></TR></TABLE>";
  for (var x=0; x < rcount; x++) {
    var fields = recs[x+1].split("|");
    text += '<TABLE width=640 border="0" cellpadding="0" cellspacing="0" justify="center"> '
    text += "<TR> <TD width='5%'> <input type=text name=qty" + eval(x+1) +" size=2 maxsize=2 value="+ fields[0]+"></TD><TD width='75%'> " 
            + fields[1] + " <br> <textarea name=itemnote" + eval(x+1) +" cols=60 rows=2 > "
            + fields[4]+ "</textarea> </TD> ";
    subtotal += eval(fields[0]*fields[3]);

    text += "<TD width='10%'> " +  fields[2] + " </TD> ";
    text += "<TD width='10%'> " +  fields[3] + " </TD> </TR></TABLE><br>";
  }
  text += "";
  text += " <br> SubTotal: " + formatCurrency(subtotal);
  tax = eval(subtotal * .08375);
  var adj1 = tax % .05;
  adjustment = eval(adj1 > .025) ?  eval(.05 - adj1) : eval(-1*adj1);
  tax += adjustment;
  if (eval(subtotal+tax)<8 & eval(subtotal) > 0) {
   delivery = 8-eval(subtotal+tax); 
  } else {
    delivery = 0; 
  }
  total = eval(subtotal + tax + delivery);
  text += " <br>      Tax: " + formatCurrency(tax);
  text += " <br> Delivery: " + formatCurrency(delivery);
  text += " <br>    Total: " + formatCurrency(total);
  text += " <br><br>    Notes: <br><textarea name=notes_main cols=100 rows=5>" + order_note + "</textarea>";
  
  text += "<br><input type=button name=b_Print onClick='window.print()'  value='Print Preview'>";
  text += "        <input type=button name=b_CS onClick='history.back()'  value='Continue Shopping'>";
  text += "</BODY> </HTML>";
 
  win.document.writeln(text);
  win.document.close();
//  if (parseInt(navigator.appVersion)>3) {
//    if (navigator.appName=="Netscape") {
//      win.outerWidth=width;
//      win.outerHeight=height;
//    }
//   else win.resizeTo(width,height);
//   }
}

function readHeader() {
  var orders = new String(top.kims_banner.vars.value);
  var recs = orders.split("]");
  var header = recs[0];
  return header;
}

function writeHeader(header) {
  var orders = new String(top.kims_banner.vars.value);
  if (orders.indexOf("]") == orders.lastIndexOf("]")) {
    top.kims_banner.vars.value = header + "]";
  } else 
  {
    orders = header+ "]" + orders.substr(eval(orders.indexOf("]")+1),orders.length);
    top.kims_banner.vars.value = orders;
   }
}

function showInfo() {
  width=640;
  height=575;
  var win = window.open("", 'infowin', "height=" + height, "width="+width);
  win.focus( );
  var text = "";
  text += "<HTML><HEAD><TITLE>Info</TITLE></HEAD><BODY BGCOLOR='#d7d7d7'>";
  text += '<TABLE width=500 border="0" cellpadding="0" cellspacing="0" justify="center"><TR> <TD > <CENTER> ';
  text += "Kim's Chinese & Sushi Takeout <BR> 3712 East Tremont Ave. <BR> Bronx, New York  10465<BR> ";
  text += "(718) 239-3335 / (718) 239-2225 <BR><BR></TD></TR>";
  text += "<TR> <TD> <IMG src='images/kims_map.jpg'></TD></TR></TABLE></BODY></HTML>";
  win.document.write(text);
  win.document.close();
  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName=="Netscape") {
      win.outerWidth=width;
      win.outerHeight=height;
    }
   else win.resizeTo(width,height);
   }
}


function formatCurrency(num) {
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num))
  num = "0";
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  cents = num%100;
  num = Math.floor(num/100).toString();
  if(cents<10)
  cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
  num = num.substring(0,num.length-(4*i+3))+','+
  num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + '$' + num + '.' + cents);
}



function addtofavorites() {
    title = "Kim's Chinese & Sushi Take Out";
    url = "http://www.kims-sushi.com";
    if (window.sidebar) {
        window.sidebar.addpanel(title, url, "");
    } else if(document.all) {
      top.external.AddFavorite(url, title);
    } else {
        alert("your browser does not support this");
    }
}


