

function setWheelOption()
	{
	document.gearratio.wheelsize.value = "Custom";
	}

function setWheel()
	{
	WC = Math.round(document.gearratio.wheelsize.value * 25.4 * 22 / 7);
	
	document.gearratio.wc.value = WC;
	}
	
function gearcalc() {
//document.getElementById('gear-calc-table').style.display="block";



	foundError = false;
		if(document.gearratio.wc.value == "") {
		document.getElementById("nameError").innerHTML= "<p style='color:#0033cc;'>Please enter the Wheel Size Circumference value</p>";
		document.getElementById("wc").select();
		document.getElementById("wc").focus();
 		return false;
		
		}
	
	foundError = false;
		if((document.gearratio.cr1.value == "") && (document.gearratio.cr2.value == "") && (document.gearratio.cr3.value == "")) {
		document.getElementById("nameError").innerHTML= "<p style='color:#0033cc;'>Please enter at least one Chainring value</p>";
		document.getElementById("cr1").select();
		document.getElementById("cr1").focus();
		return false;
		}
		
	foundError = false;
		if(document.gearratio.cad.value == "") {
		document.getElementById("nameError").innerHTML= "<p style='color:#0033cc;'>Please enter the Cadence value</p>";
		document.getElementById("cad").select();
		document.getElementById("cad").focus();
		return false;
		}
	
	foundError = false;
		if((document.gearratio.spr1.value == "") && (document.gearratio.spr2.value == "") && (document.gearratio.spr3.value == "") && (document.gearratio.spr4.value == "") && (document.gearratio.spr5.value == "") && (document.gearratio.spr6.value == "") && (		document.gearratio.spr7.value == "") && (document.gearratio.spr8.value == "") && (document.gearratio.spr9.value == "") && (document.gearratio.spr10.value == "")) {
		document.getElementById("nameError").innerHTML= "<p style='color:#0033cc;'>Please enter at least one sprocket size</p>";
		document.getElementById("spr1").select();
		document.getElementById("spr1").focus();
		return false;
		}

	// ACTUAL INFORMATION
	// Actual Wheel Circumference (WC)
	WC = document.gearratio.wc.value;

	// Preferred Cadence (CAD)
	CAD = document.gearratio.cad.value;

	// Chainring Values (CR)
	CR1 = document.gearratio.cr1.value;
	if(CR1 == "") {document.getElementById('gear-calc-table').style.display="none";}
	else{
		document.getElementById('gear-calc-table').style.display="block";
		document.getElementById('sprocket-result').style.display="block";
		document.getElementById('print-results-link').style.display="block";
		document.getElementById("nameError").style.display='none';
	}

	CR2 = document.gearratio.cr2.value;
	if(CR2 == "") {document.getElementById('gear-calc-table2').style.display="none";}
	else{document.getElementById('gear-calc-table2').style.display="block";}

	CR3 = document.gearratio.cr3.value;
	if(CR3 == "") {document.getElementById('gear-calc-table3').style.display="none";}
	else{document.getElementById('gear-calc-table3').style.display="block";}

	// Sprocket Information (SP)
	SPR1 = document.gearratio.spr1.value;
	if(SPR1 == "") document.gearratio.spr1.value = "-";
	
	SPR2 = document.gearratio.spr2.value;
	if(SPR2 == "") document.gearratio.spr2.value = "-";

	SPR3 = document.gearratio.spr3.value;
	if(SPR3 == "") document.gearratio.spr3.value = "-";

	SPR4 = document.gearratio.spr4.value;
	if(SPR4 == "") document.gearratio.spr4.value = "-";

	SPR5 = document.gearratio.spr5.value;
	if(SPR5 == "") document.gearratio.spr5.value = "-";

	SPR6 = document.gearratio.spr6.value;
	if(SPR6 == "") document.gearratio.spr6.value = "-";

	SPR7 = document.gearratio.spr7.value;
	if(SPR7 == "") document.gearratio.spr7.value = "-";

	SPR8 = document.gearratio.spr8.value;
	if(SPR8 == "") document.gearratio.spr8.value = "-";

	SPR9 = document.gearratio.spr9.value;
	if(SPR9 == "") document.gearratio.spr9.value = "-";
	
	SPR10 = document.gearratio.spr10.value;
	if(SPR10 == "") document.gearratio.spr10.value = "-";
	
	// Chainring Sprocket Calculation (GR)
	// Gear Ratio (GR)
	// Gear Speed (GS) = GR * WC * CAD * 60 / 1000
	if(((CR1 == "") || (SPR1 == "")) || ((CR1 == "-") || (SPR1 == "-")))  {
		GR1_1 = "-";
		GS1_1 = "-";
		}
	else{	
		GR1_1 = Math.round((CR1 / SPR1) * 100) / 100;
		GS1_1 = Math.round(((GR1_1 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}

	document.getElementById("gear1").innerHTML =   GS1_1;
	document.getElementById("ratio1").innerHTML =  GR1_1;
	//document.ratiotable.gr1_1.value = GR1_1;
	//document.ratiotable.gs1_1.value = GS1_1;
	
	if(((CR1 == "") || (SPR2 == "")) || ((CR1 == "-") || (SPR2 == "-")))  {
		GR1_2 = "-";
		GS1_2 = "-";
		}
	else{	
		GR1_2 = Math.round((CR1 / SPR2) * 100) / 100;
		GS1_2 = Math.round(((GR1_2 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
		document.getElementById("gear2").innerHTML = GS1_2 ;
		document.getElementById("ratio2").innerHTML =   GR1_2;
	//document.ratiotable.gr1_2.value = GR1_2;
	//document.ratiotable.gs1_2.value = GS1_2;

	if(((CR1 == "") || (SPR3 == "")) || ((CR1 == "-") || (SPR3 == "-")))  {
		GR1_3 = "-";
		GS1_3 = "-";
		}
	else{	
		GR1_3 = Math.round((CR1 / SPR3) * 100) / 100;
		GS1_3 = Math.round(((GR1_3 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3").innerHTML = GS1_3 ;
	document.getElementById("ratio3").innerHTML =   GR1_3;
	//document.ratiotable.gr1_3.value = GR1_3;
	//document.ratiotable.gs1_3.value = GS1_3;

	if(((CR1 == "") || (SPR4 == "")) || ((CR1 == "-") || (SPR4 == "-")))  {
		GR1_4 = "-";
		GS1_4 = "-";
		}
	else{	
		GR1_4 = Math.round((CR1 / SPR4) * 100) / 100;
		GS1_4 = Math.round(((GR1_4 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear4").innerHTML = GS1_4;
	document.getElementById("ratio4").innerHTML =   GR1_4;
	//document.ratiotable.gr1_4.value = GR1_4;
	//document.ratiotable.gs1_4.value = GS1_4;

	if(((CR1 == "") || (SPR5 == "")) || ((CR1 == "-") || (SPR5 == "-")))  {
		GR1_5 = "-";
		GS1_5 = "-";
		}
	else{	
		GR1_5 = Math.round((CR1 / SPR5) * 100) / 100;
		GS1_5 = Math.round(((GR1_5 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear5").innerHTML = GS1_5;
	document.getElementById("ratio5").innerHTML =   GR1_5;
	//document.ratiotable.gr1_5.value = GR1_5;
	//document.ratiotable.gs1_5.value = GS1_5;

	if(((CR1 == "") || (SPR6 == "")) || ((CR1 == "-") || (SPR6 == "-")))  {
		GR1_6 = "-";
		GS1_6 = "-";
		}
	else{	
		GR1_6 = Math.round((CR1 / SPR6) * 100) / 100;
		GS1_6 = Math.round(((GR1_6 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear6").innerHTML = GS1_6 ;
	document.getElementById("ratio6").innerHTML =   GR1_6;
	//document.ratiotable.gr1_6.value = GR1_6;
	//document.ratiotable.gs1_6.value = GS1_6;

	if(((CR1 == "") || (SPR7 == "")) || ((CR1 == "-") || (SPR7 == "-")))  {
		GR1_7 = "-";
		GS1_7 = "-";
		}
	else{	
		GR1_7 = Math.round((CR1 / SPR7) * 100) / 100;
		GS1_7 = Math.round(((GR1_7 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear7").innerHTML = GS1_7;
	document.getElementById("ratio7").innerHTML =   GR1_7;
	//document.ratiotable.gr1_7.value = GR1_7;
	//document.ratiotable.gs1_7.value = GS1_7;

	if(((CR1 == "") || (SPR8 == "")) || ((CR1 == "-") || (SPR8 == "-")))  {
		GR1_8 = "-";
		GS1_8 = "-";
		}
	else{	
		GR1_8 = Math.round((CR1 / SPR8) * 100) / 100;
		GS1_8 = Math.round(((GR1_8 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear8").innerHTML = GS1_8;
	document.getElementById("ratio8").innerHTML =   GR1_8;
	//document.ratiotable.gr1_8.value = GR1_8;
	//document.ratiotable.gs1_8.value = GS1_8;

	if(((CR1 == "") || (SPR9 == "")) || ((CR1 == "-") || (SPR9 == "-")))  {
		GR1_9 = "-";
		GS1_9 = "-";
		}
	else{	
		GR1_9 = Math.round((CR1 / SPR9) * 100) / 100;
		GS1_9 = Math.round(((GR1_9 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear9").innerHTML = GS1_9;
	document.getElementById("ratio9").innerHTML =   GR1_9;
	//document.ratiotable.gr1_9.value = GR1_9;
	//document.ratiotable.gs1_9.value = GS1_9;
	
	if(((CR1 == "") || (SPR10 == "")) || ((CR1 == "-") || (SPR10 == "-")))  {
		GR1_10 = "-";
		GS1_10 = "-";
		}
	else{	
		GR1_10 = Math.round((CR1 / SPR10) * 100) / 100;
		GS1_10 = Math.round(((GR1_10 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear10").innerHTML = GS1_10;
	document.getElementById("ratio10").innerHTML =   GR1_10;
	//document.ratiotable.gr1_10.value = GR1_10;
	//document.ratiotable.gs1_10.value = GS1_10;

	if(((CR2 == "") || (SPR1 == "")) || ((CR2 == "-") || (SPR1 == "-")))  {
		GR2_1 = "-";
		GS2_1 = "-";
		}
	else{	
		GR2_1 = Math.round((CR2 / SPR1) * 100) / 100;
		GS2_1 = Math.round(((GR2_1 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_1").innerHTML = GS2_1;
	document.getElementById("ratio2_1").innerHTML =   GR2_1;
	//document.ratiotable.gr2_1.value = GR2_1;
	//document.ratiotable.gs2_1.value = GS2_1;
	
	if(((CR2 == "") || (SPR2 == "")) || ((CR2 == "-") || (SPR2 == "-")))  {
		GR2_2 = "-";
		GS2_2 = "-";
		}
	else{	
		GR2_2 = Math.round((CR2 / SPR2) * 100) / 100;
		GS2_2 = Math.round(((GR2_2 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_2").innerHTML = GS2_2;
	document.getElementById("ratio2_2").innerHTML =   GR2_2;
	//document.ratiotable.gr2_2.value = GR2_2;
	//document.ratiotable.gs2_2.value = GS2_2;

	if(((CR2 == "") || (SPR3 == "")) || ((CR2 == "-") || (SPR3 == "-")))  {
		GR2_3 = "-";
		GS2_3 = "-";
		}
	else{	
		GR2_3 = Math.round((CR2 / SPR3) * 100) / 100;
		GS2_3 = Math.round(((GR2_3 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_3").innerHTML = GS2_3;
	document.getElementById("ratio2_3").innerHTML =   GR2_3;
	//document.ratiotable.gr2_3.value = GR2_3;
	//document.ratiotable.gs2_3.value = GS2_3;

	if(((CR2 == "") || (SPR4 == "")) || ((CR2 == "-") || (SPR4 == "-")))  {
		GR2_4 = "-";
		GS2_4 = "-";
		}
	else{	
		GR2_4 = Math.round((CR2 / SPR4) * 100) / 100;
		GS2_4 = Math.round(((GR2_4 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_4").innerHTML = GS2_4;
	document.getElementById("ratio2_4").innerHTML =   GR2_4;
	//document.ratiotable.gr2_4.value = GR2_4;
	//document.ratiotable.gs2_4.value = GS2_4;

	if(((CR2 == "") || (SPR5 == "")) || ((CR2 == "-") || (SPR5 == "-")))  {
		GR2_5 = "-";
		GS2_5 = "-";
		}
	else{	
		GR2_5 = Math.round((CR2 / SPR5) * 100) / 100;
		GS2_5 = Math.round(((GR2_5 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_5").innerHTML = GS2_5;
	document.getElementById("ratio2_5").innerHTML =   GR2_5;
	//document.ratiotable.gr2_5.value = GR2_5;
	//document.ratiotable.gs2_5.value = GS2_5;

	if(((CR2 == "") || (SPR6 == "")) || ((CR2 == "-") || (SPR6 == "-")))  {
		GR2_6 = "-";
		GS2_6 = "-";
		}
	else{	
		GR2_6 = Math.round((CR2 / SPR6) * 100) / 100;
		GS2_6 = Math.round(((GR2_6 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_6").innerHTML = GS2_6;
	document.getElementById("ratio2_6").innerHTML =   GR2_6;
	//document.ratiotable.gr2_6.value = GR2_6;
	//document.ratiotable.gs2_6.value = GS2_6;

	if(((CR2 == "") || (SPR7 == "")) || ((CR2 == "-") || (SPR7 == "-")))  {
		GR2_7 = "-";
		GS2_7 = "-";
		}
	else{	
		GR2_7 = Math.round((CR2 / SPR7) * 100) / 100;
		GS2_7 = Math.round(((GR2_7 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_7").innerHTML = GS2_7;
	document.getElementById("ratio2_7").innerHTML =   GR2_7;
	//document.ratiotable.gr2_7.value = GR2_7;
	//document.ratiotable.gs2_7.value = GS2_7;

	if(((CR2 == "") || (SPR8 == "")) || ((CR2 == "-") || (SPR8 == "-")))  {
		GR2_8 = "-";
		GS2_8 = "-";
		}
	else{	
		GR2_8 = Math.round((CR2 / SPR8) * 100) / 100;
		GS2_8 = Math.round(((GR2_8 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_8").innerHTML = GS2_8;
	document.getElementById("ratio2_8").innerHTML =   GR2_8;
	//document.ratiotable.gr2_8.value = GR2_8;
	//document.ratiotable.gs2_8.value = GS2_8;

	if(((CR2 == "") || (SPR9 == "")) || ((CR2 == "-") || (SPR9 == "-")))  {
		GR2_9 = "-";
		GS2_9 = "-";
		}
	else{	
		GR2_9 = Math.round((CR2 / SPR9) * 100) / 100;
		GS2_9 = Math.round(((GR2_9 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_9").innerHTML = GS2_9;
	document.getElementById("ratio2_9").innerHTML =   GR2_9;
	//document.ratiotable.gr2_9.value = GR2_9;
	//document.ratiotable.gs2_9.value = GS2_9;
	
	if(((CR2 == "") || (SPR10 == "")) || ((CR2 == "-") || (SPR10 == "-")))  {
		GR2_10 = "-";
		GS2_10 = "-";
		}
	else{	
		GR2_10 = Math.round((CR2 / SPR10) * 100) / 100;
		GS2_10 = Math.round(((GR2_10 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear2_10").innerHTML = GS2_10;
	document.getElementById("ratio2_10").innerHTML =   GR2_10;
	//document.ratiotable.gr2_10.value = GR2_10;
	//document.ratiotable.gs2_10.value = GS2_10;

	if(((CR3 == "") || (SPR1 == "")) || ((CR3 == "-") || (SPR1 == "-")))  {
		GR3_1 = "-";
		GS3_1 = "-";
		}
	else{	
		GR3_1 = Math.round((CR3 / SPR1) * 100) / 100;
		GS3_1 = Math.round(((GR3_1 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_1").innerHTML = GS3_1;
	document.getElementById("ratio3_1").innerHTML =   GR3_1;
	//document.ratiotable.gr3_1.value = GR3_1;
	//document.ratiotable.gs3_1.value = GS3_1;
	
	if(((CR3 == "") || (SPR2 == "")) || ((CR3 == "-") || (SPR2 == "-")))  {
		GR3_2 = "-";
		GS3_2 = "-";
		}
	else{	
		GR3_2 = Math.round((CR3 / SPR2) * 100) / 100;
		GS3_2 = Math.round(((GR3_2 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_2").innerHTML = GS3_2;
	document.getElementById("ratio3_2").innerHTML =   GR3_2;
	//document.ratiotable.gr3_2.value = GR3_2;
	//document.ratiotable.gs3_2.value = GS3_2;

	if(((CR3 == "") || (SPR3 == "")) || ((CR3 == "-") || (SPR3 == "-")))  {
		GR3_3 = "-";
		GS3_3 = "-";
		}
	else{	
		GR3_3 = Math.round((CR3 / SPR3) * 100) / 100;
		GS3_3 = Math.round(((GR3_3 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_3").innerHTML = GS3_3;
	document.getElementById("ratio3_3").innerHTML =   GR3_3;
	//document.ratiotable.gr3_3.value = GR3_3;
	//document.ratiotable.gs3_3.value = GS3_3;

	if(((CR3 == "") || (SPR4 == "")) || ((CR3 == "-") || (SPR4 == "-")))  {
		GR3_4 = "-";
		GS3_4 = "-";
		}
	else{	
		GR3_4 = Math.round((CR3 / SPR4) * 100) / 100;
		GS3_4 = Math.round(((GR3_4 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_4").innerHTML = GS3_4;
	document.getElementById("ratio3_4").innerHTML =   GR3_4;
	//document.ratiotable.gr3_4.value = GR3_4;
	//document.ratiotable.gs3_4.value = GS3_4;

	if(((CR3 == "") || (SPR5 == "")) || ((CR3 == "-") || (SPR5 == "-")))  {
		GR3_5 = "-";
		GS3_5 = "-";
		}
	else{	
		GR3_5 = Math.round((CR3 / SPR5) * 100) / 100;
		GS3_5 = Math.round(((GR3_5 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_5").innerHTML = GS3_5;
	document.getElementById("ratio3_5").innerHTML =   GR3_5;
	//document.ratiotable.gr3_5.value = GR3_5;
	//document.ratiotable.gs3_5.value = GS3_5;

	if(((CR3 == "") || (SPR6 == "")) || ((CR3 == "-") || (SPR6 == "-")))  {
		GR3_6 = "-";
		GS3_6 = "-";
		}
	else{	
		GR3_6 = Math.round((CR3 / SPR6) * 100) / 100;
		GS3_6 = Math.round(((GR3_6 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_6").innerHTML = GS3_6;
	document.getElementById("ratio3_6").innerHTML =   GR3_6;
	//document.ratiotable.gr3_6.value = GR3_6;
	//document.ratiotable.gs3_6.value = GS3_6;

	if(((CR3 == "") || (SPR7 == "")) || ((CR3 == "-") || (SPR7 == "-")))  {
		GR3_7 = "-";
		GS3_7 = "-";
		}
	else{	
		GR3_7 = Math.round((CR3 / SPR7) * 100) / 100;
		GS3_7 = Math.round(((GR3_7 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_7").innerHTML = GS3_7;
	document.getElementById("ratio3_7").innerHTML =   GR3_7;
	//document.ratiotable.gr3_7.value = GR3_7;
	//document.ratiotable.gs3_7.value = GS3_7;

	if(((CR3 == "") || (SPR8 == "")) || ((CR3 == "-") || (SPR8 == "-")))  {
		GR3_8 = "-";
		GS3_8 = "-";
		}
	else{	
		GR3_8 = Math.round((CR3 / SPR8) * 100) / 100;
		GS3_8 = Math.round(((GR3_8 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_8").innerHTML = GS3_8;
	document.getElementById("ratio3_8").innerHTML =   GR3_8;
	//document.ratiotable.gr3_8.value = GR3_8;
	//document.ratiotable.gs3_8.value = GS3_8;

	if(((CR3 == "") || (SPR9 == "")) || ((CR3 == "-") || (SPR9 == "-")))  {
		GR3_9 = "-";
		GS3_9 = "-";
		}
	else{	
		GR3_9 = Math.round((CR3 / SPR9) * 100) / 100;
		GS3_9 = Math.round(((GR3_9 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_9").innerHTML = GS3_9;
	document.getElementById("ratio3_9").innerHTML =   GR3_9;
	//document.ratiotable.gr3_9.value = GR3_9;
	//document.ratiotable.gs3_9.value = GS3_9;
	
	if(((CR3 == "") || (SPR10 == "")) || ((CR3 == "-") || (SPR10 == "-")))  {
		GR3_10 = "-";
		GS3_10 = "-";
		}
	else{	
		GR3_10 = Math.round((CR3 / SPR10) * 100) / 100;
		GS3_10 = Math.round(((GR3_10 * (WC / 1000) * CAD * 60) / 1000) * 10) / 10;
		}
	document.getElementById("gear3_10").innerHTML = GS3_10;
	document.getElementById("ratio3_10").innerHTML =   GR3_10;
	//document.ratiotable.gr3_10.value = GR3_10;
	//document.ratiotable.gs3_10.value = GS3_10;

	}


	

// End of JavaScript code -->	
