PageSourceSearch

https://hpwizard.com/javascript/tire-calculator.js

js hpwizard.com collected 2026-10-02 13:36:33 UTC 25,832 bytes, 608 lines download raw bytes

1var OFFROAD = 0;  /*value for setWidth function*/
2
3/*diaChanged is run the tire diameter is changed*/
4
5function diaChanged(exact)/*'exact' is if the the new tire diameter is an exact number*/
6{
7	/*declare all elements:*/
8	var tireDia = document.getElementById("tire-dia");	
9	var tireDiaP = document.getElementById("precise-dia");
10	var tireDiaUnit = document.getElementById("tire-dia-unit");
11	
12	/*set the new tire diameter in text:*/
13	document.getElementById("dia-text").innerHTML = tireDia.value + " " + tireDiaUnit.value;
14	
15	if(exact)	/*if the value was directly entered by the user*/
16	{
17		if(isNaN(Number(tireDia.value))) /*if it is not a valid number*/
18		{
19			tireDia.value = Math.round(1000*tireDiaP.value)/1000;	/*get the old stored value and round it up*/
20			document.getElementById("dia-text").innerHTML = tireDia.value + " " + tireDiaUnit.value;	/*set the new tire diameter in text*/
21		}
22		else{tireDiaP.value = tireDia.value;} /*set the new stored value*/
23	}
24
25	setText();	/*write text*/
26}
27
28/*unitChanged is run when the unit is changed*/
29
30function unitChanged()
31{
32	/*declare all elements:*/
33	var tireDia = document.getElementById("tire-dia");
34	var tireDiaP = document.getElementById("precise-dia");
35	var tireDiaUnit = document.getElementById("tire-dia-unit");
36	var oldUnit = document.getElementById("old-unit");
37	
38	/*get the conversion factor:*/
39	var testUnit = CFtoSI(tireDiaUnit.value,LENGTH);
40	
41	if(testUnit <=0){tireDiaUnit.value = oldUnit.value; return;} /*if unit is not appropriate, get the old stored unit and end function*/
42
43	tireDiaP.value = tireDiaP.value*CFtoSI(oldUnit.value,LENGTH)/testUnit;	/*store new tire diameter*/
44	tireDia.value = Math.round(1000*tireDiaP.value)/1000;	/*write the new, rounded, tire diameter*/
45
46	diaChanged(false);	/*tire diameter is changed*/
47
48	oldUnit.value=tireDiaUnit.value;	/*store new unit*/
49}
50
51/*findDia calculates the tire diameter based on the P-metric size*/
52
53function findDia()
54{
55	/*declare all elements:*/
56	var treadwidth = document.getElementById("treadwidth");
57	var profile = document.getElementById("profile");
58	var tireDia = document.getElementById("tire-dia");
59	var tireDiaP = document.getElementById("precise-dia");
60	var tireDiaUnit = document.getElementById("tire-dia-unit");
61	var wheelDia = document.getElementById("wheel-dia");
62	
63	if(treadwidth.value == 'other...') selectWidth(-1);
64	if(profile.value == 'other...') selectAR(-1);
65	if(wheelDia.value == 'other...') selectWheelDia(-1);
66	
67	/*calculate tire diameter in inches based on P-metric size:*/
68	var Dia = Number(treadwidth.value) / 25.4 * Number(profile.value) / 100 * 2 + Number(wheelDia.value);
69	
70	/*convert tire diameter from inches to desired unit and round it:*/
71 	tireDiaP.value = Dia*CFtoSI("in",LENGTH)/CFtoSI(tireDiaUnit.value,LENGTH);
72	tireDia.value = Math.round(1000*tireDiaP.value)/1000;
73	
74	diaChanged(false);	/*tire diameter is changed*/
75}
76
77/*selectWidth set the new width of the tire for the P-metric size*/
78
79function selectWidth(value)/*'value' is the desired tire width in mm*/
80{
81	/*declare the list box element:*/
82	var treadwidth = document.getElementById("treadwidth");
83
84	if(value==-1){value = prompt("Enter tire width (mm):");}	/*user wants to enter own value*/
85	var newValue = document.createElement("option");	/*create a new option for the list box*/
86	newValue.text=Number(value);	/*set the text of the new option*/
87	newValue.value=Number(value);	/*set the value of the new option*/
88	try{if(treadwidth.options[33].value!="other..."){treadwidth.remove(33);}}catch(ex){}	/*if there was another user-defined option added earlier, remove it*/
89	try{treadwidth.add(newValue,null)}catch(ex){treadwidth.add(newValue)};	/*add new option at the end of the list box*/
90	treadwidth.selectedIndex=33;	/*select the new added option*/
91	findDia();	/*calculate new tire diameter*/
92}
93
94/*selectAR set the new profile of the tire for the P-metric size*/
95
96function selectAR(value)/*'value' is the desired tire AR*/
97{
98	/*declare the list box element:*/
99	var profile = document.getElementById("profile");
100
101	if(value==-1){value = prompt("Enter profile:");}	/*user wants to enter own value*/
102	var newValue = document.createElement("option");	/*create a new option for the list box*/
103	newValue.text=Number(value);	/*set the text of the new option*/
104	newValue.value=Number(value);	/*set the value of the new option*/
105	try{if(profile.options[16].value!="other..."){profile.remove(16);}}catch(ex){}	/*if there was another user-defined option added earlier, remove it*/
106	try{profile.add(newValue,null)}catch(ex){profile.add(newValue)};	/*add new option at the end of the list box*/
107	profile.selectedIndex=16;	/*select the new added option*/
108	findDia();	/*calculate new tire diameter*/
109}
110
111/*selectWheelDia set the new wheel diameter of the tire for the P-metric size*/
112
113function selectWheelDia(value)
114{
115	/*declare the list box element:*/
116	var wheelDia = document.getElementById("wheel-dia");
117
118	if(value==-1){value = prompt("Enter wheel diameter (in):");}	/*user wants to enter own value*/
119	var newValue = document.createElement("option");	/*create a new option for the list box*/
120	newValue.text=Number(value);	/*set the text of the new option*/
121	newValue.value=Number(value);	/*set the value of the new option*/
122	try{if(wheelDia.options[23].value!="other..."){wheelDia.remove(23);}}catch(ex){}	/*if there was another user-defined option added earlier, remove it*/
123	try{wheelDia.add(newValue,null)}catch(ex){wheelDia.add(newValue)};	/*add new option at the end of the list box*/
124	wheelDia.selectedIndex=23;	/*select the new added option*/
125	findDia();	/*calculate new tire diameter*/
126}
127
128/*enableOffroad is run when the user selects another type notation*/
129
130function enableOffroad()
131{
132	/*declare all elements:*/
133	var offroad = document.getElementById("offroad");
134	var offroadDia = document.getElementById("offroad-dia");
135	var offroadWidth = document.getElementById("offroad-width");
136	var offroadWheelDia = document.getElementById("offroad-wheel-dia");
137	var alphaNumeric = document.getElementById("alpha-numeric");
138	var numeric = document.getElementById("numeric");
139	var euroMetric = document.getElementById("euro-metric");
140
141	if(offroad.checked)  /*user selected the offroad notation*/
142	{
143		/*enable all offroad notations:*/
144		offroadDia.disabled=false;
145		offroadWidth.disabled=false;
146		offroadWheelDia.disabled=false;
147		
148		/*disable all other types of notations:*/
149		alphaNumeric.checked=false;
150		numeric.checked=false;
151		euroMetric.checked=false;
152		enableAlphaNumeric();
153		enableNumeric();
154		enableEuroMetric();
155		
156		/*set the new P-metric size:*/
157		setWidth(offroadWidth.value);
158		selectWheelDia(offroadWheelDia.value);
159		setAR();
160	}
161	else	/*user did not select the offroad notation*/
162	{
163		/*disabled all offroad notations:*/
164		offroadDia.disabled=true;
165		offroadWidth.disabled=true;
166		offroadWheelDia.disabled=true;
167	}
168
169	setText()	/*write text*/
170}
171
172/*enableAlphaNumeric is run when the user selects another type notation*/
173
174function enableAlphaNumeric()
175{
176	/*declare all elements:*/
177	var offroad = document.getElementById("offroad");
178	var alphaNumericProfile = document.getElementById("alpha-numeric-profile");
179	var alphaNumericWidth = document.getElementById("alpha-numeric-width");
180	var alphaNumericWheelDia = document.getElementById("alpha-numeric-wheel-dia");
181	var alphaNumeric = document.getElementById("alpha-numeric");
182	var numeric = document.getElementById("numeric");
183	var euroMetric = document.getElementById("euro-metric");
184
185	if(alphaNumeric.checked)  /*user selected the alpha-numeric notation*/
186	{
187		/*enable all alpha-numeric notations:*/
188		alphaNumericProfile.disabled=false;
189		alphaNumericWidth.disabled=false;
190		alphaNumericWheelDia.disabled=false;
191		
192		/*disable all other types of notations:*/
193		offroad.checked=false;
194		numeric.checked=false;
195		euroMetric.checked=false;
196		enableOffroad();
197		enableNumeric();
198		enableEuroMetric();
199		
200		/*set the new P-metric size:*/
201		setARalpha();
202		selectWheelDia(alphaNumericWheelDia.value);
203	}
204	else	/*user did not select the offroad notation*/
205	{
206		/*disabled all alpha-numeric notations:*/
207		alphaNumericProfile.disabled=true;
208		alphaNumericWidth.disabled=true;
209		alphaNumericWheelDia.disabled=true;
210	}
211
212	setText()	/*write text*/
213}
214
215/*enableNumeric is run when the user selects another type notation*/
216
217function enableNumeric()
218{
219	/*declare all elements:*/
220	var offroad = document.getElementById("offroad");
221	var numericProfile = document.getElementById("numeric-profile");
222	var numericWidth = document.getElementById("numeric-width");
223	var numericWheelDia = document.getElementById("numeric-wheel-dia");
224	var alphaNumeric = document.getElementById("alpha-numeric");
225	var numeric = document.getElementById("numeric");
226	var euroMetric = document.getElementById("euro-metric");
227
228	if(numeric.checked)  /*user selected the numeric notation*/
229	{
230		/*enable all numeric notations:*/
231		numericProfile.disabled=false;
232		numericWidth.disabled=false;
233		numericWheelDia.disabled=false;
234		
235		/*disable all other types of notations:*/
236		offroad.checked=false;
237		alphaNumeric.checked=false;
238		euroMetric.checked=false;
239		enableOffroad();
240		enableAlphaNumeric();
241		enableEuroMetric();
242		
243		/*set the new P-metric size:*/
244		setWidth(numericWidth.value);
245		selectAR(numericProfile.value);
246		selectWheelDia(numericWheelDia.value);
247	}
248	else	/*user did not select the offroad notation*/
249	{
250		/*disabled all numeric notations:*/
251		numericProfile.disabled=true;
252		numericWidth.disabled=true;
253		numericWheelDia.disabled=true;
254	}
255
256	setText()	/*write text*/
257
258}
259
260/*enableEuroMetric is run when the user selects another type of notation*/
261
262function enableEuroMetric()
263{
264	/*declare all elements:*/
265	var offroad = document.getElementById("offroad");
266	var euroWidth = document.getElementById("euro-treadwidth");
267	var euroWheelDia = document.getElementById("euro-wheel-dia");
268	var alphaNumeric = document.getElementById("alpha-numeric");
269	var numeric = document.getElementById("numeric");
270	var euroMetric = document.getElementById("euro-metric");
271
272	if(euroMetric.checked)  /*user selected the euro-metric notation*/
273	{
274		/*enable all euro-metric notations:*/
275		euroWidth.disabled=false;
276		euroWheelDia.disabled=false;
277		
278		/*disable all other types of notations:*/
279		offroad.checked=false;
280		alphaNumeric.checked=false;
281		numeric.checked=false;
282		enableOffroad();
283		enableAlphaNumeric();
284		enableNumeric();
285		
286		/*set the new P-metric size:*/
287		selectWidth(euroWidth.value);
288		selectAR(82);
289		selectWheelDia(euroWheelDia.value);
290	}
291	else	/*user did not select the euro-metric notation*/
292	{
293		/*disabled all euro-metric notations:*/
294		euroWidth.disabled=true;
295		euroWheelDia.disabled=true;
296	}
297
298	setText()	/*write text*/
299}
300
301/*closeNotations is run when the P-metric size is changed by the user*/
302
303function  closeNotations()
304{
305	/*unchecked and disabled all other types of notations if necessary:*/
306
307	if(document.getElementById("offroad").checked)
308	{
309		document.getElementById("offroad").checked=false;
310		document.getElementById("offroad-dia").disabled=true;
311		document.getElementById("offroad-width").disabled=true;
312		document.getElementById("offroad-wheel-dia").disabled=true;
313	}
314	else if(document.getElementById("alpha-numeric").checked)
315	{
316		document.getElementById("alpha-numeric").checked=false;
317		document.getElementById("alpha-numeric-profile").disabled=true;
318		document.getElementById("alpha-numeric-width").disabled=true;
319		document.getElementById("alpha-numeric-wheel-dia").disabled=true;
320	}
321	else if(document.getElementById("numeric").checked)
322	{
323		document.getElementById("numeric").checked=false;
324		document.getElementById("numeric-profile").disabled=true;
325		document.getElementById("numeric-width").disabled=true;
326		document.getElementById("numeric-wheel-dia").disabled=true;
327	}
328	else if(document.getElementById("euro-metric").checked)
329	{
330		document.getElementById("euro-metric").checked=false;
331		document.getElementById("euro-treadwidth").disabled=true;
332		document.getElementById("euro-wheel-dia").disabled=true;
333	}
334}
335
336/*setWidth sets the tire width for the P-metric size*/
337
338function setWidth(value, style) /*'value' is the tire width in inches; 'style' is the type of notation*/
339{
340	selectWidth(Math.round(value * 25.4));	/*convert the tire width from inches to mm and set the P-metric size*/
341	if(style==OFFROAD){setAR();}	/*if offroad notation --> find the tire profile*/
342}
343
344/*setAR determines the tire profile for the P-metric size from the offroad notation*/
345
346function setAR()
347{
348	/*declare all elements:*/
349	var offroad = document.getElementById("offroad");
350	var offroadDia = document.getElementById("offroad-dia");
351	var offroadWidth = document.getElementById("offroad-width");
352	var offroadWheelDia = document.getElementById("offroad-wheel-dia");
353
354	/*calculate the profile, round it and set new profile for the P-metric size:*/
355	selectAR(Math.round((offroadDia.value-offroadWheelDia.value)/2/offroadWidth.value*100));
356}
357
358/*setWheelDia determines the wheel diameter for the P-metric size from the offroad notation*/
359
360function setWheelDia()
361{	
362	/*declare element:*/
363	var offroadWheelDia = document.getElementById("offroad-wheel-dia");
364
365	selectWheelDia(offroadWheelDia.value);	/*set wheel diameter*/
366	setAR();	/*set new tire profile*/
367}
368
369/*setWidthAlpha determines the tire width for the P-metric size from the alpha-numeric notation*/
370
371function setWidthAlpha()
372{
373	/*declare all elements:*/
374	var alphaNumericProfile = document.getElementById("alpha-numeric-profile");
375	var alphaNumericWidth = document.getElementById("alpha-numeric-width");
376	
377	/*calculate the tire width, round it, and set new tire width for the P-metric size:*/
378	selectWidth(Math.round(315-2*alphaNumericProfile.value+8*alphaNumericWidth.selectedIndex));
379}
380
381/*setARalpha determines the tire profile for the P-metric size from the alpha-numeric notation*/
382
383function setARalpha()
384{
385	/*declare element:*/
386	var alphaNumericProfile = document.getElementById("alpha-numeric-profile");
387
388	selectAR(alphaNumericProfile.value);	/*set new tire profile*/
389	setWidthAlpha();	/*determine new tire width*/
390}
391
392/*showHideExtraTextSpecial runs the showHideExtraText function to show the tire sizes*/
393
394function showHideExtraTextSpecial()
395{
396	/*declare element:*/
397	var tireDia=document.getElementById("tire-dia");
398
399	showHideExtraText('tag01','extraText01');	/*run showHideExtraText*/
400	findDia();	/*calculate new tire diameter*/
401
402	if (document.getElementById("tag01").innerHTML=="(less)")
403	{
404		tireDia.setAttribute("readonly","readonly");	/*set tire diameter as read only if tire sizes are shown*/
405		tireDia.title="Click '(less)' to edit";			/*Change tooltip*/
406	}
407	else
408	{
409		tireDia.removeAttribute("readonly","readonly");		/*set tire diameter as editable if tire sizes are hidden*/
410		tireDia.title="Enter value";						/*Change tooltip*/
411	}
412	
413	setText();	/*write text*/
414}
415
416/*setText writes the output text*/
417
418function setText()
419{
420	/*declare all elements:*/
421	var pMetric = document.getElementById("p-metric");
422	var othNot = document.getElementById("other-notation");
423
424	if (document.getElementById("tag01").innerHTML=="(less)")	/*tire size is used*/
425	{
426		if(document.getElementById("offroad").checked)	/*offroad is selected*/
427		{
428			/*write the other notation and the P-metric size:*/
429			othNot.innerHTML = "Tire size:&nbsp;&nbsp;" + document.getElementById("offroad-dia").value + "&nbsp;&nbsp;<span style='font-family:sans-serif'>x</span>&nbsp;&nbsp;" + document.getElementById("offroad-width").value + "&nbsp;&minus;&nbsp;" + document.getElementById("offroad-wheel-dia").value;
430			pMetric.innerHTML = "Equivalent tire size:&nbsp;&nbsp;" + document.getElementById("treadwidth").value + "/" + document.getElementById("profile").value + "R" + document.getElementById("wheel-dia").value;
431			othNot.style.display="block";	/*Show the other notation*/
432		}
433		else if(document.getElementById("alpha-numeric").checked)	/*alpha-numeric is selected*/
434		{
435			/*write the other notation and the P-metric size:*/
436			othNot.innerHTML = "Tire size:&nbsp;&nbsp;" + document.getElementById("alpha-numeric-width").value + document.getElementById("alpha-numeric-profile").value + "&nbsp;&minus;&nbsp;" + document.getElementById("alpha-numeric-wheel-dia").value;
437			pMetric.innerHTML = "Equivalent tire size:&nbsp;&nbsp;" + document.getElementById("treadwidth").value + "/" + document.getElementById("profile").value + "R" + document.getElementById("wheel-dia").value;
438			othNot.style.display="block";	/*Show the other notation*/
439			
440		}
441		else if(document.getElementById("numeric").checked)	/*numeric is selected*/
442		{
443			/*write the other notation and the P-metric size:*/
444			othNot.innerHTML = "Tire size:&nbsp;&nbsp;" + document.getElementById("numeric-width").value + "&nbsp;&minus;&nbsp;" + document.getElementById("numeric-wheel-dia").value + "&nbsp;&nbsp;(" + document.getElementById("numeric-profile").value + "series)";
445			pMetric.innerHTML = "Equivalent tire size:&nbsp;&nbsp;" + document.getElementById("treadwidth").value + "/" + document.getElementById("profile").value + "R" + document.getElementById("wheel-dia").value;
446			othNot.style.display="block";	/*Show the other notation*/
447		}
448		else if(document.getElementById("euro-metric").checked)	/*euro-metric is selected*/
449		{
450			/*write the other notation and the P-metric size:*/
451			othNot.innerHTML = "Tire size:&nbsp;&nbsp;" + document.getElementById("euro-treadwidth").value + "R" + document.getElementById("euro-wheel-dia").value;
452			pMetric.innerHTML = "Equivalent tire size:&nbsp;&nbsp;" + document.getElementById("treadwidth").value + "/" + document.getElementById("profile").value + "R" + document.getElementById("wheel-dia").value;
453			othNot.style.display="block";	/*Show the other notation*/
454		}
455		else	/*no other notation is selected --> P-metric size is default*/
456		{
457			/*write the P-metric size:*/
458			pMetric.innerHTML = "Tire size:&nbsp;&nbsp;" + document.getElementById("treadwidth").value + "/" + document.getElementById("profile").value + "R" + document.getElementById("wheel-dia").value;
459			othNot.style.display="none";	/*Hide the other notation*/
460		}
461		
462		pMetric.style.display="block";	/*Show the P-metric size*/
463	}
464	else	/*no other notation is selected*/
465	{
466		othNot.style.display="none";	/*Hide the other notation*/
467		pMetric.style.display="none";	/*Hide the P-metric size*/
468	}
469
470	setTable();	/*write table*/
471}
472
473/*write the table*/
474
475function setTable()
476{
477	/*declare all variables:*/
478	var dia;	/*wheel diameter*/
479	var sizes = new Array();	/*row cell values*/
480	var code	/*HTML code to be written*/
481	var colored = true;	/*determine if row background is colored or not*/
482	var j = 0;	/*column index for table*/
483	var AR;	/*tire profile*/
484	var oldAR;	/*previous tire profile*/
485	var first = true;	/*determine if it is first case studied for wheel diameter*/
486	var sizeMin;	/*minimum tire width for table cell*/
487	var sizeMax;	/*maximum tire width for table cell*/
488	var tireDia=document.getElementById("precise-dia").value*CFtoSI(document.getElementById("tire-dia-unit").value,LENGTH)/CFtoSI("in",LENGTH);	/*tire diameter converted to inches*/
489	var diaRatio; /*  wheel diameter / tire diameter  */
490	var width;	/*tire width*/
491	var widthMin = roundWidth(0.25*tireDia*25.4);	/*minimum tire width considered with respect to tire diameter*/
492	var widthMax = roundWidth(0.52*tireDia*25.4);	/*maximum tire width considered with respect to tire diameter*/
493
494	for(i=0; i<=11;i++){sizes[i]="&nbsp;";}	/*initialize all row cells to a space character*/
495
496	if(navigator.appName=="Opera"){code = "<table border=1 width=100% cellspacing=0 cellpadding=4 style='border:none; text-align:center; font-size:75%;font-family:sans-serif;background-color:white;'><caption style='font-weight:bold;font-size:200%; color:#000060;font-style:italic;background-color:white;'>tire width</caption><tr style='font-weight:bold;font-size:150%;'><td style='font-size:75%;color:#990033;'>profile &rArr;<br>wheel dia &dArr;</td><td>80</td><td>75</td><td>70</td><td>65</td><td>60</td><td>55</td><td>50</td><td>45</td><td>40</td><td>35</td><td>30</td><td>25</td></tr>";}	/*code for table header (Opera browser - uses double arrows)*/
497	else{code = "<table border=1 width=100% cellspacing=0 cellpadding=4 style='border:none; text-align:center; font-size:75%;font-family:sans-serif;background-color:white;'><caption style='font-weight:bold;font-size:200%; color:#000060;font-style:italic;background-color:white;'>tire width</caption><tr style='font-weight:bold;font-size:150%;'><td style='font-size:75%;color:#990033;'>profile &rarr;<br>wheel dia &darr;</td><td>80</td><td>75</td><td>70</td><td>65</td><td>60</td><td>55</td><td>50</td><td>45</td><td>40</td><td>35</td><td>30</td><td>25</td></tr>";}	/*code for table header (Other browsers - uses single arrows)*/
498
499	if (widthMax >
499 355){widthMax = 355;}	/*maximum tire width has to be less than or equal to 355 mm*/
500
501	for (dia=10; dia<=30; dia++)	/* each row correspond to a wheel diameter from 10" to 30" */
502	{
503		if (dia!=11 && dia!=25 && dia!=27 && dia!=29) /* 11", 25", 27" and 29" wheel diameter are not considered */
504		{
505			diaRatio=dia/tireDia;	/*determine the diameter ratio*/
506			
507			if(diaRatio>=0.52 && diaRatio<=0.82)	/*consider only diameter ratio from 0.52 to 0.82*/
508			{
509				oldAR = 1000000000;	/*set previous tire profile*/
510				
511				for(width = widthMin; width <= widthMax; width = width + 10)	/*consider for every tire width from pre-determined minimum value to maximum value*/
512				{
513					AR = roundAR((tireDia-dia)/2/width*25.4*100);	/*find closest tire profile for given data*/
514					
515					if(AR<=80 && AR>=25)	/*consider only tire profile between 25 and 80*/
516					{					
517						if(first)	/*this is the first tire width for the wheel diameter considered*/
518						{
519							sizeMin = width;	/*set tire width as minimum width*/
520							sizeMax = width;	/*set tire width as maximum width*/
521							first=false;	/*next tire widths will not be the first*/
522							switch (AR)	/*determine which tire profile it is and set appropriate column*/
523							{
524								case 80: j=0;break;
525								case 75: j=1;break;
526								case 70: j=2;break;
527								case 65: j=3;break;
528								case 60: j=4;break;
529								case 55: j=5;break;
530								case 50: j=6;break;
531								case 45: j=7;break;
532								case 40: j=8;break;
533								case 35: j=9;break;
534								case 30: j=10;break;
535								case 25: j=11;break;
536							}
537						}
538						else if(AR == oldAR)	/*tire profile is the same as the previous one*/
539						{
540							sizeMax=width;	/*set tire width as maximum width*/
541						}
542						else if(AR != oldAR)	/*tire profile is not the same as the previous one (so tire width considered is for next cell)*/
543						{
544							/*if the minimum size and the maximum size are the same, set the cell value to that single value.  Else write both values*/
545							if (sizeMin == sizeMax){sizes[j]=sizeMin;} else{sizes[j] = sizeMin + "-" + sizeMax;}
546							/*set both minimum and maximum size to the current tire width (for next cell):*/
547							sizeMin = width;
548							sizeMax = width;
549							j= j + 1;	/*set column index to next column*/
550						}
551					}
552					
553					oldAR = AR;	/*set previous tire profile*/
554				}
555				
556				if (sizeMin == sizeMax){sizes[j]=sizeMin;} else{sizes[j] = sizeMin + "-" + sizeMax;}  /*set last cell value*/
557				code = code + writeRow(colored, dia, sizes);	/*add HTML code for this row to existing code*/
558				if(colored){colored=false;}else{colored=true;}	/*change background color for next row*/
559				first=true;		/*reset 'first' for next row*/
560				for(i=0; i<=11;i++){sizes[i]="&nbsp;";}	/*reset all cells for new row*/
561			}
562		}
563	}
564	
565	document.getElementById("sizes").innerHTML = code + "</table>";		/*write code for table*/
566}
567
568/*roundAR rounds the tire profile to the nearest possible value*/
569
570function roundAR(AR)	/*'AR' is the tire profile*/
571{
572	var roundedAR = Math.round(AR/10)*10;	/*round tire profile to nearest ten*/
573	var diff = AR - roundedAR;	/*determine difference between actual value and rounded value*/
574	
575	if(diff < 2.5)
576	{
577		if(diff <= -2.5){roundedAR = roundedAR - 5;}	/*if difference is less than or equal to -2.5, remove 5 from rounded value*/
578	}
579	else{roundedAR = roundedAR + 5;}	/*if difference is greater than or equal to 2.5, add 5 to rounded value*/
580	
581	return roundedAR;
582}
583
584/*roundwidth rounds the tire width to the nearest possible value*/
585
586function roundWidth(width)	/*'width' is the tire width*/
587{
588	var roundedWidth = Math.round(width/10)*10;	/*round tire width to nearest ten*/
589
590	if(width-roundedWidth<0){roundedWidth = roundedWidth - 5;}	/*if difference between actual value and rounded value is less than 0, remove 5 from rounded value*/
591	else{roundedWidth = roundedWidth + 5;}	/*if difference between actual value and rounded value is greater than or equal to 0, add 5 to rounded value*/
592
593	return roundedWidth;
594}
595
596/*write code for the table row*/
597
598function writeRow(colored,dia,sizes)	/*'colored' sets if the row's background is colored or not; 'dia' is the wheel diameter; 'sizes' is the array containing all values for the row cells*/
599{
600	/*declare variable:*/
601	var code;
602	
603	/*code to be written depending if background is colored or not:*/
604	if (colored){code = "<tr style='background-color: #f0f0fe;'><td style='font-weight:bold;'>" + dia +"</td><td>" + sizes[0] + "</td><td>" + sizes[1] + "</td><td>" + sizes[2] + "</td><td>" + sizes[3] + "</td><td>" + sizes[4] + "</td><td>" + sizes[5] + "</td><td>" + sizes[6] + "</td><td>" + sizes[7] + "</td><td>" + sizes[8] + "</td><td>" + sizes[9] + "</td><td>" + sizes[10] + "</td><td>" + sizes[11] + "</td></tr>";}
605	else{code = "<tr><td style='font-weight:bold;'>" + dia +"</td><td>" + sizes[0] + "</td><td>" + sizes[1] + "</td><td>" + sizes[2] + "</td><td>" + sizes[3] + "</td><td>" + sizes[4] + "</td><td>" + sizes[5] + "</td><td>" + sizes[6] + "</td><td>" + sizes[7] + "</td><td>" + sizes[8] + "</td><td>" + sizes[9] + "</td><td>" + sizes[10] + "</td><td>" + sizes[11] + "</td></tr>";}
606
607	return code;
608}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.