
//================
function raglanDirections(){
		 
    raglanCalcs();
	
    patternWindow= window.open('','rowStitch','toolbar=yes, location=yes, scrollbars=yes, resizable=yes, width=400, height=500, left=0,top=0');

    patternWindow.document.write("<HTML><HEAD><BODY><H1>Knitting Directions For Seamless Knit Raglan Cardigan.</H1>")
    patternWindow.document.writeln("Knit top down. <br> Author: Lucia Liljegren.<br>")
    
    // intro
    stuff="These directions were created based on user supplied information entered in a design form for my pattern generator located at  "+ window.location.href +" on "+ currentDate +" .  Additional information, including schematics, on the design page and a number of supporting web pages. I advise you print out the design form for your records. Code and general sweater design by Lucia Liljegren, <i>The  Knitting Fiend.<\/i> ";
    
stuff +='<br>'+ p.tooFewStitches.value;
    
    patternWindow.document.writeln(stuff); stuff="";
    
    // Preliminaries
    stuff+="<hr><h2>Preliminaries<\/h2>";
	stuff+="<br> Size is "+misses + " "+ missesSize +".   Print out the design web page for further details. <P> You must achieve both the row and stitch gauge or your sweater may not fit and the yardage estimate will be incorrect.   I advise double checking your gauge as you knit.  ";

	stuff+="Stitch Gauge: "+ mainStIn +" st/inch; "+  mainRowIn +" row/inch in whatever pattern you picked as your main stitch pattern <em>after</em> you wash, dry and block the swatch. ";
	
	stuff += shrinks;
	
	
	    stuff+="<p><b>Materials:</b> To knit the main portion of the sweater, you will need circular needles in several lengths with the same diameter you used to knit your swatch.  You may also need double pointed needles to work the sleeves.  I recommend using smaller diameter needles to knit the trim on the cuffs and hem; I use 2 sizes smaller.  The directions suggest using 'appropriate' diameter needles to cast on.  I cast on tightly, so I use my larger diameter needles to cast on. If you cast on loosely, use the smaller needles to cast on. You must determine which diameter is most appropriate for your knitting style.<p>An estimate for the amount of yarn you need appears at the end of the pattern. ";  

if(trimStitch=="rib"){	
	oneByOneRib="1 x 1 rib";
	firstRow="then repeat (p1, k1)";
	}
else {
	oneByOneRib = "garter stitch"; 
	firstRow="then knit all stitches"; 
	}

 stuff+="<p>Option The program consistently suggests you knit "+oneByOneRib+"  for the trim. You may substitute <em>any</em> non curling stitch pattern, including rib, garter or seed stitch.";    
 
    patternWindow.document.writeln(stuff);stuff="";



//================Cast On For Neck
stuff += "<h2>Yoke<\/h2>";

castOnNeck=2*remSleeveAfterSmall+neckStitches+4;

stuff += "<br><b>Cast On and Work Foundation rows:<\/b>";
stuff += "<br> Discussion: You, as the final designer, must select your own increase method. I use a 'make 1' which I discuss on the design  page."
stuff+= "<ol>";
stuff+= "<li>Cheaters provisional cast On: Using appropriate diameter circular needle and waste yarn, cast on  "+ castOnNeck +"  stitches. Using larger diameter needles, knit 1 row, break yarn. <\/li>";
stuff+= "<li>With wrong side facing, place markers to indicate the front, top of sleeves and back as follows: Slip 2 stitches, place a marker 1, slip "+ remSleeveAfterSmall +" stitches (sleeve), place marker 2, slip "+ neckStitches +" stitches (back), place maker 3, slip "+ remSleeveAfterSmall +" stitches (sleeve), place maker 4, slip 2 stitches. <\/li>";
stuff+= "<li>Row 1: Begin right facing. Attach sweater yarn.  Knit 1 row. <\/li>";
stuff+= "<li>Row 2: Turn work, wrong side facing. Purl 1 row. <\/li>";

stuff+= "<li>I will use ()  brackets to highlight increases worked around markers.   <\/li>";
stuff+= "<li>Row 3: Right side facing: K 1, (inc 1, k 1, slip maker 1, k 1, inc 1), k "+ sub(remSleeveAfterSmall,2) + ", (inc 1, k 1, slip marker 2, k 1, inc 1), k " +sub(neckStitches,2) +", (inc 1, k 1, slip maker 3, k 1, inc 1), k "+ sub(remSleeveAfterSmall,2) + " (inc 1, k 1, slip maker 4, k1, inc 1), k1.  (8 stitches added to row.)  <\/li>";

stuff+= "<li>Row 4: Purl row. Increase 1 at end of row.<\/li>";

stuff+= "<li>Row 5:   K3, (inc 1, k1 slip maker 1, k1, inc 1), k "+ sub(remSleeveAfterSmall,0) +", (inc 1, k 1, slip marker 2, k 1,  inc 1), k " +sub(neckStitches,0) +", (inc 1, k 1, slip maker 3, k 1, inc 1), k "+ sub(remSleeveAfterSmall,0) +", (inc 1, k 1, slip maker 4, k1, inc 1 ), k2, inc 1. (9 stitches added to row, 1 added to previous row.) <\/li>";
stuff+= "<li>Row 6: Purl row.<\/li>";
stuff+= "<\/ol>";
stuff += "<br><b>Shape Yoke<\/b>";

sleeveStAfter0= add(remSleeveAfterSmall,4);
backStAfter0=add(neckStitches,4);
frontStAfter0= 5; 

stuff += "<br>Discussion: Notice you are beginning to shape the yoke. One sleeve is forming between markers 1 and 2; the other between 3 and 4.  The back stitches are between markers 2 & 3. There should be " + sleeveStAfter0+ " stitches between sleeve markers, " +backStAfter0+ " stitches between back markers  and 5 stitches on either side of the edge markers for the front.";
stuff+= "<ol>";


// this makes sense if the first transition is for the raglan shaping.

// sleeve stuff
	 // recall six rows to set up
	numRowsReg1=smallTimesRag*2;
	numRowsReg1Beg=numRowsReg1+sixRows;


// front stuff transition-- will almost certainly happen first. 
	numRowsFrontTrans=largeNeckTimes*largeVNeckRows
	numRowsFrontTransBeg=numRowsFrontTrans+sixRows
	

if( numRowsFrontTrans < numRowsReg1){  }

// First transtion is the smaller one -- but zero out if necessary
	numRowsFirstTrans=Math.max(Math.min(numRowsFrontTrans, numRowsReg1),0)
	numTimesFirstTrans = Math.max(Math.min(smallTimesRag,largeNeckTimes),0);
	numRowsFirstTransSinceBeg=numRowsFirstTrans+sixRows;

	sleeveStitchAfter1 =sleeveStAfter0 +numRowsFirstTrans;
	backStitchesAfter1 = backStAfter0  +numRowsFirstTrans;
	frontStitchesAfter1= frontStAfter0 +numRowsFirstTrans/2+  2*Math.floor(numRowsFirstTrans/8);// 1 for first stitch.
	frontStitchesAfter1=Math.min(halfFrontYoke,frontStitchesAfter1);

// Second transtion Version A-- increase every two rows on both edges.
	numRowsSecondTrans=Math.max(numRowsFrontTrans, numRowsReg1)-numRowsFirstTrans;// remaining.
	numRowsSecondTrans=Math.max(0,numRowsSecondTrans);	
	numRowsSecondTransSinceBeg=numRowsSecondTrans+numRowsFirstTransSinceBeg;
	numTimesSecondTrans = Math.max(smallTimesRag,largeNeckTimes) - numTimesFirstTrans;

	if( numRowsFrontTrans < numRowsReg1){  
		// every 2 at neck, every 2 at raglan. 
		transition="neckFirst (aka shallow neck)" 
		sleeveStitchAfter2= sleeveStitchAfter1+ numRowsSecondTrans ;
		backStitchesAfter2=backStitchesAfter1 + numRowsSecondTrans;
		frontStitchesAfter2=frontStitchesAfter1+ numRowsSecondTrans;// on at raglan, one at edge.
	}
	else if (numRowsFrontTrans == numRowsReg1){ 
		// doesn't matter because second transtion will be zero, but say this.
		transition = "neck and sleeve at same time" 
		sleeveStitchAfter2= sleeveStitchAfter1+ numRowsSecondTrans ;
		backStitchesAfter2=backStitchesAfter1 + numRowsSecondTrans;
		frontStitchesAfter2=frontStitchesAfter1+ numRowsSecondTrans;// on at raglan, one at edge.
	}
	else {  // every 4 at neck; every 4 at sleeve.
		transition = "sleeve first (aka deep neck)" 
		sleeveStitchAfter2= sleeveStitchAfter1+ 2* Math.floor(numRowsSecondTrans/4) ;
		backStitchesAfter2=backStitchesAfter1 + 2* Math.floor(numRowsSecondTrans/4);
		frontStitchesAfter2=frontStitchesAfter1+ numRowsSecondTrans/2 + 2* Math.floor(numRowsSecondTrans/8) ;// on at raglan, one at edge.
		}
			
		

/*stuff += "<li><b>EDIT OUT LATER</b>Counting from the cast on, there will be "+ numRowsReg1Beg +" rows for the shoulder shapes and "+ numRowsFrontTransBeg + " for the steep part of the neck shape. Make sure next bit works out ok. The transition type is "+ transition + ".";

	stuff += "<br>after first "+ sixRows+  " ragRows = " + ragRows + " . "; 
	
	stuff += "<br>Neck stuff :( small Rows " + smallVNeckRows + " : times " + smallNeckTimes+ ") ::(  large Rows " + largeVNeckRows + " * times " + largeNeckTimes + " numRowsTrans = "+ numRowsFrontTrans+ " lastFront = " +neckRows + " buttonAdjs " + subStitchesButtonBand +")" ; 
	
	stuff += "<br>Rag stuff :( small Rows 2 : times " + smallTimesRag+") ::(  large Rows 4 * times " + largeTimesRag + " numRowsSleeveTrans = "+ numRowsReg1+ " lastSleeve = " +ragRows + ")" ; 
	
	stuff += "<\/li>";
*/

incTenRowText=" K1, inc 1, knit until there is only 1 stitch before marker 1, (inc 1, k1, slip maker 1, k1, inc 1),  knit until there is only 1 stitch in front of maker 2, (inc 1, k1, slip marker 2, knit 1, inc 1), knit until 1 stitch before marker 3, (inc 1, slip maker 3, k1, inc 1),  knit until there is only 1 stitch in front of maker 4,  (inc 1, k1, slip maker 4, k1, inc1 ) , knit until only 1 stitch is left end of row, inc 1, knit 1. (10 stitches added.)";

incEightRowText="  Knit up to the stitch before marker 1, (inc 1, k1, slip maker 1, k1, inc 1), knit until there is only 1 stitch in front of marker 2, (inc 1, k1, slip marker 2, knit 1),  knit until there is 1 stitch before marker 3, (inc 1, k1, slip maker 3, k 1, inc 1),  knit until there is only 1 stitch in front of marker 4, (inc 1, k 1, slip maker 4, k1, inc 1), knit to end of row.  ( 8 stitches added.) ";

joinText = "<li>Note: You will reach the center front while working the next section.  After you knit "+ add(neckRows,5) + " rows from the cast on, the number of front stitches should be equal to half the number on the back minus " + subStitchesButtonBand + " stitch(es). (The width of these stitches is made up for by the button band).  When that happens, stop increasing at the front edges no matter what the directions say; just knit up the the marker.  " ;

if(backYoke%2==1){ 
	joinText+= ",  increase 1 stitch, to make the number of stitches on the front equal to the number on the back and front equal  "
}

joinText+=" place tips of needle together and begin knitting in rounds. working increases in the pattern established.<\/li>"


//===========================1st shape chunk ==============
if(0 < numRowsFirstTrans){
	three=largeVNeckRows-1
	if(three != 3 ){ 
		andThree=largeVNeckRows -3;}
	else{
		andThree ="" ;}
	
	if(neckRows < numRowsFirstTrans ){ stuff+= joinText; joinText="";} 
	stuff+= "<li>Increase stitches every  2  rows at the four markers and every "+ largeVNeckRows +" rows at the front neck edge as follows: <\/li>";
	stuff+= "<ol style='list-style-type: lower-alpha;'>";
	stuff+= "<li>Hang a row marker at the top of the previous row and the bottom of the next one. (A safety pin will do; you can wait to hang it after you finish the next row.  You will use this to count rows. <\/li>";

stuff+= "<li>Row 1"+ andThree + ": "+ incEightRowText+" <\/li>";
stuff+= "<li>Even Rows: Work row even.<\/li>";
	stuff+= "<li>Row "+three+": "+incTenRowText +" <\/li>";
	stuff+= "<li>Repeat rows 1 through 4  until a total of "+ numRowsFirstTrans +" rows have been worked since you placed the previous row marker.  (You have worked a total of "+ numRowsFirstTransSinceBeg + " rows since the cast on. There will be "+ sleeveStitchAfter1 + " stitches between sleeve markers, "+ backStitchesAfter1 +" between back makers and "+ frontStitchesAfter1 +" stitches on each front edge.<\/li>";
stuff+= "<\/ol>";
}
if(neckRows < numRowsFirstTrans ){ incTenRowText=incEightRowText };
//==========================2nd shape chunk -- has complications to prevent weird skips==============

if(0<numRowsSecondTrans){
	if(neckRows < (numRowsFirstTrans+numRowsSecondTrans) ){ stuff+= joinText; joinText="";} 
	if( numRowsFrontTrans < numRowsReg1){ 

		transition="neckFirst (aka shallow neck)" 
		sleeveStitchAfter2= sleeveStitchAfter1+ numRowsSecondTrans ;
		backStitchesAfter2=backStitchesAfter1 + numRowsSecondTrans;
		frontStitchesAfter2=frontStitchesAfter1+ numRowsSecondTrans;// on at raglan, one at edge.


		stuff+= "<li>You will increase stitches every 2 rows at the markers and every 2 rows at front neck edge as follows: <\/li>";
		stuff+= "<ol style='list-style-type: lower-alpha;'>";
		stuff+= "<li>Hang a row marker at the top of the previous row and the bottom of the next one. (A safety pin will do; you can wait to hang it after you finish the next row.  You will use this to count rows. <\/li>";

		stuff+= "<li>Row 1: "+incTenRowText +" <\/li>";	
		stuff+= "<li>Even Rows: Work row even.<\/li>";
}


	else {
		transition = "sleeve first (aka deep neck)" 
	
		stuff+= "<li>You will increase stitches every 4 rows at the markers and every 4 rows at front neck edge as follows: <\/li>";
		stuff+= "<ol style='list-style-type: lower-alpha;'>";
		stuff+= "<li>Hang a row marker at the top of the previous row and the bottom of the next one. (A safety pin will do; you can wait to hang it after you finish the next row.  You will use this to count rows. <\/li>";
	
	// avoid discontinuity you ended on a row 4, continue 
	if( (numRowsSecondTrans/2)%2 ==1){
		
		// every 2 at neck, every 2 at raglan, increase first.
		
		sleeveStitchAfter2= sleeveStitchAfter1+ 2* Math.ceil(numRowsSecondTrans/4) ;
		backStitchesAfter2=backStitchesAfter1 + 2* Math.ceil(numRowsSecondTrans/4);
		frontStitchesAfter2=frontStitchesAfter1+ numRowsSecondTrans/2 + 2* Math.ceil(numRowsSecondTrans/8) ;// on at raglan, one at		edge.


		stuff+= "<li>Row 1: "+ incTenRowText + "<\/li>";
		stuff+= "<li>Row 2 & 4: Work row even.<\/li>";
		stuff+= "<li>Row 3: Knit all stitches.<\/li>";
	}
	else{
		// 2 at neck, 2 at raglan, inc second.
		
		sleeveStitchAfter2= sleeveStitchAfter1+ 2* Math.floor(numRowsSecondTrans/4) ;
		backStitchesAfter2=backStitchesAfter1 + 2* Math.floor(numRowsSecondTrans/4);
		frontStitchesAfter2=frontStitchesAfter1+ numRowsSecondTrans/2 + 2* Math.floor(numRowsSecondTrans/8) ;// on at raglan, one at		edge.
	
		stuff+= "<li>Row 1: Knit all stitches.<\/li>";
		stuff+= "<li>Row 2 & 4: Purl all stitches.<\/li>";		
		stuff+= "<li>Row 3: "+ incTenRowText + "<\/li>";
	
	}
}

	frontStitchesAfter2=Math.min(halfFrontYoke,frontStitchesAfter2);

stuff+= "<li>Repeat rows 1 and 2  until a total of "+ numRowsSecondTrans +" rows have been worked since you placed the previous row marker.  (You have worked a total of "+ numRowsSecondTransSinceBeg + " rows since the cast on. There will be "+ sleeveStitchAfter2 + " stitches between sleeve markers, "+ backStitchesAfter2 +" between back makers and "+ frontStitchesAfter2 +" stitches on each front edge.)<\/li>";

}
stuff+= "<\/ol>";
if(neckRows < numRowsSecondTrans ){ incTenRowText=incEightRowText };
//===========================3rd chunk ==============
//alert("ragRows="+  ragRows);

numRowsThirdTrans=ragRows-(numRowsSecondTrans+numRowsFirstTrans);

frontStitchesAfter3 = frontStitchesAfter2 + numRowsThirdTrans*2
frontStitchesAfter3=Math.min(halfFrontYoke,frontStitchesAfter3);

// final transtion has slow on sleeve.

if(0<numRowsThirdTrans){
if(neckRows < ragRows ){ stuff+= joinText; joinText="";} 
stuff+= "<li>You will increase every 4 rows at the markers and every 2 rows each neck edge as follows: <\/li>";
stuff+= "<ol style='list-style-type: lower-alpha;'>";

stuff+= "<li>Hang a row marker at the top of the previous row and the bottom of the next one. (A safety pin will do; you can wait to hang it after you finish the next row.  You will use this to count rows. <\/li>";
stuff+= "<li>Row 1:  K1, inc 1, knit to marker knit until only 1 stitch is before end of row, inc 1, knit 1. (2 stitches added.) <\/li>";
stuff+= "<li>Row 2 & 4: Purl all stitches.<\/li>";
stuff+= "<li>Row 3:   K1, inc 1, knit until there is only 1 stitch before marker, (inc 1, k1, slip maker 1, k1, inc 1),  knit until there is only 1 stitch in front of maker, (inc 1, k1, slip marker 2, knit 1, inc 1), knit until 1 stitch before marker, (inc 1, slip maker 3, k1, inc 1),  knit until there is only 1 stitch in front of maker,  (inc 1, k1, slip maker 4, k1, inc1 ) , knit until only 1 stitch is left end of row, inc 1, knit 1. (10 stitches added.) <\/li>";

stuff+= "<li>Repeat rows 1 through 4  until a total of "+ numRowsThirdTrans +" rows have been worked since you placed the previous row marker.  (You have worked a total of "+ add(ragRows,sixRows) + " rows since the cast on. There will be "+ sleeveYoke + " stitches between sleeve markers, "+ backYoke +" between back makers and "+ frontStitchesAfter3 +" stitches on each front edge.<\/li>";
stuff+= "<\/ol>";

}
stuff+= "<\/ol>";
//== Now, one or the other region will change.
 stuff+= "<br><b>Check Point</b>  ";
  stuff+= "The length from the cast on to this point should be approximately "+ Math.round(10*frontArmholeDepth)/10 + " inches deep measured the center sleeve <em>after<\/em> you wash the sweater.  If you made a mistake with your row gauge, and the armhole is too shallow, work a few more rows, continueing to increase at the markers and, if necessary, the neck.  Because you increased at the markers,  you will need to reduce the number of stitches you increase underarms later on.<\/em> ";
  
 if(lengthBeforeRatio !=1){stuff+= ", but "+ Math.round(10*mult(frontArmholeDepth,lengthBeforeRatio))/10 + " inches deep before you wash the sweater";}
 stuff+= "<hr>";
   patternWindow.document.writeln(stuff);stuff="";

 //=============== Lower body now

//== Now, bottom is slow, might be fast.

bodyYokeStitches= backYoke+2*frontStitchesAfter3+2*(halfUnderArmStitches+halfUnderArmStitchesP1);


stuff += "<br><h2>Lower Body<\/h2>";
stuff+= "Discussion: You will now place the sleeve stitches on a holder and work the lower body.";  
stuff += "<ol>";
stuff+= "<li>Slip stitches until you reach the first marker,  place sleeve stitches on a stitch holder. (I used a piece of yarn.) Leave one marker in place; slip back stitches until you reach the next marker.  Place sleeve stitches on a stitch holder.  Leave one marker in place to separate front and back stitches, slip remaining stitches.  Test fit a bit to make sure things seem ok.   <\/li>";
stuff+= "<li> Begin right side facing.<\/li>";
stuff+= "<li>Row 1: Knit across to marker.  Set marker aside. Cast on, increase "+ halfUnderArmStitches +" stitches; place marker; increase "+ halfUnderArmStitchesP1 + " stitches." ;
stuff+=  " Knit to next marker and set aside.";
stuff+= " increase "+ halfUnderArmStitches +" stitches; place marker; increase "+ halfUnderArmStitchesP1 + " stitches. The stitch after the stitch marker is the underarm stitch." ;  
stuff+= " Knit to front edge.  Hang a row marker at the beginning of this row to measure length of body later on.  (There should be "+ bodyYokeStitches + " stitches on the needle. )<\/li>";
stuff+= "<li>Row 2: Purl all stitches.<\/li>";

	boleroRedStitches= 4*Math.floor((rowsToUnderArm+1)/6);
	hemYokeStitches = bodyYokeStitches-boleroRedStitches;
	
	bustStitches = Math.round((hemYokeStitches/4)/2);
	shortRowBustStitches= Math.round(hemYokeStitches/4)-bustStitches;
	backShortRows= Math.ceil(shortRowBustStitches/8)*2;
	
	
if(bolero=="no"){
	hemYokeStitches = bodyYokeStitches;
	stuff+= "<li>Remaining rows: Work in stitch pattern until body measures "+ Math.round(10*lengthToUnderarm)/10 + " inches from previously hung marker. <\/li> ";  
}
else { 
	
		
	stuff+= "<li>When knitting a bolero, you will want to taper the body.  To do so, decrease 1 stitch on either side of the two stitch markers every 6 rows; this reduces 4 stitches across the row. Knit the other 5 stitches with no reductions. Begin decreaseing the 5th row after you began the yoke.<\/li>";
	stuff+= "<li>Remaining rows: Work until body measures "+ Math.round(10*lengthToUnderarm)/10 + " inches from previously hung marker. (If your row gauge was entered correctly, there should be "+ rowsToUnderArm +" rows since you hung the marker and "+ hemYokeStitches +" stitches on the needle.)<\/li> ";
	
	stuff+= "<li>Optional: Try on the sweater.  Decide if you wish to make the back a little longer than the front.  If you do, work short rows.<\/li>";
	stuff+= "<li>Count over "+ bustStitches + " stitches from each front edge. Place markers.  Locate center back, place two markers "+ bustStitches +" stitches on either side of center back <\/li> ";
	stuff+= "<li>Row 1: Right side facing. Knit past first marker to fourth marker. Wrap and turn.  <\/li> ";
	stuff+= "<li>Row 2: Wrong side facing. Purl to first marker. Wrap and turn. <\/li> ";
	stuff+= "<li>Row 3: Knit 8 stitches past stitch wrapped on previous knit row.  Wrap and turn.  <\/li> ";
	stuff+= "<li>Row 4: Purl 8 stitches past stitch wrapped on previous purl row.  Wrap and turn.  <\/li> ";
	stuff+= "<li>Row 5: Repeat rows 3 and 4 until you are are only working stiches bewteen the back makers ending on a purl row. Then finish working short rows by purling to the end of a row. (You will knit approximately " + backShortRows +" short rows.  <\/li> ";


}
 lengthFromCastOn= lengthToUnderarm-lengthOneRow + eval(p.bodyTrim.value);

	halfHemYokeStitches= hemYokeStitches/2;
	halfHemStitches=  Math.round(halfHemYokeStitches* hemSnug); hemStitches= 2* halfHemStitches;
	sideDec =halfHemYokeStitches- halfHemStitches;
	
	
stuff+= "<li>Begin knit side facing. Place a stitch marker in center back. Change to smaller needles. Knit row, decreasing "+ sideDec + " stitches evenly between edge and marker, and " + sideDec + " evenly between back and front edge. <\/li>";
stuff+= "<li>Knit in "+oneByOneRib+" until trim measures "+Math.round(mult(p.bodyTrim.value,lengthBeforeRatio)*10)/10  +" inches and the length is "+ Math.round( lengthFromCastOn*lengthBeforeRatio * 10)/10 +" inches measured from marker placed after you divided the yoke. <\/li>";

stuff+= "<li>Bind off.<\/li>";

stuff += "<\/ol>";

  patternWindow.document.writeln(stuff);stuff="";
  
stuff += "<br><h2>Sleeves<\/h2>";
stuff += "<ol>";
stuff+= "<li>Remove stitches for one sleeve from stitch holder, place on the larger diameter circular needle. At underarm gap, attach yarn, cast on  "+ halfUnderArmStitches +" stitches; place marker; cast on "+ halfUnderArmStitchesP1 + " stitches.  Join tips to begin knitting rounds. <\/li>";

if(bolero=="no"){
	hemYokeStitches = bodyYokeStitches;
	stuff+= "<li>Remaining rows: Work in stitch pattern until body measures "+ Math.round(10*lengthToUnderarm)/10 + " inches from previously hung marker. <\/li> ";  
}
else { 
	boleroRedStitches= 4*Math.floor((rowsToUnderArm+1)/6);
	hemYokeStitches = bodyYokeStitches-boleroRedStitches;
	decCuffStitches = Math.floor(divide(sleeveYoke,5));
		
	stuff+= "<li>Row 1: Knit 1 row even, ending at the stitch marker. <\/li>";
	stuff+= "<li>Row 2: Decrease "+ decCuffStitches +" stitches evenly over next row. <\/li>";
	stuff+= "<li>Row 3: Purl all stitches. <\/li>";
	stuff+= "<li>Row 4: Knit all stitches. <\/li>";
	stuff+= "<li>Row 5: Bind off in purl.<\/li>";
}

stuff += "<\/ol>";

//================
// Front Trim
totTrimStitches  = "??"
frontTrimStitches="??"; 
neckTrimStiches="??";

diagonal=Math.sqrt(frontArmholeDepth*frontArmholeDepth + neckWidth*neckWidth/4);

lengthFrontTrim=lengthToUnderarm+diagonal;
frontTrimStitches = Math.round(mult(lengthFrontTrim,p.mainStIn.value)*0.80)+3;

frontRows= Math.round(mult(lengthToUnderarm+frontArmholeDepth,p.mainRowIn.value))+4

stitchesToRows= Math.round((frontTrimStitches/frontRows)*10);

stuff+= "<br><h2>Front Trim<\/h2>";
stuff+= "<ol>";
stuff+= "<li>Pick up " + frontTrimStitches + " stitches along one sweater front; pick up lives stitches you cast on stitches on back neck neck (and remove waste yarn); pick up " +frontTrimStitches + " stitches along the other sweater front. Do this in a way that lets you begin knitting all knit garter stitch, beginning with the right side facing. (Note: You will be picking up approximately "+ stitchesToRows + "stitches every  10 rows.) <\/li>";

stuff+= "<li>Knit 3 rows garter stitch  <\/li>";
stuff+= "<li>Row 4: Wrong side should be facing.  Knit 4 stitches, bind off leaving 4 live stitches at the end of the round. Don't break yarn.<\/li>";
stuff+= "<li>Check fit.  I designed the garter stitch trim to draw the front up a bit. However, the exact amount will depend on how tightly you knit garter stitch compared to stockinette.  If it draws up too much, rip back and pick up more stitches. If it doesn't draw up enough, rip back and pick up fewer stitches. Bear in mind: If you yarn is cotton and the rows shrink in height, but stitches stay the same widht,  the amount the sweater draws up will decrease when you wash your sweater. (That's what happened with  my yarn, which shrank 8% in length but not in width. I have to admit, it as difficult not to rip back.  I just figured, I could, if necessary, rip back after washing. ) <\/li>";

stuff+= "<\/ol>";

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

stuff += "<br><h2>Idiot Cord<\/h2>";
stuff += "<ol>";
stuff += "<li>Place then 4 live stitches near one hem edge on a double pointed needle.  With knit side of the sweater facing you, knit 4 stitches.  Transfer needle with the stitches to your left hand, but <em>don't turn work.</em>  Slide stitches to the right tip. Pull yarn firmly behind work, and knit 4 stitches. Repeat until ties measure about 6 inches. Break yarn, pull through open loops.  Thread yarn into a tapestry needle and weave it inside the i-cord.<\/li>";
stuff += "<li>Repeat for the other side; this time you'll need to attach the yarn. <\/li>";
stuff += "<\/ol>";

 

//================
 
stuff += "<br><b>Finish up<\/b><br>";
stuff+= "<ol>";
//alert(lengthBeforeRatio);

 stuff+= "<li>Weave in ends, block as appropriate for yarn type.<\/li>";
  stuff+= "<\/ol>";
  patternWindow.document.writeln(stuff);stuff="";
  
	  
	
	    patternWindow.document.writeln(stuff);stuff="";
  
  
//  
     
 // 
 yarnUsedText();
/* 
   stuff+= "<ol style='list-style-type: lower-alpha;'><li><\/li>"; 
   stuff+= "    <li>Test Line<\/li>"   
   
     
*/

     stuff+= "<HR>Copyright, Lucia Liljegren 2005<br> You may print an individual copy directly from my site, and knit your sweater. No other form of reproduction or redistribution permitted.";
     patternWindow.document.writeln(stuff);stuff="";
// close the window===========
	           
    patternWindow.document.write("<\/BODY><\/HEAD><\/HTML>")
    patternWindow.document.close();
	
 }
    
	
	//=================================
	
	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
    // rib
    totStitchesBodyRib= bodyStitches*(bodyRibRows+1);// body stitches to permit flexibility for knitter.
    totStitchesBod=bodyStitches*(rowsToUnderArm+2+backShortRows);// 2 for mismeasure slop.

// sleeves
    // rib
    
    totStitchesSleeve= 6*bicepStitches*(extraRows);
	totStitchesCuffRib=0; // because accounted for in sleeve.

// yoke
    stitchesBaseYoke=frontYoke+backYoke+2*sleeveYoke;
    stitchesAfterFirst= stitchesBaseYoke-8*largeTimesRag; largeRows=(largRegRag+1)*largeTimesRag;
    stitchesAfterSecond=stitchesAfterFirst - 8*smallTimesRag;  smallRows=(smallRegRag+1)*smallTimesRag
    
    totStitchesYoke=stitchesBaseYoke*(smallRegRag+2)+ smallRows *(stitchesAfterSecond+stitchesAfterFirst)/2 + (stitchesBaseYoke+stitchesAfterFirst)*largeRows/2
  
    totalPlacketStitches=0; 
    totStitchesYoke +=totalPlacketStitches;
	// I'm going to be approximate. Since I always do the slow increase first, this underestimate the yarn savings.
	totalStitchesVneck=(edgeNeckStitches-2)*(neckRows+sixRows); // because neckrows if after the first broup divide and multiply by 2.  -2 for weirdness at shaped edges.
	
	totStitchesYoke = totStitchesYoke-totalStitchesVneck;
	
    
// neck or collar-- estimate,. 
	totStitchesNeckTrim=(2*frontTrimStitches +2*remSleeveAfterSmall+neckStitches)*5*1.10; // 1 for bind off; 110% for rib, 10% for extra stitches for shaping neck.
	icordStitches= 4*Math.round(6.5,p.mainRowIn.value)*1.25;// 1.25 to make up for lengthening effect of I cord.
	totStitchesNeckTrim += icordStitches;
// 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/


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);
swatchYds= yardageFactor*normalizedInch* totStSwatch/36 ; swatchMeters = swatchYds*metersPerYard;

bodyYards     =  yardageFactor*normalizedInch* (totStitchesBod+totStitchesBodyRib)/36; 		bodyMeters=bodyYards*metersPerYard
sleeveYards   =2*yardageFactor* normalizedInch*(totStitchesSleeve+totStitchesCuffRib)/36;	sleeveMeters=sleeveYards*metersPerYard
yokeYards     = yardageFactor*normalizedInch* totStitchesYoke/36;				yokeMeters=yokeYards*metersPerYard


collarYards   =yardageFactor*normalizedInch* totStitchesNeckTrim/36;				collarMeters=collarYards*metersPerYard

totalYards=bodyYards+sleeveYards+yokeYards+collarYards +swatchYds ;  		totalMeters=totalYards*metersPerYard

}


// ==== yarn used. 
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.<br>  ";
 stuff+= "I rarely pad my estimates. However, this time, I have been a little bit conservative estimating how much yarn you need for the lower sleeves and body. This is because I think most knitters will want to try on the garment and decide if they like the amount the body draws after reducing stitches for the garter stitch. If you decide you prefer the sweater not to draw in, there should be enough yarn to rip back and work the trim without the reductions prior to the garter stitch rows. <br>  ";

 
  stuff+= "<table>";
stuff+= "<tr><td>Item<\/td>		<td> yards required<\/td>	<td> meters required<\/td><\/tr>";
stuff+= "<tr><td>Whole Sweater<\/td>	<td>" + Math.round(totalYards)   +" yards<\/td>	<td>"+ Math.round(totalMeters)    +" meters<\/td><\/tr>";
 stuff+= "<tr><td>Two lower Sleeves<\/td><td>"+  Math.round(sleeveYards)  +" yards<\/td>	<td>"+ Math.round(bodyMeters)  +" meters<\/td><\/tr>";
 stuff+= " <tr><td>Lower Body<\/td>	<td>" + Math.round(bodyYards)   +" yards<\/td>	<td>"+ Math.round(sleeveMeters)   +" meters<\/td><\/tr>";
 stuff+= " <tr><td>Yoke<\/td>		<td>" + Math.round(yokeYards)   +" yards<\/td>	<td>"+ Math.round(yokeMeters) +" meters<\/td><\/tr>";
  stuff+= " <tr><td>Front trim <\/td><td>"+ Math.round(collarYards)+" yards<\/td>	<td>"+ Math.round(collarMeters)  +" meters<\/td><\/tr>";
   stuff+= " <tr><td>Recommended for swatch:<\/td><td>"+ Math.round(swatchYds)+" yards<\/td>	<td>"+ Math.round(swatchMeters)  +" meters<\/td><\/tr>";
 stuff+= " <\/table>";
     
 patternWindow.document.writeln(stuff);stuff="";
	           
    
}

