   function Update(){
   var p = document.Slipper
   var stdRatio = 2.3; // use to change ratio of length to width.  For felted slippers 1.8, smaller for boots.
   
  
// guess for foot length based on shoe size.   
   var extra;
   if(p.range.options[p.range.selectedIndex].value == "Man") extra = 2;
   else if(p.range.options[p.range.selectedIndex].value == "Woman") extra = 0;
   else extra = -12; 
   
   var normSize= eval(p.size.value)+extra;
   p.stdLength.value = Math.round( 100*(6.8 + normSize/3) ) /100;
   p.stdWidth.value =Math.round( eval(p.stdLength.value)/stdRatio * 100)/100;
   
// Select length used.
var tightRatio=0.90;
	if(p.customFoot[0].checked )
		{
		}
	else {
		p.slLength.value=Math.round(100*tightRatio* eval(p.stdLength.value))/100;
		p.slWidth.value=Math.round(100*tightRatio*eval(p.stdWidth.value))/100;
	}
// suggest gauge based on bulky etc.
	if(p.yarnType[0].checked){p.prStGauge.value=2.5;}
	if(p.yarnType[1].checked){p.prStGauge.value=4.5;}
	if(p.yarnType[2].checked){p.prStGauge.value=6.5;}
	if(p.yarnType[3].checked){p.prStGauge.value=8.0;}
	
	p.prRowGauge.value= eval(p.prStGauge.value)*3/2;

	// let them pick their own gauge.
if(p.customGauge[1].checked ){
  p.stGauge.value = eval(p.prStGauge.value);
  p.rowGauge.value=eval(p.prRowGauge.value);
}
else {

}
rowStRat=divide(p.rowGauge.value,p.stGauge.value)
stitchPer24Rows = 24/rowStRat



// Calculate directions
// make everythign even.  That's easiest.
var stG, rowG;

if(!isNaN(p.stGauge.value)){stG= eval(p.stGauge.value);}
else {stG=0;}
if(!isNaN(p.rowGauge.value) ) {rowG= eval(p.rowGauge.value);}
else{ rowG=0;}



fillWin();
  

} // end update--------------------


function fillWin(){


 var q=newWindow.document.Slipper;
 var p = document.Slipper;
 p.warningBox.value ="";


 six=2; one=1; two=0;
if(rowStRat > 0.9) {six=6; one=2; two=1;   }// this should nevr happen.
if(rowStRat > 1.2){ six= 4; one=1; two=1;  }// hk stockinette or taller.  
if(rowStRat > 1.42){ six= 6; one=1; two=2;  } // felted stockinette.
if(rowStRat > 1.8){ six= 4; one = 0; two=2;  }// garter stitch. all plain.

//alert(rowStRat + ": six= "+ six +" :one " + one +" : " + two);

q.six.value=six; q.one.value=one;q.two.value=two

 
//q values
q.stGauge.value=p.stGauge.value;
q.rowGauge.value=p.rowGauge.value;

q.slWidth.value=p.slWidth.value
q.slLength.value=p.slLength.value


// start calculating
footRows=Math.round(mult(p.slLength.value,p.rowGauge.value)/2 - 1/2)*2+1;
p.footRows.value= footRows; q.footRows.value=p.footRows.value;

sideStitches=Math.round(two*2*(footRows-1)/six);    p.sideStitches.value=sideStitches; q.side1.value=sub(p.sideStitches.value,1); q.side2.value=q.side1.value;

// (I need to do something ore complicated.)
p.ballStitches.value= Math.round(mult(p.slWidth.value,p.stGauge.value))
decToe=Math.round(0.2*mult(p.slWidth.value,p.stGauge.value)/2)*2;//even
heelStitches=sub(p.ballStitches.value,decToe);

p.heelStitches.value=heelStitches;
toeStitches=heelStitches+(1-heelStitches%2); p.toeStitches.value=toeStitches;
if(toeStitches < 4){p.warningBox.value="Use a finer gauge for your size."}

bottomStitches= heelStitches+ toeStitches+2*sideStitches; p.bottomStitches.value=bottomStitches; q.bottomStitches.value=p.bottomStitches.value;

incRounds=Math.round(.5*sideStitches);p.incRounds.value=incRounds;//q.incRounds.value=p.incRounds.value
topStitches=bottomStitches-2*incRounds; p.topStitches.value=topStitches;  q.topStitches.value=p.topStitches.value;

incStitches=Math.round(topStitches/6);p.incStitches.value=incStitches; q.incStitches.value=p.incStitches.value;
castOn=topStitches-incStitches; p.castOn.value=castOn+1; q.castOn.value=p.castOn.value  // 1 is for the  join.

q.flangeRows.value=Math.max(4,Math.round(5*castOn/26));
q.plainRounds.value=Math.max(1,Math.round(1*castOn/26));
q.halfToe.value=Math.ceil(toeStitches/2);
q.heelP2.value=add(p.heelStitches.value,2);
q.heelM2.value=sub(p.heelStitches.value,2); q.heelM2_2.value=q.heelM2.value; q.heelM2_3.value=q.heelM2.value;
q.incBottom2.value=decToe;
q.incBottom.value=q.incBottom2.value;

// I'll need a loop to add moer rows if there are more than 2 increases.
incRows=Math.round(footRows/5)*2;q.incRows.value=incRows-1; //
q.decRows.value=Math.round(sub(footRows,incRows/2)/2)*2+1;
q.warningBox.value=p.warningBox.value;
//  now fill

/*
castOn= Math.round(stG*eval(p.slWidth.value)/2)*2;
q.castOn.value = castOn;

q.flapN1.value = p.flapN1.value;
q.heelN1.value = p.heelN1.value;
q.toeN1.value = p.toeN1.value;

q.footR1.value = p.footR1.value
q.footR2.value=p.footR2.value;
q.flapN2.value=p.flapN2.value;
q.toeN2.value=p.toeN2.value;
q.heelN2.value=p.heelN2.value;
*/

//========================


newWindow.document.close()
//================================
}

