function  isNumb(passStr) {
 	var regEx  =  /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/;
 	return regEx.test(passStr);
}
function calcula_campos_A(){
	for (cnt=0; cnt < document.formulario.elements.length; cnt++) {
		if (!isNumb(document.formulario.elements[cnt].value.toString()) && document.formulario.elements[cnt].type == "text") {
			document.formulario.elements[cnt].value = "";
		}
	}
campo1=document.formulario.campo1.value;
campo2=document.formulario.campo2.value;
campo3=document.formulario.campo3.value;
resultado = campo1*campo2;
document.formulario.resultado.value = resultado.toFixed(2);
resultado2 = (campo1*campo2*0.6)+((((campo1*campo2)+(campo1*campo2*0.6))/0.84)*0.15)+(((campo1*campo2)+(campo1*campo2*0.6)+((((campo1*campo2)+(campo1*campo2*0.6))/0.84)*0.15)/0.99)*0.01)+(campo1*0.68*campo3)+(campo1*15);
document.formulario.resultado2.value = resultado2.toFixed(2);
resultado3 = (campo1*campo2)+(campo1*campo2*0.6)+((((campo1*campo2)+(campo1*campo2*0.6))/0.84)*0.15)+(((campo1*campo2)+(campo1*campo2*0.6)+((((campo1*campo2)+(campo1*campo2*0.6))/0.84)*0.15)/0.99)*0.01)+(campo1*0.68*campo3)+(campo1*15);
document.formulario.resultado3.value = resultado3.toFixed(2);
}

function gearcalc() {
	for (cnt=0; cnt < document.formulario1.elements.length; cnt++) {
		if (!isNumb(document.formulario1.elements[cnt].value.toString()) && document.formulario1.elements[cnt].type == "text") {
			document.formulario1.elements[cnt].value = "";
		}
	}
	if (document.formulario1.ntd.value.toString()==""&&document.formulario1.pm1.value.toString()>""&&document.formulario1.pm2.value.toString()>""&&document.formulario1.pmr.value.toString()>"") {
		document.formulario1.ntw.value = Math.round((document.formulario1.pm1.value.toString()/25.4)*10)/10;
		document.formulario1.nth.value = Math.round(document.formulario1.ntw.value.toString()*(document.formulario1.pm2.value.toString()/100)*10)/10;
    	document.formulario1.ntd.value = Math.round((((2 * document.formulario1.pm1.value.toString() * document.formulario1.pm2.value.toString()) / 2540) + parseInt(document.formulario1.pmr.value.toString()))*10)/10;
    }

	if (document.formulario1.pmr.value.toString()==""&&document.formulario1.pm1.value.toString()>""&&document.formulario1.pm2.value.toString()>""&&document.formulario1.ntd.value.toString()>"") {
	    document.formulario1.pmr.value = Math.round((document.formulario1.ntd.value.toString() - ((2 * document.formulario1.pm1.value.toString() * document.formulario1.pm2.value.toString()) / 2540))*10)/10;
		document.formulario1.ntw.value = Math.round((document.formulario1.pm1.value.toString()/25.4)*10)/10;
		document.formulario1.nth.value = Math.round(document.formulario1.ntw.value.toString()*(document.formulario1.pm2.value.toString()/100)*10)/10;
    }

	if (document.formulario1.pm1.value.toString()==""&&document.formulario1.pmr.value.toString()>""&&document.formulario1.pm2.value.toString()>""&&document.formulario1.ntd.value.toString()>"") {
	    document.formulario1.pm1.value = Math.round(((document.formulario1.ntd.value.toString() - document.formulario1.pmr.value.toString()) * 2540) / (2 * document.formulario1.pm2.value.toString()));
    }

	if (document.formulario1.pm2.value.toString()==""&&document.formulario1.pmr.value.toString()>""&&document.formulario1.pm1.value.toString()>""&&document.formulario1.ntd.value.toString()>"") {
	    document.formulario1.pm2.value = Math.round(((document.formulario1.ntd.value.toString() - document.formulario1.pmr.value.toString()) * 2540) / (2 * document.formulario1.pm1.value.toString()));
		document.formulario1.ntw.value = Math.round((document.formulario1.pm1.value.toString()/25.4)*10)/10;
		document.formulario1.ntw.value = document.formulario1.ntw.value.toString();
		document.formulario1.nth.value = Math.round(document.formulario1.ntw.value.toString()*(document.formulario1.pm2.value.toString()/100)*10)/10;
    }
}

function tyrecalc() {
	for (cnt=0; cnt < document.formulario2.elements.length; cnt++) {
		if (!isNumb(document.formulario2.elements[cnt].value.toString()) && document.formulario2.elements[cnt].type == "text") {
			document.formulario2.elements[cnt].value = "";
		}
	}
	if (document.formulario2.nsp.value.toString()==""&&document.formulario2.ntd.value.toString()>""&&document.formulario2.otd.value.toString()>""&&document.formulario2.osp.value.toString()>"") {
	   document.formulario2.nsp.value = Math.round(((document.formulario2.ntd.value.toString()/document.formulario2.otd.value.toString())*document.formulario2.osp.value.toString())*10)/10;
       return;
	}

	if (document.formulario2.osp.value.toString()==""&&document.formulario2.ntd.value.toString()>""&&document.formulario2.otd.value.toString()>""&&document.formulario2.nsp.value.toString()>"") {
	   document.formulario2.osp.value = Math.round(((document.formulario2.otd.value.toString()/document.formulario2.ntd.value.toString())*document.formulario2.nsp.value.toString())*10)/10;
       return;
	}

	if (document.formulario2.ntd.value.toString()==""&&document.formulario2.osp.value.toString()>""&&document.formulario2.otd.value.toString()>""&&document.formulario2.nsp.value.toString()>"") {
	   document.formulario2.ntd.value = Math.round(((document.formulario2.nsp.value.toString()/document.formulario2.osp.value.toString())*document.formulario2.otd.value.toString())*10)/10;
       return;
	}

	if (document.formulario2.otd.value.toString()==""&&document.formulario2.osp.value.toString()>""&&document.formulario2.ntd.value.toString()>""&&document.formulario2.nsp.value.toString()>"") {
	   document.formulario2.otd.value = Math.round(((document.formulario2.osp.value.toString()/document.formulario2.nsp.value.toString())*document.formulario2.ntd.value.toString())*10)/10;
       return;
	}
}
function relacao() {
	for (cnt=0; cnt < document.formulario3.elements.length; cnt++) {
		if (!isNumb(document.formulario3.elements[cnt].value.toString()) && document.formulario3.elements[cnt].type == "text") {
			document.formulario3.elements[cnt].value = "";
		}
	}

	if (document.formulario3.ogr.value.toString()>""&&document.formulario3.trn.value.toString()>""&&document.formulario3.trc.value.toString()>"") {
		document.formulario3.crr.value = Math.round((document.formulario3.ogr.value.toString() * document.formulario3.trn.value.toString() * document.formulario3.trc.value.toString())*100)/100;
		document.formulario3.crr.value = document.formulario3.crr.value.toString() + ":1";
	}

	if (document.formulario3.rpm.value.toString()==""&&document.formulario3.mph.value.toString()>""&&document.formulario3.ogr.value.toString()>""&&document.formulario3.trn.value.toString()>""&&document.formulario3.trc.value.toString()>""&&document.formulario3.otd.value.toString()>"") {
		document.formulario3.rpm.value = Math.round(((document.formulario3.mph.value.toString() * document.formulario3.ogr.value.toString() * document.formulario3.trn.value.toString() * document.formulario3.trc.value.toString() * 336)/document.formulario3.otd.value.toString())*10)/10;
	}

	if (document.formulario3.mph.value.toString()==""&&document.formulario3.rpm.value.toString()>""&&document.formulario3.ogr.value.toString()>""&&document.formulario3.trn.value.toString()>""&&document.formulario3.trc.value.toString()>""&&document.formulario3.otd.value.toString()>"") {
	    document.formulario3.mph.value = Math.round(((document.formulario3.rpm.value.toString() * document.formulario3.otd.value.toString()) / (document.formulario3.ogr.value.toString() * document.formulario3.trn.value.toString() * document.formulario3.trc.value.toString() * 336))*10)/10;
	}

	if (document.formulario3.ogr.value.toString()==""&&document.formulario3.rpm.value.toString()>""&&document.formulario3.mph.value.toString()>""&&document.formulario3.trn.value.toString()>""&&document.formulario3.trc.value.toString()>""&&document.formulario3.otd.value.toString()>"") {
		document.formulario3.ogr.value = Math.round(((document.formulario3.rpm.value.toString() * document.formulario3.otd.value.toString()) / (document.formulario3.mph.value.toString() * document.formulario3.trn.value.toString() * document.formulario3.trc.value.toString() * 336))*100)/100;
	}

	if (document.formulario3.trn.value.toString()==""&&document.formulario3.rpm.value.toString()>""&&document.formulario3.mph.value.toString()>""&&document.formulario3.ogr.value.toString()>""&&document.formulario3.trc.value.toString()>""&&document.formulario3.otd.value.toString()>"") {
		document.formulario3.trn.value = Math.round(((document.formulario3.rpm.value.toString() * document.formulario3.otd.value.toString()) / (document.formulario3.mph.value.toString() * document.formulario3.ogr.value.toString() * document.formulario3.trc.value.toString() * 336))*100)/100;
	}

	if (document.formulario3.trc.value.toString()==""&&document.formulario3.rpm.value.toString()>""&&document.formulario3.mph.value.toString()>""&&document.formulario3.ogr.value.toString()>""&&document.formulario3.trn.value.toString()>""&&document.formulario3.otd.value.toString()>"") {
		document.formulario3.trc.value = Math.round(((document.formulario3.rpm.value.toString() * document.formulario3.otd.value.toString()) / (document.formulario3.mph.value.toString() * document.formulario3.ogr.value.toString() * document.formulario3.trn.value.toString() * 336))*100)/100;
	}

	if (document.formulario3.otd.value.toString()==""&&document.formulario3.mph.value.toString()>""&&document.formulario3.ogr.value.toString()>""&&document.formulario3.trn.value.toString()>""&&document.formulario3.trc.value.toString()>""&&document.formulario3.rpm.value.toString()>"") {
		document.formulario3.otd.value = Math.round(((document.formulario3.mph.value.toString() * document.formulario3.ogr.value.toString() * document.formulario3.trn.value.toString() * document.formulario3.trc.value.toString() * 336)/document.formulario3.rpm.value.toString())*10)/10;
	}
}
function novarelacao() {
	for (cnt=0; cnt < document.formulario4.elements.length; cnt++) {
		if (!isNumb(document.formulario4.elements[cnt].value.toString()) && document.formulario4.elements[cnt].type == "text") {
			document.formulario4.elements[cnt].value = "";
		}
	}

	if (document.formulario4.agr.value.toString()=="" &&document.formulario4.ogr.value.toString()>""&&document.formulario4.otd.value.toString()>""&&document.formulario4.ntd.value.toString()>"") {
	   document.formulario4.agr.value = Math.round(((document.formulario4.otd.value.toString() / document.formulario4.ntd.value.toString()) * document.formulario4.ogr.value.toString())*100)/100;
	   document.formulario4.agr.value = document.formulario4.agr.value.toString() + ":1";
	   document.formulario4.hgr.value = Math.round((((document.formulario4.ntd.value.toString() / document.formulario4.otd.value.toString()) * document.formulario4.ogr.value.toString()) - (((document.formulario4.ntd.value.toString() / document.formulario4.otd.value.toString()) * document.formulario4.ogr.value.toString()) * .09))*100)/100;
	   document.formulario4.hgr.value = document.formulario4.hgr.value.toString() + ":1";
	   document.formulario4.ngr.value = Math.round(((document.formulario4.ntd.value.toString() / document.formulario4.otd.value.toString()) * document.formulario4.ogr.value.toString())*100)/100;
	   document.formulario4.ngr.value = document.formulario4.ngr.value.toString() + ":1";
	   document.formulario4.lgr.value = Math.round((((document.formulario4.ntd.value.toString() / document.formulario4.otd.value.toString()) * document.formulario4.ogr.value.toString()) + (((document.formulario4.ntd.value.toString() / document.formulario4.otd.value.toString()) * document.formulario4.ogr.value.toString()) * .09))*100)/100;
	   document.formulario4.lgr.value = document.formulario4.lgr.value.toString() + ":1";
       return;
	}
}
function ringpinion() {
	for (cnt=0; cnt < document.formulario5.elements.length; cnt++) {
		if (!isNumb(document.formulario5.elements[cnt].value.toString()) && document.formulario5.elements[cnt].type == "text") {
			document.formulario5.elements[cnt].value = "";
		}
	}

	if (document.formulario5.ngr2.value.toString()==""&&document.formulario5.rgc.value.toString()>""&&document.formulario5.pgc.value.toString()>"") {
	   document.formulario5.ngr2.value = Math.round((document.formulario5.rgc.value.toString()/document.formulario5.pgc.value.toString())*100)/100;
       return;
	}

	if (document.formulario5.pgc.value.toString()==""&&document.formulario5.rgc.value.toString()>""&&document.formulario5.ngr2.value.toString()>"") {
	   document.formulario5.pgc.value = Math.round((document.formulario5.rgc.value.toString()/document.formulario5.ngr2.value.toString())*100)/100;
       return;
	}

	if (document.formulario5.rgc.value.toString()==""&&document.formulario5.pgc.value.toString()>""&&document.formulario5.ngr2.value.toString()>"") {
	   document.formulario5.rgc.value = Math.round((document.formulario5.pgc.value.toString()*document.formulario5.ngr2.value.toString())*100)/100;
       return;
	}
}
function rtitable() {
	for (cnt=0; cnt < document.formulario6.elements.length; cnt++) {
		if (!isNumb(document.formulario6.elements[cnt].value.toString()) && document.formulario6.elements[cnt].type == "text") {
			document.formulario6.elements[cnt].value = "";
		}
	}

	if (document.formulario6.tht.value.toString()>""&&document.formulario6.whb.value.toString()>"") {
		ang = Math.sin(20 * Math.PI/180);
		inc = document.formulario6.tht.value.toString()/ang;
		document.formulario6.rti.value = Math.round(inc/document.formulario6.whb.value.toString()*1000);
		document.formulario6.itr.value = Math.round(inc*10)/10;
    }
}
var trannyList     = [];
var tcaseList      = [];
var underdriveList = [];
function Transmission(name, gears, gear1, gear2, gear3, gear4, gear5, gear6, gearR, mult) {
    this.Name = name;
    this.ForwardGears = gears;
    this.TrannyGear1 = gear1;
    this.TrannyGear2 = gear2;
    this.TrannyGear3 = gear3;
    this.TrannyGear4 = gear4;
    this.TrannyGear5 = gear5;
    this.TrannyGear6 = gear6;
    this.ReverseGear = gearR;
    this.TrannyMultiplier = mult;
}
function TrannyGears(form) {
    trannyIndex = 0;
    var ForwardGears     = 0;
    var TrannyGear1      = 0.00;
    var TrannyGear2      = 0.00;
    var TrannyGear3      = 0.00;
    var TrannyGear4      = 0.00;
    var TrannyGear5      = 0.00;
    var TrannyGear6      = 0.00;
    var ReverseGear      = 0.00;
    var TrannyMultiplier = 0;
        ForwardGears = parseInt(form.EntryGears.value);
        TrannyGear1  = parseFloat(form.EntryRatio1.value);
        TrannyGear2  = parseFloat(form.EntryRatio2.value);
        TrannyGear3  = parseFloat(form.EntryRatio3.value);
        TrannyGear4  = parseFloat(form.EntryRatio4.value);
        TrannyGear5  = parseFloat(form.EntryRatio5.value);
        TrannyGear6  = parseFloat(form.EntryRatio6.value);
        ReverseGear  = parseFloat(form.EntryRatioR.value);
        if (form.TransType[0].checked) {
            TrannyMultiplier = 336;
        } else {
            TrannyMultiplier = 355;
        }
    this.ForwardGears = ForwardGears;
    this.Gear1        = TrannyGear1;
    this.Gear2        = TrannyGear2;
    this.Gear3        = TrannyGear3;
    this.Gear4        = TrannyGear4;
    this.Gear5        = TrannyGear5;
    this.Gear6        = TrannyGear6;
    this.Reverse      = ReverseGear;
    this.Multiplier   = TrannyMultiplier;
}
function Tcase(name, hi, low, stak) {
    this.Name = name;
    this.Hi = hi;
    this.Low = low;
    this.STaK = stak;
}
function TcaseGears(form) {
    var TcaseHiRange   = 0;
    var TcaseLowRange  = 0;
    var TcaseSTaKRange = 0;
    tcaseIndex = 0;
        TcaseHiRange = parseFloat(form.EntryHiRange.value);
        TcaseLowRange = parseFloat(form.EntryLowRange.value);
        TcaseSTaKRange = 0;
    this.HiRange   = TcaseHiRange;
    this.LowRange  = TcaseLowRange;
    this.STaKRange = TcaseSTaKRange;
}
function Underdrive(name, hi, low) {
    this.Name = name;
    this.Hi = hi;
    this.Low = low;
}
function UnderdriveGears(form) {
    var UnderdriveUsed = false;
    var UnderdriveHi   = 0;
    var UnderdriveLow  = 0;
    underdriveIndex = 0;
    this.Used = UnderdriveUsed;
    this.Hi   = UnderdriveHi;
    this.Low  = UnderdriveLow;
}
function clearForm(form) {
    form.DriveRatioHi6.value  = ""; form.DriveRatioLo6.value  = "";
    form.DriveRatioHi5.value  = ""; form.DriveRatioLo5.value  = "";
    form.DriveRatioHi4.value  = ""; form.DriveRatioLo4.value  = "";
    form.DriveRatioHi3.value  = ""; form.DriveRatioLo3.value  = "";
    form.DriveRatioHi2.value  = ""; form.DriveRatioLo2.value  = "";
    form.DriveRatioHi1.value  = ""; form.DriveRatioLo1.value  = "";
    form.DriveRatioHiR.value  = ""; form.DriveRatioLoR.value  = "";
    form.CrawlLow_6.value     = ""; form.CrawlMid_6.value     = ""; form.CrawlHi_6.value      = "";
    form.CrawlLow_5.value     = ""; form.CrawlMid_5.value     = ""; form.CrawlHi_5.value      = "";
    form.CrawlLow_4.value     = ""; form.CrawlMid_4.value     = ""; form.CrawlHi_4.value      = "";
    form.CrawlLow_3.value     = ""; form.CrawlMid_3.value     = ""; form.CrawlHi_3.value      = "";
    form.CrawlLow_2.value     = ""; form.CrawlMid_2.value     = ""; form.CrawlHi_6.value      = "";
    form.CrawlLow_1.value     = ""; form.CrawlMid_1.value     = ""; form.CrawlHi_1.value      = "";
    form.CrawlLow_R.value     = ""; form.CrawlMid_R.value     = ""; form.CrawlHi_R.value      = "";
    form.SpeedLow_6.value     = ""; form.SpeedMid_6.value     = ""; form.SpeedHi_6.value      = "";
    form.SpeedLow_5.value     = ""; form.SpeedMid_5.value     = ""; form.SpeedHi_5.value      = "";
    form.SpeedLow_4.value     = ""; form.SpeedMid_4.value     = ""; form.SpeedHi_4.value      = "";
    form.SpeedLow_3.value     = ""; form.SpeedMid_3.value     = ""; form.SpeedHi_3.value      = "";
    form.SpeedLow_2.value     = ""; form.SpeedMid_2.value     = ""; form.SpeedHi_2.value      = "";
    form.SpeedLow_1.value     = ""; form.SpeedMid_1.value     = ""; form.SpeedHi_1.value      = "";
    form.SpeedLow_R.value     = ""; form.SpeedMid_R.value     = ""; form.SpeedHi_R.value      = "";
    form.RPMLowSpd6.value     = ""; form.RPMMidSpd6.value     = ""; form.RPMHiSpd6.value      = "";
    form.RPMLowSpd5.value     = ""; form.RPMMidSpd5.value     = ""; form.RPMHiSpd5.value      = "";
    form.RPMLowSpd4.value     = ""; form.RPMMidSpd4.value     = ""; form.RPMHiSpd4.value      = "";
    form.RPMLowSpd3.value     = ""; form.RPMMidSpd3.value     = ""; form.RPMHiSpd3.value      = "";
    form.RPMLowSpd2.value     = ""; form.RPMMidSpd2.value     = ""; form.RPMHiSpd2.value      = "";
    form.RPMLowSpd1.value     = ""; form.RPMMidSpd1.value     = ""; form.RPMHiSpd1.value      = "";
    form.RPMLowSpdR.value     = ""; form.RPMMidSpdR.value     = ""; form.RPMHiSpdR.value      = "";
}
function marcha(form) {
	for (cnt=0; cnt < document.formulario7.elements.length; cnt++) {
		if (!isNumb(document.formulario7.elements[cnt].value.toString()) && document.formulario7.elements[cnt].type == "text") {
			document.formulario7.elements[cnt].value = "";
		}
	}
    clearForm(form);
    Tranny = new TrannyGears(form);
    Tcase = new TcaseGears(form);
    Underdrive = new UnderdriveGears(form);
    AxleGear = parseFloat(form.AxleGear.value);
    if (form.TireType[1].checked) {
        SectionWidth = parseInt(form.TireSection.value) / 25.4;
        AspectRatio  = parseInt(form.TireAspect.value)  / 100.0;
        RimDiameter  = parseInt(form.TireRim.value);
        TireSize = ((SectionWidth * AspectRatio) * 2.0) + RimDiameter;
        form.TireSize.value = TireSize.toFixed(2);
    } else {
        TireSize = parseFloat(form.TireSize.value);
    }
    switch (Tranny.ForwardGears) {
        case 6:
            DriveRatioHi6 = Tranny.Gear6 * AxleGear * Tcase.HiRange;
            DriveRatioLo6 = Tranny.Gear6 * AxleGear * Tcase.LowRange;
            if (Underdrive.Used) {
                DriveRatioUh6 = DriveRatioHi6 * Underdrive.Low;
                DriveRatioUl6 = DriveRatioLo6 * Underdrive.Low;
                DriveRatioHi6 = DriveRatioHi6 * Underdrive.Hi;
                DriveRatioLo6 = DriveRatioLo6 * Underdrive.Hi;
                form.DriveRatioUh6.value = DriveRatioUh6.toFixed(2);
                form.DriveRatioUl6.value = DriveRatioUl6.toFixed(2);
                form.DriveRatioHi6.value = DriveRatioHi6.toFixed(2);
                form.DriveRatioLo6.value = DriveRatioLo6.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt6 = 0;
                    DriveRatioUs6 = 0;
                    DriveRatioSt6 = 0;
                    form.DriveRatioUs6.value = 0;
                    form.DriveRatioSt6.value = 0;
                    Crawl6 = DriveRatioUs6;
                } else {
                    Crawl6 = DriveRatioUl6;
                }
            }
            else
            {
                form.DriveRatioHi6.value = DriveRatioHi6.toFixed(2);
                form.DriveRatioLo6.value = DriveRatioLo6.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt6 = 0;
                    form.DriveRatioSt6.value = 0;
                    Crawl6 = DriveRatioSt6;
                } else {
                    Crawl6 = DriveRatioLo6;
                }
            }
        case 5:
            DriveRatioHi5 = Tranny.Gear5 * AxleGear * Tcase.HiRange;
            DriveRatioLo5 = Tranny.Gear5 * AxleGear * Tcase.LowRange;
            if (Underdrive.Used) {
                DriveRatioUh5 = DriveRatioHi5 * Underdrive.Low;
                DriveRatioUl5 = DriveRatioLo5 * Underdrive.Low;
                DriveRatioHi5 = DriveRatioHi5 * Underdrive.Hi;
                DriveRatioLo5 = DriveRatioLo5 * Underdrive.Hi;
                form.DriveRatioUh5.value = DriveRatioUh5.toFixed(2);
                form.DriveRatioUl5.value = DriveRatioUl5.toFixed(2);
                form.DriveRatioHi5.value = DriveRatioHi5.toFixed(2);
                form.DriveRatioLo5.value = DriveRatioLo5.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt5 = 0;
                    DriveRatioUs5 = 0;
                    DriveRatioSt5 = 0;
                    form.DriveRatioUs5.value = 0;
                    form.DriveRatioSt5.value = 0;
                    Crawl5 = DriveRatioUs5;
                } else {
                    Crawl5 = DriveRatioUl5;
                }
            }
            else
            {
                form.DriveRatioHi5.value = DriveRatioHi5.toFixed(2);
                form.DriveRatioLo5.value = DriveRatioLo5.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt5 = 0;
                    form.DriveRatioSt5.value = 0;
                    Crawl5 = DriveRatioSt5;
                } else {
                    Crawl5 = DriveRatioLo5;
                }
            }
        case 4:
            DriveRatioHi4 = Tranny.Gear4 * AxleGear * Tcase.HiRange;
            DriveRatioLo4 = Tranny.Gear4 * AxleGear * Tcase.LowRange;
            if (Underdrive.Used) {
                DriveRatioUh4 = DriveRatioHi4 * Underdrive.Low;
                DriveRatioUl4 = DriveRatioLo4 * Underdrive.Low;
                DriveRatioHi4 = DriveRatioHi4 * Underdrive.Hi;
                DriveRatioLo4 = DriveRatioLo4 * Underdrive.Hi;
                form.DriveRatioUh4.value = DriveRatioUh4.toFixed(2);
                form.DriveRatioUl4.value = DriveRatioUl4.toFixed(2);
                form.DriveRatioHi4.value = DriveRatioHi4.toFixed(2);
                form.DriveRatioLo4.value = DriveRatioLo4.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt4 = 0;
                    DriveRatioUs4 = 0;
                    DriveRatioSt4 = 0;
                    form.DriveRatioUs4.value = 0;
                    form.DriveRatioSt4.value = 0;
                    Crawl4 = DriveRatioUs4;
                } else {
                    Crawl4 = DriveRatioUl4;
                }
            }
            else
            {
                form.DriveRatioHi4.value = DriveRatioHi4.toFixed(2);
                form.DriveRatioLo4.value = DriveRatioLo4.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt4 = 0;
                    form.DriveRatioSt4.value = 0;
                    Crawl4 = DriveRatioSt4;
                } else {
                    Crawl4 = DriveRatioLo4;
                }
            }
         case 3:
            DriveRatioHi3 = Tranny.Gear3 * AxleGear * Tcase.HiRange;
            DriveRatioLo3 = Tranny.Gear3 * AxleGear * Tcase.LowRange;
            if (Underdrive.Used) {
                DriveRatioUh3 = DriveRatioHi3 * Underdrive.Low;
                DriveRatioUl3 = DriveRatioLo3 * Underdrive.Low;
                DriveRatioHi3 = DriveRatioHi3 * Underdrive.Hi;
                DriveRatioLo3 = DriveRatioLo3 * Underdrive.Hi;
                form.DriveRatioUh3.value = DriveRatioUh3.toFixed(2);
                form.DriveRatioUl3.value = DriveRatioUl3.toFixed(2);
                form.DriveRatioHi3.value = DriveRatioHi3.toFixed(2);
                form.DriveRatioLo3.value = DriveRatioLo3.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt3 = 0;
                    DriveRatioUs3 = 0;
                    DriveRatioSt3 = 0;
                    form.DriveRatioUs3.value = 0;
                    form.DriveRatioSt3.value = 0;
                    Crawl3 = DriveRatioUs3;
                } else {
                    Crawl3 = DriveRatioUl3;
                }
            }
            else
            {
                form.DriveRatioHi3.value = DriveRatioHi3.toFixed(2);
                form.DriveRatioLo3.value = DriveRatioLo3.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt3 = 0;
                    form.DriveRatioSt3.value = 0;
                    Crawl3 = DriveRatioSt3;
                } else {
                    Crawl3 = DriveRatioLo3;
                }
            }
        case 2:
            DriveRatioHi2 = Tranny.Gear2 * AxleGear * Tcase.HiRange;
            DriveRatioLo2 = Tranny.Gear2 * AxleGear * Tcase.LowRange;
            if (Underdrive.Used) {
                DriveRatioUh2 = DriveRatioHi2 * Underdrive.Low;
                DriveRatioUl2 = DriveRatioLo2 * Underdrive.Low;
                DriveRatioHi2 = DriveRatioHi2 * Underdrive.Hi;
                DriveRatioLo2 = DriveRatioLo2 * Underdrive.Hi;
                form.DriveRatioUh2.value = DriveRatioUh2.toFixed(2);
                form.DriveRatioUl2.value = DriveRatioUl2.toFixed(2);
                form.DriveRatioHi2.value = DriveRatioHi2.toFixed(2);
                form.DriveRatioLo2.value = DriveRatioLo2.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt2 = 0;
                    DriveRatioUs2 = 0;
                    DriveRatioSt2 = 0;
                    form.DriveRatioUs2.value = 0;
                    form.DriveRatioSt2.value = 0;
                    Crawl2 = DriveRatioUs2;
                } else {
                    Crawl2 = DriveRatioUl2;
                }
            }
            else
            {
                form.DriveRatioHi2.value = DriveRatioHi2.toFixed(2);
                form.DriveRatioLo2.value = DriveRatioLo2.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt2 = 0;
                    form.DriveRatioSt2.value = 0;
                    Crawl2 = DriveRatioSt2;
                } else {
                    Crawl2 = DriveRatioLo2;
                }
            }
        case 1:
            DriveRatioHi1 = Tranny.Gear1 * AxleGear * Tcase.HiRange;
            DriveRatioLo1 = Tranny.Gear1 * AxleGear * Tcase.LowRange;
            if (Underdrive.Used) {
                DriveRatioUh1 = DriveRatioHi1 * Underdrive.Low;
                DriveRatioUl1 = DriveRatioLo1 * Underdrive.Low;
                DriveRatioHi1 = DriveRatioHi1 * Underdrive.Hi;
                DriveRatioLo1 = DriveRatioLo1 * Underdrive.Hi;
                form.DriveRatioUh1.value = DriveRatioUh1.toFixed(2);
                form.DriveRatioUl1.value = DriveRatioUl1.toFixed(2);
                form.DriveRatioHi1.value = DriveRatioHi1.toFixed(2);
                form.DriveRatioLo1.value = DriveRatioLo1.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt1 = 0;
                    DriveRatioUs1 = 0;
                    form.DriveRatioUs1.value = 0;
                    form.DriveRatioSt1.value = 0;
                    Crawl1 = DriveRatioUs1;
                } else {
                    Crawl1 = DriveRatioUl1;
                }
            }
            else
            {
                form.DriveRatioHi1.value = DriveRatioHi1.toFixed(2);
                form.DriveRatioLo1.value = DriveRatioLo1.toFixed(2);
                if (Tcase.STaKRange) {
                    DriveRatioSt1 = 0;
                    form.DriveRatioSt1.value = 0;
                    Crawl1 = DriveRatioSt1;
                } else {
                    Crawl1 = DriveRatioLo1;
                }
            }
            if (Tranny.Reverse) {
                DriveRatioHiR = Tranny.Reverse * AxleGear * Tcase.HiRange;
                DriveRatioLoR = Tranny.Reverse * AxleGear * Tcase.LowRange;
                if (Underdrive.Used) {
                    DriveRatioUhR = DriveRatioHiR * Underdrive.Low;
                    DriveRatioUlR = DriveRatioLoR * Underdrive.Low;
                    DriveRatioHiR = DriveRatioHiR * Underdrive.Hi;
                    DriveRatioLoR = DriveRatioLoR * Underdrive.Hi;
                    form.DriveRatioUhR.value = DriveRatioUhR.toFixed(2);
                    form.DriveRatioUlR.value = DriveRatioUlR.toFixed(2);
                    form.DriveRatioHiR.value = DriveRatioHiR.toFixed(2);
                    form.DriveRatioLoR.value = DriveRatioLoR.toFixed(2);
                    if (Tcase.STaKRange) {
                        DriveRatioStR = 0;
                        DriveRatioUsR = 0;
                        DriveRatioStR = 0;
                        form.DriveRatioUsR.value = 0;
                        form.DriveRatioStR.value = 0;
                        CrawlR = DriveRatioUsR;
                    } else {
                        CrawlR = DriveRatioUlR;
                    }
                }
                else
                {
                    form.DriveRatioHiR.value = DriveRatioHiR.toFixed(2);
                    form.DriveRatioLoR.value = DriveRatioLoR.toFixed(2);
                    if (Tcase.STaKRange) {
                        DriveRatioStR = 0;
                        form.DriveRatioStR.value = 0;
                        CrawlR = DriveRatioStR;
                    } else {
                        CrawlR = DriveRatioLoR;
                    }
                }
            }
             break;
        default:
            return;
            break;
    }
    switch (Tranny.ForwardGears) {
        case 6:
            SpeedBase = TireSize / (Tranny.Multiplier / 1.6);
            Crawl = (SpeedBase / Crawl6) * (1000 / 60);
            RPM = DriveRatioHi6 * (Tranny.Multiplier / 1.6) / TireSize;
            Speed = SpeedBase / DriveRatioHi6;
            CrawlLow6 = Crawl * parseInt(form.CrawlLowSelect.value);
            CrawlMid6 = Crawl * parseInt(form.CrawlMidSelect.value);
            CrawlHi6  = Crawl * parseInt(form.CrawlHiSelect.value);
            SpeedLow6 = Speed * parseInt(form.SpeedLowSelect.value);
            SpeedMid6 = Speed * parseInt(form.SpeedMidSelect.value);
            SpeedHi6  = Speed * parseInt(form.SpeedHiSelect.value);
            RPMLow6   = RPM   * parseInt(form.RPMLowSelect.value);
            RPMMid6   = RPM   * parseInt(form.RPMMidSelect.value);
            RPMHi6    = RPM   * parseInt(form.RPMHiSelect.value);
            form.CrawlLow_6.value = CrawlLow6.toFixed(0);
            form.CrawlMid_6.value = CrawlMid6.toFixed(0);
            form.CrawlHi_6.value  = CrawlHi6.toFixed(0);
            form.SpeedLow_6.value = SpeedLow6.toFixed(0);
            form.SpeedMid_6.value = SpeedMid6.toFixed(0);
            form.SpeedHi_6.value  = SpeedHi6.toFixed(0);
            form.RPMLowSpd6.value = RPMLow6.toFixed(0);
            form.RPMMidSpd6.value = RPMMid6.toFixed(0);
            form.RPMHiSpd6.value  = RPMHi6.toFixed(0);
        case 5:
            SpeedBase = TireSize / (Tranny.Multiplier / 1.6);
            Crawl = (SpeedBase / Crawl5) * (1000 / 60);
            RPM = DriveRatioHi5 * (Tranny.Multiplier / 1.6) / TireSize;
            Speed = SpeedBase / DriveRatioHi5;
            CrawlLow5 = Crawl * parseInt(form.CrawlLowSelect.value);
            CrawlMid5 = Crawl * parseInt(form.CrawlMidSelect.value);
            CrawlHi5  = Crawl * parseInt(form.CrawlHiSelect.value);
            SpeedLow5 = Speed * parseInt(form.SpeedLowSelect.value);
            SpeedMid5 = Speed * parseInt(form.SpeedMidSelect.value);
            SpeedHi5  = Speed * parseInt(form.SpeedHiSelect.value);
            RPMLow5   = RPM   * parseInt(form.RPMLowSelect.value);
            RPMMid5   = RPM   * parseInt(form.RPMMidSelect.value);
            RPMHi5    = RPM   * parseInt(form.RPMHiSelect.value);
            form.CrawlLow_5.value = CrawlLow5.toFixed(0);
            form.CrawlMid_5.value = CrawlMid5.toFixed(0);
            form.CrawlHi_5.value  = CrawlHi5.toFixed(0);
            form.SpeedLow_5.value = SpeedLow5.toFixed(0);
            form.SpeedMid_5.value = SpeedMid5.toFixed(0);
            form.SpeedHi_5.value  = SpeedHi5.toFixed(0);
            form.RPMLowSpd5.value = RPMLow5.toFixed(0);
            form.RPMMidSpd5.value = RPMMid5.toFixed(0);
            form.RPMHiSpd5.value  = RPMHi5.toFixed(0);
        case 4:
            SpeedBase = TireSize / (Tranny.Multiplier / 1.6);
            Crawl = (SpeedBase / Crawl4) * (1000 / 60);
            RPM = DriveRatioHi4 * (Tranny.Multiplier / 1.6) / TireSize;
            Speed = SpeedBase / DriveRatioHi4;
            CrawlLow4 = Crawl * parseInt(form.CrawlLowSelect.value);
            CrawlMid4 = Crawl * parseInt(form.CrawlMidSelect.value);
            CrawlHi4  = Crawl * parseInt(form.CrawlHiSelect.value);
            SpeedLow4 = Speed * parseInt(form.SpeedLowSelect.value);
            SpeedMid4 = Speed * parseInt(form.SpeedMidSelect.value);
            SpeedHi4  = Speed * parseInt(form.SpeedHiSelect.value);
            RPMLow4   = RPM   * parseInt(form.RPMLowSelect.value);
            RPMMid4   = RPM   * parseInt(form.RPMMidSelect.value);
            RPMHi4    = RPM   * parseInt(form.RPMHiSelect.value);
            form.CrawlLow_4.value = CrawlLow4.toFixed(0);
            form.CrawlMid_4.value = CrawlMid4.toFixed(0);
            form.CrawlHi_4.value  = CrawlHi4.toFixed(0);
            form.SpeedLow_4.value = SpeedLow4.toFixed(0);
            form.SpeedMid_4.value = SpeedMid4.toFixed(0);
            form.SpeedHi_4.value  = SpeedHi4.toFixed(0);
            form.RPMLowSpd4.value = RPMLow4.toFixed(0);
            form.RPMMidSpd4.value = RPMMid4.toFixed(0);
            form.RPMHiSpd4.value  = RPMHi4.toFixed(0);
        case 3:
            SpeedBase = TireSize / (Tranny.Multiplier / 1.6);
            Crawl = (SpeedBase / Crawl3) * (1000 / 60);
            RPM = DriveRatioHi3 * (Tranny.Multiplier / 1.6) / TireSize;
            Speed = SpeedBase / DriveRatioHi3;
            CrawlLow3 = Crawl * parseInt(form.CrawlLowSelect.value);
            CrawlMid3 = Crawl * parseInt(form.CrawlMidSelect.value);
            CrawlHi3  = Crawl * parseInt(form.CrawlHiSelect.value);
            SpeedLow3 = Speed * parseInt(form.SpeedLowSelect.value);
            SpeedMid3 = Speed * parseInt(form.SpeedMidSelect.value);
            SpeedHi3  = Speed * parseInt(form.SpeedHiSelect.value);
            RPMLow3   = RPM   * parseInt(form.RPMLowSelect.value);
            RPMMid3   = RPM   * parseInt(form.RPMMidSelect.value);
            RPMHi3    = RPM   * parseInt(form.RPMHiSelect.value);
            form.CrawlLow_3.value = CrawlLow3.toFixed(0);
            form.CrawlMid_3.value = CrawlMid3.toFixed(0);
            form.CrawlHi_3.value  = CrawlHi3.toFixed(0);
            form.SpeedLow_3.value = SpeedLow3.toFixed(0);
            form.SpeedMid_3.value = SpeedMid3.toFixed(0);
            form.SpeedHi_3.value  = SpeedHi3.toFixed(0);
            form.RPMLowSpd3.value = RPMLow3.toFixed(0);
            form.RPMMidSpd3.value = RPMMid3.toFixed(0);
            form.RPMHiSpd3.value  = RPMHi3.toFixed(0);
        case 2:
            SpeedBase = TireSize / (Tranny.Multiplier / 1.6);
            Crawl = (SpeedBase / Crawl2) * (1000 / 60);
            RPM = DriveRatioHi2 * (Tranny.Multiplier / 1.6) / TireSize;
            Speed = SpeedBase / DriveRatioHi2;
            CrawlLow2 = Crawl * parseInt(form.CrawlLowSelect.value);
            CrawlMid2 = Crawl * parseInt(form.CrawlMidSelect.value);
            CrawlHi2  = Crawl * parseInt(form.CrawlHiSelect.value);
            SpeedLow2 = Speed * parseInt(form.SpeedLowSelect.value);
            SpeedMid2 = Speed * parseInt(form.SpeedMidSelect.value);
            SpeedHi2  = Speed * parseInt(form.SpeedHiSelect.value);
            RPMLow2   = RPM   * parseInt(form.RPMLowSelect.value);
            RPMMid2   = RPM   * parseInt(form.RPMMidSelect.value);
            RPMHi2    = RPM   * parseInt(form.RPMHiSelect.value);
            form.CrawlLow_2.value = CrawlLow2.toFixed(0);
            form.CrawlMid_2.value = CrawlMid2.toFixed(0);
            form.CrawlHi_2.value  = CrawlHi2.toFixed(0);
            form.SpeedLow_2.value = SpeedLow2.toFixed(0);
            form.SpeedMid_2.value = SpeedMid2.toFixed(0);
            form.SpeedHi_2.value  = SpeedHi2.toFixed(0);
            form.RPMLowSpd2.value = RPMLow2.toFixed(0);
            form.RPMMidSpd2.value = RPMMid2.toFixed(0);
            form.RPMHiSpd2.value  = RPMHi2.toFixed(0);
        case 1:
            SpeedBase = TireSize / (Tranny.Multiplier / 1.6);
            Crawl = (SpeedBase / Crawl1) * (1000 / 60);
            RPM = DriveRatioHi1 * (Tranny.Multiplier / 1.6) / TireSize;
            Speed = SpeedBase / DriveRatioHi1;
            CrawlLow1 = Crawl * parseInt(form.CrawlLowSelect.value);
            CrawlMid1 = Crawl * parseInt(form.CrawlMidSelect.value);
            CrawlHi1  = Crawl * parseInt(form.CrawlHiSelect.value);
            SpeedLow1 = Speed * parseInt(form.SpeedLowSelect.value);
            SpeedMid1 = Speed * parseInt(form.SpeedMidSelect.value);
            SpeedHi1  = Speed * parseInt(form.SpeedHiSelect.value);
            RPMLow1   = RPM   * parseInt(form.RPMLowSelect.value);
            RPMMid1   = RPM   * parseInt(form.RPMMidSelect.value);
            RPMHi1    = RPM   * parseInt(form.RPMHiSelect.value);
            form.CrawlLow_1.value = CrawlLow1.toFixed(0);
            form.CrawlMid_1.value = CrawlMid1.toFixed(0);
            form.CrawlHi_1.value  = CrawlHi1.toFixed(0);
            form.SpeedLow_1.value = SpeedLow1.toFixed(0);
            form.SpeedMid_1.value = SpeedMid1.toFixed(0);
            form.SpeedHi_1.value  = SpeedHi1.toFixed(0);
            form.RPMLowSpd1.value = RPMLow1.toFixed(0);
            form.RPMMidSpd1.value = RPMMid1.toFixed(0);
            form.RPMHiSpd1.value  = RPMHi1.toFixed(0);
            if (Tranny.Reverse) {
                SpeedBase = TireSize / (Tranny.Multiplier / 1.6);
                Crawl = (SpeedBase / CrawlR) * (1000 / 60);
                RPM = DriveRatioHiR * (Tranny.Multiplier / 1.6) / TireSize;
                Speed = SpeedBase / DriveRatioHiR;
                CrawlLowR = Crawl * parseInt(form.CrawlLowSelect.value);
                CrawlMidR = Crawl * parseInt(form.CrawlMidSelect.value);
                CrawlHiR  = Crawl * parseInt(form.CrawlHiSelect.value);
                SpeedLowR = Speed * parseInt(form.SpeedLowSelect.value);
                SpeedMidR = Speed * parseInt(form.SpeedMidSelect.value);
                SpeedHiR  = Speed * parseInt(form.SpeedHiSelect.value);
                RPMLowR   = RPM   * parseInt(form.RPMLowSelect.value);
                RPMMidR   = RPM   * parseInt(form.RPMMidSelect.value);
                RPMHiR    = RPM   * parseInt(form.RPMHiSelect.value);
                form.CrawlLow_R.value = CrawlLowR.toFixed(0);
                form.CrawlMid_R.value = CrawlMidR.toFixed(0);
                form.CrawlHi_R.value  = CrawlHiR.toFixed(0);
                form.SpeedLow_R.value = SpeedLowR.toFixed(0);
                form.SpeedMid_R.value = SpeedMidR.toFixed(0);
                form.SpeedHi_R.value  = SpeedHiR.toFixed(0);
                form.RPMLowSpdR.value = RPMLowR.toFixed(0);
                form.RPMMidSpdR.value = RPMMidR.toFixed(0);
                form.RPMHiSpdR.value  = RPMHiR.toFixed(0);
            }
            break;
        default:
            return;
            break;
    }
}
function PopulateTrannysLeft() {
    for(idx = 0; idx < trannyList.length; idx++) {
        var NewOption = document.createElement('option');
        NewOption.value = idx;
        var Selector = document.getElementById('TransmissionLeft');
        try {
            Selector.add(NewOption, null);
        }
        catch(ex) {
            Selector.add(NewOption);
        }
    }
}
function PopulateTcasesLeft() {
    for(idx = 0; idx < tcaseList.length; idx++) {
        var NewOption = document.createElement('option');
        NewOption.value = idx;
        var Selector = document.getElementById('TransferCaseLeft');
        try {
            Selector.add(NewOption, null);
        }
        catch(ex) {
            Selector.add(NewOption);
        }
    }
}
function PopulateUnderdrivesLeft() {
    for(idx = 0; idx < underdriveList.length; idx++) {
        var NewOption = document.createElement('option');
        NewOption.value = idx;
        var Selector = document.getElementById('UnderdriveLeft');
        try {
            Selector.add(NewOption, null);
        }
        catch(ex) {
            Selector.add(NewOption);
        }
    }
}
function InitTrannys() {
    trannyIndex = 0;
    trannyList[trannyIndex++] = new Transmission("Entre c/ os dados",
                                                 0,
                                                 0.00,
                                                 0.00,
                                                 0.00,
                                                 0.00,
                                                 0.00,
                                                 0.00,
                                                 0.00,
                                                 336);
}
function InitTcases() {
    tcaseIndex = 0;
    tcaseList[tcaseIndex++] = new Tcase("Entre c/ os dados",
                                        0.00,
                                        0.00,
                                        0.00);
} // Function InitTcases
function InitUnderdrives () {
    underdriveIndex = 0;
    underdriveList[underdriveIndex++] = new Underdrive("Nenhum",
                                                       0.00,
                                                       0.00);

    underdriveList[underdriveIndex++] = new Underdrive("Entre c/ os dados",
                                                       0.00,
                                                       0.00);
}
function InitGlobals () {
    InitTrannys();
    InitTcases();
    InitUnderdrives();
}
InitGlobals();

