// JavaScript Document

<!--

function berechnen(radtyp) {
	switch(radtyp) {
		case 'hardtail':
		var sh = checkSH(document.rahmenhoehe.hardtail_sh.value);
		if(sh){
			var zoll = sh*0.226;
			var cm = zoll*2.54;
			document.rahmenhoehe.hardtail_zoll.value = Math.round(zoll);
			document.rahmenhoehe.hardtail_cm.value = Math.round(cm);
		}
		else {
			document.rahmenhoehe.hardtail_sh.select();
			document.rahmenhoehe.hardtail_zoll.value = '';
			document.rahmenhoehe.hardtail_cm.value = '';
		}
		break;

		case 'fullsuspension':
		var sh = checkSH(document.rahmenhoehe.fullsuspension_sh.value);
		if(sh){
			var zoll = sh*0.226;
			var cm = zoll*2.54;
			document.rahmenhoehe.fullsuspension_zoll.value = Math.round(zoll);
			document.rahmenhoehe.fullsuspension_cm.value = Math.round(cm);
		}
		else {
			document.rahmenhoehe.fullsuspension_sh.select();
			document.rahmenhoehe.fullsuspension_zoll.value = '';
			document.rahmenhoehe.fullsuspension_cm.value = '';
		}
		break;

		case 'rennrad':
		var sh = checkSH(document.rahmenhoehe.rennrad_sh.value);
		if(sh){
			var rennrad_cm = Math.round(sh*0.665);
			var triathlonrad_cm = rennrad_cm-4.25;
			document.rahmenhoehe.rennrad_cm.value = rennrad_cm;
			document.rahmenhoehe.triathlonrad_cm.value = triathlonrad_cm;
		}
		else {
			document.rahmenhoehe.rennrad_sh.select();
			document.rahmenhoehe.rennrad_cm.value = '';
			document.rahmenhoehe.triathlonrad_cm.value = '';
		}
		break;

		case 'touringbike':
		var sh = checkSH(document.rahmenhoehe.touringbike_sh.value);
		if(sh){
			var zoll = sh*0.24;
			var cm = sh*0.61;
			document.rahmenhoehe.touringbike_zoll.value = Math.round(zoll);
			document.rahmenhoehe.touringbike_cm.value = Math.round(cm);
		}
		else {
			document.rahmenhoehe.touringbike_sh.select();
			document.rahmenhoehe.touringbike_zoll.value = '';
			document.rahmenhoehe.touringbike_cm.value = '';
		}
		break;

		case 'reiserad':
		var sh = checkSH(document.rahmenhoehe.reiserad_sh.value);
		if(sh){
			var zoll = sh*0.259;
			var cm = sh*0.66;
			document.rahmenhoehe.reiserad_zoll.value = Math.round(zoll);
			document.rahmenhoehe.reiserad_cm.value = Math.round(cm);
		}
		else {
			document.rahmenhoehe.reiserad_sh.select();
			document.rahmenhoehe.reiserad_zoll.value = '';
			document.rahmenhoehe.reiserad_cm.value = '';
		}
		break;
	}
}

function checkSH(s){
	if ( isNaN(s) ) {
		alert('Für die Schritthöhe bitte nur eine Zahl eingeben.');
		return false;
	}
	return s;
}

function getZentimeter(z){
// Inch oder englisches Zoll exakt 25,4 mm oder 2,54 cm
	var cm = Math.round(z * 2.54);
	return cm;
}