var inch = 2.54;
function tire(n){
	n = "" + n;
	if(n.indexOf(".")!=-1){
		n = n.substr(0,n.indexOf(".")+2);
	}
	m = "" + Math.abs(n);
	if(m.substr(0,1)=="."){
		if(n<0){
			n = "-0" + m;
		} else {
			n = "0" + m;
		}
	}
	return n;
}
function calc(){
	d = document.tirechooser;
	r = document.result;
	w1 = parseInt(d.width_org.options[d.width_org.selectedIndex].value);
	p1 = parseInt(d.profile_org.options[d.profile_org.selectedIndex].value);
	d1 = parseInt(d.dim_org.options[d.dim_org.selectedIndex].value);
	w2 = parseInt(d.width_new.options[d.width_new.selectedIndex].value);
	p2 = parseInt(d.profile_new.options[d.profile_new.selectedIndex].value);
	d2 = parseInt(d.dim_new.options[d.dim_new.selectedIndex].value);
	height_org1 = ((w1*(p1/100)*2)/10) + d1*inch;
	profile_org1 = (w1*(p1/100)/10);
	circumference_org1 = height_org1 * Math.PI;
	height_org2 = ((w2*(p2/100)*2)/10) + d2*inch;
	profile_org2 = (w2*(p2/100)/10);
	circumference_org2 = height_org2 * Math.PI;
	r.h1.value = tire(height_org1);
	r.p1.value = tire(profile_org1);
	r.o1.value = tire(circumference_org1);
	r.h2.value = tire(height_org2);
	r.p2.value = tire(profile_org2);
	r.o2.value = tire(circumference_org2);
	r.hmm.value = tire(r.h2.value - r.h1.value);
	r.pmm.value = tire(r.p2.value - r.p1.value);
	r.omm.value = tire(r.o2.value - r.o1.value);
	r.hproc.value = tire((r.hmm.value/r.h1.value)*100);
	r.pproc.value = tire((r.pmm.value/r.p1.value)*100);
	r.oproc.value = tire((r.omm.value/r.o1.value)*100);
}