// JustGoFly JavaScript Document - all contents copyrighted
// Initialize things

Prices = new Array();


Prices["Qty_G_A6_Charger"]=59.95;
Prices["Qty_12V_5Amp_Power_Supply"]=12.95;
Prices["Qty_50_Tractor_5mm_Motor"]=99.95;
Prices["Qty_30_Tractor_5mm_Motor"]=89.95;
Prices["Qty_20_Tractor_5mm_Motor"]=79.95;

Prices["Qty_560TH_Tractor_5mm_Motor"]=59.95;

Prices["Qty_550T_Pusher_4mm_w_free_X_Mount_Motor"]=69.95;
Prices["Qty_550T_Tractor_3_17mm_Motor"]=69.95;
Prices["Qty_550TH_Pusher_4mm_Motor_GEN_1"]=54.95;
Prices["Qty_550TH_Pusher_4mm_Motor_GEN_2"]=59.95;

Prices["Qty_550TH_Tractor_3_17mm_Motor_GEN_1"]=54.95;
Prices["Qty_550TH_Tractor_3_17mm_Motor_GEN_2"]=59.95;

Prices["Qty_550TH_Pusher_4mm_Motor"]=59.95;
Prices["Qty_550ST_Pusher_4mm_w_free_X_Mount_Motor"]=69.95;
Prices["Qty_550XT_Pusher_4mm_w_free_X_Mount_Motor"]=49.95;

Prices["Qty_450T2_Pusher_w_free_X_Mount_Motor"]=39.95;

// put the word "Motor" on the end of a label and it counts towards free shipping deal 2 motors = free shipping
Prices["Qty_5345_7_200Kv_Motor_8mm_axle_w_Prop_Adapter_X_Mount"]=119.95;
Prices["Qty_4130_6_530Kv_Motor_6mm_axle_w_Prop_Adapter_X_Mount"]=61.95;
Prices["Qty_4120_6_Motor_6mm_axle_w_Prop_Adapter_X_Mount"]=53.95;
Prices["Qty_4120_7_Motor_6mm_axle_w_Prop_Adapter_X_Mount"]=53.95;
Prices["Qty_2204_14_Motor_Only"]=14.95;
Prices["Qty_2204_Motor_ESC_Battery_3D_Combo_Deal"]=50.00;
Prices["Qty_2204_Motor_ESC_3D_Combo_Deal"]=30.00;
Prices["Qty_2212_930Kv_Motor_3_17_hardened_axle"]=16.95;
Prices["Qty_U2826_4_1000Kv_Motor_5mm_axle"]=36.95;
Prices["Qty_U2814_8_1100Kv_Motor_4mm_axle"]=29.95;
Prices["Qty_3520_6_Motor_840_kv_5mm_axle"]=39.95;
Prices["Qty_40_amp_ESC_3amp_BEC"]=30.00;
Prices["Qty_10_Amp_ESC"]=14.95;
Prices["Qty_18_Amp_ESC"]=17.95;

Prices["Qty_500SH_Tractor_Motor"]=59.95;

Prices["Qty_500TH_Tractor_3_17mm_Motor"]=59.95;
Prices["Qty_500TH_Pusher_4mm_Motor"]=59.95;
Prices["Qty_500T_Tractor_3_17mm_Motor"]=59.95;
Prices["Qty_500T_Pusher_4mm_Motor"]=59.95;
Prices["Qty_500TH_Pusher_4mm_w_free_X_Mount_Motor"]=59.95;
Prices["Qty_500T_Pusher_4mm_w_free_X_Mount_Motor"]=59.95;
Prices["Qty_500XT_Pusher_4mm_Motor"]=39.95;
Prices["Qty_500XT_Tractor_3_17mm_Motor"]=39.95;
Prices["Qty_500XTF_Pusher_4mm_Motor"]=39.95;

Prices["Qty_Radio_Neck_Strap"]=7.95;
Prices["Qty_Radio_Neck_Strap_w_JustGoFly_Text"]=7.45;

Prices["Qty_DPR_50"]=45.95;
Prices["Qty_DPR_100"]=80.95;
Prices["Qty_DPR_50_Temp_Sensor"]=9.95;
Prices["Qty_DPR_50_Temp_Probe_LED_Sensor"]=9.95;
Prices["Qty_DPR_RPM_Sensor"]=9.95;

Prices["Qty_B29_10_1000_Motor"]=40.00;

Prices["Qty_300_DF_Motor"]=31.95;
Prices["Qty_300DF_3mm_Tractor_Motor"]=31.95;
Prices["Qty_300_DF_Pusher_Motor"]=31.95;

Prices["Qty_400_F_2_3_Tractor_Motor"]=39.95;
Prices["Qty_400_F_3mm_Tractor_Motor"]=39.95;
Prices["Qty_400_F_Pusher_3mm_Motor"]=39.95;

// SALE !
Prices["Qty_400_DF_2_3mm_Tractor_Motor"]=39.95;
Prices["Qty_400_DF_3mm_Tractor_Motor"]=39.95;
Prices["Qty_400_DF_3mm_Pusher_Motor"]=39.95;
// SALE !

Prices["Qty_400_T_Motor"]=39.95;
Prices["Qty_400_T_Pusher_Motor"]=39.95;

Prices["Qty_400DH_Motor"]=49.95;

Prices["Qty_450DH_Motor"]=55.95;
Prices["Qty_450TH_3_17_mm_Tractor_Motor"]=55.95;
Prices["Qty_450TH_2_3mm_Tractor_Motor"]=55.95;
Prices["Qty_450TH_Pusher_Motor"]=55.95;
Prices["Qty_450TH_3_mm_Tractor_Motor"]=55.95;

Prices["Qty_450T_Pusher_Motor"]=55.95;
Prices["Qty_450T_Tractor_3mm_Motor"]=55.95;

Prices["Qty_450F_Tractor_Motor"]=55.95;
Prices["Qty_450F_Tractor_3mm_Motor"]=55.95;
Prices["Qty_450F_Pusher_Motor"]=55.95;

Prices["Qty_450FT_Tractor_3mm_Motor"]=55.95;
Prices["Qty_450FT_Pusher_3mm_Motor"]=55.95;
Prices["Qty_450FT_Tractor_2_3mm_Motor"]=55.95;

Prices["Qty_450XT_Motor"]=41.95;
Prices["Qty_450XT_3mm_Tractor_Motor"]=41.95;

Prices["Qty_MDRIVE_60_ESC"]=59.95;
Prices["Qty_DYNAM_30_ESC"]=39.95;
Prices["Qty_DYNAM_40_ESC"]=44.95;
Prices["Qty_DYNAM_70_ESC"]=49.95;
Prices["Qty_DYNAM_ESC_Programming_Card"]=10.00;

Prices["Qty_60_ESC_w_5_amp_UBEC"]=49.95;
Prices["Qty_70_ESC_w_5_amp_UBEC"]=55.95;
Prices["Qty_50_amp_ESC_3amp_BEC"]=35.95;
Prices["Qty_50_amp_ESC_OPTO"]=35.95;

Prices["Qty_MMM_12_ESC"]=36.95;
Prices["Qty_MMM_22_ESC"]=32.95;
Prices["Qty_MMM_32_ESC"]=49.95;
Prices["Qty_Infinity_25_ESC"]=34.95;

Prices["Qty_UBEC_5v_6v_3amp"]=12.00;
Prices["Qty_UBEC_5v_5amp"]=15.00;
Prices["Qty_CC_P10_ESC"]=51.95;
Prices["Qty_CC_P25_ESC"]=68.95;
Prices["Qty_CC_P35_ESC"]=84.95;
Prices["Qty_8T_Pinion"]=3.95;
Prices["Qty_9T_Pinion"]=3.95;
Prices["Qty_10T_Pinion"]=3.95;
Prices["Qty_15T_Pinion"]=4.00;

Prices["Qty_Short_8T_Pt5_Modulus_2_3mm_Pinion"]=2.95;
Prices["Qty_Short_9T_Pt5_Modulus_2_3mm_Pinion"]=2.95;
Prices["Qty_Short_10T_Pt5_Modulus_2_3mm_Pinion"]=2.95;

Prices["Qty_12T_Pt6_Modulus_5mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_13T_Pt6_Modulus_5mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_14T_Pt6_Modulus_5mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_15T_Pt6_Modulus_5mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_16T_Pt6_Modulus_5mm_Pinion_w_set_screw"]=3.95;

Prices["Qty_10T_Pt5_Modulus_3mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_11T_Pt5_Modulus_3mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_12T_Pt5_Modulus_3mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_13T_Pt5_Modulus_3mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_14T_Pt5_Modulus_3mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_15T_Pt5_Modulus_3mm_Pinion_w_set_screw"]=3.95;

Prices["Qty_10T_Pt5_Modulus_3_17mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_11T_Pt5_Modulus_3_17mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_12T_Pt5_Modulus_3_17mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_13T_Pt5_Modulus_3_17mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_14T_Pt5_Modulus_3_17mm_Pinion_w_set_screw"]=3.95;
Prices["Qty_15T_Pt5_Modulus_3_17mm_Pinion_w_set_screw"]=3.95;


Prices["Qty_GB400_D_3"]=10.00;
Prices["Qty_GB400_E_3_4"]=10.00;
Prices["Qty_GB400_F_3_9"]=10.00;
Prices["Qty_GB400_H_5_28"]=10.00;
Prices["Qty_GoldConnectors_2_4mm"]=3.00;
Prices["Qty_GoldConnectors_3_5mm"]=4.00;
Prices["Qty_Aluminum_6mm_Collet_for_3mm_Shaft_w_grub_screws"]=2.50;
Prices["Qty_5mm_Collet_for_3mm_Shaft_Friction_Fit"]=2.50;
Prices["Qty_5mm_Collet_for_3_17mm_Shaft_Friction_Fit"]=1.50;
Prices["Qty_5mm_Bullet_Collet_for_3_17mm_Shaft_Friction_Fit"]=2.50;
Prices["Qty_8mm_Collet_for_4mm_Shaft_Friction_Fit"]=3.50;
Prices["Qty_6mm_Collet_for_4mm_Shaft_Friction_Fit_Bullet_Style"]=3.00;

Prices["Qty_Collet_for_5mm_Shaft_Friction_Fit_Bullet_Style"]=4.00;
Prices["Qty_Collet_for_6mm_Shaft_Friction_Fit_Bullet_Style"]=4.50;

Prices["Qty_Digital_Volt_Meter"]=9.95;

Prices["Qty_WattMeter"]=39.95;
Prices["Qty_GWS_8x4_HD_Prop"]=1.00;
Prices["Qty_GWS_10x6_HD_Prop"]=1.50;
Prices["Qty_GWS_10x4_7_SF_Prop"]=1.00;
Prices["Qty_GWS_11x7_HD_Prop"]=1.60;
Prices["Qty_GWS_12x8_HD_Prop"]=2.00;
Prices["Qty_DD_Motor_Mount"]=19.95;

Prices["Qty_APC_41x41_Prop"]=2.00;
Prices["Qty_APC_42x2_Sport_Prop"]=2.00;
Prices["Qty_APC_42x4_Free_Flight_Prop"]=2.00;
Prices["Qty_APC_45x41_Prop"]=2.00;
Prices["Qty_APC_e_47x42_Prop"]=2.00;
Prices["Qty_APC_4_75x4_75_Prop"]=2.00;
Prices["Qty_APC_475_55_e_Prop"]=2.00;
Prices["Qty_APC_5_5_e_Prop"]=2.00;
Prices["Qty_APC_525x475_e_Prop"]=2.00;
Prices["Qty_APC_525x625_e_Prop"]=2.00;
Prices["Qty_APC_55x25_Sport_Prop"]=2.00;
Prices["Qty_APC_5_5x4_5_e_Prop"]=2.00;
Prices["Qty_APC_5_7x3_Sport_Prop"]=2.00;
Prices["Qty_APC_6x2_Sport_Prop"]=2.00;
Prices["Qty_APC_6x3_Sport_Prop"]=2.00;
Prices["Qty_APC_6x4_e_Prop"]=2.00;
Prices["Qty_APC_6x5_5_e_Prop"]=2.00;

Prices["Qty_EMP_6x4_scimitar_Prop"]=2.00;

Prices["Qty_APC_7x3_Sport_Prop"]=2.00;
Prices["Qty_APC_7x4_Slow_Fly_Prop"]=2.00;
Prices["Qty_APC_7x5_E_Prop"]=2.00;
Prices["Qty_APC_7x6_e_Prop"]=2.50;
Prices["Qty_APC_7x6_Sport_Prop"]=2.50;
Prices["Qty_APC_7x7_Sport_Prop"]=2.50;
Prices["Qty_APC_7x8_Sport_Prop"]=2.50;
Prices["Qty_APC_7x9_Sport_Prop"]=2.50;
Prices["Qty_APC_7x10_Sport_Prop"]=2.50;

Prices["Qty_APC_6_5x5_Pylon_Prop"]=4.00;
Prices["Qty_APC_6_5x5_5_Pylon_Prop"]=4.00;
Prices["Qty_APC_6_5x5_Pylon_Prop"]=4.00;
Prices["Qty_APC_6_5x6_Pylon_Prop"]=4.00;
Prices["Qty_APC_6_5x6_5_Pylon_Prop"]=4.00;

Prices["Qty_APC_8x4_e_Prop"]=2.50;
Prices["Qty_APC_8x6_e_Prop"]=2.50;
Prices["Qty_APC_8x8_e_Prop"]=2.50;
Prices["Qty_APC_9x6_e_Prop"]=2.60;
Prices["Qty_APC_9x7_5_e_Prop"]=2.60;
Prices["Qty_APC_9x9_e_Prop"]=2.60;
Prices["Qty_APC_11x7_e_Prop"]=3.20;
Prices["Qty_APC_10x10_e_Prop"]=2.90;
Prices["Qty_APC_11x5_5_e_Prop"]=3.20;
Prices["Qty_APC_12x6_e_Prop"]=3.95;

Prices["Qty_APC_8x3_8_sf_Prop"]=2.50;
Prices["Qty_APC_8x6_sf_Prop"]=2.50;
Prices["Qty_APC_9x3_8_sf_Prop"]=2.60;
Prices["Qty_APC_10x3_8_sf_Prop"]=3.00;
Prices["Qty_APC_10x4_7_sf_Prop"]=3.00;
Prices["Qty_APC_12x4_7_sf_Prop"]=4.00;


Prices["Qty_Blue_Anodized_Gearbox"]=15.00;
Prices["Qty_Red_Anodized_Gearbox"]=19.50;
Prices["Qty_WhiteSpur_N_Pinion_3_89"]=3.00;
Prices["Qty_Motor_Mount_Plastic"]=2.00;
Prices["Qty_Motor_Mount_Red_Aluminum"]=8.00;
Prices["Qty_Spur_N_Axle_For_Blue_Gearbox"]=4.00;

Prices["Qty_Blenderm_1_Inch_by_five_yards"]=2.50;

Prices["NoGearbox"]=0.00;
Prices["NoGearboxCOMBO"]=0.00;
Prices["Qty_Blue_Anodized_GearboxCOMBO"]=15.00;
Prices["Qty_Red_Anodized_GearboxCOMBO"]=15.00;
Prices["Qty_3mmPropSaver"]=3.00;
Prices["Qty_Bell_300_DF_2_3mm"]=10.00;
Prices["Qty_Bell_300_DF_3mm"]=10.00;
Prices["Qty_Bell_300_DF_3mm_Pusher"]=10.00;
Prices["Qty_Bell_400F_Tractor_2_3mm"]=12.00;
Prices["Qty_Bell_400DF_Tractor_2_3mm"]=12.00;
Prices["Qty_Bell_400DH_Tractor_2_3mm"]=15.00;
Prices["Qty_Bell_400_Tractor_3mm"]=12.00;
Prices["Qty_Bell_400_Pusher_3mm"]=12.00;

Prices["Qty_500T_Pusher_Bell_4mm"]=15.00;
Prices["Qty_500T_Tractor_Bell_3_17mm"]=15.00;
Prices["Qty_500TH_Pusher_Bell_4mm"]=15.00;
Prices["Qty_500TH_Tractor_Bell_3_17mm"]=15.00;

Prices["Qty_Bell_450_Tractor_3mm_HighSpeed"]=15.00;
Prices["Qty_Bell_450_Tractor_2_3mm_HighSpeed"]=15.00;
Prices["Qty_Bell_450_Pusher_3mm_HighSpeed"]=15.00;
Prices["Qty_Bell_450_Tractor_3mm_MidSpeed"]=15.00;
Prices["Qty_Bell_450_Pusher_3mm_MidSpeed"]=15.00;
Prices["Qty_Bell_450_Tractor_2_3mm_MidSpeed"]=15.00;

Prices["Qty_3mm_C_Clip"]=1.00;
Prices["Qty_4mm_C_Clip"]=1.00;

Prices["Qty_Infinity_400_Motor"]=39.95;

Prices["Qty_300ST_Motor"]=39.95;
Prices["Qty_400ST_Motor"]=39.95;

Prices["Qty_LiPo_1800"]=29.95;
Prices["Qty_LiPo_2200"]=43.95;
Prices["Qty_LiPo_1300_Tronics_3S_15C"]=32.95;

Prices["Qty_LiPo_1500_Tronics_2S_10C"]=15.95;
Prices["Qty_LiPo_1500_Tronics_3S_10C"]=22.95;

Prices["Qty_LiPo_2100_LiPo_3S_20C"]=34.95;
Prices["Qty_LiPo_2200_LiPo_3S_30C"]=41.95;
Prices["Qty_LiPo_2200_LiPo_4S_30C"]=59.95;
Prices["Qty_LiPo_1300_LiPo_3S_25C"]=29.95;
Prices["Qty_LiPo_4800_LiPo_3S_25C"]=95.95;
Prices["Qty_LiPo_4800_LiPo_5S_25C"]=149.95;

Prices["Qty_2S_Balance_Connector"]=1.00;
Prices["Qty_3S_Balance_Connector"]=1.50;

Prices["Qty_Belt_Drive"]=60.00;

Prices["Qty_Servo_3_6_gram"]=15.00;
Prices["Qty_Servo_5_gram"]=8.00;
Prices["Qty_Servo_9_gram"]=8.00;
Prices["Qty_UltraConnector_Set"]=2.00;
Prices["Qty_JSTConnector_Set"]=2.00;
Prices["Qty_X_Axi_Motor_Mount"]=2.75;

Prices["Qty_Designs_Flag1"]=16.00;
Prices["Qty_Designs_Flag2"]=16.00;
Prices["Qty_Designs_Flag3"]=16.00;
Prices["Qty_Designs_Stars"]=16.00;
Prices["Qty_Designs_Combat"]=16.00;
Prices["Qty_Designs_Race"]=16.00;
Prices["Qty_Designs_Cool1"]=16.00;
Prices["Qty_Designs_Ice"]=16.00;

Prices["Qty_Crystal_Airplane"]=64.95;
Prices["Qty_Custom_3_Inch_L_Bracket"]=8.00;
Prices["Qty_Custom_2_Inch_T_Bracket"]=8.00;
Prices["Qty_Custom_2_Inch_L_Bracket_w_Screws"]=8.50;
Prices["Qty_Custom_3_Inch_L_Bracket_1_in_Wide"]=8.50;

Prices["Qty_Infinity_20mm_Heat_Sink"]=15.00;
<!-- Vinnie -->

// Edit CALCPRICE to add new postal charges
Prices["International_small"]=12.00;
Prices["International_large"]=15.00;
Prices["International_EMS"]=28.00;

// Search for $79.95 if these values change !
var Combo300=38.00;
var Combo400=43.00;
var ComboMMMESC=41.95;
var ComboP10ESC=51.95;
var ComboP25ESC=63.95;

ComboPrices = new Array();

ComboPrices["NoMotor_NoESC"] = 0.0;
ComboPrices["NoMotor_P10_ESC"] = Prices["Qty_CC_P10_ESC"];
ComboPrices["NoMotor_P25_ESC"] = Prices["Qty_CC_P25_ESC"];
ComboPrices["NoMotor_MMM_ESC"] = Prices["Qty_MMM_ESC"];
ComboPrices["300DF_NoESC"] = Prices["Qty_300_DF_Motor"];
ComboPrices["300DF_Pusher_NoESC"] = Prices["Qty_300_DF_Pusher_Motor"];

ComboPrices["300DF_P10_ESC"] = Combo300+ComboP10ESC;
ComboPrices["300DF_P25_ESC"] = Combo300+ComboP25ESC;
ComboPrices["300DF_MMM_ESC"] = Combo300+ComboMMMESC;
ComboPrices["300DF_Pusher_P10_ESC"] = Combo300+ComboP10ESC;
ComboPrices["300DF_Pusher_P25_ESC"] = Combo300+ComboP25ESC;
ComboPrices["300DF_Pusher_MMM_ESC"] = Combo300+ComboMMMESC;

//400T
ComboPrices["400T_NoESC"] = Prices["Qty_400_T_Motor"];
ComboPrices["400T_Pusher_NoESC"] = Prices["Qty_400_T_Pusher_Motor"];
ComboPrices["400T_P10_ESC"] = Combo400+ComboP10ESC;
ComboPrices["400T_P25_ESC"] = Combo400+ComboP25ESC;
ComboPrices["400T_MMM_ESC"] = Combo400+ComboMMMESC;
ComboPrices["400T_Pusher_P10_ESC"] = Combo400+ComboP10ESC;
ComboPrices["400T_Pusher_P25_ESC"] = Combo400+ComboP25ESC;
ComboPrices["400T_Pusher_MMM_ESC"] = Combo400+ComboMMMESC;

// Example:
// writeCookie("myCookie", "my name", 24);
// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.
// from: http://www.webmaster-talk.com/archive/validate-form-entries-t26378.html
function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
   expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

// From http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14267
function FormatAsDollars (amount) {
//
// Make sure we're given a real number to work with:  
   if (amount.isNan) {
     return NaN;
   }
//
// Convert everything to cents. A float is assumed to be
// dollars-and-cents, while an integer is assumed to be in
// dollars.  
   amount = amount*100;
   amount = Math.round(amount);
//
// Handle less-than-a-dollar single-digit and double-digit cases:   
   amount = String(Math.floor(amount));
   if (amount.length == 1) {
     return ("$ 0.0"+amount);
   }
   if (amount.length == 2) {
     return ("$ 0."+amount);
   }
   
//
// First grab the last two characters as cents, and remove them
// from the amount string:
   cents = amount.slice(-2);
   amount = amount.substring(0, amount.length-2);
//
// Now stuff the last three digits at a time into an array, removing
// them from the string. (We have to work backwards to figure where
// commas should go.)
   dollars = [];
   do {
     dollars.push(amount.slice(-3));
     amount = amount.substring(0, amount.length-3);
   } while (amount.length>3);
//
// If there are 1 or 2 numbers remaining, they'll need to be at
// the front of the number, with their own comma. (We need to test
// to make sure we don't end up with $,123.00 or such.)   
   if (amount.length) {
     dollars.push(amount);
   }
//
// Now reverse the array, so the last elements appear first:   
   dollars.reverse();
//
// Finally construct the return string. The "join()" function turns
// an array to a comma-delimited string.   
   return ("$ "+ dollars.join() + "." + cents);
} 

function replaceCharacters(conversionString,inChar,outChar)

{

  var convertedString = conversionString.split(inChar);

  convertedString = convertedString.join(outChar);

  return convertedString;

}

function ConvertSpaceToZero(Element)
{
	if (Element.value=='') Element.value='0';
}


function CalcFinalPrice()
{
	var Total, NumMotors, Shipping, Tax;
	var form_elements_name;
	var form_elements;
	var InvoiceForm = document.OrderForm;
	var form = document.OrderForm;
	var Item;

//	form_elements = form.elements;
	form_elements = document.forms['OrderForm'].elements;
	NumMotors=0;
	Total=0;
	Shipping=0;
	InvoiceForm.Invoice.value="\n"
	for (i = 0; i < form_elements.length; i++) 
	{
		form_elements_object = form_elements[i];
		form_elements_name = form_elements_object.name;
		if (form_elements_object.tagName=="INPUT") 
		{
			if (form_elements_name.substr(0,3)=="Qty")
			{
				qty=form_elements_object.value * 1;	
//				writeCookie(form_elements_object.name, qty, 48);
				if (qty>0)
				{
					Item=replaceCharacters(form_elements_object.name,"_"," ");
					
					Total += Prices[form_elements_object.name]*qty;	
					InvoiceForm.Invoice.value+=qty.toString(10)+"  "+FormatAsDollars(Prices[form_elements_object.name])+"  "+Item.substr(4,Item.length-4)+"\n";  // +"   "+Prices[form_elements_object.name].toString(10)
					if (form_elements_name.substr(form_elements_name.length-5, 5) == "Motor")
					{
						NumMotors+=qty;
					}				
				}
			}
		}
	}
	
	// Add Combo Deal totals !
//
//	Total += form.elements["Combo_price300DF"].value.substr(2)*1;
//	Total += form.elements["Combo_price400T"].value.substr(2)*1;
//	// Check to see if any combo deals included motors - add to qty
//	if (form_elements["Combo300DF_Motor"].value!="") 
//	{
//		if (form_elements["Combo300DF_Motor"].value!="NoMotor")
//		{
//			NumMotors+=1;
//		}
//	}
//	// Check to see if any combo deals included motors - add to qty
//	if (form_elements["Combo400T_Motor"].value!="") 
//	{
//		if (form_elements["Combo400T_Motor"].value!="NoMotor")
//		{
//			NumMotors+=1;
//		}
//	}
//



//		if (form_elements["NYS_Tax"].status==true)   // MS ONLY !
	if (document.forms['OrderForm'].elements['NYS_Tax'].checked==true)
	{
//		writeCookie("NYS_Tax", "TRUE", 48);
		Tax=Math.round(Total*8) /100;

		InvoiceForm.Invoice.value+="   "+FormatAsDollars(Tax)+"  NYS Tax\n"
		Total *= 1.08;
	}

	// HEREHERE
//	if ((form_elements["Qty_Crystal_Airplane"].value * 1)>0)
//	{
//		Shipping=12;
//		form["FinalPrice"].value += " Includes Shipping cost for plane";
//	}
//	else
	{
//		if (form_elements["Shipping"].value==2) // International Shipping   - MS ONLY
		if (document.forms['OrderForm'].elements['Shipping'].value==2)  // International Shipping
		{
//			if (form_elements["International"][1].status==true)	 // MS ONLY
			if (document.forms['OrderForm'].elements['International'][1].checked==true)	
			{
				Shipping = Prices["International_large"];
			}
			else
			{
				if (document.forms['OrderForm'].elements['International'][2].checked==true)	// $24
				{
					Shipping = Prices["International_EMS"];
				}					
				else
				{	// default
					Shipping = Prices["International_small"];
					form_elements["International"][0].checked=true;
				}
			}
			InvoiceForm.Invoice.value+="    "+FormatAsDollars(Shipping)+"  Shipping International \n"
		}
		else
		{
			// Add Shipping !
			if (NumMotors<=1)
			{
				if (Total > 0)
				{
					Shipping=7.00;
					InvoiceForm.Invoice.value+="   "+FormatAsDollars(Shipping)+"  Shipping U.S.\n"
				}
			}
		}
	}
	Total+=Shipping;

	Total = Math.round(Total*100) /100;
	form["FinalPrice"].value = " " + FormatAsDollars(Total);	
//	writeCookie("Shipping", Shipping.toString(10), 48);
	writeCookie("FinalPrice", Total.toString(10), 48);

	if (Total>0)
	{
		if ((form["Shipping"].value!=2) && (NumMotors>1))
		{
			form["FinalPrice"].value += " Free Shipping";
		}
		else
		{
			form["FinalPrice"].value += " Includes Shipping";
		}
	}		
//	parent.frames["bottomFrame"].FinalPrice=form["FinalPrice"].value
//	bottomFrame.FinalPrice=form["FinalPrice"].value
	InvoiceForm.Invoice.value+="-------------------------------------------\nTotal : "+FormatAsDollars(Total);

}

function Price_Change(ComboMotor, ComboESC, ComboGearbox, ComboPrice)
{
	var form = document.OrderForm;
	var Motor = ComboMotor[ComboMotor.selectedIndex].value;
	var ESC = ComboESC[ComboESC.selectedIndex].value;
	var price=ComboPrices[Motor + '_' + ESC];
//vinnie
	if (price==0)
	{	// no discount !
		if (ComboGearbox!= 0) // make sure it's a combo that includes gearbox deal ?
		{
			price+= Prices[ComboGearbox[ComboGearbox.selectedIndex].value];	
		}
	}
	else
	{
		if (ComboGearbox!= 0) // make sure it's a combo that includes gearbox deal ?
		{
			if (ComboGearbox[ComboGearbox.selectedIndex].value!=0) 
			{
				price+= Prices[ComboGearbox[ComboGearbox.selectedIndex].value+'COMBO'];	
			}
		}
	}
	form[ComboPrice.name].value=" "+ FormatAsDollars(price);
	CalcFinalPrice();
}

// Vinnie
// element = form.elements['Qty_300_DF']	// example

// generic routine for an edit or check box field to enable a series of 1..n radio buttons
// when check box is unchecked radio buttons are enabled and third parameter chooses preferred initial setting
// when unchecked the radio buttons are disabled.
// use onBlur="SetPropState(elements['Qty_300_DF'], elements['Prop_300DF'], 1)" 
//  onBlur="SetPropState(elements['Qty_400_F'], elements['Prop_400F'], 2)"
//  onBlur="SetPropState(elements['Qty_400_T'], elements['Prop_400T'], 0)" 
//  onBlur="SetPropState(elements['Qty_400_T_Pusher'], elements['Prop_400T_Pusher'], 0)" 
function SetPropState(Qty, Prop, IdealProp)
{
	var IndexSelected =-1;

	IndexSelected=SetInternationalShippingState(Qty.value==0, Prop);	

	if (IndexSelected < 0)							// only if it's never been changed - set it
	{
		if (Len==1)
		{
			Prop.status=true;	// Choose index of ideal prop 0...2 = 8040, 1045, 1170
			if (Prop.isDisabled==false)
				Prop.focus();
		}
		else
		{
			Prop[IdealProp].status=true;
			if (Prop[IdealProp].isDisabled==false)
				Prop[IdealProp].focus();
		}
	}
	CalcFinalPrice();
}

// If param1 is checked, enable field2,  
// If param1 is unchecked, disable field2 and set field2 to zero
// enableIfChecked(elements['EmailResults'], elements['Qty_B29_10_1000_Motor'])
function enableIfChecked(FieldChecked, DisEnableField)
{
	DisEnableField.disabled=FieldChecked.checked==false;
	if (FieldChecked.checked==false)  
		DisEnableField.value="0";
	CalcFinalPrice();
}
// If state is false - disable Prop
function SetInternationalShippingState(state, Prop)
{
	var IndexSelected =-1;
	var Len;
	var bValue=false;
	
	if (Prop[0]==null)	// only one radio button
		Len=1;
	else
		Len=Prop.length;	// take from array element
	//LW added '&& form.P25_or_Better.checked==false'
	for (i=0;i<Len;i++)
	{
		if (Len==1)
		{
			Prop.disabled=(Qty.value==0);
			if (Prop.status==true)
				IndexSelected=0;	// only one to choose from
		}
		else
		{
			if (state.type="undefined")
				bValue=state;
			else
				if (state.type="checkbox") 
					bValue=(state.status=false);
				else 
					bValue=state.value;
			Prop[i].disabled=bValue; // (bValue==0)||(Qty.type=="checkbox" && Qty.status==false);
			if (Prop[i].status==true)	// check to see if one was previously selected - if so don't change it
			{
				IndexSelected=i;
			}
		}
	}
}

function IsCheckBoxChecked()
{
	var form = document.OrderForm;
	CalcFinalPrice();
	//LW added '&& form.P25_or_Better.checked==false'
	if (form.Qty_400DH_Motor.value>0 && form.P25_or_Better.checked==false)
	{
		alert("Castle Creations P25 required for this motor !");
		form.Qty_400DH_Motor.focus(); //LW changed from form.P25_or_Better.focus();
		form.Qty_400DH_Motor.value = 0; //LW added
		return false;
	}
	return true;
}

// Vinnie Validation Script

function check400dh(form) { 
	if (form.value>0)
	{
		if (form.P25_or_Better.checked==false)
		{
			alert("Castle Creations P25 required for this motor !");
			return false;
		}
	}
	return true;
}

function right(evnt){
if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null) {
if (evnt.which >= 2){
alert("Scroll to the bottom of the form to submit the order. All orders will be replied to with a quote.");
return false;
}
}else if (event.button>=2) alert("Scroll to the bottom of the form to submit the order. All orders will be replied to with a quote.");
}

document.onmousedown = right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
