// This js developed by Darbie Marlin, DMarlin@runway.net
// and Runway-WebMaker - web development services 509-328-8680 
  
// -- Order Form Calculation script --------- last modified 1/27/10 ------>

<!-- Hide from other browsers
function quote(form)
{
// -- Line One --------------->
// -- Determine the line one subtotal ------>
var qty  =  form.qty.selectedIndex;
var price = 24.95 ;
var line = price * qty;
form.line.value  = (qty == 0) ? ' ' : Prec2(line);

// -- The Total for this order (not including tax) is --->
var items = qty ;
// form.Qty_total.value = (Items == 0) ? ' ' : Items;
var subtotal = qty * price;
form.subtotal.value  = (subtotal == 0) ? ' ' : Prec2(subtotal);


// form.Shipping.value = (subtotal > 100) ? '0' : Prec2(Ship);

// State of Nevada = 30 -- because of adding 'outside US/Canada' as #1
var state = form.state.selectedIndex;
var tax = 0 ;
   
if (state == 30) { tax = .07725 * subtotal ;
		   subtotal = subtotal + tax; }
form.taxNV.value = (tax == 0) ? ' ' : Prec2(tax);

// Is country US or Canada? (this part isn't working)
if ( state == 0 ) { 	form.country.selectedIndex = 0; }
else {
	if (1 < state && state < 53) { country = "US"; 
	form.country.selectedIndex = 1;  }
else {
if (52 < state && state <64) { country = "Canada"; 
	form.country.selectedIndex = 2; }
	 }
	}
	
var country = 2 ; // assume initial country is US.
if (state == 1 ) { // country cannot be US or Canada
	country = form.country.selectedIndex ;
	if (country == 1) form.country.selectedIndex = 0 ;
	if (country == 2) form.country.selectedIndex = 0 ;
	}
	
// shipping rate depends upon destination country
// default surface air rate is $1 for US and Canada, $2 for all others.

var shipType = form.shipType.selectedIndex; // 1 = surface, 2 = Air

var surface = 4 ; var air = 6 ; // base line is for US or Canada
if ( country == 3 ) { // Mexico
	surface = 8 ; air = 10; }
if ( country == 4 ) { // South America
	surface = 10 ; air = 15; }
if ( country == 5 ) { // Japan
	surface = 10 ; air = 15; }
if ( country == 6 ) { // Europe
	surface = 10 ; air = 15; }
if ( country > 6 ) { // Australia or New Zealand
	surface = 12 ; air = 17; }
	
	if ( shipType == 1 ) shipRate = surface ;
	if ( shipType == 2 ) shipRate = air ;
	
	shipping = (subtotal == 0) ? 0 : (shipRate*qty);
if ( shipType == 0 ) {
	form.shipping.value = "";
	form.total.value = "";
	}
else {
if ( subtotal > 100 ) { shipping = 0 } ;
form.shipping.value = (subtotal == 0) ? ' ' : Prec2(shipping);

total = subtotal + shipping ;
form.total.value = (total == 0) ? ' ' : Prec2(total);
}
	
}
// Stop hiding from other browsers -->
