// This js developed by Darbie Marlin, Darbie@WebMaker-nw.com
// and Runway-WebMaker - web development services 509-328-8680 

// -- This function returns currency values with two decimal places 
  function prec2(value)
  {
    var result = "$" + Math.floor(value) + ".";
    var cents = 100*(value - Math.floor(value))+0.5;
    result += Math.floor(cents/10);
    result += Math.floor(cents%10);
    return result;
  }
// End of function prec2 definition ---
  
// -- Order Form Calculation script --------- last modified 3/31/04 ---

<!-- Hide from other browsers
function quote(form)
{

var pik_price = 1.98 ;
var q_items = 0 ;
var q_piks = 0 ;
var subtotal = 0 ;
var vld = "y" ;
form.note1.value = "" ;

// ------------------------------------------------- Brass Piks ------------------
// -- Line One -------------
var qty =  form.qty_b_md.value * 1;
	if ( isNaN(qty) ) { 
		qty = 0; 
		vld = "n"; 
		form.qty_b_md.value = 0 ; }
var price = pik_price ;
var line = price * qty;
form.brass_md.value  = (qty == 0) ? ' ' : prec2(line);
q_items += qty;
q_piks += qty;
subtotal += line;

// -- Line Two -------------
qty =  form.qty_b_lg.value * 1;
	if ( isNaN(qty) ) { 
		qty = 0; 
		vld = "n"; 
		form.qty_b_lg.value = 0 ; }
price = pik_price ;
line = price * qty;
form.brass_lg.value  = (qty == 0) ? ' ' : prec2(line);
q_items += qty;
q_piks += qty;
subtotal += line;

// -- Line Three -------------
qty =  form.qty_b_xl.value * 1;
	if ( isNaN(qty) ) { 
		qty = 0; 
		vld = "n"; 
		form.qty_b_xl.value = 0 ; }
price = pik_price ;
line = price * qty;
form.brass_xl.value  = (qty == 0) ? ' ' : prec2(line);
q_items += qty;
q_piks += qty;
subtotal += line;

// -- Line Four -------------
qty =  form.qty_b_set.value * 1;
	if ( isNaN(qty) ) { 
		qty = 0; 
		vld = "n"; 
		form.qty_b_set.value = 0 ; }
price = pik_price ;
line = 3 * price * qty;
form.brass_set.value  = (qty == 0) ? ' ' : prec2(line);
q_items += qty;
q_piks += 3 * qty;
subtotal += line;

// ------------------------------------------------- Plastic Piks ------------------
// -- Line Five -------------
qty =  form.qty_p_sm.value * 1;
	if ( isNaN(qty) ) { 
		qty = 0; 
		vld = "n"; 
		form.qty_p_sm.value = 0 ; }
price = pik_price ;
line = price * qty;
form.plastic_sm.value  = (qty == 0) ? ' ' : prec2(line);
q_items += qty;
q_piks += qty;
subtotal += line;

// -- Line Six -------------
qty =  form.qty_p_md.value * 1;
	if ( isNaN(qty) ) { 
		qty = 0; 
		vld = "n"; 
		form.qty_p_md.value = 0 ; }
price = pik_price ;
line = price * qty;
form.plastic_md.value  = (qty == 0) ? ' ' : prec2(line);
q_items += qty;
q_piks += qty;
subtotal += line;

// -- Line Seven -------------
qty =  form.qty_p_lg.value * 1;
	if ( isNaN(qty) ) { 
		qty = 0; 
		vld = "n"; 
		form.qty_p_lg.value = 0 ; }
price = pik_price ;
line = price * qty;
form.plastic_lg.value  = (qty == 0) ? ' ' : prec2(line);
q_items += qty;
q_piks += qty;
subtotal += line;

// -- Line Eight -------------
qty =  form.qty_p_xl.value * 1;
	if ( isNaN(qty) ) { 
		qty = 0; 
		vld = "n"; 
		form.qty_p_xl.value = 0 ; }
price = pik_price ;
line = price * qty;
form.plastic_xl.value  = (qty == 0) ? ' ' : prec2(line);
q_items += qty;
q_piks += qty;
subtotal += line;

// -- Line Nine -------------
qty =  form.qty_p_set.value * 1;
	if ( isNaN(qty) ) { 
		qty = 0; 
		vld = "n"; 
		form.qty_p_set.value = 0 ; }
price = pik_price ;
line = 4 * price * qty;
form.plastic_set.value  = (qty == 0) ? ' ' : prec2(line);
q_items += qty;
q_piks += 4 * qty;
subtotal += line;

form.note1.value = ( vld == "y" ) ? ' ' : "  All pik quantities MUST be numbers! ";
// if ( vld != "" ) flag = 1;

// -- The Total for this order (not including tax) is 

// form.Qty_total.value = (Items == 0) ? ' ' : Items;

form.qty_items.value = (q_items == 0) ? ' ' : q_items;
form.qty_picks.value = (q_piks == 0) ? ' ' : q_piks;
form.subtotal.value  = (q_items == 0) ? ' ' : prec2(subtotal);

// shipping rate is constant at $3.95
	
shipping = (subtotal == 0) ? 0 : 3.95;

form.shipping.value = (subtotal == 0) ? ' ' : "$3.95" ;

// State of Washington = 48 -- because of adding 'outside US/Canada' as #1
var state = form.stateAbbr.selectedIndex;
var tax = 0 ;
   
if (state == 48) { tax = .087 * (subtotal + shipping) ; }
form.taxWA.value = (tax == 0) ? ' ' : prec2(tax);

// Is country US or Canada? (this part isn't working)
var country = 3 ;
if ( state == 0 ) { 	country = 0; }
else {
	if (1 < state && state < 53) { country = "US"; 
	country = 1;  }
else {
if (52 < state && state <63) { country = "Canada"; 
	country = 2; }
	 }
	}
	
// assume initial country is foreign
form.country.selectedIndex = country;
	
total = subtotal + shipping + tax ;
form.total.value = (total == 0) ? ' ' : prec2(total);

}
// End of Order Quote function 

// Stop hiding from other browsers -->

