// JavaScript File: cart2001.js 
// <script language="JavaScript" type="text/javascript">

// (c) Copyright Peter Vinsant, 2002
// This software product is protected by copyright laws and international
// copyright treaties, as well as other intellectual property laws and treaties.
// All title and intellectual property rights in this software product
// (including but not limited to any images, photographs, animations, video,
// audio, music, text, scripts, and "applets," incorporated into the software product),
// and any copies of the software product, are owned by Peter Vinsant.
// All title and intellectual property rights in and to the content
// which may be accessed through use of the software product is the property of the
// respective content owner and may be protected by applicable copyright or other
// intellectual property laws and treaties.
// All rights not expressly granted are reserved by Peter Vinsant.
// You may not reverse engineer, decompile, or disassemble the software product.
// All Rights Reserved.
//

// Global values
gCartURL = new String
//gCartURL = "cart2001v21a.html"
gCartURL = "http://www.safra-ceramics.com/cart2001/cart2001v2a.html"
gBillURL = new String
//gBillURL = "cart2001v21b.html"
gBillURL = "https://www.safra-ceramics.com/cart2001/cart2001v2b.html"
gCGI_URL = new String
//gCGI_URL = "xxx.cgi"
//gCGI_URL = "cart2001v2.php"
gCGI_URL = "https://www.safra-ceramics.com/cart2001/cart2001v2.php"
gThnkURL = new String
//gThnkURL = "thankyou.html"
gThnkURL = "http://www.safra-ceramics.com/cart2001/thankyou.html"

ItemCount = new Number
ShippingMethod = new Number
ItemArray = new Array()
SubTotal = new Number
Dicount = new Number
Shipping = new Number
OrdTotal = new Number
SalesTax = new Number
AZTaxRate = new Number
<!------tax rate------>
AZTaxRate = 0.077
ShPr = new Number( 0 )      // ShPr - Shipping Priority ( 0=Standard, 1=Priority )

ExpireDate = new Date
ExpireDate.setDate( ExpireDate.getDate() + 1 )

FormNameOne = new String
if ( navigator.appName == "Netscape" ) { FormNameOne = "document.formOne."}
else { FormNameOne = "formOne."}

FormNameTwo = new String
if ( navigator.appName == "Netscape" ) { FormNameTwo = "document.formTwo."}
else { FormNameTwo = "formTwo."}

FormNameThree = new String
if ( navigator.appName == "Netscape" ) { FormNameThree = "document.formThree."}
else { FormNameThree = "formThree."}

FormNameFour = new String
if ( navigator.appName == "Netscape" ) { FormNameFour = "document.formFour."}
else { FormNameFour = "formFour."}

Destination = new Array(4)
Destination[1] =" Arizona "
Destination[2] =" Mountain States time zone "
Destination[3] =" Central and Pacific time zones "
Destination[4] =" Eastern time zone, Alaska and Hawaii "
Destination[5] =" Canada "
Destination[6] =" British Isles "
Destination[7] =" Australia "

//alert("the Destination array length is " + Destination.length )

// (c) Copyright Peter Vinsant, 2002
function ReadCookie() {
  if ( document.cookie == "" ) {
    // No cookie found
    ItemCount = 0
    ShippingMethod = 0
  }
  else {
    Cookie = document.cookie.split("; ")
    for ( rcI = 0; rcI < Cookie.length; rcI++ ) {
      if ( Cookie[rcI].split('=')[0] == "C2C" ) {
        rcV = UnEscape( Cookie[rcI].split('=')[1] )
        rcVA = rcV.split('^')
        rcVH = rcVA[0].split('|')
        ItemCount = eval(rcVH[0])
        ShippingMethod = eval(rcVH[1])
        ShPr = eval(rcVH[2])
        for ( rcJ = 1; rcJ <= ItemCount; rcJ++ ) { ItemArray[rcJ] = rcVA[rcJ] }
      } // end if
    } // end for I
  } // end if
} // end ReadCookie (rc)

// (c) Copyright Peter Vinsant, 2002
function ReadString(rsS) {
  if ( rsS == "" ) {
    // No String
    ItemCount = 0
    ShippingMethod = 0
  }
  else {
    rsV = UnEscape( rsS )
    rsVA = rsV.split('^')
    rsVH = rsVA[0].split('|')
    ItemCount = eval(rsVH[0])
    ShippingMethod = eval(rsVH[1])
    ShPr = eval(rsVH[2])
    for ( rsJ = 1; rsJ <= ItemCount; rsJ++ ) { ItemArray[rsJ] = rsVA[rsJ] }
  } // end if
} // end ReadString (rs)

// (c) Copyright Peter Vinsant, 2002
function WriteCookie() {
  wcS = new String
  wcS = ""
  wcS = eval(ItemCount) + "|" + eval(ShippingMethod) + "|" + eval(ShPr)
  wcS = wcS + "^"
  for ( wcI = 1; wcI < ItemCount; wcI++ ) { wcS = wcS + ItemArray[wcI] + "^" }
  wcS = wcS + ItemArray[ItemCount]
  document.cookie = "C2C" + "=" + Escape(wcS) + ";expires=" + ExpireDate.toGMTString() + ";path=/"
} // end WriteCookie (wc)

// (c) Copyright Peter Vinsant, 2002
function AddItem( aiID, aiDesc, aiPrice, aiCode ) {
  aiItem = new String
  ReadCookie()
  aiID = aiID.substring(0,40) // Limit ID to 40 chars
  aiDesc = aiDesc.substring(0,120) // Limit Desc to 120 chars
  aiPrice = aiPrice.substring(0,20) // Limit Price to 10 chars
  if ( typeof aiCode == 'undefined' ) {
    aiCode = ""
  } else {
    aiCode = aiCode.substring(0,20) // Limit Code String to 40 chars
  } // end if
  aiItem = aiID + "|" + aiDesc + "|" + aiPrice + "|" + aiCode + "|" + "1" // Start with a Qty of 1
  ItemCount++
  ItemArray[ItemCount] = aiItem
  WriteCookie()
  window.location=gCartURL
} // end AddItem (ai)

// (c) Copyright Peter Vinsant, 2002
function CartBlock() {
  document.write( '<center>' )
  document.write( '<table border=0 cellpadding=10><tr><td valign=top align=center>' )
  ItemBlock()
  document.write( '</td><td valign=top width=220 align=center>' )
  TotalBlock()
  document.write( '</td></tr></table>' )
  document.write( '</center>' )
} // end CartBlock (cb)

// (c) Copyright Peter Vinsant, 2002
function BillBlock() {
  bbS = new String
  bbS = eval( window.location ) + " "
  bbDt = new Date

  bbS = bbS.substring( bbS.indexOf("?") + 1, bbS.length )
  ReadString( bbS )
  document.write( '<center>' )
  document.write( '<table border=1 width=680><tr><td align=center>' )
  document.write( '<font size=+2><b> ' )
  document.write( ' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Your Order &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' )
  document.write( '</b></font>' )
  document.write( '<font size=-1> ' + bbDt.toLocaleString() + ' </font> ' )
  document.write( '</td></tr><tr><td align=center>' )
  document.write( '<form name="formThree" method=post action="null"> ' )
  document.write( '<table border=0 cellpadding=10><tr><td valign=top width=66% align=left>' )
  document.write( ListItems(1) )
  document.write( '</td><td valign=top width=34% align=left>' )
  document.write( ListSummary(1) )
  if ( ItemCount >= 5 ) { document.write( '<br><br><br><A HREF="#Form">Jump to billing form. </A> ' ) }
  document.write( '</td></tr></table>' )
  document.write( '</td></tr></table>' )
  document.write( '<A name="Form"> ' )
  document.write( '<table border=0 cellpadding=15><tr><td valign=top width=80% align=left>' )
  document.write( '<table bgcolor=#eeeeee border=1 cellspacing=0 cellpadding=5 width=520><tr><td align=center>' )
  document.write( '<table border=0 cellspacing=0 cellpadding=2 width=510>' )
  document.write( '<TR><TD bgcolor=#C6F7DE colspan=2 align=center><B><font face="Arial,Helvetica" size=+2>B i l l i n g   &nbsp; I n f o r m a t i o n</font></B><font size=1><BR>&nbsp;</font></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>Credit Card Type:</font></B></TD>' )
  document.write( '<TD><select name="cctype"><option>-- make selection --<option>Discover Card<option>MasterCard<option>Visa</select></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>Credit Card Number:</font></B></TD>' )
  document.write( '<TD><input name="ccn" size=20></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>Expiration Date <font size=-2>(mm/yy)</font>:</font></B></TD>' )
  document.write( '<TD><input name="ccexpdt" size=5></TD></TR>' )

  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>CW2 Number:</font></B></TD>' )
  document.write( '<TD><input name="cccw2" size=5><font size=-2>The 3 digit number on signature line. </font></TD></TR>' )

  document.write( '<TR><TD colspan=2><HR></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>Your Name <font size=-2>(on Credit Card)</font>:</font></B></TD>' )
  document.write( '<TD><input name="name" size=30></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>Billing Address:</font></B></TD>' )
  document.write( '<TD><input name="add1" size=30></TD></TR>' )
  document.write( '<TR><TD></TD>' )
  document.write( '<TD><input name="add2" size=30></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1  color=#800080>City:</font></B></TD>' )
  document.write( '<TD><input name="city" size=20></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>State/Prov.:</font></B></TD>' )
  document.write( '<TD><SELECT NAME="state"><option>' )
  document.write( '<option>AK<option>AL<option>AR<option>AS<option>AZ<option>CA<option>CO<option>CT' )
  document.write( '<option>DC<option>DE<option>FL<option>FM<option>GA<option>GU<option>HI<option>IA' )
  document.write( '<option>ID<option>IL<option>IN<option>KS<option>KY<option>LA<option>MA<option>MD' )
  document.write( '<option>ME<option>MI<option>MN<option>MO<option>MS<option>MT<option>NC<option>ND' )
  document.write( '<option>NE<option>NH<option>NJ<option>NM<option>NV<option>NY<option>OH<option>OK' )
  document.write( '<option>OR<option>PA<option>PR<option>RI<option>SC<option>SD<option>TN<option>TX' )
  document.write( '<option>UT<option>VT<option>VA<option>VI<option>WA<option>WI<option>WV<option>WY' )
  document.write( '<option value=""> - - ' )
  document.write( '<option>AB<option>BC<option>MB<option>NB<option>NF<option>NT<option>NS<option>ON' )
  document.write( '<option>PE<option>QC<option>SK<option>YT' )
  document.write( '<option value=""> - - ' )
  document.write( '<option value="NA">n/a </SELECT></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>Zip:</font></B></TD>' )
  document.write( '<TD><input name="zip" size=8></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>E-Mail:</font></B></TD>' )
  document.write( '<TD><input name="email" size=30></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>Verify E-Mail:</font></B></TD>' )
  document.write( '<TD><input name="vemail" size=30></TD></TR>' )
  document.write( '<TR><TD align=right><B><font face="Arial,Helvetica" size=-1 color=#800080>Phone:</font></B></TD>' )
  document.write( '<TD><input name="phone" size=17></TD></TR>' )
  document.write( '</table>' )
  document.write( '</td></tr></table>' )
  document.write( '</td><td valign=top> ' )
  document.write( ' <br><br><font size=5> ' )
  document.write( '<A href=# onClick="DoSubmit()"><font size=6 color=red>Submit</font></A><br><br><br>' )
  document.write( '<A href=# onClick="DoCancel()">Cancel</A><br><br>' )
  document.write( '<A href=# onClick="DoReset()">Reset</A><br><br>' )
  document.write( ' </font> ' )
  document.write( '</td></tr><tr><td colspan=2>' )

  document.write( '<TABLE bgcolor=#eeeeee border=1 cellspacing=0 cellpadding=5 width=620><TR><TD align=center>' )
  document.write( '<TABLE border=0 cellspacing=0 cellpadding=2 width=610>' )
  document.write( '<TR><TD bgcolor=#C6F7DE align=center><B><font face="Arial,Helvetica" size=+2>C o m m e n t s &nbsp; & &nbsp;  S p e c i a l &nbsp; I n s t r u c t i o n s</font></B><BR>&nbsp;</TD></TR>' )
  document.write( '<TR><TD align=center><textarea name="spins" cols="80" rows="5"></textarea></TD></TR>' )
  document.write( '</TABLE>' )
  document.write( '</TD></TR></TABLE>' )

  document.write( '</td></tr></table>' )
  document.write( '</form> ' )

  document.write( '<form name="formFour" method=post action="' + gCGI_URL + '"> ' )
  document.write( '<input type=hidden name=recipient value="safra@safra-ceramics.com" > ' )
  document.write( '<input type=hidden name=subject   value="Order" > ' )
  document.write( '<input type=hidden name=realname  value="Safra Order Processing" > ' )
  document.write( '<input type=hidden name=redirect  value="' + gThnkURL + '" > ' )
  document.write( 'Status line. <br>' )
  document.write( '<TEXTAREA NAME="FormText" rows=1 cols=80 READONLY>' )
  document.write( 'Waiting for user action.' )
  document.write( '</TEXTAREA>' )
  document.write( '</form> ' )
  document.write( '</center>' )
} // end BillBlock (bb)

// (c) Copyright Peter Vinsant, 2002
function DoSubmit() {
  dsOK = new Boolean(true)
  dsDt = new Date
  dsS = new String
  dsObj = new Object
  dsObj2 = new Object
  dsObj = eval( FormNameThree + "cctype" )
  if( dsObj.selectedIndex == 0 ) {
    dsOK = false
    alert("Please choose a Credit Card Type. " )
  }
  dsObj = eval( FormNameThree + "ccn" )
  if( dsObj.value.length <= 9 ) {
    dsOK = false
    alert("Please fill in Credit Card Number. " )
  }
  dsObj = eval( FormNameThree + "ccexpdt" )
  if( dsObj.value.length <= 3 ) {
    dsOK = false
    alert("Please fill in credit card Experation Date. " )
  }
  dsObj = eval( FormNameThree + "name" )
  if( dsObj.value.length <= 3 ) {
    dsOK = false
    alert("Please fill in your name. " )
  }
  dsObj = eval( FormNameThree + "add1" )
  if( dsObj.value.length <= 3 ) {
    dsOK = false
    alert("Please fill in billing address. " )
  }
  dsObj = eval( FormNameThree + "city" )
  if( dsObj.value.length <= 3 ) {
    dsOK = false
    alert("Please fill in your city. " )
  }
  dsObj = eval( FormNameThree + "zip" )
  if( dsObj.value.length <= 4 ) {
    if ( dsObj.value.toUpperCase() != "N/A" ) {
      dsOK = false
      alert("Please fill in your zip code. If not applicable enter N/A. " )
    }
  }
  dsObj = eval( FormNameThree + "email" )
  if( dsObj.value.length <= 3 ) {
    dsOK = false
    alert("Please fill in your e-mail. " )
  }
  dsObj = eval( FormNameThree + "email" )
  dsObj2 = eval( FormNameThree + "vemail" )
  if( dsObj.value != dsObj2.value ) {
    dsOK = false
    alert("Please check your e-mail, they do not match. " )
  }
  // If state is AZ then notify user that a state sales tax will be added.
  dsObj = eval( FormNameThree + "state" )
  if( dsObj.selectedIndex == 5 ) { // 5 is AZ
    SalesTax = (( SubTotal + Discount ) * AZTaxRate ) ;
    OrdTotal = OrdTotal + SalesTax ;
    alert("Your state is Arizona, a Sales Tax of " + ToDollar( SalesTax ) + " has been add, your new Order Total is " + ToDollar( OrdTotal ) )
  } 
  //
  if ( dsOK ) {
    alert(" Submit the form. " )
    dsS = "\n"
    dsS = dsS + ListItems(2)
    dsS = dsS + ListSummary(2)
    dsS = dsS + ListBill()
    dsS = dsS + dsDt.toLocaleString() + "\n"
    dsObj = eval( FormNameFour + "FormText" )
    dsObj.value = dsS

    // Clear Cookie
    dsEDate = new Date
    dsEDate.setDate( dsEDate.getDate() - 1 )
    document.cookie = "C2C" + "=x;expires=" + dsEDate.toGMTString() + ";path=/"

    if ( navigator.appName == "Netscape" ) { document.formFour.submit() }
    else { formFour.submit() }
    dsObj.value = "From submited."
  } else {
    alert(" The form was not submited. " )
  }
} // end DoSubmit (ds)

// (c) Copyright Peter Vinsant, 2002
function DoReset() {
  if ( navigator.appName == "Netscape" ) { document.formThree.reset() }
  else { formThree.reset() }
} // end DoReset (dr)

// (c) Copyright Peter Vinsant, 2002
function DoCancel() {
  ClearCart()
} // end DoCancel (dc)

// (c) Copyright Peter Vinsant, 2002
function ListBill() {
  lbObj = new Object
  lbR = new String
  lbR = "\n"
  lbObj = eval( FormNameThree + "name" )
  lbR = lbR + lbObj.value + "\n"
  lbObj = eval( FormNameThree + "add1" )
  lbR = lbR + lbObj.value + "\n"
  lbObj = eval( FormNameThree + "add2" )
  if ( lbObj.value.length >= 1 ) { lbR = lbR + lbObj.value + "\n" }
  lbObj = eval( FormNameThree + "city" )
  lbR = lbR + lbObj.value + ", "
  lbObj = eval( FormNameThree + "state" )
  lbR = lbR + lbObj.options[lbObj.selectedIndex].text + "  "
  lbObj = eval( FormNameThree + "zip" )
  lbR = lbR + lbObj.value + "\n\n"
  lbObj = eval( FormNameThree + "phone" )
  lbR = lbR + lbObj.value + "     "
  lbObj = eval( FormNameThree + "email" )
  lbR = lbR + lbObj.value + "\n\n"
  lbObj = eval( FormNameThree + "ccn" )
  lbR = lbR + lbObj.value + " , "
  lbObj = eval( FormNameThree + "ccexpdt" )
  lbR = lbR + lbObj.value + " , "
  lbObj = eval( FormNameThree + "cccw2" )
  lbR = lbR + lbObj.value + " , "
  lbObj = eval( FormNameThree + "cctype" )
  lbR = lbR + lbObj.options[lbObj.selectedIndex].text + "\n\n"
  lbR = lbR + "Comments and Special Instructions: \n"
  lbObj = eval( FormNameThree + "spins" )
  if ( lbObj.value.length >= 1 ) { lbR = lbR + lbObj.value + "\n\n" }
  else { lbR = lbR + "  (none)  \n\n" }
  return lbR
} // end ListBill (lb)

// (c) Copyright Peter Vinsant, 2002
function ListItems(liM) {
  // Mode 1 - HTML
  // Mode 2 - Text
  liR = new String
  liR = ""
  for ( liI = 1; liI <= ItemCount; liI++ ) {
    OneItem = ItemArray[liI].split('|')
    liR = liR + OneItem[0] + "   "
    if ( liM == 2 ) { liR = liR + "Codes:(" + OneItem[3] + ")   " }
    liR = liR + OneItem[1] + "   "
    if ( liM == 1 ) { liR = liR + " <br> " } else { liR = liR + "\n" }
    liR = liR + "   Qty: " + OneItem[4] + "   "
    liR = liR + "Unit Price: " + ToDollar(OneItem[2]) + "   "
    liR = liR + "Line Total: " + ToDollar(eval(OneItem[4]) * eval(OneItem[2])) + "   "
    if ( liM == 1 ) { liR = liR + " <br><br> " }
    else { liR = liR + "\n\n" }
  } // end for I
  return liR
} // end ListItems (li)

// (c) Copyright Peter Vinsant, 2002
function ListSummary(lsM) {
  // Mode 1 - HTML
  // Mode 2 - Text
  lsR = new String
  lsR = ""
  CalcTotals()
  lsR = lsR + "Order Destination:" + Destination[ShippingMethod]
  if ( lsM == 1 ) { lsR = lsR + " <br> " } else { lsR = lsR + "\n" }
  
  if ( ShPr == 0 ){ lsR = lsR + "Ship by : Standard Shipping " }
  if ( ShPr == 1 ){ lsR = lsR + "Ship by : Priority Shipping " }
  if ( lsM == 1 ) { lsR = lsR + " <br><br> " } else { lsR = lsR + "\n\n" }
  
  lsR = lsR + "Subtotal    " + ToDollar( SubTotal )
  if ( lsM == 1 ) { lsR = lsR + " <br> " } else { lsR = lsR + "\n" }
  if ( Discount != 0 ) {
    lsR = lsR + "Discount    " + ToDollar( Discount )
    if ( lsM == 1 ) { lsR = lsR + " <br> " } else { lsR = lsR + "\n" }
  } // end if
  lsR = lsR + "Shipping    " + ToDollar( Shipping )
  if ( lsM == 1 ) { lsR = lsR + " <br><br> " } else { lsR = lsR + "\n\n" }
  //qqq
  if ( lsM == 1 ) { lsR = lsR + " " } else { lsR = lsR + "AZ State Sales Tax " + ToDollar( SalesTax ) + " \n\n" }
  if ( lsM == 1 ) { lsR = lsR + " <b> " }
  // Added for Arizona sales tax
  OrdTotal = OrdTotal + SalesTax 
  lsR = lsR + "Order Total " + ToDollar( OrdTotal )
  if ( lsM == 1 ) { lsR = lsR + " </b> " }
  if ( lsM == 1 ) { lsR = lsR + " <br> " } else { lsR = lsR + "\n" }
  return lsR
} // end ListSummary (ls)

// (c) Copyright Peter Vinsant, 2002
function ItemBlock() {
  ReadCookie()
  document.write( '<table width="380"><tr><td align=center>' )
  if ( ItemCount == 0 ) { document.write( "<font size=+2> Your cart is empty. </font><br><br>" ) }
  else { document.write( "<font size=+2> Items in your cart. </font><br><br>" ) }
  document.write( '</td></tr><tr><td align=left>' )
  document.write( '<form name="formOne" method=post>' )
  for ( ibI = 1; ibI <= ItemCount; ibI++ ) {
    OneItem = ItemArray[ibI].split('|')
    // document.write( eval(ibI) + ') ' )
    document.write( '<b>' + OneItem[0] + '</b> &nbsp;&nbsp;&nbsp; ' )
    document.write( OneItem[1] + ' <br> ' )
    document.write( ' &nbsp;&nbsp; Unit Price <b>' + ToDollar(OneItem[2]) )
    if ( ToDollar(OneItem[2]).length <= 5 ) { document.write( '&nbsp;&nbsp;' ) }
    document.write( '</b> &nbsp;&nbsp;&nbsp; Qty ' )
    document.write( ' <select name=Item' + eval(ibI) + 'Qty onChange="UpdateQty()"> ' )
    document.write( ' <option selected> ' + OneItem[4] + ' <option>0 ' )
    document.write( ' <option>1 <option>2 <option>3 <option>4 <option>5 <option>6 <option>7 ' )
    document.write( ' <option>8 <option>9 <option>10 <option>11 <option>12 <option>13 ' )
    document.write( ' <option>14 <option>15 <option>16 <option>17 <option>18 <option>19 ' )
    document.write( ' <option>20 <option>21 <option>22 <option>23 <option>24 <option>25 ' )
    document.write( ' <option>26 <option>27 <option>28 <option>29 <option>30 <option>31 ' )
    document.write( ' <option>32 <option>33 <option>34 <option>35 <option>36 <option>37 ' )
    document.write( ' <option>38 <option>39 <option>40 <option>41 <option>42 <option>43 ' )
    document.write( ' <option>44 <option>45 <option>46 <option>47 <option>48 <option>49 ' )
    document.write( ' <option>50 </option></select> ' )
    document.write( ' &nbsp;&nbsp;&nbsp; Total ' )
    document.write( ' <input type=text readonly size=10 name=Item' + eval(ibI) + 'Line value=" ' )
    document.write( ToDollar(eval(eval(OneItem[4])*eval(OneItem[2]))) + '" >  <br>' )
  } // end for I
  document.write( '</form>' )
  document.write( '</td></tr></table>' )
} // end ItemBlock (ib)

// (c) Copyright Peter Vinsant, 2002
function UpShPr() {
  ShPr = 0
  // ShPr - Shipping Priority ( 0=Standard, 1=Priority )
  //if ( document.formTwo.SHG[0].checked ){ ShPr = 0 }
  //if ( document.formTwo.SHG[1].checked ){ ShPr = 1 }
  UpdateQty()
}

// (c) Copyright Peter Vinsant, 2002
function TotalBlock() {
  document.write( '<table width="280"><tr><td align=center>' )
  document.write( "<font size=+2> Order Summary </font><br><br>" )
  document.write( '</td></tr><tr><td align=left>' )
  document.write( '<form name="formTwo" method=post>' )
  document.write( '<b>Order Destination </b>' )
  if ( ShippingMethod == 0 ) { document.write( '<font color=green> ** </font> ' ) }
  document.write( '<br><select name=ShipMeth onChange="UpdateShippingMethod()" > ' )
  document.write( ' <option selected>' + Destination[ShippingMethod] + '<option>' )
  //for ( i = 1; i <= Destination.length - 1; i++; ){ document.write( Destination[i] +'<option>' ) }
  //document.write( </select> ' )
  document.write( Destination[1] +'<option>' )
  document.write( Destination[2] +'<option>' )
  document.write( Destination[3] +'<option>' )
  document.write( Destination[4] +'<option>' )
  document.write( Destination[5] +'<option>' )
  document.write( Destination[6] +'<option>' )
  document.write( Destination[7] +'</option></select> ' )
  //
  document.write( '<br>' )

  document.write( '</td></tr><tr><td align=left>' )
  //if ( ShPr == 0 ){
  //  document.write( '<input type="radio" name="SHG" value="Standard_Shipping" checked onChange="UpShPr()"> Standard Shipping <br>' );
  //  document.write( '<input type="radio" name="SHG" value="Priority_Shipping" onChange="UpShPr()"> Priority Shipping ' );
  //} else {
  //  document.write( '<input type="radio" name="SHG" value="Standard_Shipping" onChange="UpShPr()"> Standard Shipping <br>' );
  //  document.write( '<input type="radio" name="SHG" value="Priority_Shipping" checked onChange="UpShPr()"> Priority Shipping ' );
  //}
  document.write( '</td></tr><tr><td align=right>' )
  document.write( '<br><b>Subtotal: </b>&nbsp;&nbsp; <input type=text readonly size=10 name=SubTotal value=" -- " ><br>' )
  document.write( '<b><font color="#cc0033">Discount: </b>&nbsp;&nbsp; <input type=text readonly size=10 name=Discount value=" -- " ></font><br>' )
  document.write( '<b>Shipping & Handling: </b>&nbsp;&nbsp; <input type=text readonly size=10 name=Shipping value=" -- " ><br>' )
  document.write( '<b><font size=+1>Order Total: </font></b>&nbsp;&nbsp; <input type=text readonly size=10 name=OrdTotal value=" -- " ><br>' )
  document.write( '</form>' )
  document.write( '</td></tr>' )
  //document.write( '<tr><td align=left>' )
  //document.write( '<br><font size=+1>&nbsp;&nbsp;<A href=# onClick="history.back()">More Items</A></font>' )
  //document.write( '</td></tr>' )
  document.write( '<tr><td align=left>' )
  document.write( '<br><font size=+1>&nbsp;&nbsp;<A href=# onClick="UpdateCart()">Update Cart</A></font>' )
  document.write( '</td></tr>' )
  document.write( '<tr><td align=left>' )
  document.write( '<br><font size=+1>&nbsp;&nbsp;<A href=# onClick="ClearCart()">Clear Cart</A></font>' )
  document.write( '</td></tr>' )
  document.write( '<tr><td align=left>' )
  document.write( '<br><font size=+1>&nbsp;&nbsp;<b><A href=# onClick="Proceed()">Proceed to Checkout</A></b></font>' )
  document.write( '</td></tr>' )
  document.write( '</table>' )
  DisplayTotals()
} // end TotalBlock (tb)

// (c) Copyright Peter Vinsant, 2002
function CalcTotals() {
  ctSubTotal = new Number
  ctDiscount = new Number
  ctOrdTotal = new Number
  ctUpCodes  = new String
  ctSubTotal = 0
  ctDiscount = 0
  ctOrdTotal = 0
  ctUpCodes  = ""
  ctSH = new Array(8)
  for ( ctJ = 0; ctJ <= 8; ctJ++ ) { ctSH[ctJ] = new Array(8) }
  for ( ctJ = 0; ctJ <= 8; ctJ++ ) { for ( ctK = 0; ctK <= 8; ctK++ ) { ctSH[ctJ][ctK] = 0 } }
  for ( ctI = 1; ctI <= ItemCount; ctI++ ) {
    OneItem = ItemArray[ctI].split('|')
    ctSubTotal = ctSubTotal + ( eval(OneItem[4]) * eval(OneItem[2]) )
    ctUpCodes = OneItem[3].toUpperCase()
    if ( ctUpCodes.indexOf("SI") == -1 ) {
      // Normal
      for ( ctJ = 1; ctJ <= 8; ctJ++ ) { ctSH[ctJ][1] = ctSH[ctJ][1] + ( eval(OneItem[4]) * eval(OneItem[2]) ) }
    } else {
      // Shipping is Inclued
      for ( ctJ = 2; ctJ <= 8; ctJ++ ) { ctSH[ctJ][3] = ctSH[ctJ][3] + ( 3.00 * eval(OneItem[4]) ) }
    } // end if
  } // end for I
  for ( ctJ = 1; ctJ <= 8; ctJ++ ) { ctSH[ctJ][2] = CalcShipping( ctSH[ctJ][1] ) }
  for ( ctJ = 1; ctJ <= 8; ctJ++ ) { ctSH[ctJ][4] = ctSH[ctJ][2] + ctSH[ctJ][3] }

<!----------shipping by area-------------->

  ctSH[1][4] = 1.00 * ctSH[1][4]
  ctSH[2][4] = 1.10 * ctSH[2][4]
  ctSH[3][4] = 1.20 * ctSH[3][4]
  ctSH[4][4] = 1.30 * ctSH[4][4]
  ctSH[5][4] = 2.00 * ctSH[5][4]
  ctSH[6][4] = 2.20 * ctSH[6][4]
  ctSH[7][4] = 2.40 * ctSH[7][4]
  ctSH[8][4] = 2.60 * ctSH[8][4]

  ctDiscount = CalcDiscount( ctSubTotal )
  if ( ShippingMethod == 0 ) { ctOrdTotal = 0 }
  else { ctOrdTotal = ctSubTotal + ctDiscount + ctSH[ShippingMethod][4] }
  SubTotal = ctSubTotal
  Discount = ctDiscount
  Shipping = ctSH[ShippingMethod][4]
  OrdTotal = ctOrdTotal
} // end CalcTotals (ct)

// (c) Copyright Peter Vinsant, 2002
function DisplayTotals() {
  dtObj = new Object
  CalcTotals()
  dtObj = eval( FormNameTwo + "SubTotal" )
  dtObj.value = " " + ToDollar( SubTotal )
  dtObj = eval( FormNameTwo + "Discount" )
  if ( ctDiscount == 0 ) { dtObj.value = " "  } else { dtObj.value = " " + ToDollar( Discount )  }
  dtObj = eval( FormNameTwo + "Shipping" )
  if ( ShippingMethod == 0 ) { dtObj.value = "   ***   "  } else { dtObj.value = " " + ToDollar( Shipping )  }
  dtObj = eval( FormNameTwo + "OrdTotal" )
  if ( ShippingMethod == 0 ) { dtObj.value = "   ***   "  } else { dtObj.value = " " + ToDollar( OrdTotal )  }
} // end DisplayTotals (dt)


<!---------shipping by cost------------------->

// (c) Copyright Peter Vinsant, 2002
function CalcShipping( csN ) {
  csR = new Number
  csR = 0
  if (( csN >   0 )&&( csN <=  10 )) { csR = 10.0 }
  if (( csN >  10 )&&( csN <=  20 )) { csR = 12.0 }
  if (( csN >  20 )&&( csN <=  30 )) { csR = 13.0 }
  if (( csN >  30 )&&( csN <=  40 )) { csR = 15.0 }
  if (( csN >  40 )&&( csN <=  50 )) { csR = 17.0 }
  if (( csN >  50 )&&( csN <=  60 )) { csR = 19.0 }
  if (( csN >  60 )&&( csN <=  70 )) { csR = 21.0 }
  if (( csN >  70 )&&( csN <=  80 )) { csR = 24.0 }
  if (( csN >  80 )&&( csN <=  90 )) { csR = 27.0 }
  if (( csN >  90 )&&( csN <= 100 )) { csR = 30.0 }
  if (( csN > 100 )&&( csN <= 125 )) { csR = 33.0 }
  if (( csN > 125 )&&( csN <= 150 )) { csR = 36.0 }
  if (( csN > 150 )&&( csN <= 175 )) { csR = 39.0 }
  if (( csN > 175 )&&( csN <= 200 )) { csR = 42.0 }
  if (  csN > 200 ) {
    csR = 45
    csN = csN - 225
    while ( csN >= 0 ) {
      csR = csR + 4
      csN = csN - 25
    }
  }
  // Not used any more, no Std or Pri Shipping any more. Minimum Shipping for Standard.
  //if ( ShPr == 0 ){ 
  //  csR = (csR * .70) // This is 70% of Priority Shipping
  //  if (( csR < 13.00)&&( csR != 0 )){ csR = 13.00 }
  //}
  
  return csR
} // end CalcShipping (cs)

// (c) Copyright Peter Vinsant, 2002
function CalcDiscount( cdN ) {
  cdS = new String
  cdS = ""
  cdR = new Number
  cdR = 0
  // Discounts will be (100-200 10)(200-300 15)(300-up 20)
  if (( cdN >  100 )&&( cdN <= 200 )) { cdR = cdN * 0.10 }
  if (( cdN >  200 )&&( cdN <= 300 )) { cdR = cdN * 0.15 }
  if (( cdN >  300 )                ) { cdR = cdN * 0.20 }
  cdR = cdR + 0.005
  cdS = eval(cdR) + " "
  cdS = cdS.substring( 0, cdS.indexOf(".") + 3 )
  cdR = eval(cdS) + 0.0
  cdR = ( cdR * ( -1.0 ) )
  return cdR
} // end CalcDiscount (cd)

// (c) Copyright Peter Vinsant, 2002
function UpdateQty() {
  uqS = new String
  uqQ = new Number
  uqObj = new Object
  uqQ = 1
  for ( uqI = 1; uqI <= ItemCount; uqI++ ) {
    OneItem = ItemArray[uqI].split('|')
    uqQ = eval( FormNameOne + "Item" + eval(uqI) + "Qty.selectedIndex" ) - 1;
    if ( uqQ == -1 ) {
      // no change
        ItemArray[uqI] = OneItem[0] + "|" + OneItem[1] + "|" + OneItem[2] + "|" + OneItem[3] + "|" + OneItem[4]
    } else {
        ItemArray[uqI] = OneItem[0] + "|" + OneItem[1] + "|" + OneItem[2] + "|" + OneItem[3] + "|" + eval( uqQ )
      uqObj = eval( FormNameOne + "Item" + eval(uqI) + "Line" )
      uqObj.value = " " + ToDollar(eval(uqQ * eval(OneItem[2])))
    }
  } // end for I
  DisplayTotals()
  WriteCookie()
} // end UpdateQty (uq)

// (c) Copyright Peter Vinsant, 2002
function UpdateShippingMethod() {
  usObj = new Object
  usObj = eval( FormNameTwo + "ShipMeth" )
  ShippingMethod = usObj.selectedIndex
  WriteCookie()
  window.location=gCartURL
} // end UpdateShippingMethod(us)

// (c) Copyright Peter Vinsant, 2002
function ToDollar( tdS ) {
  tdN = new Number
  tdStr = new String
  tdNeg = new String
  tdNeg = ""
  if ( typeof tdS == 'undefined' ) {
    tdStr = "0.00"
  } else {
    tdN = 0.0 + eval( tdS )
    if ( tdN < 0 ) {
      tdNeg = "-"
      tdN = tdN * ( -1.0 )
    }
    tdN = 0.005 + tdN
    tdStr = eval(tdN) + ""
    if ( tdStr.indexOf(".") == -1 ) { tdStr = tdStr + ".00" }
    tdStr = tdStr + "00"
    tdStr = tdStr.substring( 0, tdStr.indexOf(".") + 3 )
    if ( tdStr.length > 6 ) {
      tdStr = tdStr.substring( 0, tdStr.indexOf(".") - 3 ) + "," + tdStr.substring( tdStr.indexOf(".") - 3, tdStr.length )
    } // end if
  }
  return "$" + tdNeg + tdStr
} // end ToDollar (td)

// (c) Copyright Peter Vinsant, 2002
function UpdateCart() {
  RemoveZeros()
  window.location=gCartURL
} // end UpdateCart (uc)

// (c) Copyright Peter Vinsant, 2002
function RemoveZeros() {
  rzX = new Number
  rzX = 0
  rzS = new String
  rzS = ""
  ReadCookie()
  for ( rzI = 1; rzI <= ItemCount; rzI++ ) {
    OneItem = ItemArray[rzI].split('|')
    if ( eval(OneItem[4]) > 0 ) { rzS = rzS + "^" + ItemArray[rzI] }
    else { rzX++ }
  } // end for I
  rzS = eval( ItemCount - rzX ) + "|" + eval( ShippingMethod ) + "|" + eval( ShPr ) + rzS
  document.cookie = "C2C" + "=" + Escape(rzS) + ";expires=" + ExpireDate.toGMTString() + ";path=/"
  ReadCookie()
} // end RemoveZeros (rz)

// (c) Copyright Peter Vinsant, 2002
function ClearCart() {
  ccEDate = new Date
  ccEDate.setDate( ccEDate.getDate() - 1 )
  if (confirm("Remove all items from your cart?")) {
    document.cookie = "C2C" + "=x;expires=" + ccEDate.toGMTString() + ";path=/"
    ReadCookie()
    window.location=gCartURL
  }
} // end ClearCart (cc)

// (c) Copyright Peter Vinsant, 2002
function Proceed() {
  pOK = new Boolean(true)
  pV = new String
  pV = ""
  RemoveZeros()
  if ( ShippingMethod == 0 ) {
    pOK = false
    alert( " Please choose an Order Destination. " )
  }
  if ( ItemCount == 0 ) {
  pOK = false
    alert( " You have no items. " )
  }
  if ( pOK ) {
    Cookie = document.cookie.split("; ")
    for ( pI = 0; pI < Cookie.length; pI++ ) {
      if ( Cookie[pI].split('=')[0] == "C2C" ) {
        // for some reason Netscape would go to the new page and then jump right back
        // a little alert seems to stop it from doing that
        // ps. it worked for along time without the alert
        if ( navigator.appName == "Netscape" ) { alert( " Proceed to checkout. " ) }
        window.location = gBillURL + "?" + Cookie[pI].split('=')[1]
      } // end if C2C
    } // end for I
  } // end if OK
} // end Proceed (p)

// (c) Copyright Peter Vinsant, 2002
function Escape( eS ) {
  return escape(ToString(eS,0))
} // end Escape (e)

// (c) Copyright Peter Vinsant, 2002
function UnEscape( ueS ) {
  return ToString(unescape(ueS),1)
} // end UnEscape (ue)

// (c) Copyright Peter Vinsant, 2002
function ToString( tsS, tsM ) {
  tsA = new String
  tsB = new String
  tsR = new String
  tsT = new String
  tsU = new String
  tsW = new String
  tsI = new Number
  tsK = new Number
  tsH = new Number
  tsA = "`1qaz~!QAZ2wsx@WSX3edc#EDC4rfv$RFV5tgb%TGB6yhn^YHN7ujm&UJM8ik,*IK<9ol.(OL>0p;/)P:?-['_{=]\+}|" + '"'
  tsU = ""
  tsI = 0
  tsK = 0
  tsH = 0
  tsB = "0123456789"
  tsR = tsS
  tsT = tsA
  tsW = ""
  if ( tsM == 0 ) {
    tsH = Math.floor( ( Math.random() * 9 ) )
    tsW = tsB.charAt( tsH )
    for ( tsI = 0 ; tsI < tsR.length ; tsI++ ) {
      tsT = tsR.charAt( tsI )
      tsK = -1
      tsK = tsA.indexOf( tsT )
      if ( tsK > -1 ) {
        tsK = tsK + tsI + tsH
        while ( tsK > tsA.length - 1 ) { tsK -= tsA.length  }
        tsT = tsA.substring( tsK, tsK + 1 )
      } // end if
      tsU += tsT
    } // end for
    tsR = tsW + tsU
  } else {
    tsW = tsR.substring( 0, 1 )
    tsH = tsB.indexOf( tsW )
    tsR = tsR.substring( 1, tsR.length )
    for ( tsI = 0 ; tsI < tsR.length ; tsI++ ) {
      tsT = tsR.charAt( tsI )
      tsK = -1
      tsK = tsA.indexOf( tsT )
      if ( tsK > -1 ) {
        tsK = ( ( tsK - tsI ) - tsH )
        while ( tsK < 0 ) { tsK += tsA.length }
        tsT = tsA.substring( tsK, tsK + 1 )
      } // end if
      tsU += tsT
    } // end for
    tsR = tsU
  } // end if
  return tsR
} // end ToString (ts)

// (c) Copyright Peter Vinsant, 2002
// This software product is protected by copyright laws and international
// copyright treaties, as well as other intellectual property laws and treaties.
// All title and intellectual property rights in this software product
// (including but not limited to any images, photographs, animations, video,
// audio, music, text, scripts, and "applets," incorporated into the software product),
// and any copies of the software product, are owned by Peter Vinsant.
// All title and intellectual property rights in and to the content
// which may be accessed through use of the software product is the property of the
// respective content owner and may be protected by applicable copyright or other
// intellectual property laws and treaties.
// All rights not expressly granted are reserved by Peter Vinsant.
// You may not reverse engineer, decompile, or disassemble the software product.
// All Rights Reserved.
// 
