function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var menu_selection="";
var radio_selection="";
function  checkForm() {
if (dropDownMenu() && radioButtons()) {
document.forms[0].results1.value=menu_selection;
document.forms[0].results2.value=radio_selection;
alert("\nForm has been filled out correctly.");
   }
}
function dropDownMenu(form)  {
var myindex=document.forms[0].menu.selectedIndex;
if (myindex==0) {
alert("\nYou must make a selection from the drop-down menu.");
document.forms[0].menu.focus();
}
else {
menu_selection=document.forms[0].menu.options[myindex].value;
return true;
   }
}
function radioButtons() {
if (radio_selection=="")
alert("\nYou must check one of the radio buttons.");
else {
return true;
   }
}
function resetForm() {
document.forms[0].menu.options[0].selected = true;
menu_selection="";
radio_selection="";
}
function about() {
alert("\nVALIDATOR checks to see that a selection has been made from  the drop-down menu and that a radio button has been checked.\n\nIf filled out properly, the data will be displayed below.");
}


///////////////format functions///////////////
///////////////to_currency///////////////
function to_currency(val,currency){  
	while(!val) {
		  alert("Please provide \"to_currency\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_currency\" ");
		  return;
	}  
	//var large_pi=Math.round(100*Math.PI); 
	val=""+Math.round(1000*val);
	var dec_point=val.length-3;
	var first_part=val.substring(0,dec_point);
	var second_part=val.substring(dec_point,val.length);
	var result=first_part+"."+second_part;
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	result=currency+result; 
  	// "3" + decimal point + "14"
	//alert (result);
  	return result;
}

///////////////to_droop////////////////
////////////format Droop Travel value//
////////////(document.form.DT.value)///
function to_droop(val,currency){  
	while(!val) {
		  alert("Please provide \"to_droop\" a value ");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_droop\" ");
		  return;
	}
	//if (val) {
	//	  alert("to_droop is valid!");
	//}
	//////val=""+Math.round(1*val);
	val=""+Math.abs(1*val);
	//alert("val = " + val);
	//var result = Math.abs(val/100);
	//alert("result = Math.abs(val/100) " + result);
	var dec_point=val.length-2;
	var first_part=val.substring(0,dec_point);
	var second_part=val.substring(dec_point,val.length);
	//////var result=first_part+"."+second_part;
	var result = (first_part+"."+second_part);
	//alert ("result = (first_part+\".\"+second_part) " + result);
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	var result = (currency + result); 
  	// "3" + decimal point + "14"
	//alert ("result = (currency + result) " + result);
  	return result;
}

///////////////to_springrate////////////////
/////////////format Spring Rate value///////
///////////////(document.form.SR.value)/////
function to_springrate(val,currency){  
	while(!val) {
		  alert("Please provide \"to_springrate\" a value");
		  resetForm();
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_springrate\" ");
		  resetForm();
		  return;
	}  
	val=""+Math.round(1000*val);
	var dec_point=val.length-3;
	var first_part=val.substring(0,dec_point);
	var second_part=val.substring(dec_point,val.length);
	var result=first_part+"."+second_part;
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	result=currency+result; 
  	// "3" + decimal point + "14"
	//alert (result);
  	return result;
}

///////////////to_mround5////////////////
/////mround5 = FINAL Spring Rate value///
/////(document.form.SR.value)////////////
function to_mround5(val,currency){  
	while(!val) {
		  alert("Please provide \"to_mround5\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_mround5\" ");
		  return;
	}  
	//var large_pi=Math.round(100*Math.PI); 
	val=""+Math.round(100*val);
	////alert ("val " + val + "  " + val.length);
	var dec_point=val.length-2;
	////alert ("dec_point=val.length-2  " + dec_point);
	var first_part=val.substring(0,dec_point);
	////alert ("first_part=val.substring(0,dec_point);  " + first_part + "  " + "val.length  " + val.length);
	var second_part=val.substring(dec_point,val.length);
	var result=first_part+"."+second_part;
	////alert ("result " + result + " " + val.length);
	
	//Round to the nearest '5'
	var resultRounded = Math.round(result);
	////alert (resultRounded);
	var mod5 = (resultRounded % 5);
	////alert (mod5);
	//test for rounding
	if (mod5 > 2) {
		var div5 = (resultRounded / 5);
		////alert (div5);
		var vDiv5 = Math.ceil(div5);
		////alert (vDiv5);
		var newResult = (vDiv5*5)
		////alert (newResult);	
	}  else  {
		var div5 = (resultRounded / 5);
		////alert (div5);
		var vDiv5 = Math.floor(div5);
		////alert (vDiv5);
		var newResult = (vDiv5*5)
		////alert (newResult);	
	}
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	////result=currency+result; 
	newResult=currency+newResult; 
  	// "3" + decimal point + "14"
	//alert (result);
  	//return result;
	return newResult;
}

///////////////to_wheelrate////////////////
//////////format Wheel Rate value//////////
//////////(document.form.WRA.value)////////
function to_wheelrate(val,currency){  
	while(!val) {
		  alert("val = !val >> Please provide \"to_wheelrate\" a value");
		  return;
	}
	while(val=null) {
		  alert("val=null >> Please provide \"to_wheelrate\" a value");
		  return;
	} 
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_wheelrate\" ");
		  return;
	}  
	//var large_pi=Math.round(100*Math.PI); 
	//////val=""+Math.round(10000*val);
	//val=""+Math.abs(10000*val);
	//////alert("val for to_wheelrate is " + val);
	val=""+Math.abs(1*val);
	//alert("val=\"\"+Math.abs(val) is " + val);
	//val=""+Math.abs(10000*val);
	//////val=(10000*val);
	//////alert("val=(10000*val) is " + val);
	//val=""+Math.round(10000*val);
	//val=""+Math.round(val);
	//////val=Math.round(val);
	//////alert("val=\"\"+Math.abs(10000*val) is " + val);
	//alert("val=\"\"+Math.round(10000*val) is " + val);
	////alert (val);
	//var dec_point=val.length-3;
	var dec_point=val.length-2;
	//alert("dec_point=val.length-2 is " + dec_point);
	var first_part=val.substring(0,dec_point);
	//alert("first_part=val.substring(0,dec_point) is " + first_part);
	////alert("1st= " + first_part);
	var second_part=val.substring(dec_point,val.length);
	//alert("second_part=val.substring(dec_point,val.length) is " + second_part);
	////alert("2nd= " + second_part);
	var result=first_part+"."+second_part;
	//alert("result=first_part+\".\"+second_part is " + result);
	////alert("result= " + result);
	
	//round result to nearest TTHTS.dd
	//then format to display new HTS.dd
	//by dividing by 100
	//(moving decimal point back two places)
	var resultWRArounded = Math.round(result);
	//alert ("resultWRArounded = Math.round(result) is " + resultWRArounded);
	var newResultWRA = (resultWRArounded/100);
	//alert ("newResultWRA = (resultWRArounded/100) is " + newResultWRA);	
	
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	////result=currency+result; 
	newResultWRA=currency+newResultWRA; 
	return newResultWRA;
}

///////////////to_motionratio////////////////
//////////format Motion Ratio value//////////
/////////(document.form.MR.value)////////////
function to_motionratio(val,currency){  
	while(!val) {
		  alert("Please provide \"to_motionratio\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_motionratio\" ");
		  return;
	}
	//if (val) {
	//	  alert("motionratio is valid");
	//}
	val=""+Math.floor(1000*val);
	//val=""+Math.abs(1*val);
	//alert("val= " + val);
	var dec_point = (val.length-1);
	var first_part = val.substring(0,dec_point);
	var second_part = val.substring(dec_point,val.length);
	var dec_result = first_part+"."+second_part;
	//////alert("dec_result = (first_part+\".\"+second_part) is " + dec_result);
	var result = Math.round(dec_result);
	//////alert("result = Math.round(dec_result) is " + result);
	//var divTest = Math.abs(result%100);
	//alert("divTest = Math.abs(result%100) is " + divTest);
	if ((result%100) == 0 && (result%10) == 0) {
		mod_result = (result/100);
		mod_result = mod_result + ".00";
		//////alert("mod_result = mod_result + \".00\" is " + mod_result);
	}
	if ((result%100) != 0  && (result%10) == 0) {
		mod_result = (result/100);
		mod_result = mod_result + ".0";
		//////alert("mod_result = mod_result + \".0\" is " + mod_result);
	}
	if ((result%10) != 0) {
		mod_result = (result/100);
		//////alert("mod_result = (result/100) is " + mod_result);
	}
	
	//round Motion Ratio
	//////var newMRresult = Math.round(result);
	//////var newMRresult = Math.abs(result/100);
	//////alert("newMRresult = Math.abs(result/100) is " + newMRresult);
	//var newMRresult = Math.round(newMRresult);
	//alert("newMRresult = Math.round(newMRresult) is " + newMRresult);
	//alert("newMRresult=Math.round(result) " + newMRresult);
	//////var mr_result = (newMRresult);
	//////var mr_result = Math.abs(mod_result);
	//////alert("mr_result = Math.abs(mod_result) " + mr_result);
	//alert("mr_result = " + mr_result);
	//var newMRresult = (newMRresult/100);
	//////mrVal=""+ newMRresult;
	//alert("mrVal.length= " + mrVal.length);
	//////var mr_dec_point=mrVal.length-2;
	//alert("mr_dec_point= " + mr_dec_point);
	//////if  (mr_dec_point*(-1) > 0) {
	//////	var mr_first_part=mrVal*Math.pow(10,(mr_dec_point-1));
		//alert("mr_first_part= " + mr_first_part);
		////alert("mr_first_part= " + mr_first_part);	
		//var mr_second_part=mrVal.substring(0,mrVal.length);
	//////	var mr_second_part=mrVal.substring(mrVal.length,mrVal.length);
		////alert("mr_second_part= " + mr_second_part);
		//var mr_result="."+mr_first_part+mr_second_part;
	//////	var mr_result=mr_first_part+mr_second_part;
	//////} else  {
		////var mr_first_part=mrVal.substring(0,dec_point);
		//alert("mrVal= " + mrVal);
	//////	var mr_first_part=(mrVal*10/Math.pow(10,(mr_dec_point+3)));
		//alert("mr_first_part= " + mr_first_part);
		//test for ending zero
	//////	firstString = "" + mrVal;
		//alert("firstString= " + firstString);
	//////	lastPos = firstString.substr(firstString.length-1);
		//alert("lastPos= " + lastPos);
	//////	if (lastPos == '0') {
	//////		var mr_second_part=mrVal.substring(mrVal.length-1,mrVal.length);
	//////	} else {
	//////		var mr_second_part=mrVal.substring(mrVal.length,mrVal.length);
	//////	}
		//var mr_second_part=mrVal.substring(mrVal.length-1,mrVal.length);
		//alert("mr_second_part= " + mr_second_part);
	//////	var mr_result=mr_first_part+mr_second_part;
	//////}
	
	/////////////if (mr_dec_point > 0)////////////////
	////alert("mr_first_part= " + mr_first_part);	
	////alert("mr_second_part= " + mr_second_part);
	////var mr_result=first_part+"."+second_part;
	////var mr_result="."+mr_first_part+mr_second_part;
	////alert("mr_result= " + mr_result);
	//////var new_mr_result = (mr_result);
	var new_mr_result = (mod_result);
	
	//alert("new_mr_result= " + new_mr_result);
	
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	////result=currency+result; 
	new_mr_result = (currency + new_mr_result);
	//alert("new_mr_result = " + new_mr_result);
	return new_mr_result;
}

///////////////to_ridefreq////////////////
//////////format Ride Frequency value/////
//////////(document.form.RF.value)////////
function to_ridefreq(valNum,currency){  
	while(!valNum) {
		  alert(valNum + " is not valid; Please provide \"to_ridefreq\" a value");
		  return;
	}
	while(valNum=null) {
		  alert(valNum + " is not valid; Please provide \"to_ridefreq\" a value");
		  return;
	}
	while(isNaN(valNum)){
		  alert(valNum + " is not a valid input for \"to_ridefreq\"");
		  return;
	}
	valNum=""+Math.round(100*valNum);
	//alert("valNum=\"\"+Math.round(100*valNum) is " + valNum);
	var dec_point=valNum.length-2;
	//alert("dec_point=valNum.length-2 is " + dec_point);
	//if (dec_point == 0) {
	//	var first_part = 0;
	//	alert("first_part is " + first_part);
	//}
	if (dec_point <= 0) {
		var first_part = 0;
		//alert("first_part is " + first_part);
	}
	//else if (dec_point != 0) {
	//	var first_part=val.substring(0,dec_point);
	//	alert("first_part=val.substring(0,dec_point) is " + first_part);
	//}
	else if (dec_point > 0) {
		var first_part=valNum.substring(0,dec_point);
		//alert("first_part=valNum.substring(0,dec_point) is " + first_part);
	}
	
	//////var first_part=val.substring(0,dec_point);
	//////alert("first_part=val.substring(0,dec_point) is " + first_part);
	var second_part=valNum.substring(dec_point,valNum.length);
	//alert("second_part=valNum.substring(dec_point,valNum.length) is " + second_part);
	var result=first_part+"."+second_part;
	//alert("result=first_part+\".\"+second_part is " + result);
	//nresult=""+Math.abs(1*result);
	//if (Math.abs(nresult) < 1) {
	//	var new_result = "0"+nresult;
	//	alert("new_result = " + new_result);
	//} else {
	//	var new_result = nresult;
	//	alert("new_result = " + new_result);
	//}
	////alert ("new_result= " + new_result);
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	////result=currency+result; 
	//new_result=currency+new_result;
	new_result=currency+result;
	//alert("new_result = " + new_result);
	return new_result;
}

//////////////////////to_roundTSR////////////////////
///////vTSRrounded = FINAL Tender Spring Rate value//
//////////////(document.form.TSR.value)//////////////
function to_roundTSR(val,currency){  
	while(!val) {
		  alert("Please provide \"to_roundTSR\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_roundTSR\" ");
		  return;
	}  
	//var large_pi=Math.round(100*Math.PI); 
	val=""+Math.round(100*val);
	////alert ("val " + val + "  " + val.length);
	var dec_point=val.length-2;
	////alert ("dec_point=val.length-2  " + dec_point);
	var first_part=val.substring(0,dec_point);
	////alert ("first_part=val.substring(0,dec_point);  " + first_part + "  " + "val.length  " + val.length);
	var second_part=val.substring(dec_point,val.length);
	var result=first_part+"."+second_part;
	////alert ("result " + result + " " + val.length);
	
	//Round to the nearest '5'
	var resultRounded = Math.round(result);
	////alert (resultRounded);
	var mod5 = (resultRounded % 5);
	////alert (mod5);
	//test for rounding
	if (mod5 > 2) {
		var div5 = (resultRounded / 5);
		////alert (div5);
		var vDiv5 = Math.ceil(div5);
		////alert (vDiv5);
		var newResult = (vDiv5*5)
		////alert (newResult);	
	}  else  {
		var div5 = (resultRounded / 5);
		////alert (div5);
		var vDiv5 = Math.floor(div5);
		////alert (vDiv5);
		var newResult = (vDiv5*5)
		////alert (newResult);	
	}
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	////result=currency+result; 
	newResult=currency+newResult; 
	//alert (result);
  	//return result;
	return newResult;
}

///////////////to_mainspringrate///////////////
///////////format Main Spring Rate value///////
//////////////(document.form.MSR.value)////////
function to_mainspringrate(val,currency){  
	while(!val) {
		  alert("Please provide \"to_mainspringrate\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_mainspringrate\" ");
		  return;
	}  
	//var large_pi=Math.round(100*Math.PI); 
	val=""+Math.round(100*val);
	var dec_point=val.length-2;
	var first_part=val.substring(0,dec_point);
	var second_part=val.substring(dec_point,val.length);
	var result=first_part+"."+second_part;
	////alert("result= " + result);
	
		//Round to the nearest '5'
	var resultRounded = Math.round(result);
	////alert (resultRounded);
	var mod5 = (resultRounded % 5);
	////alert ("mod5= " + mod5);
	//test for rounding
	if (mod5 > 2) {
		var div5 = (resultRounded / 5);
		////alert (div5);
		var vDiv5 = Math.ceil(div5);
		////alert (vDiv5);
		var newResult = (vDiv5*5)
		////alert (newResult);	
	}  else  {
		var div5 = (resultRounded / 5);
		////alert ("div5=" + div5);
		var vDiv5 = Math.floor(div5);
		////alert ("vDiv5=" + vDiv5);
		var newResult = (vDiv5*5)
		////alert (newResult);	
	}
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	////result=currency+result; 
	newResult=currency+newResult; 

	//alert (result);
  	//return result;
	return newResult;

}

///////////////to_secondwheelrate///////////////
////////format Secondary Wheel Rate value///////
////////////(document.form.SWR.value)///////////
function to_secondwheelrate(val,currency){  
	while(!val) {
		  alert("Please provide \"to_secondwheelrate\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_secondwheelrate\" ");
		  return;
	}  
	val=""+Math.round(1000*val);
	//////alert ("val=\"\"+Math.round(1000*val) is " + val);
	var dec_point=val.length-3;
	//////alert ("dec_point=val.length-3 is " + dec_point);
	var first_part=val.substring(0,dec_point);
	//////alert ("first_part=val.substring(0,dec_point) is " + first_part);
	var second_part=val.substring(dec_point,val.length);
	//////alert ("second_part=val.substring(dec_point,val.length) is " + second_part);
	var result=first_part+"."+second_part;
	//////alert ("result=first_part+\".\"+second_part is " + result);
	
	//round result to nearest TTHTS.dd
	//then format to display new HTS.dd
	//by dividing by 100
	//(moving decimal point back two places)
	var new_resultSWR = Math.round(result*100);
	//////alert("new_resultSWR = Math.round(result*100) is " + new_resultSWR);
	var newResultSWR = (new_resultSWR/100);
	//////alert("newResultSWR = (new_resultSWR/100) is " + new_resultSWR);
	//swr=""+ (new_result/100);
	//alert("swr=" + swr);
	////alert("newResultSWR= " + newResultSWR);
	
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	//result=currency+result;
	newResultSWR=currency+newResultSWR; 
  	// "3" + decimal point + "14"
	//alert (result);
  	//return result;
	return newResultSWR;
}

///////////////////////////to_pad////////////////////////////
//////to pad left-aligned space within input text fields/////
////////input value length passed as a parameter/////////////
/////////padded space returned///////////////////////////////
function to_pad (val,space){  
	while(!val) {
		  alert("Please provide \"to_pad\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_pad\" ");
		  return;
	}  
	val=""+Math.round((10*val)/10);
	//alert("val " + val + "  " + val.length);
	//if (vWRA.length < 8) 
	var mVal = val;
	if (mVal < 9) {
		pad_input = "000000000";
		var len = (pad_input.length - mVal);
		//alert("len= " + len);
		var first_pad_part=pad_input.substring(0,len);
		//alert("first_pad_part= " + first_pad_part);
		var second_pad_part=pad_input.substring(len,pad_input.length);
		//alert("second_pad_part= " + second_pad_part);
		//var pad_result=first_part+"."+second_part;
		var pad_result=""+first_pad_part;
		//alert("pad_result= " + pad_result);
			
		pad_string = pad_result.toString();
		//alert("pad_string= " + pad_string);
		//pad = pad_string.substr(pad_result, *space.length);
		for (i=0; i < len; i++) {
			pad_string = pad_string.replace("0", " ");
		}
		//pad = pad_string.replace("0", " ");
		pad = pad_string;
		//alert("pad= " + pad);
		////replace( regexp, replacetext)
		//alert ("pad= " + pad);
		//var front_pad = 	
	}
	// if no space arg, set space to empty string
	if(!space){space="";}
	// if no currency arg, result =""+ result (same thing)
	//result=currency+result;
	pad=space+pad; 
	//return pad_result;
	return pad;
}

///////////////////to_primary////////////////////
////////////format PRIMARY value/////////////////
////////////////(document.form.PRIMARY.value)////
function to_primary(val,currency){  
	while(!val) {
		  alert("Please provide \"to_primary\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_primary\" ");
		  return;
	}  
	val=""+Math.round(val);
	//alert (val);
	var new_prime = val;
	//alert("new_prime= " + new_prime);
	//var dec_point=val.length-3;
	////var dec_point=val.length-2;
	////var first_part=val.substring(0,dec_point);
	////alert("1st= " + first_part);
	////var second_part=val.substring(dec_point,val.length);
	////alert("2nd= " + second_part);
	////var result=first_part+"."+second_part;
	////alert("result= " + result);
	
	//round result to nearest TTHTS.dd
	//then format to display new HTS.dd
	//by dividing by 100
	//(moving decimal point back two places)
	////var resultWRArounded = Math.round(result);
	////alert ("resultWRArounded= " + resultWRArounded);
	////var newResultWRA = (resultWRArounded/100);
	////alert ("newResultWRA= " + newResultWRA);	
	
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	////result=currency+result; 
	new_prime=currency+new_prime; 
	//alert (result);
  	////return result;
	return new_prime;
}

////////////////to_sliderprimary///////////////
///////////format Primary Rate value///////////
////////in Slider Travel/Location Calculator///
///////(document.form.SLIDERPRIMARY.value)/////
function to_sliderprimary(val,currency){  
	while(!val) {
		  alert("Please provide \"to_sliderprimary\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_sliderprimary\" ");
		  return;
	}  
	//var large_pi=Math.round(100*Math.PI); 
	val=""+Math.round(100*val);
	////alert (val);
	var dec_point=val.length-2;
	////alert("dec_point= " + dec_point);
	var sp_first_part=val.substring(0,dec_point);
	////alert("sp_first_part= " + sp_first_part);
	var sp_second_part=val.substring(dec_point,val.length);
	////alert("sp_second_part= " + sp_second_part);
	var sp_result=sp_first_part+"."+sp_second_part;
	////alert("sp_result= " + sp_result);	
	
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	//result=currency+result;
	sp_result=currency+sp_result; 
	//alert (result);
  	//return result;
	return sp_result;
}

////////////////to_slidertravel///////////////
//////////format Slider Travel value//////////
///////in Slider Travel/Location Calculator///
////////(document.form.SLIDERTRAVEL.value)////
function to_slidertravel(val,currency){  
	while(!val) {
		  alert("Please provide \"to_slidertravel\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_slidertravel\" ");
		  return;
	}  
	//var large_pi=Math.round(100*Math.PI); 
	val=""+Math.round(100*val);
	////alert (val);
	var dec_point=val.length-2;
	////alert("dec_point= " + dec_point);
	var st_first_part=val.substring(0,dec_point);
	////alert("st_first_part= " + st_first_part);
	var st_second_part=val.substring(dec_point,val.length);
	////alert("st_second_part= " + st_second_part);
	var st_result=st_first_part+"."+st_second_part;
	////alert("st_result= " + st_result);	
	
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	//result=currency+result;
	st_result=currency+st_result; 
	//alert (result);
  	//return result;
	return st_result;
}

////////////////to_dualprimary///////////////
///////format Dual Primary Rate value////////
//////////in Dual Rate Calculator////////////
//////(document.form.DUALPRIMARY.value)//////
function to_dualprimary(val,currency){  
	while(!val) {
		  alert("Please provide \"to_dualprimary\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_dualprimary\" ");
		  return;
	}  
	//var large_pi=Math.round(100*Math.PI); 
	val=""+Math.round(100*val);
	////alert (val);
	var dec_point=val.length-2;
	////alert("dec_point= " + dec_point);
	var dp_first_part=val.substring(0,dec_point);
	////alert("sp_first_part= " + sp_first_part);
	var dp_second_part=val.substring(dec_point,val.length);
	////alert("sp_second_part= " + sp_second_part);
	var dp_result=dp_first_part+"."+dp_second_part;
	////alert("sp_result= " + sp_result);	
	
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	//result=currency+result;
	dp_result=currency+dp_result; 
	//alert (result);
  	//return result;
	return dp_result;
}

////////////////to_shaftdia///////////////
//////////format Shaft Diameter value//////////
///////in Resevoir Piston Travel Calculations///
////////(document.form.SHAFTDIA.value)////
function to_shaftdia(val,currency){  
	while(!val) {
		  alert("Please provide \"to_shaftdia\" a value");
		  return;
	}  
	while(isNaN(val)){
		  alert(val+" is an invalid input \"to_shaftdia\" ");
		  return;
	}  
	//var large_pi=Math.round(100*Math.PI); 
	//val=""+Math.round((10*val)/(1000));
	val=""+Math.abs((10*val)/(10));
	//alert (val);
	var dec_point=val.length-3;
	//alert("dec_point= " + dec_point);
	var st_first_part=val.substring(0,dec_point);
	//alert("st_first_part= " + st_first_part);
	var st_second_part=val.substring(dec_point,val.length);
	//alert("st_second_part= " + st_second_part);
	var st_result=st_first_part+"."+st_second_part;
	//alert("st_result= " + st_result);	
	
	// if no currency arg, set currency to empty string
	if(!currency){currency="";}
	// if no currency arg, result =""+ result (same thing)
	//result=currency+result;
	st_result=currency+st_result; 
	//alert (result);
  	//return result;
	return st_result;
}

//////////////////////////////////////////////////////////////
//////////////////////END FORMAT FUNCTIONS////////////////////
//////////////////////////////////////////////////////////////


////////////////////////STEP FUNCTIONS////////////////////////
////These sre the functions invoked by the "Next" buttons ////
//////////////////////////////////////////////////////////////

///////////////////////function step1()///////////////////////
function step1() {
	while(document.form.WT.value <= 0 || isNaN(document.form.WT.value)){
		alert ("Please be sure the Wheel Travel value is greater than 0!");
		var vWTvalue = document.form.WT.value;
		alert("vWTvalue=" + vWTvalue);
		function toForm() {
			document.form.WT.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.CSW.value <= 0 || isNaN(document.form.CSW.value)){
		alert ("Please be sure the Corner Sprung Weight value is greater than zero!");
		var vCSWvalue = document.form.CSW.value;
		alert("vCSWvalue=" + vCSWvalue);
		function toForm() {
			document.form.CSW.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.CUSW.value <= 0 || isNaN(document.form.CUSW.value)){
		alert ("Please be sure the Corner Unsprung Weight value is greater than zero!");
		var vCUSWvalue = document.form.CUSW.value;
		alert("vCUSWvalue=" + vCUSWvalue);
		function toForm() {
			document.form.CUSW.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.D1.value <= 0 || isNaN(document.form.D1.value)){
		alert ("Please be sure the D1 value is greater than zero!");
		var vD1value = document.form.D1.value;
		alert("vD1value=" + vD1value);
		function toForm() {
			document.form.D1.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.D2.value <= 0 || isNaN(document.form.D2.value)){
		alert ("Please be sure the D2 value is greater than zero!");
		var vD2value = document.form.D2.value;
		alert("vD2value=" + vD2value);
		function toForm() {
			document.form.D2.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	//while(document.form.AT.value <= 0 || isNaN(document.form.AT.value)){
	while(document.form.AT.value < 0 || isNaN(document.form.AT.value)){
		alert ("Please be sure the AT value is greater than zero!");
		var vATvalue = document.form.AT.value;
		alert("vATvalue=" + vATvalue);
		function toForm() {
			document.form.AT.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	//while(document.form.AA.value <= 0 || isNaN(document.form.AA.value)){
	while(document.form.AA.value < 0 || isNaN(document.form.AA.value)){
		alert ("Please be sure the AA value is greater than zero!");
		var vAAvalue = document.form.AA.value;
		alert("vAAvalue=" + vAAvalue);
		function toForm() {
			document.form.AA.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.DP.value <= 0 || isNaN(document.form.DP.value)){
		alert ("Please be sure the DP value is greater than zero!");
		var vDPvalue = document.form.DP.value;
		alert("vDPvalue=" + vDPvalue);
		function toForm() {
			document.form.DP.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.SUR.value <= 0 || isNaN(document.form.SUR.value)){
		alert ("Please be sure the SUR value is greater than zero!");
		var vSURvalue = document.form.SUR.value;
		alert("vSURvalue=" + vSURvalue);
		function toForm() {
			document.form.SUR.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	

		////1/////////////Droop Travel////////////////////
	    var WT = document.form.WT.value;
		var DP = document.form.DP.value;
		var vDT = to_droop(WT*DP);
		//alert (vDT);
	    //document.form.DT.value = ((WT*DP)/100);
		document.form.DT.value = (vDT);
		
		//2/////////////////SR = Spring Rate///////////////
		var CSW = document.form.CSW.value;
		var D1 = document.form.D1.value;
		var D2 = document.form.D2.value;
		var AT = document.form.AT.value;
		var AA = document.form.AA.value;
		var pi = Math.PI;
		var radianAT =  ((AT)*(pi/180));
		var radianAA =  ((AT-AA)*(pi/180));
		var MR =  Math.abs((D1/D2)*(Math.cos(radianAT))*(Math.cos(radianAA)));
		//var vTestAT = Math.cos(radianAT);
		//alert("vTestAT = Math.cos(radianAT) is " + vTestAT);
		//var vTestAA = Math.cos(radianAA);
		//alert("vTestAA = Math.cos(radianAA) is " + vTestAA);
		////Javascript rounds to 17 decimal places!!
		////Excel rounds to 16 decimal places!!!!!!!
		//////alert ("MR = " + MR);
		////var vMR = to_currency(MR);
		////alert (vMR);
		var vMRSQR = (MR*MR);
		//alert ("vMRSQR = (MR*MR) is " + vMRSQR);
		//var vMRSQR = to_springrate(vMRSQR);
		//alert (vMRSQR);
		var MRSQR = null;
		var MRSQR = to_springrate(vMRSQR);
		//alert ("MRSQR = to_springrate(vMRSQR) is " + MRSQR);		
		//document.form.SR.value = Math.round((document.form.CSW.value/document.form.DT.value)/MRSQR);
		//document.form.SR.value = Math.round((CSW/document.form.DT.value)/MRSQR);
		//document.form.SR.value = (CSW/document.form.DT.value)/MRSQR;
		//alert ((CSW/vDT));
		////alert ((CSW/vDT)/MRSQR);
		//var vSR = null;
		//alert ("vSR= " + vSR);
		//var vSR = ((CSW/vDT)/MRSQR);
		var vSR = ((CSW/vDT)/vMRSQR);
		//alert ("vSR=((CSW/vDT)/vMRSQR) is " + vSR);
		////var vSRA = to_mround5(vSR);
		var SR = to_mround5(vSR);
		//alert ("SR = to_mround5(vSR) is " + SR);
		//////alert ("vSRA=to_mround5(vSR) is " + vSRA);
		////document.form.SR.value = ((CSW/vDT)/MRSQR);
		////////document.form.SR.value = (vSR);
		////document.form.SR.value = (SR+".00");
		////var vSRAnum = vSRA;
		//////alert("vSRAnum = vSRA is " + vSRAnum);
		var final_result = (SR + ".00");
		//////alert("final_result = (vSRAnum + \".00\") is " + final_result);
		//////document.form.SR.value = (vSRA+".00");
		document.form.SR.value = (final_result);
		
		//3/////////////WRA = Wheel Rate//////////////////
		////var SR = document.form.SR.value;
		////var SR = vSR;
		//var SR = vSRA;
		//////alert("SR = vSRA is " + SR);
		//alert (MRSQR);
		//to_currency(MRSQR);
		////alert ("SR*vMRSQR= " + SR*vMRSQR);
		/////////var vWRA = null;
		//////alert("vWRA = null is" + vWRA);
		//alert("vMRSQR= " + vMRSQR);
		//alert("SR*vMRSQR = " + SR*vMRSQR);
		var vWRA = (SR*vMRSQR);
		//alert("vWRA = (SR*vMRSQR) is " + vWRA);
		//var vWRAintermediate = Math.round(vWRAintermediate*100);
		//alert("vWRAintermediate = Math.round(vWRAintermediate*1000) is " + vWRAintermediate);
		//var vWRA = null;
		////////var vWRA = to_wheelrate(SR*vMRSQR);
		//////var vWRA = to_wheelrate(vWRAintermediate);
		var vWRA2 = to_wheelrate(vWRA);
		//alert("vWRA2 = to_wheelrate(vWRA) is " + vWRA2);
		//////alert ("vWRA = to_wheelrate(SR*vMRSQR) is " + vWRA);
		////document.form.WRA.value = (SR*vMRSQR);
		//////var vWRAorg = (SR*vMRSQR);
		//var vWRAorg = vWRAintermediate;		
		//alert ("vWRAorg = vWRAintermediate is " + vWRAorg);
		//alert ("vWRA= " + vWRA);
		//alert("vWRA.length= " + vWRA.length);
		//var vInput = to_pad(vWRA.length);
		//alert("vInput= " + vInput);
		//var pWRA = vInput + vWRA;
		//var pWRA = vInput.concat(vWRA);
		//alert("pWRA= " + pWRA);
		if (vWRA == 0) {
			//alert("vWRA = " + vWRA);
			//document.form.WRA.value = (vWRA);
			document.form.WRA.value = ("0.00");
		}
		if (vWRA != 0) {
			//alert("vWRA = " + vWRA);
			vTemp = Math.round(100*vWRA);
			//alert("vTemp = Math.round(100*vWRA) is " + vTemp);
			vTemp = (vTemp/100);
			//alert("vTemp = (vTemp/100) is " + vTemp);
			document.form.WRA.value = (vTemp);
		}
				
		//4////////////////MRA = Motion Ratio/////////////////
		//alert (MR);
		////var vMR = to_currency(MR);
		////alert ("vMR= " + vMR);
		//alert (to_currency(MR));
		//document.form.MR.value = to_currency(MR);
		//alert("MR= " + MR);
		var vMR = to_motionratio(MR);
		//alert ("vMR= " + vMR);
		//alert("vMR.length= " + vMR.length);
		//var pMR = to_pad(vMR.length);
		//alert("pMR= " + pMR)
		////document.form.MR.value = to_motionratio(vMR);
		document.form.MR.value = (vMR);
		//document.form.MR.value = (pMR);
		
		//5//////////////////RF = Ride Frequency/////////////////////
		//var vRF = to_ridefreq(document.form.WRA.value);
		//////var vRF = to_ridefreq((3.1285*(Math.sqrt(document.form.WRA.value/CSW))));
		var vRFTemp = Math.abs(1*document.form.WRA.value);
		//alert("vRFTemp = document.form.WRA.value is " + vRFTemp);
		////var vRF = to_ridefreq((3.1285*(Math.sqrt(Math.abs(1*(document.form.WRA.value))/CSW))));
		var theNum = Math.abs(3.1285);
		//alert("theNum = Math.abs(3.1285) is " + theNum);
		//var vRF = to_ridefreq(3.1285*(Math.sqrt(vRFTemp/CSW)));
		var vRF = (theNum*(Math.sqrt(vRFTemp/CSW)));
		//alert("vRF = (theNum*(Math.sqrt(vRFTemp/CSW))) is " + vRF);
		//var vRF = to_ridefreq(theNum*(Math.sqrt(vRFTemp/CSW)));
		////////////////var RF = to_ridefreq(vRF);
		////////////////alert ("RF = to_ridefreq(vRF) is " + RF);
		var RFtemp = Math.round(100*vRF);
		//alert ("RFtemp = Math.round(100*vRF) is " + RFtemp);
		var RF = (RFtemp/100);
		//alert ("RF = (RFtemp/100) is " + RF);
		//alert (RF);
		//document.form.RF.value = (vRF);
		document.form.RF.value = (RF);
		
		//6///////////////////TSR = Tender Spring Rate/////////////////////
		//ALSO - Calculate K factor
		var SUR = document.form.SUR.value;
		var vK = (SUR/100)-1;
		//////alert ("vK = (SUR/100)-1 is " + vK);
		//alert (vK);
		//var vTSR = Math.round((document.form.SR.value*(1+vK))/vK);
		var vNumerTest1 = (1+vK);
		//////alert ("vNumerTest1 = (1+vK) is " + vNumerTest1);
		
		var vNumerTest2 = (document.form.SR.value * vNumerTest1);
		//////alert ("vNumerTest2 = (document.form.SR.value * vNumerTest1) is " + vNumerTest2);
		
		var vNumerTest3 = (vNumerTest2/vK);
		//////alert ("vNumerTest3 = (vNumerTest2/vK) is " + vNumerTest3);
		
		var vTSR = vNumerTest3;
		
		//var vTSR = Math.round((10000000*vinter2)/vK);
		//alert ("vTSR = Math.round((10000000*vinter2)/vK) is " + vTSR);

		//var vTSR = (vTSR/10000000);
		//alert ("vTSR = (vTSR/10000000) is " + vTSR);
		//var vTSR = (document.form.SR.value*(1+vK))/vK;
		//alert ("vTSR = (document.form.SR.value*(1+vK))/vK is " + vTSR);
		var vTSRrounded = to_roundTSR(vTSR);
		////alert("vTSRrounded= " + vTSRrounded);
		//alert (vTSR);
		////document.form.TSR.value = vTSR;
		document.form.TSR.value = (vTSRrounded+".00");
		
		//7/////////////////MSR = Main Spring Rate//////////////////////
		////var vMSR = Math.round(vTSR*vK);
		var vMSR = Math.round(vTSRrounded*vK);
		////alert ("vMSR= " + vMSR);
		var vNewMSR = to_mainspringrate(vMSR);
		//alert("vNewMSR = to_mainspringrate(vMSR) is " + vNewMSR);
		////alert ("vNewMSR= " + vNewMSR);
		//alert (vMSR);
		////document.form.MSR.value = vMSR;
		document.form.MSR.value = (vNewMSR+".00");
		
		//8/////////////////SWR = Secondary Wheel Rate////////////////////
		////var vSWR = (vMSR*vMRSQR);
		var vSWR = (vNewMSR*vMRSQR);
		//alert("vSWR = (vNewMSR*vMRSQR) is " + vSWR);
		////alert ("vSWR= " + vSWR);
		var vNewSWR = to_secondwheelrate(vSWR);
		//alert("vNewSWR = to_secondwheelrate(vSWR) is " + vNewSWR);
		////alert ("vNewSWR= " + vNewSWR);
		////document.form.SWR.value = vSWR;
		document.form.SWR.value = vNewSWR;
		
		//9//////////////////MAIN - from MSR//////////////////////////////
		////vNewMSR
		var vMAIN = vNewMSR;
		document.form.MAIN.value = vMAIN;
		
		//9//////////////////SLIDERMAIN - from MSR//////////////////////////////
		////vNewMSR
		//var vMAIN = vNewMSR;
		document.form.SLIDERMAIN.value = vMAIN;
		
		//9//////////////////DUALMAIN - from MSR//////////////////////////////
		////vNewMSR
		//var vMAIN = vNewMSR;
		document.form.DUALMAIN.value = vMAIN;
		
		//10//////////////////CENTER - freeform////////////////////////////
		////default = 150
		var vCENTER = Math.round((150*10)/10);
		document.form.CENTER.value = vCENTER;
		
		//11///////////////////TENDER - from TSR///////////////////////////
		////vTSRrounded
		var vTENDER = vTSRrounded;
		document.form.TENDER.value = vTENDER;
		
		//11///////////////////SLIDERTENDER - from TSR///////////////////////////
		////vTSRrounded
		//var vTENDER = vTSRrounded;
		document.form.SLIDERTENDER.value = vTENDER;
		
		//11///////////////////DUALTENDER - from TSR///////////////////////////
		////vTSRrounded
		//var vTENDER = vTSRrounded;
		document.form.DUALTENDER.value = vTENDER;
		
		//12///////////////////ST - Shock Travel///////////////////////////
		////default = 15
		var vST = Math.round((15*10)/10);
		document.form.ST.value = vST;
		
		//12///////////////////SLIDERST - Shock Travel///////////////////////////
		////default = 15
		//var vST = Math.round((15*10)/10);
		document.form.SLIDERST.value = vST;
		
		
		//**///////////////////SHAFTTRVL - Shaft Travel///////////////////////////
		////default = 12
		var vShaftTrvl = Math.abs((12*10)/10);	
		document.form.SHAFTTRVL.value = vShaftTrvl;
		
		//**///////////////////SHAFTDIA - Shaft Diameter///////////////////////////
		////default = .575
		//var vShaftDia = Math.round((575*10)/10000);
		var vShaftDia = Math.abs((875*10)/10);
		var vNewShaftDia = to_shaftdia(vShaftDia);
		document.form.SHAFTDIA.value = vNewShaftDia;
		
		//**///////////////////BOREDIA - Bore Diameter///////////////////////////
		////default = .0321
		var vBoreDia = Math.abs((2252*10)/10);
		var vNewBoreDia = to_shaftdia(vBoreDia);
		document.form.BOREDIA.value = vNewBoreDia;	
		

  		//MM_goToURL('parent','#step2');
		MM_goToURL('parent','#step5');

}////////////////END function step1()////////////////

////////////////THIS function step12() NOT EMPLOYED YET!!!////////////////
//function step12() {
//	if (document.form.WT.value == 0 || document.form.CSW.value == 0){
//		alert ("Please Provide both Total Wheel Travel and Sprung Weight");
//		return;
//  	}else{
//		MM_goToURL('parent','#step2');
//	}
//}

///////////////////////function step2()///////////////////////
function step2() {
	
	while(document.form.MAIN.value <= 0 || isNaN(document.form.MAIN.value)){
		alert ("Please be sure the MAIN value is greater than 0!");
		var vMAINvalue = document.form.MAIN.value;
		alert("vMAINvalue=" + vMAINvalue);
		function toForm() {
			document.form.MAIN.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.CENTER.value <= 0 || isNaN(document.form.CENTER.value)){
		alert ("Please be sure the CENTER value is greater than 0!");
		var vCENTERvalue = document.form.CENTER.value;
		alert("vCENTERvalue=" + vCENTERvalue);
		function toForm() {
			document.form.CENTER.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.TENDER.value <= 0 || isNaN(document.form.TENDER.value)){
		alert ("Please be sure the TENDER value is greater than 0!");
		var vTENDERvalue = document.form.TENDER.value;
		alert("vTENDERvalue=" + vTENDERvalue);
		function toForm() {
			document.form.TENDER.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	
	if (document.form.MAIN.value == 0 || document.form.CENTER.value == 0 || document.form.TENDER.value == 0){
		alert ("Verify MAIN, CENTER and TENDER are greater than 0!");
		return;
  	}
	else{		
		//13///////////////////////////////PRIMARY////////////////////////////////
		///////= (TENDER*CENTER*MAIN)/(MAIN*CENTER)+(MAIN*TENDER)+(CENTER*TENDER)
		var vMAIN = document.form.MAIN.value;
		var vCENTER = document.form.CENTER.value;
		var vTENDER = document.form.TENDER.value;
		var vST = document.form.ST.value;		
		
		var vNUMERATOR = (vTENDER*vCENTER*vMAIN);
		//alert("vNUMERATOR= " + vNUMERATOR);
		var vDENOMINATOR = (vMAIN*vCENTER)+(vMAIN*vTENDER)+(vCENTER*vTENDER);
		//alert("vDENOMINATOR= " + vDENOMINATOR);
		var vPRIMARY = (vNUMERATOR/vDENOMINATOR);
		//alert("vPRIMARY= " +  vPRIMARY);
		var vPRIMErounded = to_primary(vPRIMARY);
		//alert("vPRIMErounded= " + vPRIMErounded);
		//document.form.PRIMARY.value =  vPRIMARY;
		document.form.PRIMARY.value =  vPRIMErounded;
		
		//14/////////////////////////SECONDARY//////////////////////////////////
		//= (CENTER*MAIN)/(MAIN+CENTER)
		var vSECNUM = (vCENTER*vMAIN);
		//alert("vSECNUM= " + vSECNUM);
		var vSECDEN = Math.round(vCENTER) + Math.round(vMAIN);
		//alert("vSECDEN= " + vSECDEN);
		var vSECONDARY = (vSECNUM/vSECDEN);
		var vSECONDrounded = Math.round(vSECONDARY);
		//alert("vSECONDrounded= " + vSECONDrounded);
		document.form.SECONDARY.value = vSECONDrounded;
		
		//15//////////////////////////FINAL//////////////////////////////////////
		//= MAIN
		var vFINAL = vMAIN;
		document.form.FINAL.value = vFINAL;
		
		
		//16//////////////////////////Slider C-T/////////////////////////////////
		//////= ST*PRIMARY/TENDER
		//////var vSLINUM = vST*vPRIMErounded;
		///////alert(vST);
		////////alert(vPRIMErounded)
		var vSLINUM = vST*vPRIMARY;
		//var vSLINUM = vST*vPRIMErounded;
		//alert("vSLINUM= " + vSLINUM);
		var vSLIDEN = vTENDER;
		//alert("vSLIDEN= " + vSLIDEN);
		var vSLIDC = vSLINUM/vSLIDEN;
		var vSLIDCrounded = Math.round(100*vSLIDC);
		var vNewSLIDC = (vSLIDCrounded/100);
		//alert("vNewSLIDC= " + vNewSLIDC);
		//alert("vSLIDCrounded= " + vSLIDCrounded);
		//alert("vSLIDC= " + vSLIDC);
		//document.form.SLIDER_CT.value = vSLIDC;
		document.form.SLIDER_CT.value = vNewSLIDC;
		
		//17/////////////////////////Slider M-C///////////////////////////////////
		///////////= (ST*PRIMARY)/((TENDER*CENTER)/(TENDER+CENTER));
		////////var vSLINUM = vST*vPRIMErounded;
		/////////alert(vST);
		/////////alert(vPRIMErounded)
		var vSLIMNUM = vST*vPRIMARY;
		//var vSLINUM = vST*vPRIMErounded;
		//alert("vSLIMNUM= " + vSLIMNUM);
		var vSLIMDEN = (vTENDER*vCENTER)/((Math.round(vTENDER) + Math.round(vCENTER)));
		//alert("vSLIMDEN= " + vSLIMDEN);
		var vSLIMC = vSLIMNUM/vSLIMDEN;
		var vSLIMCrounded = Math.round(100*vSLIMC);
		var vNewSLIMDC = (vSLIMCrounded/100);
		//alert("vNewSLIMDC= " + vNewSLIMDC);
		//alert("vSLIDCrounded= " + vSLIDCrounded);
		//alert("vSLIDC= " + vSLIDC);
		//document.form.SLIDER_CT.value = vSLIDC;
		document.form.SLIDER_MC.value = vNewSLIMDC;
		
		//18///////////////////////////MAIN TR////////////////////////////////
		////////////= (ST - SLIDER_MC);
		////////////var vSLINUM = vST*vPRIMErounded;
		////////////alert(vST);
		////////////alert(vPRIMErounded)
		var vMainTR = Math.abs(vST) - (vNewSLIMDC);
		//alert("vMainTR= " + vMainTR);
		//var vSLINUM = vST*vPRIMErounded;
		//alert("vSLIMNUM= " + vSLIMNUM);
		//var vSLIMDEN = (vTENDER*vCENTER)/((Math.round(vTENDER) + Math.round(vCENTER)));
		//alert("vSLIMDEN= " + vSLIMDEN);
		//var vSLIMC = vSLIMNUM/vSLIMDEN;
		var vMainrounded = Math.round(100*vMainTR);
		var vNewMain = (vMainrounded/100);
		//alert("vNewSLIMDC= " + vNewSLIMDC);
		//alert("vSLIDCrounded= " + vSLIDCrounded);
		//alert("vSLIDC= " + vSLIDC);
		//document.form.SLIDER_CT.value = vSLIDC;
		document.form.MAIN_TR.value = vNewMain;
		
		//19////////////////////////////CENTER TR//////////////////////////////////
		//= (SLIDER_MC - SLIDER_CT);
		var aSLIDMC = Math.abs(vNewSLIMDC);
		//alert("aSLIDMC= " + aSLIDMC);
		var aSLIDCT = Math.abs(vNewSLIDC);
		//alert("aSLIDCT= " + aSLIDCT);
		
		var vCenterTR = (aSLIDMC - aSLIDCT);
		//alert("vCenterTR= " + vCenterTR);
		//var vSLINUM = vST*vPRIMErounded;
		//alert("vSLIMNUM= " + vSLIMNUM);
		//var vSLIMDEN = (vTENDER*vCENTER)/((Math.round(vTENDER) + Math.round(vCENTER)));
		//alert("vSLIMDEN= " + vSLIMDEN);
		//var vSLIMC = vSLIMNUM/vSLIMDEN;
		var vCENTERrounded = Math.round(100*vCenterTR);
		var vNewCenter = (vCENTERrounded/100);
		//alert("vNewSLIMDC= " + vNewSLIMDC);
		//alert("vSLIDCrounded= " + vSLIDCrounded);
		//alert("vSLIDC= " + vSLIDC);
		//document.form.SLIDER_CT.value = vSLIDC;
		document.form.CENTER_TR.value = vNewCenter;
		
		//20///////////////////////////TENDER TR////////////////////////////////////
		//= (SLIDER_CT);
		var aTendTR = Math.abs(vNewSLIDC);
		//alert("aTendTR= " + aTendTR);
		//alert("vCenterTR= " + vCenterTR);
		//var vSLINUM = vST*vPRIMErounded;
		//alert("vSLIMNUM= " + vSLIMNUM);
		//var vSLIMDEN = (vTENDER*vCENTER)/((Math.round(vTENDER) + Math.round(vCENTER)));
		//alert("vSLIMDEN= " + vSLIMDEN);
		//var vSLIMC = vSLIMNUM/vSLIMDEN;
		var vTendTRrounded = Math.round(100*aTendTR);
		var vNewTendTR = (vTendTRrounded/100);
		//alert("vNewSLIMDC= " + vNewSLIMDC);
		//alert("vSLIDCrounded= " + vSLIDCrounded);
		//alert("vSLIDC= " + vSLIDC);
		//document.form.SLIDER_CT.value = vSLIDC;
		document.form.TENDER_TR.value = vNewTendTR;
		
		//////////Slider Travel/Location Calculator////////////
		//////INPUTS - values from Triple Rate Calculator//////
		//////MAIN, TENDER and ST populated upon invoking//////
		//////'Next' button in function step2()////////////////
		//////////MAIN//////////
		////alert("vMAIN= " + vMAIN);
		document.form.SLIDERMAIN.value = vMAIN;
		//////////TENDER//////////
		////alert("vTENDER= " + vTENDER);
		document.form.SLIDERTENDER.value = vTENDER;
		//////////ST//////////
		////alert("vST= " + vST);
		document.form.SLIDERST.value = vST;
		
		//9//////////////////DUALMAIN - from MSR//////////////////////////////
		////vNewMSR
		//var vMAIN = vNewMSR;
		document.form.DUALMAIN.value = vMAIN;		
		
		//11///////////////////DUALTENDER - from TSR///////////////////////////
		////vTSRrounded
		//var vTENDER = vTSRrounded;
		document.form.DUALTENDER.value = vTENDER;	
		
		
		
  		MM_goToURL('parent','#step3');
	}
}////////////////END function step2()////////////////


///////////////////////function step4()///////////////////////
function step4() {

	while(document.form.SLIDERMAIN.value <= 0 || isNaN(document.form.SLIDERMAIN.value)){
		alert ("Please be sure the Main value is greater than 0!");
		var vSLIDERMAINvalue = document.form.SLIDERMAIN.value;
		alert("vSLIDERMAINvalue=" + vSLIDERMAINvalue);
		function toForm() {
			document.form.SLIDERMAIN.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.SLIDERTENDER.value <= 0 || isNaN(document.form.SLIDERTENDER.value)){
		alert ("Please be sure the Tender value is greater than 0!");
		var vSLIDERTENDERvalue = document.form.SLIDERTENDER.value;
		alert("vSLIDERTENDERvalue=" + vSLIDERTENDERvalue);
		function toForm() {
			document.form.SLIDERTENDER.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.SLIDERST.value <= 0 || isNaN(document.form.SLIDERST.value)){
		alert ("Please be sure the Slider travel (ST) value is greater than 0!");
		var vSLIDERSTvalue = document.form.SLIDERST.value;
		alert("vSLIDERSTvalue=" + vSLIDERSTvalue);
		function toForm() {
			document.form.SLIDERST.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
		
		var vSLIDERTENDER = document.form.SLIDERTENDER.value;
		var vSLIDERMAIN = document.form.SLIDERMAIN.value;
		var vSLIDERST = document.form.SLIDERST.value;
	
		////1) new Primary rate
		//// SLIDERPRIMARY = (SLIDERTENDER*SLIDERMAIN)/(SLIDERTENDER+SLIDERMAIN)		
		var vSPNUM = (vSLIDERTENDER*vSLIDERMAIN);
		////alert("vSPNUM= " + vSPNUM);
		var vSPDEN = Math.abs(vSLIDERTENDER) + Math.abs(vSLIDERMAIN);
		////alert("vSPDEN= " + vSPDEN);
		var vSLIDERPRIMARY = (vSPNUM/vSPDEN);
		////alert("vSLIDERPRIMARY= " + vSLIDERPRIMARY);		
		////var vSProunded = Math.round(100*vSLIDERPRIMARY);
		var vSProunded = to_sliderprimary(vSLIDERPRIMARY);
		////alert("vSProunded= " + vSProunded);
		
		///var vSPnew = Math.abs(vSProunded/100);
		////alert("vSPnew= " + vSPnew);
		////document.form.SLIDERPRIMARY.value = vSLIDERPRIMARY;
		////document.form.SLIDERPRIMARY.value = vSPnew;
		document.form.SLIDERPRIMARY.value = vSProunded;
		
		////2) new Slider Travel
		////SLIDERTRAVEL = SLIDERST*SLIDERPRIMARY/SLIDERTENDER
		var vSTNUM = (vSLIDERST*vSLIDERPRIMARY);
		////alert("vSTNUM= " + vSTNUM);
		var vSTDEN = (vSLIDERTENDER);
		////alert("vSTDEN= " + vSTDEN);
		var vSLIDERTRAVEL = (vSTNUM/vSTDEN);
		////alert("vSLIDERTRAVEL= " + vSLIDERTRAVEL);
		var vSTrounded = to_slidertravel(vSLIDERTRAVEL);
		////alert("vSTrounded= " + vSTrounded);
		////document.form.SLIDERTRAVEL.value = vSLIDERTRAVEL;
		document.form.SLIDERTRAVEL.value = vSTrounded;
		
		
		//////////////////////////Dual Rate Calculator///////////////////////////
		/////////INPUTS - values from Slider Travel/Location Calculator//////////
		/////////////DUALMAIN and DUALTENDER populated upon invoking/////////////
		////////////////'Next' button in function step4()////////////////////////
		//////////DUALMAIN//////////
		////alert("vMAIN= " + vMAIN);
		document.form.DUALMAIN.value = vSLIDERMAIN;
		//////////TENDER//////////
		////alert("vTENDER= " + vTENDER);
		document.form.DUALTENDER.value = vSLIDERTENDER;	
		
		
		MM_goToURL('parent','#step6');

}////////////////END function step4()////////////////

///////////////////////function step6() NOT EMPLOYED YET!///////////////////////
//function step6() {
//	if (document.form.WT.value == 0 && document.form.CSW.value == 0){
//		alert ("Please Provide both Wheel Travel and Corner Sprung Weight");
//		return;
//  	}else{
//  		//MM_goToURL('parent','#step3');
//		MM_goToURL('parent');
//	}
//}

///////////////////////function step7()///////////////////////
function step7() {

	while(document.form.DUALMAIN.value <= 0 || isNaN(document.form.DUALMAIN.value)){
		alert ("Please be sure the Main Dual Rate Spring value is greater than 0!");
		var vDUALMAINvalue = document.form.DUALMAIN.value;
		alert("vDUALMAINvalue=" + vDUALMAINvalue);
		function toForm() {
			document.form.DUALMAIN.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.DUALTENDER.value <= 0 || isNaN(document.form.DUALTENDER.value)){
		alert ("Please be sure the Tender Dual Rate Spring value is greater than 0!");
		var vDUALTENDERvalue = document.form.DUALTENDER.value;
		alert("vDUALTENDERvalue=" + vDUALTENDERvalue);
		function toForm() {
			document.form.DUALTENDER.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
		
		var vDUALMAIN = document.form.DUALMAIN.value;
		////alert("vDUALMAIN= " + vDUALMAIN);
		var vDUALTENDER = document.form.DUALTENDER.value;
		////alert("vDUALTENDER= " + vDUALTENDER);
		
		////1)********************Primary Rate********************
		//= (DUALMAIN*DUALTENDER)/(DUALMAIN+DUALTENDER)
		var vDUALPRIMARYnum = (vDUALMAIN*vDUALTENDER);
		////alert("vDUALPRIMARYnum= " + vDUALPRIMARYnum);
		var vDUALPRIMARYden = Math.abs(vDUALMAIN)+Math.abs(vDUALTENDER);
		////alert("vDUALPRIMARYden= " + vDUALPRIMARYden);
		var vDUALPRIMARY = (vDUALPRIMARYnum/vDUALPRIMARYden);
		////alert("vDUALPRIMARY= " +  vDUALPRIMARY);
		var vDUALPRIMErounded = to_dualprimary(vDUALPRIMARY);
		////alert("vDUALPRIMErounded= " + vDUALPRIMErounded);
		//document.form.PRIMARY.value =  vPRIMARY;
		document.form.DUALPRIMARY.value =  vDUALPRIMErounded;
		
		////2)********************Secondary Rate********************
		////SECONDRATE = document.form.DUALMAIN.value;
		////var vDUALMAIN = document.form.DUALMAIN.value;
		var vSECONDRATE = vDUALMAIN;
		////alert("vSECONDRATE= " + vSECONDRATE);
		////var vSECNUM = (vCENTER*vMAIN);
		//alert("vSECNUM= " + vSECNUM);
		////var vSECDEN = Math.round(vCENTER) + Math.round(vMAIN);
		//alert("vSECDEN= " + vSECDEN);
		////var vSECONDARY = (vSECNUM/vSECDEN);
		var vSECONDRATErounded = Math.round(vSECONDRATE);
		////alert("vSECONDRATErounded= " + vSECONDRATErounded);
		//alert("vSECONDrounded= " + vSECONDrounded);
		document.form.SECONDRATE.value = vSECONDRATErounded;
		
		
  		MM_goToURL('parent','#step8');

}////////////////END function step7()////////////////


///////////////////////function step9()///////////////////////
function step9() {

	while(document.form.G.value <= 0 || isNaN(document.form.G.value)){
		alert ("Please be sure the Modulus of Elasticity (G) value is greater than 0!");
		var vGvalue = document.form.G.value;
		alert("vGvalue=" + vGvalue);
		function toForm() {
			document.form.G.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.d.value <= 0 || isNaN(document.form.d.value)){
		alert ("Please be sure the wire diameter (d) value is greater than 0!");
		var vdvalue = document.form.d.value;
		alert("vdvalue=" + vdvalue);
		function toForm() {
			document.form.d.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.N.value <= 0 || isNaN(document.form.N.value)){
		alert ("Please be sure the number of active coils (N) value is greater than 0!");
		var vNvalue = document.form.N.value;
		alert("vNvalue=" + vNvalue);
		function toForm() {
			document.form.N.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.OD.value <= 0 || isNaN(document.form.OD.value)){
		alert ("Please be sure the spring OD (OD) value is greater than 0!");
		var vODvalue = document.form.OD.value;
		alert("vODvalue=" + vODvalue);
		function toForm() {
			document.form.OD.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
		//////////local variables//////////
		////G////
		var vG = document.form.G.value;
		var vGnew = Math.abs(vG);
		////alert("vGnew= " + vGnew);
		
		////d////
		var vd = document.form.d.value;
		var vdNew = Math.abs(vd);
		////alert("vdNew= " + vdNew);
		
		////N////
		var vN = document.form.N.value;
		var vNnew = Math.abs(vN);
		////alert("vNnew= " + vNnew);
		
		////OD////
		var vOD = document.form.OD.value;
		var vODnew = Math.abs(vOD);
		////alert("vODnew= " + vODnew);
		
		////D////
		////D = (OD - d);
		var vD = Math.abs(vODnew) - Math.abs(vdNew);
		/////alert("vD= " + vD);
		var vDrounded = Math.round(vD*100);
		////alert("vDrounded = " + vDrounded);
		var vDnew = (vDrounded/100);
		////document.form.D.value = vD;
		document.form.D.value = vDnew;
		
		////ID////
		var vID = document.form.ID.value;
		var vIDcalc = Math.abs(vD) - Math.abs(vdNew);
		////alert("vIDcalc= " + vIDcalc);
		var vIDrounded = Math.round(vIDcalc*1000);
		////alert("vIDrounded= " + vIDrounded);
		var vIDnew = (vIDrounded/1000);
		document.form.ID.value = vIDnew;
		
		////////K////////
		////K = (Math.pow(d, 4)*G)/(8*Math.pow(D, 3)*N);
		var vKnum = (Math.pow(vdNew, 4)*vGnew);
		////alert("vKnum= " + vKnum);
		var vKden = (8*Math.pow(vD, 3)*vNnew);
		////alert("vKden= " + vKden);
		var vK = Math.abs(vKnum/vKden);
		////alert("vK= " + vK);
		var vKrounded = Math.round(vK);
		////alert("vKrounded = " + vKrounded);
		document.form.K.value = vKrounded;
			
		
  		MM_goToURL('parent','#step10');

}////////////////END function step9()////////////////

//////////////////function step11()//////////////////
function step11() {

	while(document.form.SHAFTTRVL.value <= 0 || isNaN(document.form.SHAFTTRVL.value)){
		alert ("Please be sure the Shaft Trvl value is greater than 0!");
		var vSHAFTTRVLvalue = document.form.SHAFTTRVL.value;
		alert("vSHAFTTRVLvalue=" + vSHAFTTRVLvalue);
		function toForm() {
			document.form.SHAFTTRVL.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.SHAFTDIA.value <= 0 || isNaN(document.form.SHAFTDIA.value)){
		alert ("Please be sure the Shaft Dia. value is greater than 0!");
		var vSHAFTDIAvalue = document.form.SHAFTDIA.value;
		alert("vSHAFTDIAvalue=" + vSHAFTDIAvalue);
		function toForm() {
			document.form.SHAFTDIA.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}
	
	while(document.form.BOREDIA.value <= 0 || isNaN(document.form.BOREDIA.value)){
		alert ("Please be sure the Bore Dia. value is greater than 0!");
		var vBOREDIAvalue = document.form.BOREDIA.value;
		alert("vBOREDIAvalue=" + vBOREDIAvalue);
		function toForm() {
			document.form.BOREDIA.focus();
			// Replace field1 in the script with the field name of which you want to place the focus.
		}
		//resetForm();
		return;
  	}

			/////////////////local variables/////////////////
			var vShaftTrvl = document.form.SHAFTTRVL.value;
			//alert("vShaftTrvl= " + vShaftTrvl);

			var vShaftDia = document.form.SHAFTDIA.value;
			//alert("vShaftDia= " + vShaftDia);

			var vBoreDia = document.form.BOREDIA.value;
			//alert("vBoreDia= " + vBoreDia);

			/* while (document.form.SHAFTTRVL.value == 0) */			
			while (vShaftTrvl <= 0) {
				alert ("Please be sure that Shaft Trvl has a value greater than zero!");
			    var vTransition = document.form.SHAFTTRVL.value;
				if (vTransition <= 0) {
				var bool = false;				
				}
				var bool = true; 
				return;
			}
		
			///////////////Calculate Piston Trvl///////////////
			var vPistonTrvlNUM = vShaftTrvl;
			//alert("vPistonTrvlNUM= " + vPistonTrvlNUM);
			var vPistonTrvlDEN1 = Math.pow((vShaftDia/2),2);  // a to the power b
			//alert("vPistonTrvlDEN1= " + vPistonTrvlDEN1);
			var vPistonTrvlDEN2 =  Math.pow((vBoreDia/2),2);
			//alert("vPistonTrvlDEN2= " + vPistonTrvlDEN2);
			var vPistonTrvl = (vPistonTrvlNUM*(vPistonTrvlDEN1/vPistonTrvlDEN2));
			//alert("vPistonTrvl= " + vPistonTrvl);
			var vPistonTrvlROUNDED = Math.round(1000*vPistonTrvl);
			//alert("vPistonTrvlROUNDED= " + vPistonTrvlROUNDED);
			var vPistonTrvlNEW = (vPistonTrvlROUNDED/1000);
			//alert("vPistonTrvlNEW= " + vPistonTrvlNEW);			
			document.form.PISTONTRVL.value = vPistonTrvlNEW;	
			
	MM_goToURL('parent','#step12');
	
}////////////////END function step11()////////////////


///////////////////BEGIN INPUT FORMATS///////////////////
////light green
function hoverItemOn(x) {
	x.style.backgroundColor = "#336699";
    x.style.color = "#FFFFFF";
}
function hoverItemOff(x) {
   x.style.backgroundColor = "#99FF99";
   x.style.color = "#000000";
}
////dark green
function hoverItemOnG(x) {
	x.style.backgroundColor = "#336699";
    x.style.color = "#FFFFFF";
}
function hoverItemOffG(x) {
   x.style.backgroundColor = "#009966";
   x.style.color = "#000000";
}
////orange
function hoverItemOnO(x) {
	x.style.backgroundColor = "#336699";
    x.style.color = "#FFFFFF";
}
function hoverItemOffO(x) {
   x.style.backgroundColor = "#FF6600";
   x.style.color = "#000000";
}
////grey #FF6600
function hoverItemOnGR(x) {
	x.style.backgroundColor = "#336699";
    x.style.color = "#FFFFFF";
}
function hoverItemOffGR(x) {
   x.style.backgroundColor = "#CCCCCC";
   x.style.color = "#000000";
}
////red
function hoverItemOnR(x) {
	x.style.backgroundColor = "#336699";
    x.style.color = "#FFFFFF";
}
function hoverItemOffR(x) {
   x.style.backgroundColor = "#BB0000";
   x.style.color = "#000000";
}
////tomato
function hoverItemOnT(x) {
	x.style.backgroundColor = "#336699";
    x.style.color = "#FFFFFF";
}
function hoverItemOffT(x) {
   x.style.backgroundColor = "#CC0000";
   x.style.color = "#CCFF33";
}
///////////////////END INPUT FORMATS///////////////////
