function yarnUsed(){
// swatch
    swSt=Math.ceil(mult(4.5,p.mainStIn.value)+4);
    swRs=Math.ceil(mult(4.5,p.mainRowIn.value)+6);
    totStSwatch=swSt*swRs;

// body
totalBodyStitches=castOn*(rowsPlacket*2+2) ;
totalBodyStitches += (castOn+stitchesAfterHalfFast+1)*(fastIncSleeve+1)*halfFastTimes/2;
totalBodyStitches += (stitchesAfterHalfFast+stitchesAfterThisSlow+1)*(slowIncSleeve+1)*slowTimes/2;
totalBodyStitches += (stitchesAfterThisSlow+bindOff+1)*(fastIncSleeve+1)*secondHalfFastTimes/2;

// I cord
Length1= Math.round(mult(p.bottomWidth.value,1.5));

Length2 = Math.round(mult(p.bottomWidth.value,1))+ 2*Math.round(p.bottomWidth.value,0.8);
totalIcordStiitch1= mult((Length1+Length2)*1.1,p.mainStIn.value)*3;

 // total  yarn yused
    yardageFactor=Math.PI*1.02*1.02 // current factor.  about pi * some fudge  (1.02 is the empirical factor. I'm adding 2% safety to help just a touch. This should be enough for sewing up etc/

 stitchPat="stockinette"; // stockinette
     twelve=0
	 
/*
if(eval(p.stitchPat.selectedIndex)==0){
    stitchPat="stockinette"; // stockinette
     twelve=0
    }
else if(eval(p.stitchPat.selectedIndex)==1) {
    brokenRib=1;yardageFactor=yardageFactor*1.11/1.02;
    stitchPat="broken rib"
    twelve=12
    }
else{
    yardageFactor=yardageFactor*1.24;
    stitchPat="mystery use lots of yarn pattern."
     twelve=24
    } // what the heck!
*/

inchPerStitch=divide(1,p.mainStIn.value)*lengthBeforeRatio; 
inchPerRow=divide(1,p.mainRowIn.value)*widthBeforeRatio;

normalizedInch= Math.sqrt(inchPerStitch*inchPerStitch+ inchPerRow*inchPerRow);

metersPerYard= 36*2.54/100;

 
 //alert(recStitch + ":"+ recRows+ ":"+ yardageFactor + ":"+ stitchesForGaugeSwatch);
swatchYards= yardageFactor*normalizedInch* totStSwatch/36 ; swatchMeters = swatchYards*metersPerYard;
mainYards=totalBodyStitches*yardageFactor*normalizedInch/36 ;  	mainMeters=mainYards*metersPerYard
IcordYards=totalIcordStiitch1*yardageFactor*normalizedInch/36 ; IcordMeters=IcordYards*metersPerYard;

totalYards=mainYards+swatchYards+IcordYards ;totalMeters=totalYards*metersPerYard;


}
function yarnUsedText(){
yarnUsed()
 
 stuff+= "<H2>Yarn Requirements.<\/H2><\/ol>";
 stuff+= "I predict you will need the following amount of yarn for the whole sweater and various individual parts of the sweater. I assume you are knitting the sweater in the following stitch pattern: " + stitchPat+".  This uses " + twelve + "% more yarn per stitch than stockinette knit at the same gauge. The yarn estimate is based on the gauge <em>before</em> washing your swatch. ";

 
  stuff+= "<table>";
stuff+= "<tr><td>Item<\/td>		<td> yards required<\/td>	<td> meters required<\/td><\/tr>";
stuff+= "<tr><td>Whole Halter<\/td>	<td>" + Math.round(totalYards)   +" yards<\/td>	<td>"+ Math.round(totalMeters)    +" meters<\/td><\/tr>";

stuff+= "<tr><td>Main Piece<\/td>	<td>" + Math.round(mainYards)   +" yards<\/td>	<td>"+ Math.round(mainMeters)    +" meters<\/td><\/tr>";
stuff+= "<tr><td>I Cord Straps<\/td>	<td>" + Math.round(IcordYards)   +" yards<\/td>	<td>"+ Math.round(IcordMeters)    +" meters<\/td><\/tr>";


stuff+= " <tr><td>Recommended for swatch:<\/td><td>"+ Math.round(swatchYards)+" yards<\/td>	<td>"+ Math.round(swatchMeters)  +" meters<\/td><\/tr>";
 stuff+= " <\/table>";
     
 patternWindow.document.writeln(stuff);stuff="";
}