function rotateCogs(r,m,l)
{
	// r = right, m = middle, l = left

	var pr = ENIGMA.plaintext.indexOf(document.getElementById('rightw_set').value.toUpperCase());
	var pm = ENIGMA.plaintext.indexOf(document.getElementById('middlew_set').value.toUpperCase());
	var pl = ENIGMA.plaintext.indexOf(document.getElementById('leftw_set').value.toUpperCase());

	if (pr == parseFloat(ENIGMA.arrKnockpoints[r][0]) || pr == parseFloat(ENIGMA.arrKnockpoints[r][1])) {
		// If the knockpoint on the right wheel is reached rotate middle wheel
		// But first check if it too is a knock point
		if (pm == parseFloat(ENIGMA.arrKnockpoints[m][0]) || pm == parseFloat(ENIGMA.arrKnockpoints[m][1])) {
			// If the knockpoint on the middle wheel is reached rotate left wheel
			pl++;
		}
		pm++;
	} else {
		if (pm == parseFloat(ENIGMA.arrKnockpoints[m][0]) || pm == parseFloat(ENIGMA.arrKnockpoints[m][1])) {
			// If the knockpoint on the middle wheel is reached rotate left AND middle wheels
			// (the double stepping mechanism)
			pl++;
			pm++;
		}
	}

	// Rotate right wheel (this wheel is always rotated).
	pr++;

	// If rotating brings us beyond "Z" (26), then start at "A" (1) again.
	if (pr > 26) {pr = 1;}
	if (pm > 26) {pm = 1;}
	if (pl > 26) {pl = 1;}

	// Display new values in browser
	document.getElementById('rightw_set').value = ENIGMA.plaintext.charAt(pr);
	document.getElementById('middlew_set').value = ENIGMA.plaintext.charAt(pm);
	document.getElementById('leftw_set').value = ENIGMA.plaintext.charAt(pl);

	// Make values available to the rest of the script as an array.
	return new Array(pr, pm, pl);
}
/* FUNCTION --------------------------------------------------------
	As text is entered, rotate the wheels (aka cogs) by one letter.
	This occurs BEFORE the entered text is mapped.
   ----------------------------------------------------------------- */
FUNCTION
As text is entered, rotate the wheels (aka cogs) by one letter.
This occurs BEFORE the entered text is mapped.
FUNCTION As text is entered rotate the wheels ( aka cogs ) by one letter . This occurs BEFORE the entered text is mapped .
function rotateCogs(r,m,l)
{
	var pr = ENIGMA.plaintext.indexOf(document.getElementById('rightw_set').value.toUpperCase());
	var pm = ENIGMA.plaintext.indexOf(document.getElementById('middlew_set').value.toUpperCase());
	var pl = ENIGMA.plaintext.indexOf(document.getElementById('leftw_set').value.toUpperCase());
	if (pr == parseFloat(ENIGMA.arrKnockpoints[r][0]) || pr == parseFloat(ENIGMA.arrKnockpoints[r][1])) {
		if (pm == parseFloat(ENIGMA.arrKnockpoints[m][0]) || pm == parseFloat(ENIGMA.arrKnockpoints[m][1])) {
			pl++;
		}
		pm++;
	} else {
		if (pm == parseFloat(ENIGMA.arrKnockpoints[m][0]) || pm == parseFloat(ENIGMA.arrKnockpoints[m][1])) {
			pl++;
			pm++;
		}
	}
	pr++;
	if (pr > 26) {pr = 1;}
	if (pm > 26) {pm = 1;}
	if (pl > 26) {pl = 1;}
	document.getElementById('rightw_set').value = ENIGMA.plaintext.charAt(pr);
	document.getElementById('middlew_set').value = ENIGMA.plaintext.charAt(pm);
	document.getElementById('leftw_set').value = ENIGMA.plaintext.charAt(pl);
	return new Array(pr, pm, pl);
}
function rotateCogs ( r , m , l ) { var pr = ENIGMA . plaintext . indexOf ( document . getElementById ( 'rightw_set' ) . value . toUpperCase ( ) ) ; var pm = ENIGMA . plaintext . indexOf ( document . getElementById ( 'middlew_set' ) . value . toUpperCase ( ) ) ; var pl = ENIGMA . plaintext . indexOf ( document . getElementById ( 'leftw_set' ) . value . toUpperCase ( ) ) ; if ( pr == parseFloat ( ENIGMA . arrKnockpoints [ r ] [ 0 ] ) || pr == parseFloat ( ENIGMA . arrKnockpoints [ r ] [ 1 ] ) ) { if ( pm == parseFloat ( ENIGMA . arrKnockpoints [ m ] [ 0 ] ) || pm == parseFloat ( ENIGMA . arrKnockpoints [ m ] [ 1 ] ) ) { pl ++ ; } pm ++ ; } else { if ( pm == parseFloat ( ENIGMA . arrKnockpoints [ m ] [ 0 ] ) || pm == parseFloat ( ENIGMA . arrKnockpoints [ m ] [ 1 ] ) ) { pl ++ ; pm ++ ; } } pr ++ ; if ( pr > 26 ) { pr = 1 ; } if ( pm > 26 ) { pm = 1 ; } if ( pl > 26 ) { pl = 1 ; } document . getElementById ( 'rightw_set' ) . value = ENIGMA . plaintext . charAt ( pr ) ; document . getElementById ( 'middlew_set' ) . value = ENIGMA . plaintext . charAt ( pm ) ; document . getElementById ( 'leftw_set' ) . value = ENIGMA . plaintext . charAt ( pl ) ; return new Array ( pr , pm , pl ) ; }
FUNCTION
As text is entered, rotate the wheels (aka cogs) by one letter.
FUNCTION As text is entered rotate the wheels ( aka cogs ) by one letter .
// r = right, m = middle, l = left // If the knockpoint on the right wheel is reached rotate middle wheel // But first check if it too is a knock point // If the knockpoint on the middle wheel is reached rotate left wheel // If the knockpoint on the middle wheel is reached rotate left AND middle wheels // (the double stepping mechanism) // Rotate right wheel (this wheel is always rotated). // If rotating brings us beyond "Z" (26), then start at "A" (1) again. // Display new values in browser // Make values available to the rest of the script as an array.