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+1)*underCasing + castOn*overCasing ;
totalBodyStitches += chestStitches*(frontRows+backRows+2)/2;

// skirt part
totalSkirtStitches= (rowsForYarnEstimate+2)*stitchesHem;
//alert(totalSkirtStitches + " = " + rowsForYarnEstimate + " * " +stitchesHem);

 // 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;
IcordYards=0; IcordMeters=IcordYards*metersPerYard;  // none yet.
// lace skirt
laceSkirtYards= totalSkirtStitches* yardageFactor*normalizedInch/36; laceSkirtMeters=laceSkirtYards*metersPerYard;

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

laceSkirtYardsLower= laceSkirtYards*0.75; laceSkirtMetersLower=laceSkirtMeters*.75
totalYardsLower = mainYards+swatchYards+IcordYards+ laceSkirtYardsLower;
totalMetersLower =totalYardsLower*metersPerYard;
}
function yarnUsedText(){
yarnUsed()
 
 stuff+= "<H2>Yarn Requirements.<\/H2><\/ol>";
 stuff+= "Here are two estimates for the yarn you need to knit the top. The estimate on the left side assumes you knit it in stockinette; the estimate on the right assumes you knit the lower portion in Vine Lace.  I found Vine Lace used 25% less yarn than I would have used if I'd knit the piece in stockinette.  The yarn estimate is based on the gauge <em>before</em> washing your swatch.  Note: Lace generally uses less yarn than stockinette. ";

 stuff+= "<br><br><center>"; 
 
  stuff+= "<table border='1' cellpadding='2' cellspacing='2' style='text-align: center'>";
stuff+= "<tr><td>Item<\/td>		<td colspan='4' align='center'> yardage<\/td> <\/tr>";
stuff+= "<tr><td><\/td>		    <td colspan='2' align='center' > all stockinette<\/td>	<td colspan='2' align='center'>with lace skirt<\/td><\/tr>";

stuff+= "<tr><td>Whole Top<\/td>	<td>" + Math.round(totalYards)   +" yards<\/td>	<td>"+ Math.round(totalMeters)    +" meters<\/td> <td>" + Math.round(totalYardsLower)   +" yards<\/td>	<td>"+ Math.round(totalMetersLower)    +" meters<\/td>  <\/tr>";

stuff+= "<tr><td>Tube top<\/td>	<td>" + Math.round(mainYards)   +" yards<\/td>	<td>"+ Math.round(mainMeters)    +" meters<\/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> <td><\/td> <td><\/td> <\/tr>";

stuff+= "<tr><td>Lace Skirt<\/td>	<td>" + Math.round(laceSkirtYards) +"   yards<\/td>	<td>"+ Math.round(laceSkirtMeters)    +" meters<\/td> <td>" + Math.round(laceSkirtYardsLower) +"   yards<\/td>	<td>"+ Math.round(laceSkirtMetersLower)    +" meters<\/td>  <\/tr>";


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