function total(that) {

lang = window.lang
//alert("lang = "+lang);


    // Product constructor: NEXT VERSION
    // PRICES with no decimal point! ex: 3995
    // WEIGHT,in grams!
    // Name,PRICE,WEIGHT
    ///////////////////////////////////////
    /*
    function make_product(name,price,weight){
      this.name     = name;
      this.price    = price;
      this.weight   = weight;
      this.amount   = 0;
    }
    */
    
    //
    if(lang=="french"){
		
		Please_choose_a_state_or_province="Choisissez un état ou une province."
		You_chose_Canada_as_a_country="You chose Canada as a country. Please choose a Canadian province."
		Please_choose_a_country="Choisissez un état."
		Outside="Outside"
		Please_call="Appelez SVP"
		
    }else if(lang=="spanish"){
		
		Please_choose_a_state_or_province="Seleccione estado/provincia."
		You_chose_Canada_as_a_country="Eligió Canada. Por favor, elija una provincia canadiense."
		Please_choose_a_country="Por favor, elija un paí."
		Outside="Outside"
		Please_call="Por favor, llame a"
		
    }else{
		
		Please_choose_a_state_or_province="Please choose a state or province."
		You_chose_Canada_as_a_country="You chose Canada as a country. Please choose a Canadian province."
		Please_choose_a_country="Please choose a country."
		Outside="Outside"
		Please_call="Please call"

    }
    // PRICES with no decimal point! ex: 3995
    var cost_adventureII_net = 5495;
    var cost_long_lasting_net = 4995;  
    var cost_bed_net = 4495;
    var cost_patio_net = 6995;
    var cost_repellant_pump = 995;
    var cost_repellant_lotion = 1195;
    var cost_gazebo = 8900;
    var cost_popup = 8900;
    var cost_mosnet = 2900;
    var cost_water_filter = 2995; 
    var cost_water_drops = 1995; 
    var cost_water_filter_straw = 1995; 
    
    // WEIGHT,in grams!
    var weight_adventureII_net = 850;
    var weight_long_lasting_net = 390;   
    var weight_bed_net = 390;
    var weight_patio_net = 2300;
    var weight_repellant_pump = 150;
    var weight_repellant_lotion = 300;
    var weight_gazebo = 3200;
    var weight_popup = 3600;
    var weight_mosnet = 500;
    var weight_water_filter = 220; 
    var weight_water_drops = 80;    
    var weight_water_filter_straw = 27; 
    
    // initialize amounts at 0
    var amount_adventureII_net = 0;
    var amount_long_lasting_net = 0;   
    var amount_bed_net = 0;
    var amount_patio_net = 0;
    var amount_repellant_pump = 0;
    var amount_repellant_lotion = 0;
    var amount_gazebo = 0;
    var amount_popup = 0;
    var amount_mosnet = 0;
    var amount_water_filter = 0; 
    var amount_water_drops = 0; 
    var amount_water_filter_straw = 0; 
    
    // overnight delivery
    var amount_overnight = 0;
    
////////////////////////////////////////////////////////////////////
    // THAT should be all you need to edit!//
    
    // some more initial values
    var total =0;
    var total_weight = 0;
    var row = 0;
    var col = 0;
    var item_total = 0;
    var shipping_total = 0;
    var total_total = 0 ;
    
    var gst = 0 ;
    that.gst.value =  "";   
    
    var has_gst = 0;
    var qst = 0 ;
    var has_qst = 0;
    that.qst.value = "";

    // get form amounts into var amounts as integers
    if (typeof(that.qty_adventureII_net) != "undefined" && that.qty_adventureII_net.value > 0){
        amount_adventureII_net = parseInt(that.qty_adventureII_net.value,10);
    }

    if (typeof(that.qty_long_lasting_net) != "undefined" && that.qty_long_lasting_net.value > 0){
        amount_long_lasting_net = parseInt(that.qty_long_lasting_net.value,10);
    } 

    if (typeof(that.qty_bed_net) != "undefined" && that.qty_bed_net.value > 0){
        amount_bed_net = parseInt(that.qty_bed_net.value,10) ;
    }

    if (typeof(that.qty_repellant_pump) != "undefined" && that.qty_repellant_pump.value > 0){
        amount_repellant_pump = parseInt(that.qty_repellant_pump.value,10);
    }

    if (typeof(that.qty_repellant_lotion) != "undefined" && that.qty_repellant_lotion.value > 0){
        amount_repellant_lotion = parseInt(that.qty_repellant_lotion.value,10);
    }

    if (typeof(that.qty_water_filter) != "undefined" && that.qty_water_filter.value > 0){
        amount_water_filter = parseInt(that.qty_water_filter.value,10);
    }

    if (typeof(that.qty_water_drops) != "undefined" && that.qty_water_drops.value > 0){
        amount_water_drops = parseInt(that.qty_water_drops.value,10);
    }

    if (typeof(that.qty_water_filter_straw) != "undefined" && that.qty_water_filter_straw.value > 0){
        amount_water_filter_straw = parseInt(that.qty_water_filter_straw.value,10);
    }   

    that.Shipping_Total.value="";
    
    // If a checkbox has been selected it will return true
    // (If not it will return false)
    if (that.overnight.checked
    && (parseInt(that.country.value,10) == 200 
    || parseInt(that.country.value,10) == 190)
    ){ 
        amount_overnight = 1000;
        that.Overnight_Shipping.value = "10.00"; 
    }else{
        that.Overnight_Shipping.value = "";
        that.overnight.checked = false;
    }


    // calculate item amount: cost * quantity
    if (amount_adventureII_net > 0 
    || amount_long_lasting_net > 0   
    || amount_bed_net > 0 
    || amount_patio_net > 0 
    || amount_repellant_pump > 0 
    || amount_repellant_lotion > 0
    || amount_mosnet > 0
    || amount_gazebo > 0
    || amount_popup > 0
    || amount_water_filter > 0
    || amount_water_drops > 0
    || amount_water_filter_straw > 0
    ){

        total =
        (cost_adventureII_net * amount_adventureII_net) 
        + (cost_long_lasting_net * amount_long_lasting_net)       
        + (cost_bed_net * amount_bed_net) 
        + (cost_patio_net * amount_patio_net) 
        + (cost_repellant_pump * amount_repellant_pump) 
        + (cost_repellant_lotion * amount_repellant_lotion)
        + (cost_mosnet * amount_mosnet)
        + (cost_gazebo * amount_gazebo)
        + (cost_popup * amount_popup)
        + (cost_water_filter * amount_water_filter)
        + (cost_water_drops * amount_water_drops)
        + (cost_water_filter_straw * amount_water_filter_straw);
    }

    if(that.state.value == ""){
       if(parseInt(that.country.value,10) != 200 && parseInt(that.country.value,10) != 190){ 
         that.state.value = "Not in USA/Canada";
       }else{
        alert(Please_choose_a_state_or_province);
        return false;
       }
    }
    
    //find column based on country code->group
    if (parseInt(that.country.value,10) == 200){
        // canadian, eh?
        has_gst = 1;
        has_hst = 0;
        
        if(that.state.value == "Alberta"){          col = 15; }
        else if(that.state.value == "British Columbia"){    col = 16; has_hst=1;}
        else if(that.state.value == "Manitoba"){        col = 15; }
        else if(that.state.value == "Nanuvut"){         col = 16; }
        else if(that.state.value == "New Brunswick"){       col = 14; has_hst=1; }
        else if(that.state.value == "Newfoundland"){        col = 16; has_hst=1; }
        else if(that.state.value == "Nova Scotia"){         col = 14; has_hst=1; }
        else if(that.state.value == "Northwest Territories"){   col = 16; }
        else if(that.state.value == "Ontario"){         col = 13; has_hst=1; }
        else if(that.state.value == "Quebec"){
          col = 13; 
          has_qst = 1;
        }

        else if(that.state.value == "Prince Edward Island"){    col = 14; }
        else if(that.state.value == "Saskatchewan"){        col = 15; }
        else if(that.state.value == "Yukon"){           col = 16; }
        else if(that.state.value == "Not in USA/Canada"){ 
            alert(You_chose_Canada_as_a_country);
            return false;
        }
        else{
            alert(You_chose_Canada_as_a_country);
            return false;
        }
        

    }else if(parseInt(that.country.value,10) == 190){
        // american
        col = 17;

        if(that.state.value == "Not in USA/Canada"){ 
            alert(Please_choose_a_country);
            return false;
        }
    }else{
        col = group[parseInt(that.country.value,10)];
    }

    // find row based on total weight (quantity * weight of each)
    total_weight = 
        amount_adventureII_net*weight_adventureII_net
        + amount_long_lasting_net*weight_long_lasting_net      
        + amount_bed_net*weight_bed_net 
        + amount_patio_net*weight_patio_net 
        + amount_repellant_pump*weight_repellant_pump 
        + amount_repellant_lotion*weight_repellant_lotion
        + amount_mosnet*weight_mosnet
        + amount_gazebo*weight_gazebo
        + amount_popup*weight_popup
        + amount_water_filter*weight_water_filter
        + amount_water_drops*weight_water_drops
        + amount_water_filter_straw*weight_water_filter_straw;

    // total_weight array

    if (total_weight== 0          ){ row = 1; col = 18;}
    if (total_weight<=500         ){ row = 1; }
    if (total_weight>500 && total_weight<=1000){ row = 2; }
    if (total_weight>1000 && total_weight<=1500){ row = 3; }
    if (total_weight>1500 && total_weight<=2000){ row = 4; }
    if (total_weight>2000 && total_weight<=2500){ row = 5; }
    if (total_weight>2500 && total_weight<=3000){ row = 6; }
    if (total_weight>3000 && total_weight<=3500){ row = 7; }
    if (total_weight>3500 && total_weight<=4000){ row = 8; }
    if (total_weight>4000 && total_weight<=4500){ row = 9; }
    if (total_weight>4500 && total_weight<=5000){ row = 10; }
    if (total_weight>5000 && total_weight<=5500){ row = 11; }
    if (total_weight>5500 && total_weight<=6000){ row = 12; }
    if (total_weight>6000 && total_weight<=6500){ row = 13; }
    if (total_weight>6500 && total_weight<=7000){ row = 14; }
    if (total_weight>7000 && total_weight<=7500){ row = 15; }
    if (total_weight>7500 && total_weight<=8000){ row = 16; }
    if (total_weight>8000 && total_weight<=8500){ row = 17; }
    if (total_weight>8500 && total_weight<=9000){ row = 18; }
    if (total_weight>9000 && total_weight<=9500){ row = 19; }
    if (total_weight>9500 && total_weight<=10000){ row = 20; }
    if (total_weight>10000 && total_weight<=10500){ row = 21; }
    if (total_weight>10500 && total_weight<=11000){ row = 22; }
    if (total_weight>11000 && total_weight<=11500){ row = 23; }
    if (total_weight>11500 && total_weight<=12000){ row = 24; }
    if (total_weight>12000 && total_weight<=13000){ row = 25; }
    if (total_weight>13000 && total_weight<=14000){ row = 26; }
    if (total_weight>14000 && total_weight<=15000){ row = 27; }
    if (total_weight>15000 && total_weight<=16000){ row = 28; }
    if (total_weight>16000 && total_weight<=17000){ row = 29; }
    if (total_weight>17000 && total_weight<=18000){ row = 30; }
    if (total_weight>18000 && total_weight<=19000){ row = 31; }
    if (total_weight>19000 && total_weight<=20000){ row = 32; }

    
    if( parseInt(that.country.value,10) != 190 && parseInt(that.country.value,10) != 200){
    // not USA or CANADA
        that.Shipping_Total.value=Outside; 
        row = 33;
        col = 1;

    }
    if (total_weight>20500){ 
        that.Shipping_Total.value=Please_call; 
        row = 33;
        col = 1;
    }

    shipping_total = ship[col][row]

    // display for debugging
    //
    //country_d += ""
    //that.country_d.value = that.country.value
    
    //row += ""
    //col += ""
    //var total_weight_d
    //total_weight_d += ""
    //that.total_weight_d.value = total_weight
    //that.row_d.value = row
    //that.col_d.value = col


    // convert to stings for display
    if (that.Shipping_Total.value != Please_call
    &&
    that.Shipping_Total.value != Outside){ 
    
        
        shipping_total = shipping_total*0.8900;
        // SEPT 20 2005 ADD 10% to shipping, add fuel surcharge
        shipping_total = shipping_total * 1.1;
        fuel_surcharge = shipping_total * .135;
        
        if(that.cut_delivery_half.checked == true){
              shipping_total = shipping_total * 0.5;
              fuel_surcharge = fuel_surcharge * 0.5;
        }
        
        shipping_total =Number(shipping_total);
        with(Math){
            shipping_total =round(shipping_total);
        }
        
        fuel_surcharge =Number(fuel_surcharge);
        with(Math){
            fuel_surcharge =round(fuel_surcharge);
        }
        
        
        //alert(shipping_total);
        
        total_total = total + shipping_total + fuel_surcharge + amount_overnight;
        shipping_total += "";
        shipping_total = shipping_total . substring (0, shipping_total . length - 2) +
                "." +
                shipping_total . substring (shipping_total . length - 2, shipping_total . length);
        that.Shipping_Total.value = shipping_total
        
        fuel_surcharge += "";
        fuel_surcharge = fuel_surcharge . substring (0, fuel_surcharge . length - 2) +
                "." +
                fuel_surcharge . substring (fuel_surcharge . length - 2, fuel_surcharge . length);
        that.Fuel_Surcharge.value = fuel_surcharge
        
    }else if(that.Shipping_Total.value == Outside){
    
       shipping_total = 5000;
       fuel_surcharge = 0;
       amount_overnight = 0;
       total_total = total + shipping_total
       
       that.Fuel_Surcharge.value = "";
       that.Shipping_Total.value = "50.00";
    
    
    }else{
        that.Fuel_Surcharge.value = Please_call
        total_total = total
    }
    if(has_gst == 1){
        if(has_hst){
			//alert("has hst");
			// 29 July 2010
			// old: gst = total_total * 12875 / 100000;
			//BC: Change GST/HST to 12%
			//ON: Change GST/HST to 13%
			//NB: Change GST/HST to 13%
			//NF: Change GST/HST to 13%
			//NS: Change GST/HST to 15%   
			if(that.state.value == "British Columbia"){    gst = total_total * 12 / 100}
			else if(that.state.value == "New Brunswick"){  gst = total_total * 13 / 100 }
			else if(that.state.value == "Newfoundland"){   gst = total_total * 13 / 100 }
			else if(that.state.value == "Nova Scotia"){    gst = total_total * 15 / 100}
			else if(that.state.value == "Ontario"){        gst = total_total * 13 / 100}
            
        }else{
            gst = total_total * 5 / 100;
       }
    }
    if(has_qst == 1){
        qst = ( total_total + gst ) * 75 / 1000;
        
    }
    
    gst =Number(gst);
    with(Math){
        gst =round(gst);
    }
    qst =Number(qst);
    with(Math){
        qst =round(qst);
    }
    if(has_gst){
       total_total = total_total + gst;
       gst += "";
        gst = gst.substring (0, gst . length - 2) + "." + gst.substring (gst . length - 2, gst . length);
        that.gst.value = gst;
    }
    
    if(has_qst){
        total_total = total_total + qst;
        qst += "";
        qst = qst.substring (0, qst . length - 2) + "." + qst.substring (qst . length - 2, qst . length);
        that.qst.value = qst;
    }

    total += ""
    total = total . substring (0, total . length - 2) + "." + total . substring (total . length - 2, total . length);
    that.Item_Total.value =total

    total_total += ""
    total_total = total_total . substring (0, total_total . length - 2) +
        "." +
        total_total . substring (total_total . length - 2, total_total . length);
    that.Total.value = total_total
    return true;

}


