function getMeasurement()  {
	<!-- error check for a numeric character only -->
	var trigger = true;
	if (!isNumeric(document.selection.floorm.value))  {
		alert("Please enter a valid figure");
		document.selection.floorm.value="";
		trigger = false;
	}
	if ((document.selection.typep.checked || document.selection.typec.checked) && trigger)  {
		getTreads();
	}
}


function isNumeric(string)  {
  var validChars = "0123456789";
  var strChar;
  var blnResult = true;
  var dotCounter=0;
  for (i = 0; i < string.length && blnResult == true; i++)  {
    strChar = string.charAt(i);
    if (validChars.indexOf(strChar) == -1)  {
      blnResult = false;
    }
	if (strChar == ".")  {
	  dotCounter++;
	}
  }
  if (dotCounter > 1)  {
    blnResult=false;
  }
  return blnResult;
}


function checkRadio(id)  {
	if (id=="c")  {
		if (document.selection.typec.checked)  {
			document.selection.typec.checked=false;
		}
	} else {
		if (document.selection.typep.checked)  {
			document.selection.typep.checked=false;
		}
	}
	/*if (document.selection.floorm.value != "")  {
		getTreads();
	}*/
	getTreads();
}


function recalculateGoing()  {
	var floortofloor=eval(document.selection.floorm.value);
	var numbertreads=eval(document.selection.treads.options[document.selection.treads.selectedIndex].value);
	if (document.selection.typec.checked)  {
		var type="common";
	} else {
		var type="private";
	}
	eval(rise=(floortofloor / numbertreads));
	getNewGoing(type);
	return false;
}


function getNewGoing(type)  {

}


function getTreads()  {
	if (document.selection.floorm.value != "")  {
	  var goingChoices = document.selection.going.length;
	  if (document.selection.typep.checked)  {
		var theRise = document.selection.risep.value;
		if (goingChoices == 61)  {
			var counter=239;
			for (var x=61;x<81;x++)  {
				document.selection.going.options[x] = new Option(counter+" mm",counter,false,false);
				counter--;
			}
		}
	  } else {
		var theRise = document.selection.risec.value;
		if (goingChoices == 81)  {
			for (var x=goingChoices;x>60;x--)  {
				document.selection.going.remove(x);
			}
		}
	  }
	  var theStart = (Math.round(document.selection.floorm.value / theRise));	
	  <!-- now alter the rise height accordingly -->
	  var theMath = (document.selection.floorm.value / theStart);
	  <!--alert(theStart+" :: "+theMath);-->
	  if (document.selection.typep.checked)  {
		while ((document.selection.floorm.value / theStart) > 220)  {
			<!--alert("Sorry but the current configuration is invalid. Please alter the rise or floor-to-floor value");
			theStart++;
		}
	  } else {
		while ((document.selection.floorm.value / theStart) > 190)  {
			<!--alert("Sorry but the current configuration is invalid. Please alter the rise or floor-to-floor value");
			theStart++;
		}
	  }
	  document.selection.treads.value = theStart;
	  getLength(theStart);
    }
}


function getLength(treads)  {
	if (document.selection.typep.checked)  {
		theRise = document.selection.risep.value;
		maxRise = 220;
		minGoing = 220;
		theAngle = 42;
	} else {
		theRise = document.selection.risec.value;
		maxRise = 190;
		minGoing = 240;
		theAngle = 38;
	}
    if (theRise != 0)  {
		theRise = document.selection.floorm.value / treads;
		if (theRise > maxRise)  {
			theRise = maxRise;
		}
		<!-- POSSIBLY CHANGE THIS LINE ???????? -->
		theGoing = Math.ceil(theRise / 0.900404);
		<!--alert(theGoing+":"+theRise);
		if (theGoing < minGoing)  {
			theGoing = minGoing;
		}
		totalLength = Math.ceil(theGoing * (treads-1));
		document.selection.totalgoing.value = totalLength+30;
		<!--alert(300-theGoing);
		document.selection.going.selectedIndex = 300-theGoing;
	}
}


function getnewLength(name)  {
	/* formula: theAngle = ((Math.atan(RISE/LENGTH))/0.0453293); 
	   need to check that the angle doesn't exceed the given max for the type of stair selected  */
	var theForm = eval("document.selection."+name);
	var theLength = theForm.options[theForm.selectedIndex].value;
	if (document.selection.typep.checked)  {
		theRise = document.selection.risep.value;
		minGoing = 220;
		theAngle = 42.4;
	} else {
		theRise = document.selection.risec.value;
		minGoing = 240;
		theAngle = 38.4;
	}
	<!--alert((Math.atan(theRise/theLength))/0.017453293);-->
	if (((Math.atan(theRise/theLength))/0.017453293) > theAngle)  {
		alert("Incorrect length chosen :: If you wish further advice please feel free to contact us.");
		<!--getLength(document.selection.treads.options[document.selection.treads.selectedIndex].value);
		getLength(document.selection.treads.value);
	} else {
		if (theLength < minGoing)  {
			alert("Sorry, incorrect");
			theLength = minGoing;
			theForm.selectedIndex = 60;
		}
		document.selection.totalgoing.value = (theLength * (document.selection.treads.value-1))+30;
	}
}


function changeHeight(id)  {
	if (id=="p")  {
		if (!document.selection.typep.checked)  {
			document.selection.typep.checked = true;
		}
		if (document.selection.typec.checked)  {
			document.selection.typec.checked = false;
		}
	} else {
		if (!document.selection.typec.checked)  {
			document.selection.typec.checked = true;
		}
		if (document.selection.typep.checked)  {
			document.selection.typep.checked = false;
		}
	}
	getTreads();
}


function checkStep1(option)  {
	if (document.selection.floorm.value == "")  {
		alert("Please fill in the floor to floor measurement");
		return false;
	}
	if (!document.selection.typep.checked && !document.selection.typec.checked)  {
		alert("Please select type of stairs");
		return false;
	}
	if (option == "y")  {
		if (!document.selection.direction[0].checked && !document.selection.direction[1].checked)  {
			alert("Please select a direction");
			return false;
		}
	}
	return true;
}


function checkStep13(stairs)  {
	var thePage=document.selection;
	if (thePage.stringwood.options[thePage.stringwood.selectedIndex].value == "x")  {
		alert("Please select string wood type");
		return false;
	}
	if (thePage.treadwood.options[thePage.treadwood.selectedIndex].value == "x")  {
		alert("Please select tread wood type");
		return false;
	}
	if (thePage.risertype.options[thePage.risertype.selectedIndex].value == "x")  {
		alert("Please select a riser type");
		return false;
	}
	if (thePage.tread1.options[thePage.tread1.selectedIndex].value == "x")  {
		alert("Please select a tread type");
		return false;
	}
	if (thePage.newelca.options[thePage.newelca.selectedIndex].value != "0:None")  {
		if (thePage.newelwoodca.options[thePage.newelwoodca.selectedIndex].value == "x")  {
			alert("Please select mandatory newel post 1 wood type");
			return false;
		}
		<!-- added by Clive 22/1 -->
		if (thePage.newelstyleca.options[thePage.newelstyleca.selectedIndex].value == "0")  {
			alert("Please select mandatory newel post 1 style");
			return false;
		}
		<!-- end of added -->
	}
	if (thePage.newelcb.options[thePage.newelcb.selectedIndex].value != "0:None")  {
		if (thePage.newelwoodcb.options[thePage.newelwoodcb.selectedIndex].value == "x")  {
			alert("Please select mandatory newel post 2 wood type");
			return false;
		}
		<!-- added by Clive 22/1 -->
		if (thePage.newelstylecb.options[thePage.newelstylecb.selectedIndex].value == "0")  {
			alert("Please select mandatory newel post 2 style");
			return false;
		}
		<!-- end of added -->
	}
	if (thePage.newela.options[thePage.newela.selectedIndex].value != "0:None")  {
		if (thePage.newelwooda.options[thePage.newelwooda.selectedIndex].value == "x")  {
			alert("Please select newel post nA wood type");
			return false;
		}
		<!-- added by Clive 22/1 -->
		if (thePage.newelstylea.options[thePage.newelstylea.selectedIndex].value == "0")  {
			alert("Please select newel post nA style");
			return false;
		}
		<!-- end of added -->
	}
	if (thePage.newelb.options[thePage.newelb.selectedIndex].value != "0:None")  {
		if (thePage.newelwoodb.options[thePage.newelwoodb.selectedIndex].value == "x")  {
			alert("Please select newel post nB wood type");
			return false;
		}
		<!-- added by Clive 22/1 -->
		if (thePage.newelstyleb.options[thePage.newelstyleb.selectedIndex].value == "0")  {
			alert("Please select newel post nB style");
			return false;
		}
		<!-- end of added -->
	}
	if (thePage.newelc.options[thePage.newelc.selectedIndex].value != "0:None")  {
		if (thePage.newelwoodc.options[thePage.newelwoodc.selectedIndex].value == "x")  {
			alert("Please select newel post nC wood type");
			return false;
		}
		<!-- added by Clive 22/1 -->
		if (thePage.newelstylec.options[thePage.newelstylec.selectedIndex].value == "0")  {
			alert("Please select newel post nC style");
			return false;
		}
		<!-- end of added -->
	}
	if (thePage.neweld.options[thePage.neweld.selectedIndex].value != "0:None")  {
		if (thePage.newelwoodd.options[thePage.newelwoodd.selectedIndex].value == "x")  {
			alert("Please select newel post nD wood type");
			return false;
		}
		<!-- added by Clive 22/1 -->
		if (thePage.newelstyled.options[thePage.newelstyled.selectedIndex].value == "0")  {
			alert("Please select newel post nD style");
			return false;
		}
		<!-- end of added -->
	}
	if (thePage.newelstylea.options[thePage.newelstylea.selectedIndex].value != "0")  {
		if (thePage.newelwooda.options[thePage.newelwooda.selectedIndex].value == "x")  {
			alert("Please select newel post nA wood type");
			return false;
		}
		if (thePage.newela.options[thePage.newela.selectedIndex].value == "0")  {
			alert("Please select newel post nA type");
			return false;
		}
	}
	if (thePage.newelstyleb.options[thePage.newelstyleb.selectedIndex].value != "0")  {
		if (thePage.newelwoodb.options[thePage.newelwoodb.selectedIndex].value == "x")  {
			alert("Please select newel post nB wood type");
			return false;
		}
		if (thePage.newelb.options[thePage.newelb.selectedIndex].value == "0")  {
			alert("Please select newel post nB type");
			return false;
		}
	}
	if (thePage.newelstylec.options[thePage.newelstylec.selectedIndex].value != "0")  {
		if (thePage.newelwoodc.options[thePage.newelwoodc.selectedIndex].value == "x")  {
			alert("Please select newel post nC wood type");
			return false;
		}
		if (thePage.newelc.options[thePage.newelc.selectedIndex].value == "0")  {
			alert("Please select newel post nC type");
			return false;
		}
	}
	if (thePage.newelstyled.options[thePage.newelstyled.selectedIndex].value != "0")  {
		if (thePage.newelwoodd.options[thePage.newelwoodd.selectedIndex].value == "x")  {
			alert("Please select newel post nD wood type");
			return false;
		}
		if (thePage.neweld.options[thePage.neweld.selectedIndex].value == "0")  {
			alert("Please select newel post nD type");
			return false;
		}
	}
	if (thePage.handrailtype.options[thePage.handrailtype.selectedIndex].value != "0")  {
		if (thePage.handrailwood.options[thePage.handrailwood.selectedIndex].value == "0")  {
			alert("Please select a handrail wood type");
			return false;
		}
	}
	if (thePage.bracerailtype.options[thePage.bracerailtype.selectedIndex].value != "0")  {
		if (thePage.bracerailwood.options[thePage.bracerailwood.selectedIndex].value == "0")  {
			alert("Please select a baserail wood type");
			return false;
		}
	}
	if (thePage.extrahandtype.options[thePage.extrahandtype.selectedIndex].value != "0")  {
		if (thePage.extrahandrailwood.options[thePage.extrahandrailwood.selectedIndex].value == "0")  {
			alert("Please select an extra-handrail wood type");
			return false;
		}
		if (thePage.handlength.options[thePage.handlength.selectedIndex].value == "0")  {
			alert("Please select an extra handrail length");
			return false;
		}
	}
	if (thePage.extrabracetype.options[thePage.extrabracetype.selectedIndex].value != "0")  {
		if (thePage.extrabracerailwood.options[thePage.extrabracerailwood.selectedIndex].value == "0")  {
			alert("Please select an extra-baserail wood type");
			return false;
		}
		if (thePage.bracelength.options[thePage.bracelength.selectedIndex].value == "0")  {
			alert("Please select an extra-baserail length");
			return false;
		}
	}
	if (thePage.extraspindle.options[thePage.extraspindle.selectedIndex].value != "0")  {
		if (thePage.extraSpindlewood.options[thePage.extraSpindlewood.selectedIndex].value == "0")  {
			alert("Please select an extra-spindle wood type");
			return false;
		}
		if (thePage.extraSpindleNumber.options[thePage.extraSpindleNumber.selectedIndex].value == "0")  {
			alert("Please select an extra-spindle length");
			return false;
		}
	}
	if (stairs=="2")  {
	  if (thePage.newelstyleca.options[thePage.newelstyleca.selectedIndex].value == "0")  {
		alert("You must select newel post no1 style");
		  return false;
		}
	  if (thePage.newelwoodca.options[thePage.newelwoodca.selectedIndex].value == "x")  {
		alert("You must select newel post no1 wood");
		  return false;
		}
	}
	if (stairs=="3")  {
	  if (thePage.newelstyleca.options[thePage.newelstyleca.selectedIndex].value == "0")  {
		alert("You must select newel post no1 style");
		  return false;
		}
	  if (thePage.newelwoodca.options[thePage.newelwoodca.selectedIndex].value == "x")  {
		alert("You must select newel post no1 wood");
		  return false;
		}
	  if (thePage.newelstylecb.options[thePage.newelstylecb.selectedIndex].value == "0")  {
		alert("You must select newel post n02 style");
		  return false;
	  }
	  if (thePage.newelwoodcb.options[thePage.newelwoodcb.selectedIndex].value == "x")  {
		alert("You must select newel post no2 wood");
		  return false;
		}
	}
	return true;
}


function checkStep21()  {
	var thePage=document.selection;
	corner1Array=thePage.corner1.options[thePage.corner1.selectedIndex].value.split(":");
	if (corner1Array[1] == "x")  {
		alert("Please select a corner configuration");
		return false;
	}
	var totalTreads=thePage.totalTreads.value;
	var flight1=thePage.flight1.options[thePage.flight1.selectedIndex].value;
	var flight2=thePage.flight2.value;
	var pickCount=eval(corner1Array[0])+eval(flight1)+eval(flight2);
	if (totalTreads != pickCount)  {
		alert("Please select number of treads per flight");
		return false;
	}
	if (flight2 == "0")  {
		alert("Please select a minimum of 1 tread on flight 2");
		return false;
	}
	if (flight1 == "0" && corner1Array[1] == "quarter")  {
		alert("Sorry this configuration is unavailable");
		return false;
	}
	return true;
}


function checkStep22()  {
	var thePage=document.selection;
	corner1Array=thePage.corner1.options[thePage.corner1.selectedIndex].value.split(":");
	if (corner1Array[1] == "x")  {
		alert("Please select a corner configuration");
		return false;
	}
	if (corner1Array[1] == "half")  {
		flightTreads=eval(corner1Array[0]);
		<!-- added by Clive 22/1 -->
		if (document.selection.wellsize.value=="")  {
			alert("Please select a well size");
			return false;
		}
		<!-- end of added -->
	} else {
		corner2Array=thePage.corner2.options[thePage.corner2.selectedIndex].value.split(":");
		if (corner2Array[1] == "x")  {
			alert("Please select a corner configuration");
			return false;
		}
		flightTreads=eval(corner1Array[0])+eval(corner2Array[0]);
	}
	var totalTreads=thePage.totalTreads.value;
	var flight1=eval(thePage.flight1.options[thePage.flight1.selectedIndex].value);
	if (thePage.flight2.length == 0 && corner1Array[1] != "half")  {
		alert("Please select number of treads per flight");
		return false;
	}
	if (corner1Array[1] == "half")  {
		var flight2=0;
	} else {
		var flight2=eval(thePage.flight2.options[thePage.flight2.selectedIndex].value);
	}
	var flight3=eval(thePage.flight3.value);
	if (totalTreads != eval(flightTreads+flight1+flight2+flight3))  {
		alert("Please select number of treads per flight");
		return false;
	}
	return true;
}


function getFlightSingle()  {
  if (document.selection.flight1.length > 0)  {
  	for (var x=document.selection.flight1.length;x>0;x--)  {
	  document.selection.flight1.remove(x);
	}
  }
  var totalTreads=document.selection.totalTreads.value;
  var corner1Array=document.selection.corner1.options[document.selection.corner1.selectedIndex].value.split(":");
  var corner1=corner1Array[0];
  var treadRemain=(totalTreads-corner1)-1;
  for (x=treadRemain;x>=0;x--)  {
  	document.selection.flight1.options[x] = new Option(" :: "+x+" :: ",x,false,false);
  }
  document.selection.flight1.options[document.selection.flight1.length] = new Option("Treads",x,false,true);
  document.selection.flight2.value=0;
}


function getFlightsC1()  {
  emptyFlights();
  var totalTreads=document.selection.totalTreads.value;
  var corner1Array=document.selection.corner1.options[document.selection.corner1.selectedIndex].value.split(":");
  var corner1=eval(corner1Array[0]);
  if (corner1Array[1] != "half")  {
    MM_showHideLayers('wellSize','','hide');
  	document.selection.corner2.options[0] = new Option("Landing","x:x",false,false);
  	document.selection.corner2.options[1] = new Option("1/4 landing","1:quarter",false,false);
  	document.selection.corner2.options[2] = new Option("2 tread","2:two",false,false);
    document.selection.corner2.options[3] = new Option("3 tread","3:three",false,false);
  } else {
    MM_showHideLayers('wellSize','','show');
  	for (var x=document.selection.corner2.length;x>=0;x--)  {
	  document.selection.corner2.remove(x);
	}
	var treadRemain=(totalTreads-corner1)-1;
    for (x=treadRemain;x>=0;x--)  {
  	  document.selection.flight1.options[x] = new Option(" :: "+x+" :: ",x,false,false);
    }
  document.selection.flight1.options[document.selection.flight1.length] = new Option("Treads",x,false,true);
  }
  document.selection.flight3.value=0;
}


<!-- new functions by Clive 22/1 -->

function checkWellSize(minWidth)  {
	minWidth2 = (eval(minWidth) + 63);
	if (eval(document.selection.wellsize.value < minWidth2))  {
		alert("Please select a correct well size (more than "+minWidth2+"mm)");
		document.selection.wellsize.value="";
	}
}


function checkSandBuild()  {
	var build = document.finalstep.build.options[document.finalstep.build.selectedIndex].value;
	var finish = document.finalstep.finish.options[document.finalstep.finish.selectedIndex].value;
	if (build == "constructed")  {
		if (finish == "2")  {
			alert("Sorry, but build / finish combination is invalid");
			return false;
		}
	}
	return true;
}


function checkNewelStyle(type,style)  {
	var typeCheck=eval("document.selection."+type+".options[document.selection."+type+".selectedIndex]");
	var styleCheck=eval("document.selection."+style+".options[document.selection."+style+".selectedIndex]");
	var styleBack=eval("document.selection."+style);
	var typeString=typeCheck.value;
	var styleString=styleCheck.value;
	if (!typeString.match("None"))  {
		if (!typeString.match("Standard"))  {
			if (styleString.match("Turned"))  {
				alert("Sorry, invalid style type");
				styleBack.selectedIndex=0;
				return false;
			}
			if (styleString.match("Stop"))  {
				alert("Sorry, invalid style type");
				styleBack.selectedIndex=0;
			}
		}
	}
	switch(type)  {
		case "newela":
			theWood="newelaWood";
			break;
		case "newelb":
			theWood="newelbWood";
			break;
		case "newelc":
			theWood="newelcWood";
			break;
		case "neweld":
			theWood="neweldWood";
			break;
	}
	if (!typeString.match("None"))  {
    	MM_showHideLayers(theWood,'','show');
	} else {
    	MM_showHideLayers(theWood,'','hide');
	}
	return false;
}


function checkTread1Type()  {
 var theType=document.selection.tread1.options[document.selection.tread1.selectedIndex].value;
 if (theType == "7" || theType == "8" || theType == "9" || theType == "10" || theType == "x")  {
      MM_showHideLayers('tread1style','','hide');
 } else {
      MM_showHideLayers('tread1style','','show');
 }
 return false;
}


function checkHidden(theSelect,theDiv,theDiv2)  {
	var typeCheck=eval("document.selection."+theSelect+".options[document.selection."+theSelect+".selectedIndex].value");
	if (typeCheck == 0)  {
    	MM_showHideLayers(theDiv,'','hide');
    	MM_showHideLayers(theDiv2,'','hide');
	} else {
    	MM_showHideLayers(theDiv,'','show');
    	MM_showHideLayers(theDiv2,'','show');
	}
}
<!-- end of new functions -->


function getFlightsC2()  {
  emptyFlights();
  var totalTreads=document.selection.totalTreads.value;
  var corner1Array=document.selection.corner1.options[document.selection.corner1.selectedIndex].value.split(":");
  var corner1=eval(corner1Array[0]);
  var corner2Array=document.selection.corner2.options[document.selection.corner2.selectedIndex].value.split(":");
  var corner2=eval(corner2Array[0]);
  var treadRemain=(totalTreads-eval(corner1+corner2))-1;
  for (x=treadRemain;x>=0;x--)  {
  	document.selection.flight1.options[x] = new Option(" :: "+x+" :: ",x,false,false);
  }
  document.selection.flight1.options[document.selection.flight1.length] = new Option("Treads",x,false,true);
  document.selection.flight3.value=0;
}


function emptyFlights()  {
  if (document.selection.flight1.length > 0)  {
  	for (var x=document.selection.flight1.length;x>=0;x--)  {
	  document.selection.flight1.remove(x);
	}
  }
  if (document.selection.flight2.length > 0)  {
  	for (var x=document.selection.flight2.length;x>=0;x--)  {
	  document.selection.flight2.remove(x);
	}
  }
}


/*
function getFlights(landing)  {
  if (document.selection.flight1.length > 0)  {
  	for (var x=document.selection.flight1.length;x>=0;x--)  {
	  document.selection.flight1.remove(x);
	}
  }
  if (document.selection.flight2.length > 0)  {
  	for (var x=document.selection.flight2.length;x>=0;x--)  {
	  document.selection.flight2.remove(x);
	}
  }
  var totalTreads=document.selection.totalTreads.value;
  var corner1List=document.selection.corner1.options[document.selection.corner1.selectedIndex].value;
  var corner1Array=corner1List.split(":");
  var corner1=eval(corner1Array[0]);
  if (corner1Array[1] != "half" && landing != "2")  {
  	  document.selection.corner2.options[0] = new Option("Landing","x:x",false,false);
  	  document.selection.corner2.options[1] = new Option("1/4 landing","1:quarter",false,false);
  	  document.selection.corner2.options[2] = new Option("2 tread","2:two",false,false);
  	  document.selection.corner2.options[3] = new Option("3 tread","3:three",false,false);
  } else {
	if (landing != "2")  {
  	  for (var x=document.selection.corner2.length;x>=0;x--)  {
	    document.selection.corner2.remove(x);
	  }
	}
    var treadRemain=totalTreads-eval(corner1);
    for (x=treadRemain;x>=0;x--)  {
  	  document.selection.flight1.options[x] = new Option(" :: "+x+" :: ",x,false,false);
    }
  }
  var corner2Array=document.selection.corner2.options[document.selection.corner2.selectedIndex].value.split(":");
  var corner2=eval(corner2Array[0]);
  if ((corner1 != -1 && corner2 != -1) || corner1 == 2)  {
	if (corner1 == 2)  {
		corner2=0;
	}
    var treadRemain=totalTreads-eval(corner1+corner2);
	alert("here :: "+treadRemain+" :: "+totalTreads+" :: "+corner1+" :: "+corner2);
    for (var y=0;y<treadRemain;y++)  {
  	  document.selection.flight1.options[y] = new Option(" :: "+y+" :: ",y,false,false);
    }
  }
  document.selection.flight3.value=0;
}
*/



function getFlightSingle2()  {
  var flight1=document.selection.flight1.options[document.selection.flight1.selectedIndex].value;
  if (flight1 == -1)  {
	  document.selection.flight2.value="";
  } else {
  	var corner1Array=document.selection.corner1.options[document.selection.corner1.selectedIndex].value.split(":");;
  	var corner1=eval(corner1Array[0]);
  	var totalTreads=document.selection.totalTreads.value;
  	document.selection.flight2.value = (totalTreads-corner1)-flight1;
  }
}


function getFlights2(flight)  {
  var totalTreads=document.selection.totalTreads.value;
  var corner1Array=document.selection.corner1.options[document.selection.corner1.selectedIndex].value.split(":");
  var corner1=eval(corner1Array[0]);
  if (corner1Array[1] == "half")  {
    var treadRemain=totalTreads-corner1;
  } else {
    var corner2Array=document.selection.corner2.options[document.selection.corner2.selectedIndex].value.split(":");
    var corner2=eval(corner2Array[0]);
    var treadRemain=totalTreads-eval(corner1+corner2);
  }
  var treads1=eval(document.selection.flight1.options[document.selection.flight1.selectedIndex].value);
  if (treads1 == -1)  {
      if (document.selection.flight2.length > 0)  {
  	    for (var x=document.selection.flight2.length;x>0;x--)  {
	      document.selection.flight2.remove(x);
	  	}
	  }
	  document.selection.flight3.value="";
  } else {
  	var treadOver=eval((treadRemain-treads1)-1);
  	if (flight == 1)  {
      if (document.selection.flight2.length > 0)  {
  	    for (var x=document.selection.flight2.length;x>0;x--)  {
	      document.selection.flight2.remove(x);
	  	}
      }
	  if (corner1Array[1] == "half")  {
	  	treads2=0;
		document.selection.flight3.value=treadRemain-treads1;
	  } else {
	    for (x=treadOver;x>=0;x--)  {
  	      document.selection.flight2.options[x] = new Option(" :: "+x+" :: ",x,false,false);
        }
  	    document.selection.flight2.options[document.selection.flight2.length] = new Option("Treads",x,false,true);
        var treads2=eval(document.selection.flight2.options[document.selection.flight2.selectedIndex].value);
	  }
	  if (document.selection.flight2.options[document.selection.flight2.selectedIndex].value == -1)  {
		  document.selection.flight3.value="";
	  } else {
      	document.selection.flight3.value=treadRemain-(eval(treads1+treads2));  
	  }
    } else {
      var treads2=eval(document.selection.flight2.options[document.selection.flight2.selectedIndex].value);
	  if (treads2 == -1)  {
		document.selection.flight3.value="";
	  } else {	
    	document.selection.flight3.value=treadRemain-(eval(treads1+treads2));  
	  }
    }
  }
}


function getCheapest(number)  {
  document.selection.stringwood.selectedIndex = 1;
  document.selection.tread1.selectedIndex = 1;
  document.selection.treadwood.selectedIndex = 1;
  document.selection.risertype.selectedIndex = 1;
  document.selection.newela.selectedIndex = 0;
  document.selection.newelb.selectedIndex = 0;
  document.selection.newelc.selectedIndex = 0;
  document.selection.neweld.selectedIndex = 0;
  document.selection.newelstylea.selectedIndex = 0;
  document.selection.newelstyleb.selectedIndex = 0;
  document.selection.newelstylec.selectedIndex = 0;
  document.selection.newelstyled.selectedIndex = 0;
  document.selection.newelwooda.selectedIndex = 0;
  document.selection.newelwoodb.selectedIndex = 0;
  document.selection.newelwoodc.selectedIndex = 0;
  document.selection.newelwoodd.selectedIndex = 0;
  document.selection.handrailtype.selectedIndex = 0;
  document.selection.handrailwood.selectedIndex = 0;
  document.selection.bracerailtype.selectedIndex = 0;
  document.selection.bracerailwood.selectedIndex = 0;
  document.selection.spindletype.selectedIndex = 0;
  MM_showHideLayers('materialsSpindle','','hide');
  MM_showHideLayers('materialsHandrail','','hide');
  MM_showHideLayers('materialsBaserail','','hide');
  document.selection.extraspindle.selectedIndex = 0;
  if (number == 2)  {
      document.selection.neweltypeca.selectedIndex = 1;
      MM_showHideLayers('newel01Wood','','show');
      document.selection.newelwoodca.selectedIndex = 1;
	  document.selection.newelstyleca.selectedIndex = 1;
  } else if (number == 3) {
      MM_showHideLayers('newel01Wood','','show');
      document.selection.neweltypeca.selectedIndex = 1;
      document.selection.newelwoodca.selectedIndex = 1;
	  document.selection.newelstyleca.selectedIndex = 1;
      MM_showHideLayers('newel02Wood','','show');
      document.selection.neweltypecb.selectedIndex = 1;
      document.selection.newelwoodcb.selectedIndex = 1;
	  document.selection.newelstylecb.selectedIndex = 1;
  }
  return false;
}

function jumpPage(url)  {
  this.location.href=url;
}
