function setCheckShorthand ()
{
   if(top.topframe.document.orderform.shipdest[0].checked == true) { ship2usa = 1 } else { ship2usa = 0 }
   if(top.topframe.document.orderform.shipdest[1].checked == true) { ship2can = 1 } else { ship2can = 0 }
   if(top.topframe.document.orderform.shipdest[2].checked == true) { ship2intl = 1 } else { ship2intl = 0 }

   if (top.topframe.document.orderform.cb_life.checked == true)   { orderlife = 1 }   else { orderlife = 0 }
   if (top.topframe.document.orderform.cb_ptbook.checked == true) { orderptbook = 1 } else { orderptbook = 0 }
   if (top.topframe.document.orderform.cb_jsbook.checked == true) { orderjsbook = 1 } else { orderjsbook = 0 }
}

function checkOrder()
{
   setCheckShorthand ();

   if((orderlife == 0)&&(orderptbook == 0)&&(orderjsbook == 0))
   {
      alert("Please choose an item to order.");
   }
   else
   {
      if((ship2usa == 0)&&(ship2can == 0)&&(ship2intl == 0))
      {
         if((orderptbook == 1)||(orderjsbook == 1))
         {
            alert("Please choose a shipping destination.");
         }
         else
         {
            evaluateshipping();
            evaluateprices();
            make_buysection();
            buildIntermediatePage();
         }
      }
      else
      {
         evaluateshipping();
         evaluateprices();
         make_buysection();
         buildIntermediatePage();
      }
   }
}





function evaluateshipping ()
{
   //what is shipping destination?
   if(ship2usa == 1) { shipdest = "usa"; }
   else if(ship2can == 1) { shipdest = "can"; }
   else if(ship2intl == 1) { shipdest = "intl"; }

   //ptbook only
   if((orderptbook == 1)&&(orderjsbook == 0))
   {
      if(shipdest == "usa") { amt_shipping = pt_usa; }
      else if(shipdest == "can") { amt_shipping = pt_can; }
      else if(shipdest == "intl") { amt_shipping = pt_intl; }
   }
   //jsbook only
   else if((orderptbook == 0)&&(orderjsbook == 1))
   {
      if(shipdest == "usa") { amt_shipping = js_usa; }
      else if(shipdest == "can") { amt_shipping = js_can; }
      else if(shipdest == "intl") { amt_shipping = js_intl; }
   }
   //bothbooks
   else if((orderptbook == 1)&&(orderjsbook == 1))
   {
      if(shipdest == "usa") { amt_shipping = both_usa; }
      else if(shipdest == "can") { amt_shipping = both_can; }
      else if(shipdest == "intl") { amt_shipping = both_intl; }
   }
   //nobooks
   else if((orderptbook == 0)&&(orderjsbook == 0))
   {
      amt_shipping = 0;
   }
}



function evaluateprices()
{
   //life only
   if((orderlife == 1)&&(orderptbook == 0)&&(orderjsbook == 0))
   {
      amt_life = g_life;
      amt_ptbook = 0;
      amt_jsbook = 0;
      productno = 110;
   }
   //ptbook only
   else if((orderlife == 0)&&(orderptbook == 1)&&(orderjsbook == 0))
   {
      amt_life = 0;
      amt_ptbook = g_ptbook;
      amt_jsbook = 0;
      productno = 130;
   }
   //jsbook only
   else if((orderlife == 0)&&(orderptbook == 0)&&(orderjsbook == 1))
   {
      amt_life = 0;
      amt_ptbook = 0;
      amt_jsbook = g_jsbook;
      productno = 150;
   }
   //ptbook + membership
   else if((orderlife == 1)&&(orderptbook == 1)&&(orderjsbook == 0))
   {
      amt_life = g_life_reduced;
      amt_ptbook = g_ptbook;
      amt_jsbook = 0;
      productno = 190;
   }
   //jsbook + membership
   else if((orderlife == 1)&&(orderptbook == 0)&&(orderjsbook == 1))
   {
      amt_life = g_life_reduced;
      amt_ptbook = 0;
      amt_jsbook = g_jsbook;
      productno = 210;
   }
   //ptbook + jsbook
   else if((orderlife == 0)&&(orderptbook == 1)&&(orderjsbook == 1))
   {
      amt_life = 0;
      amt_ptbook = g_ptbook_reduced;
      amt_jsbook = g_jsbook_reduced;
      productno = 170;
   }
   //ptbook & jsbook + membership
   else if((orderlife == 1)&&(orderptbook == 1)&&(orderjsbook == 1))
   {
      amt_life = g_life_reduced;
      amt_ptbook = g_ptbook_reduced;
      amt_jsbook = g_jsbook_reduced;
      productno = 230;
   }
   else
   {
      alert("Houston... we seem to have a problem in evaluateprices\(\).");
   }

   //calculate total & subtotal
   amt_subtotal = amt_life + amt_ptbook + amt_jsbook;

   //fiddle with subtotal to make sure it ends up right
   amt_subtotal = Math.floor(amt_subtotal*100);
   amt_subtotal = amt_subtotal/100;

   //fiddle with total to make sure it ends up right
   amt_total = amt_subtotal + amt_shipping;
   amt_total = Math.floor(amt_total*100);
   amt_total = amt_total/100;

   //consolidate data
   cd_product_number = get_product_number();
   cd_iffnumber = ProductArray[cd_product_number][1];
   cd_3digit = ProductArray[cd_product_number][0];
   cd_life = cent(amt_life);
   cd_ptbook = cent(amt_ptbook);
   cd_jsbook = cent(amt_jsbook);
   cd_ship = cent(amt_shipping);
   cd_subtotal = cent(amt_subtotal);
   cd_total = cent(amt_total);
   cd_desc1 = ProductArray[cd_product_number][2];
   cd_desc3 = cd_3digit + " - " + ProductArray[cd_product_number][2];


   // swap 0.00 for dashes
   if(cd_life == "0.00")   { cd_life = "--"; }
   if(cd_ptbook == "0.00") { cd_ptbook = "--"; }
   if(cd_jsbook == "0.00") { cd_jsbook = "--"; }
   if(cd_ship == "0.00")   { cd_ship = "--"; }

}












