function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

prices = new Array();

usd_car = 0;
prices[usd_car] = new Array();
prices[usd_car][1] = 50.00;
prices[usd_car][2] = 46.00;
prices[usd_car][3] = 46.00;
prices[usd_car][4] = 46.00;
prices[usd_car][5] = 43.00;
prices[usd_car][6] = 43.00;
prices[usd_car][7] = 43.00;
prices[usd_car][8] = 43.00;
prices[usd_car][9] = 43.00;
prices[usd_car][10] = 40.00;
prices[usd_car][25] = 37.00;
prices[usd_car][50] = 34.00;
old_usd_car = 1;
prices[old_usd_car] = new Array();
prices[old_usd_car][1] = 55.00;
prices[old_usd_car][2] = 48.00;
prices[old_usd_car][3] = 46.00;
prices[old_usd_car][4] = 44.00;
prices[old_usd_car][5] = 42.00;
prices[old_usd_car][6] = 40.00;
prices[old_usd_car][7] = 40.00;
prices[old_usd_car][8] = 40.00;
prices[old_usd_car][9] = 40.00;
prices[old_usd_car][10] = 40.00;
prices[old_usd_car][25] = 40.00;
prices[old_usd_car][50] = 40.00;
rec_veh = 2;
prices[rec_veh] = new Array();
prices[rec_veh][1] = 90.00;
prices[rec_veh][2] = 87.00;
prices[rec_veh][3] = 84.00;
prices[rec_veh][4] = 82.00;
prices[rec_veh][5] = 80.00;
prices[rec_veh][6] = 78.00;
prices[rec_veh][7] = 78.00;
prices[rec_veh][8] = 78.00;
prices[rec_veh][9] = 78.00;
prices[rec_veh][10] = 78.00;
prices[rec_veh][25] = 78.00;
prices[rec_veh][50] = 78.00;
motrcy = 3;
prices[motrcy] = new Array();
prices[motrcy][1] = 50.00;
prices[motrcy][2] = 46.00;
prices[motrcy][3] = 41.00;
prices[motrcy][4] = 39.00;
prices[motrcy][5] = 37.00;
prices[motrcy][6] = 35.00;
prices[motrcy][7] = 35.00;
prices[motrcy][8] = 35.00;
prices[motrcy][9] = 35.00;
prices[motrcy][10] = 35.00;
prices[motrcy][25] = 35.00;
prices[motrcy][50] = 35.00;
man_home = 4;
prices[man_home] = new Array();
prices[man_home][1] = 95.00;
prices[man_home][2] = 83.00;
prices[man_home][3] = 81.00;
prices[man_home][4] = 79.00;
prices[man_home][5] = 77.00;
prices[man_home][6] = 76.00;
prices[man_home][7] = 76.00;
prices[man_home][8] = 76.00;
prices[man_home][9] = 76.00;
prices[man_home][10] = 76.00;
prices[man_home][25] = 76.00;
prices[man_home][50] = 76.00;
clas_coll = 5;
prices[clas_coll] = new Array();
prices[clas_coll][1] = 40.00;
prices[clas_coll][2] = 36.00;
prices[clas_coll][3] = 32.00;
prices[clas_coll][4] = 30.00;
prices[clas_coll][5] = 28.00;
prices[clas_coll][6] = 26.00;
prices[clas_coll][7] = 26.00;
prices[clas_coll][8] = 26.00;
prices[clas_coll][9] = 26.00;
prices[clas_coll][10] = 26.00;
prices[clas_coll][25] = 26.00;
prices[clas_coll][50] = 26.00;
title_reg = 6;
prices[title_reg] = new Array();
prices[title_reg][1] = 95.00;
prices[title_reg][2] = 85.00;
prices[title_reg][3] = 85.00;
prices[title_reg][4] = 85.00;
prices[title_reg][5] = 80.00;
prices[title_reg][6] = 80.00;
prices[title_reg][7] = 80.00;
prices[title_reg][8] = 80.00;
prices[title_reg][9] = 80.00;
prices[title_reg][10] = 75.00;
prices[title_reg][25] = 75.00;
prices[title_reg][50] = 75.00;
van_truck = 7;
prices[van_truck] = new Array();
prices[van_truck][1] = 30.00;
prices[van_truck][2] = 25.00;
prices[van_truck][3] = 25.00;
prices[van_truck][4] = 25.00;
prices[van_truck][5] = 23.00;
prices[van_truck][6] = 23.00;
prices[van_truck][7] = 23.00;
prices[van_truck][8] = 23.00;
prices[van_truck][9] = 23.00;
prices[van_truck][10] = 21.00;
prices[van_truck][15] = 20.00;
prices[van_truck][50] = 20.00;
com_truck = 8;
prices[com_truck] = new Array();
prices[com_truck][1] = 100.00;
prices[com_truck][2] = 100.00;
prices[com_truck][3] = 100.00;
prices[com_truck][4] = 100.00;
prices[com_truck][5] = 100.00;
prices[com_truck][6] = 100.00;
prices[com_truck][7] = 100.00;
prices[com_truck][8] = 100.00;
prices[com_truck][9] = 100.00;
prices[com_truck][10] = 100.00;
prices[com_truck][25] = 100.00;
prices[com_truck][50] = 100.00;
marine = 9;
prices[marine] = new Array();
prices[marine][1] = 95.00;
prices[marine][2] = 86.00;
prices[marine][3] = 83.00;
prices[marine][4] = 81.00;
prices[marine][5] = 79.00;
prices[marine][6] = 78.00;
prices[marine][7] = 78.00;
prices[marine][8] = 78.00;
prices[marine][9] = 78.00;
prices[marine][10] = 78.00;
prices[marine][25] = 78.00;
prices[marine][50] = 78.00;
old_marine = 10;
prices[old_marine] = new Array();
prices[old_marine][1] = 62.00;
prices[old_marine][2] = 55.00;
prices[old_marine][3] = 53.00;
prices[old_marine][4] = 51.00;
prices[old_marine][5] = 49.00;
prices[old_marine][6] = 47.00;
prices[old_marine][7] = 47.00;
prices[old_marine][8] = 47.00;
prices[old_marine][9] = 47.00;
prices[old_marine][10] = 47.00;
prices[old_marine][25] = 47.00;
prices[old_marine][50] = 47.00;
bb_onccg = 11;
prices[bb_onccg] = new Array();
prices[bb_onccg][50] = 81.00;
prices[bb_onccg][25] = 81.00;
prices[bb_onccg][10] = 81.00;
prices[bb_onccg][9] = 81.00;
prices[bb_onccg][8] = 81.00;
prices[bb_onccg][7] = 81.00;
prices[bb_onccg][6] = 81.00;
prices[bb_onccg][5] = 81.00;
prices[bb_onccg][4] = 81.00;
prices[bb_onccg][3] = 81.00;
prices[bb_onccg][2] = 81.00;
prices[bb_onccg][1] = 81.00;
bb_ucmgw = 12;
prices[bb_ucmgw] = new Array();
prices[bb_ucmgw][1] = 99.00;
prices[bb_ucmgw][2] = 99.00;
prices[bb_ucmgw][3] = 99.00;
prices[bb_ucmgw][4] = 99.00;
prices[bb_ucmgw][5] = 99.00;
prices[bb_ucmgw][6] = 99.00;
prices[bb_ucmgw][7] = 99.00;
prices[bb_ucmgw][8] = 99.00;
prices[bb_ucmgw][9] = 99.00;
prices[bb_ucmgw][10] = 99.00;
prices[bb_ucmgw][25] = 99.00;
prices[bb_ucmgw][50] = 99.00;
bb_utvsuv = 13;
prices[bb_utvsuv] = new Array();
prices[bb_utvsuv][1] = 83.70;
prices[bb_utvsuv][2] = 83.70;
prices[bb_utvsuv][3] = 83.70;
prices[bb_utvsuv][4] = 83.70;
prices[bb_utvsuv][5] = 83.70;
prices[bb_utvsuv][6] = 83.70;
prices[bb_utvsuv][7] = 83.70;
prices[bb_utvsuv][8] = 83.70;
prices[bb_utvsuv][9] = 83.70;
prices[bb_utvsuv][10] = 83.70;
prices[bb_utvsuv][25] = 83.70;
prices[bb_utvsuv][50] = 83.70;
bb_ocmgm = 14;
prices[bb_ocmgm] = new Array();
prices[bb_ocmgm][1] = 65.70;
prices[bb_ocmgm][2] = 65.70;
prices[bb_ocmgm][3] = 65.70;
prices[bb_ocmgm][4] = 65.70;
prices[bb_ocmgm][5] = 65.70;
prices[bb_ocmgm][6] = 65.70;
prices[bb_ocmgm][7] = 65.70;
prices[bb_ocmgm][8] = 65.70;
prices[bb_ocmgm][9] = 65.70;
prices[bb_ocmgm][10] = 65.70;
prices[bb_ocmgm][25] = 65.70;
prices[bb_ocmgm][50] = 65.70;
bb_ucmg = 15;
prices[bb_ucmg] = new Array();
prices[bb_ucmg][1] = 72.00;
prices[bb_ucmg][2] = 72.00;
prices[bb_ucmg][3] = 72.00;
prices[bb_ucmg][4] = 72.00;
prices[bb_ucmg][5] = 72.00;
prices[bb_ucmg][6] = 72.00;
prices[bb_ucmg][7] = 72.00;
prices[bb_ucmg][8] = 72.00;
prices[bb_ucmg][9] = 72.00;
prices[bb_ucmg][10] = 72.00;
prices[bb_ucmg][25] = 72.00;
prices[bb_ucmg][50] = 72.00;
bb_xorucpg = 16;
prices[bb_xorucpg] = new Array();
prices[bb_xorucpg][1] = 76.50;
prices[bb_xorucpg][2] = 76.50;
prices[bb_xorucpg][3] = 76.50;
prices[bb_xorucpg][4] = 76.50;
prices[bb_xorucpg][5] = 76.50;
prices[bb_xorucpg][6] = 76.50;
prices[bb_xorucpg][7] = 76.50;
prices[bb_xorucpg][8] = 76.50;
prices[bb_xorucpg][9] = 76.50;
prices[bb_xorucpg][10] = 76.50;
prices[bb_xorucpg][25] = 76.50;
prices[bb_xorucpg][50] = 76.50;
bb_cpicvvg = 17;
prices[bb_cpicvvg] = new Array();
prices[bb_cpicvvg][1] = 43.20;
prices[bb_cpicvvg][2] = 43.20;
prices[bb_cpicvvg][3] = 43.20;
prices[bb_cpicvvg][4] = 43.20;
prices[bb_cpicvvg][5] = 43.20;
prices[bb_cpicvvg][6] = 43.20;
prices[bb_cpicvvg][7] = 43.20;
prices[bb_cpicvvg][8] = 43.20;
prices[bb_cpicvvg][9] = 43.20;
prices[bb_cpicvvg][10] = 43.20;
prices[bb_cpicvvg][25] = 43.20;
prices[bb_cpicvvg][50] = 43.20;
bb_omvc = 18;
prices[bb_omvc] = new Array();
prices[bb_omvc][1] = 69.30;
prices[bb_omvc][2] = 69.30;
prices[bb_omvc][3] = 69.30;
prices[bb_omvc][4] = 69.30;
prices[bb_omvc][5] = 69.30;
prices[bb_omvc][6] = 69.30;
prices[bb_omvc][7] = 69.30;
prices[bb_omvc][8] = 69.30;
prices[bb_omvc][9] = 69.30;
prices[bb_omvc][10] = 69.30;
prices[bb_omvc][25] = 69.30;
prices[bb_omvc][50] = 69.30;
bb_ohdttg = 19;
prices[bb_ohdttg] = new Array();
prices[bb_ohdttg][1] = 90.00;
prices[bb_ohdttg][2] = 90.00;
prices[bb_ohdttg][3] = 90.00;
prices[bb_ohdttg][4] = 90.00;
prices[bb_ohdttg][5] = 90.00;
prices[bb_ohdttg][6] = 90.00;
prices[bb_ohdttg][7] = 90.00;
prices[bb_ohdttg][8] = 90.00;
prices[bb_ohdttg][9] = 90.00;
prices[bb_ohdttg][10] = 90.00;
prices[bb_ohdttg][25] = 90.00;
prices[bb_ohdttg][50] = 90.00;
bb_orvg = 20;
prices[bb_orvg] = new Array();
prices[bb_orvg][1] = 73.80;
prices[bb_orvg][2] = 73.80;
prices[bb_orvg][3] = 73.80;
prices[bb_orvg][4] = 73.80;
prices[bb_orvg][5] = 73.80;
prices[bb_orvg][6] = 73.80;
prices[bb_orvg][7] = 73.80;
prices[bb_orvg][8] = 73.80;
prices[bb_orvg][9] = 73.80;
prices[bb_orvg][10] = 73.80;
prices[bb_orvg][25] = 73.80;
prices[bb_orvg][50] = 73.80;


function find_price(quantity_field) 
{
	// This uses JS's eval function to convert the name of the
	// HTML field ( "new_veh", for example) into its appropriate
	// index number.
	var guide_type_index = eval(quantity_field.name);

	// This looks at the array stored in the JS prices[index] array
	// (counting downwards) and compares our order count to each count limit
	// until the amount ordered is greater than the count limit.  Then we
	// return that amount
	for (i=prices[guide_type_index].length; i >= 0; i--) {
		if (prices[guide_type_index][i] && quantity_field.value >= i) 
			return prices[guide_type_index][i];
	}
	return 0;
}
	
function dp(price)
 {
    
    string = "" + price;
    number = string.length - string.indexOf('.');
    if (string.indexOf('.') == -1)
       return string + '.00';
    if (number == 1)
       return string + '00';
    if (number == 2)
       return string + '0';
    if (number > 3)
       return string.substring(0,string.length-number+3);
 return string;
 }

 function checkInt(checkField) {
	if (checkField.value == '') { return; }
 if (parseInt(checkField.value) != checkField.value || parseInt(checkField.value) < 0) {
		alert("Please enter a non-decimal, positive number");
		checkField.value = "";
		checkField.focus();
		return false;
	}	
	return true;
}
 
 
 function calculate()
 {
 	// The following function checks to make sure the entered values are positive integers

 
     document.calcform.usd_car_p.value = find_price(document.calcform.usd_car);
      document.calcform.usd_car_t.value = dp((document.calcform.usd_car_p.value)*(document.calcform.usd_car.value));
     document.calcform.old_usd_car_p.value = find_price(document.calcform.old_usd_car);
      document.calcform.old_usd_car_t.value = dp((document.calcform.old_usd_car_p.value)*(document.calcform.old_usd_car.value));
     document.calcform.rec_veh_p.value = find_price(document.calcform.rec_veh);
      document.calcform.rec_veh_t.value = dp((document.calcform.rec_veh_p.value)*(document.calcform.rec_veh.value));
     document.calcform.motrcy_p.value = find_price(document.calcform.motrcy);
      document.calcform.motrcy_t.value = dp((document.calcform.motrcy_p.value)*(document.calcform.motrcy.value));
     document.calcform.man_home_p.value = find_price(document.calcform.man_home);
      document.calcform.man_home_t.value = dp((document.calcform.man_home_p.value)*(document.calcform.man_home.value));
     document.calcform.clas_coll_p.value = find_price(document.calcform.clas_coll);
      document.calcform.clas_coll_t.value = dp((document.calcform.clas_coll_p.value)*(document.calcform.clas_coll.value));
     document.calcform.title_reg_p.value = find_price(document.calcform.title_reg);
      document.calcform.title_reg_t.value = dp((document.calcform.title_reg_p.value)*(document.calcform.title_reg.value));
     document.calcform.van_truck_p.value = find_price(document.calcform.van_truck);
      document.calcform.van_truck_t.value = dp((document.calcform.van_truck_p.value)*(document.calcform.van_truck.value));
     document.calcform.com_truck_p.value = find_price(document.calcform.com_truck);
      document.calcform.com_truck_t.value = dp((document.calcform.com_truck_p.value)*(document.calcform.com_truck.value));
     document.calcform.marine_p.value = find_price(document.calcform.marine);
      document.calcform.marine_t.value = dp((document.calcform.marine_p.value)*(document.calcform.marine.value));
     document.calcform.old_marine_p.value = find_price(document.calcform.old_marine);
      document.calcform.old_marine_t.value = dp((document.calcform.old_marine_p.value)*(document.calcform.old_marine.value));
     document.calcform.bb_onccg_p.value = find_price(document.calcform.bb_onccg);
      document.calcform.bb_onccg_t.value = dp((document.calcform.bb_onccg_p.value)*(document.calcform.bb_onccg.value));
     document.calcform.bb_ucmgw_p.value = find_price(document.calcform.bb_ucmgw);
      document.calcform.bb_ucmgw_t.value = dp((document.calcform.bb_ucmgw_p.value)*(document.calcform.bb_ucmgw.value));
     document.calcform.bb_utvsuv_p.value = find_price(document.calcform.bb_utvsuv);
      document.calcform.bb_utvsuv_t.value = dp((document.calcform.bb_utvsuv_p.value)*(document.calcform.bb_utvsuv.value));
     document.calcform.bb_ocmgm_p.value = find_price(document.calcform.bb_ocmgm);
      document.calcform.bb_ocmgm_t.value = dp((document.calcform.bb_ocmgm_p.value)*(document.calcform.bb_ocmgm.value));
     document.calcform.bb_ucmg_p.value = find_price(document.calcform.bb_ucmg);
      document.calcform.bb_ucmg_t.value = dp((document.calcform.bb_ucmg_p.value)*(document.calcform.bb_ucmg.value));
     document.calcform.bb_xorucpg_p.value = find_price(document.calcform.bb_xorucpg);
      document.calcform.bb_xorucpg_t.value = dp((document.calcform.bb_xorucpg_p.value)*(document.calcform.bb_xorucpg.value));
     document.calcform.bb_cpicvvg_p.value = find_price(document.calcform.bb_cpicvvg);
      document.calcform.bb_cpicvvg_t.value = dp((document.calcform.bb_cpicvvg_p.value)*(document.calcform.bb_cpicvvg.value));
     document.calcform.bb_omvc_p.value = find_price(document.calcform.bb_omvc);
      document.calcform.bb_omvc_t.value = dp((document.calcform.bb_omvc_p.value)*(document.calcform.bb_omvc.value));
     document.calcform.bb_ohdttg_p.value = find_price(document.calcform.bb_ohdttg);
      document.calcform.bb_ohdttg_t.value = dp((document.calcform.bb_ohdttg_p.value)*(document.calcform.bb_ohdttg.value));
     document.calcform.bb_orvg_p.value = find_price(document.calcform.bb_orvg);
      document.calcform.bb_orvg_t.value = dp((document.calcform.bb_orvg_p.value)*(document.calcform.bb_orvg.value));

subt = parseFloat(document.calcform.usd_car_t.value) + 
parseFloat(document.calcform.old_usd_car_t.value) + 
parseFloat(document.calcform.rec_veh_t.value) + 
parseFloat(document.calcform.motrcy_t.value) + 
parseFloat(document.calcform.man_home_t.value) + 
parseFloat(document.calcform.clas_coll_t.value) + 
parseFloat(document.calcform.title_reg_t.value) + 
parseFloat(document.calcform.van_truck_t.value) + 
parseFloat(document.calcform.com_truck_t.value) + 
parseFloat(document.calcform.marine_t.value) + 
parseFloat(document.calcform.old_marine_t.value) + 
parseFloat(document.calcform.bb_onccg_t.value) + 
parseFloat(document.calcform.bb_ucmgw_t.value) + 
parseFloat(document.calcform.bb_utvsuv_t.value) + 
parseFloat(document.calcform.bb_ocmgm_t.value) + 
parseFloat(document.calcform.bb_ucmg_t.value) + 
parseFloat(document.calcform.bb_xorucpg_t.value) + 
parseFloat(document.calcform.bb_cpicvvg_t.value) + 
parseFloat(document.calcform.bb_omvc_t.value) + 
parseFloat(document.calcform.bb_ohdttg_t.value) + 
parseFloat(document.calcform.bb_orvg_t.value);

document.calcform.total.value = dp(subt);

}
