Я вижу только два места куда вы можете вставить свой код, указал комментариями:
(function() {
var oSheme, oCalculator, oDiscCalculator, oSpeedometer = [];
window.onload = function () {
initLegend();
initCalculator();
initDiscCalculator();
}
function initLegend() {
var elem = document.getElementById('shemeLegend');
if (elem) {
oSheme = {
'nLegend': elem,
'aLabels': []
}
initLegendLabel('L');
initLegendLabel('H');
initLegendLabel('D');
initLegendLabel('DD');
}
}
function initLegendLabel(sLabel) {
var elem = document.getElementById('labelSheme' + sLabel);
if (oSheme && elem) {
elem.onmouseover = function () {
legendMouseOver(sLabel);
};
elem.onmouseout = function () {
legendMouseOut();
};
oSheme.aLabels.push(sLabel);
if (elem = document.getElementById('sheme' + sLabel)) {
doPreload(elem.src);
}
}
}
function legendMouseOver(sLabel) {
legendMouseOut();
addClass(oSheme.nLegend, 'label' + sLabel);
}
function legendMouseOut() {
for (i in oSheme.aLabels) {
removeClass(oSheme.nLegend, 'label' + oSheme.aLabels[i]);
}
}
function initCalculator() {
oCalculator = {
'oldWidth': document.getElementById('oldWidth'),
'oldDiameter': document.getElementById('oldDiameter'),
'oldProfile': document.getElementById('oldProfile'),
'newWidth': document.getElementById('newWidth'),
'newDiameter': document.getElementById('newDiameter'),
'newProfile': document.getElementById('newProfile'),
'oldL': document.getElementById('oldL'),
'newL': document.getElementById('newL'),
'deltaL': document.getElementById('deltaL'),
'oldH': document.getElementById('oldH'),
'newH': document.getElementById('newH'),
'deltaH': document.getElementById('deltaH'),
'oldD': document.getElementById('oldD'),
'newD': document.getElementById('newD'),
'deltaD': document.getElementById('deltaD'),
'oldDD': document.getElementById('oldDD'),
'newDD': document.getElementById('newDD'),
'deltaDD': document.getElementById('deltaDD')
}
var elem, i = 10;
while (elem = document.getElementById('speed' + i)) {
oSpeedometer[i] = elem;
i += 10;
}
applyCalculateEvent(oCalculator.oldWidth);
applyCalculateEvent(oCalculator.oldDiameter);
applyCalculateEvent(oCalculator.oldProfile);
applyCalculateEvent(oCalculator.newWidth);
applyCalculateEvent(oCalculator.newDiameter);
applyCalculateEvent(oCalculator.newProfile);
doCalculate();
}
function applyCalculateEvent(nNode) {
nNode.onchange = function () {
doCalculate();
// либо сюда вставляете свой код
};
}
function doCalculate() {
var iOldL = oCalculator.oldWidth.value;
var iNewL = oCalculator.newWidth.value;
var iOldD = Math.round(oCalculator.oldDiameter.value * 25.4);
var iNewD = Math.round(oCalculator.newDiameter.value * 25.4);
var iOldDD = Math.round(
oCalculator.oldWidth.value *
oCalculator.oldProfile.value * 0.02 +
oCalculator.oldDiameter.value * 25.4
);
var iNewDD = Math.round(
oCalculator.newWidth.value *
oCalculator.newProfile.value * 0.02 +
oCalculator.newDiameter.value * 25.4
);
var iOldH = Math.round((iOldDD - iOldD) / 2);
var iNewH = Math.round((iNewDD - iNewD) / 2);
var iSpeedCoeff = iNewDD / iOldDD;
setTextValue(oCalculator.oldL, iOldL);
setTextValue(oCalculator.newL, iNewL);
setTextValue(oCalculator.deltaL, iNewL - iOldL);
setTextValue(oCalculator.oldH, iOldH);
setTextValue(oCalculator.newH, iNewH);
setTextValue(oCalculator.deltaH, iNewH - iOldH);
setTextValue(oCalculator.oldD, iOldD);
setTextValue(oCalculator.newD, iNewD);
setTextValue(oCalculator.deltaD, iNewD - iOldD);
setTextValue(oCalculator.oldDD, iOldDD);
setTextValue(oCalculator.newDD, iNewDD);
setTextValue(oCalculator.deltaDD, iNewDD - iOldDD);
for (i in oSpeedometer) {
setTextValue(oSpeedometer[i], Math.round(i * iSpeedCoeff * 10) / 10);
}
}
function initDiscCalculator() {
if (
document.getElementById('tireWidth') &&
document.getElementById('tireDiameter') &&
document.getElementById('tireProfile') &&
document.getElementById('discDiameter') &&
document.getElementById('discWidthMin') &&
document.getElementById('discWidthMax')
) {
oDiscCalculator = {
'tireWidth': document.getElementById('tireWidth'),
'tireDiameter': document.getElementById('tireDiameter'),
'tireProfile': document.getElementById('tireProfile'),
'discDiameter': document.getElementById('discDiameter'),
'discWidthMin': document.getElementById('discWidthMin'),
'discWidthMax': document.getElementById('discWidthMax')
}
applyCalculateDiscEvent(oDiscCalculator.tireWidth);
applyCalculateDiscEvent(oDiscCalculator.tireDiameter);
applyCalculateDiscEvent(oDiscCalculator.tireProfile);
doCalculateDisc();
}
}
function applyCalculateDiscEvent(nNode) {
nNode.onchange = function () {
doCalculateDisc();
// либо сюда вставляете свой код
};
}
function doCalculateDisc() {
if (oDiscCalculator) {
var iWidth = oDiscCalculator.tireWidth.value;
var iProfile = oDiscCalculator.tireProfile.value;
var iDiameter = oDiscCalculator.tireDiameter.value;
var iWidthMin = (Math.round(((iWidth * ((iProfile < 50) ? 0.85 : 0.7)) * 0.03937) * 2)) / 2;
var iWidthMax = (iWidthMin + 1.5);
setTextValue(oDiscCalculator.discDiameter, iDiameter);
setTextValue(oDiscCalculator.discWidthMin, iWidthMin);
setTextValue(oDiscCalculator.discWidthMax, iWidthMax);
}
}
function setTextValue(nNode, sValue) {
sValue = String(sValue);
sValue = sValue.replace(/\./, ',');
nNode.innerHTML = sValue;
}
function isClass(nNode, sClassName) {
return (nNode.className.indexOf(sClassName) >= 0);
}
function addClass(nNode, sClassName) {
if (nNode.className) {
var aClass = nNode.className.split(' ');
for (var i in aClass) {
if (sClassName == aClass[i]) {
sClassName = '';
}
}
if (sClassName) {
aClass.push(sClassName);
}
nNode.className = aClass.join(' ');
} else {
nNode.className = sClassName;
}
}
function removeClass(nNode, sClassName) {
if (nNode.className) {
var aClass = nNode.className.split(' ');
for (var i in aClass) {
if (sClassName == aClass[i]) {
aClass.splice(i, 1);
break;
}
}
nNode.className = aClass.join(' ');
}
}
function doPreload(sImg) {
var oPreload = new Image();
oPreload.src = sImg;
}
})();