function designBack(){
/* 
@copyright 2004 Lucia Liljegren
*/

p=document.sweaterForm;

warn="";
if(window.location.hostname!="" && window.location.hostname!="www.thedietdiary.com" ){  window.location.hostname="www.thedietdiary.com" }

// 

mainStIn=divide(p.stitches.value,p.widthAfter.value); p.mainStIn.value=Math.round(100*mainStIn)/100;
mainRowIn=divide(p.rows.value,p.lengthAfter.value); p.mainRowIn.value=Math.round(100*mainRowIn)/100;

p.mainNeedle2.value=p.mainNeedle.value

 garterFactor=(1-1/6);// I'll use thsi for crochet stuff later.


// set sizes
missesSize= (2*(eval(p.missesSize.selectedIndex)-1))+4 
missesSizeIndex=eval(p.missesSize.selectedIndex-1)
var numSizes=8


if(missesSize< 12){ wearerChest=34+missesSizeIndex*1;}
else{	 wearerChest=38.5 +(missesSizeIndex-4)*1.5; }

if(p.missesSize.selectedIndex==0){custom=1;}
else{
    chestEase=1.5*(1 +1*wearerChest/34);  p.chest.value=Math.round((wearerChest+chestEase)*10)/10;
    shoulder = 12.5+ missesSizeIndex*0.32; shoulderEase=5*(1/2)+0.2;
    p.shoulderWidth.value = Math.round(10*(shoulder+shoulderEase))/10;
    armholeDepthSweater = 8 + missesSizeIndex*(9.5-8)/numSizes;p.armHoleDepth.value =Math.round(10*(armholeDepthSweater + 0.8))/10;  // 0.8" is extra for vest.
    sweaterLength=24.0+Math.max(missesSizeIndex,7)*0.25; p.totalLength.value=Math.round(sweaterLength*10)/10-5.8

    headCirc = 21.25 + (23-21.25)*missesSizeIndex/numSizes;
    headNeck= 0.8* headCirc/2.7;
    shoulderNeck= shoulder/3;

    largeNeck= Math.max(headNeck,shoulderNeck)
    smallNeck=Math.min(headNeck,shoulderNeck)
 
     p.neckWidth.value= Math.round(10*(largeNeck+.1))/10;
     p.shoulderSlope.value=1.0
     
    }
//   

 totalLength = p.totalLength.value;
 totalStitches=Math.round(mult(totalLength,p.mainStIn.value));  p.totalStitches.value=totalStitches; p.totalStitches2.value=totalStitches;
incStitches=Math.round(totalStitches*(1-garterFactor)); // for reducing with chain stitch.
 castOn=totalStitches-incStitches; //p.castOn.value=castOn;
 
// two= Math.max(Math.round(2.25*totalStitches/63),2);  // used to set up trim.


//
neckDepth=divide(p.neckWidth.value,6)
neckInc=Math.max(Math.round(mult(neckDepth,p.mainStIn.value)),2);  p.neckInc.value=neckInc-2; p.totNeckInc.value=neckInc;
p.neckIncM.value=p.neckInc.value; // approximation. may change later.

beforeNeckStitches=totalStitches-neckInc;

p.beforeNeckStitches.value =beforeNeckStitches;p.beforeNeckStitches2.value=p.beforeNeckStitches.value 
neckIncLength= divide(neckInc,p.mainStIn.value);
bindOff=sub(p.beforeNeckStitches.value,incStitches);//p.bindOff.value=bindOff;

widthAdjust=2* divide(p.neckInc.value,p.mainRowIn.value);// this is width taken up by increase. There are two rows per.
//trimAdjust= divide(two/2 +1,p.mainRowIn.value); p.trimAdjust.value=Math.round(10*trimAdjust)/10;// half of trim plus reduction row.
trimAdjust=0;  // the crochet chain trim has zero thickness.

halfNeckWidth=Math.round(( divide(p.neckWidth.value,2)- widthAdjust-trimAdjust) *20)/20; // on front.
halfNeckWidthBack=Math.round(( divide(p.neckWidth.value,2)- widthAdjust) *20)/20; // on back
       //p.halfNeckWidth.value=halfNeckWidth; p.halfNeckWidth2.value=halfNeckWidthBack;


 rowsToNeckShape=2*Math.ceil(mult(halfNeckWidth, p.mainRowIn.value)/2);  p.rowsToNeckShape.value= rowsToNeckShape; p.rowsToNeckShape2.value=p.rowsToNeckShape.value
 rowsForNeckShape=2*(neckInc-2)+2;
 rowsToEndNeckShape= rowsToNeckShape+rowsForNeckShape; p.rowsToEndNeckShape.value=rowsToEndNeckShape;

// fill increases evenly across row
 regions=incStitches
 incPortion=bindOff;
 
 incRepSmall=Math.floor( incPortion/ regions); //p.incRepSmall.value=incRepSmall-1; p.incRepSmallM.value=p.incRepSmall.value
 incRepLarge=Math.ceil( incPortion/ regions); // p.incRepLarge.value=incRepLarge-1; p.incRepLargeM.value=p.incRepSmall.value
 
 largeReps= incPortion%regions
 smallReps=regions-largeReps;
 
 smallRepTimes=smallReps-1;  //p.smallRepTimes.value=smallRepTimes; p.smallRepTimesM.value=smallRepTimes;
 largeRepTimes=largeReps; //p.largeRepTimes.value= largeRepTimes; p.largeRepTimesM.value= largeRepTimes;
 
/* /*  I don't think I'll need this.
 // 
 if(largeRepTimes%2==0){ // large is even, split into two groups.
    //   Times						stitches
	p.oddRepTimes.value=   smallRepTimes;       p.incRepOdd.value=incRepSmall-1;
	p.evenRepTimes.value=  largeRepTimes/2;     p.incRepEven.value=incRepLarge-1;
	p.evenRepTimes2.value= largeRepTimes/2;     p.incRepEven2.value=p.incRepEven.value;
    }
    
else {  // large is odd, small may be ven or odd, split into two groups.  
	p.oddRepTimes.value=   largeRepTimes;      		p.incRepOdd.value=incRepLarge-1;    	
        p.evenRepTimes.value=  Math.floor(smallRepTimes/2);    p.incRepEven.value=incRepSmall-1;
	p.evenRepTimes2.value= Math.ceil(smallRepTimes/2);   	p.incRepEven2.value=p.incRepEven.value

}

preInc=Math.floor((incRepSmall)/2);   p.preInc.value=preInc;
postInc=incRepSmall-preInc-1;           p.postInc.value=postInc;  

  
 //  fill increases evenly across row with 1 less--------------
 /*  I don't think I'll need this.

 pad=1
 regions=incStitches-1
 incPortion=bindOff-2*pad;// (Because I want to pad sides by 2 stitch.)
 
 incRepSmall=Math.floor( incPortion/ regions); //p.incRepSmall.value=incRepSmall-1; p.incRepSmallM.value=p.incRepSmall.value
 incRepLarge=Math.ceil( incPortion/ regions); // p.incRepLarge.value=incRepLarge-1; p.incRepLargeM.value=p.incRepSmall.value
 
 largeReps= incPortion%regions
 smallReps=regions-largeReps;
 
 smallRepTimes=smallReps-1;  //p.smallRepTimes.value=smallRepTimes; p.smallRepTimesM.value=smallRepTimes;
 largeRepTimes=largeReps; //p.largeRepTimes.value= largeRepTimes; p.largeRepTimesM.value= largeRepTimes;
 
 if(largeRepTimes%2==0){ // large is even, split into two groups.
    //   Times						stitches
	p.oddRepTimesM.value=   smallRepTimes;       p.incRepOddM.value=incRepSmall-1;
	p.evenRepTimesM.value=  largeRepTimes/2;     p.incRepEvenM.value=incRepLarge-1;
	p.evenRepTimes2M.value= largeRepTimes/2;     p.incRepEven2M.value=p.incRepEvenM.value;
    }
    
else {  // large is odd, small may be ven or odd, split into two groups.  
	p.oddRepTimesM.value=   largeRepTimes;      		p.incRepOddM.value=incRepLarge-1;    	
        p.evenRepTimesM.value=  Math.floor(smallRepTimes/2);    p.incRepEvenM.value=incRepSmall-1;
	p.evenRepTimes2M.value= Math.ceil(smallRepTimes/2);   p.incRepEven2M.value=p.incRepEvenM.value

}

preInc=Math.floor((incRepSmall)/2);     p.preIncM.value=preInc+pad;
postInc=incRepSmall-preInc-1;           p.postIncM.value=postInc+pad;  
 
*/ 
 
 // shoulder stuff=====================
 lengthOneRow=divide(0,p.mainRowIn.value);  // because 0 rows are knit after before putting stitches on waste yarn.
  halfShoulderWidth=(divide( p.shoulderWidth.value,2)-trimAdjust)-lengthOneRow; 
    halfShoulderWidthBack=(divide(p.shoulderWidth.value,2)); 
	//p.halfShoulderWidth.value=Math.round(halfShoulderWidth*10)/10; p.halfShoulderWidth2.value=Math.round(halfShoulderWidthBack/10);
    
 totalShoulderRows=2*Math.round(mult(p.shoulderWidth.value, p.mainRowIn.value)/4); p.totalShoulderRows.value= totalShoulderRows;
 shoulderRows=totalShoulderRows-rowsToEndNeckShape;
 redShoulderStitches=Math.max(Math.round(mult(p.shoulderSlope.value,p.mainStIn.value)),1);// force at least 1 
 p.afterShoulderStitches.value=totalStitches-redShoulderStitches;


 // shoulder; 
 regions=redShoulderStitches;
 shapeOps=(shoulderRows-2)/2;// throw extra two to edge increases.
if(shapeOps < 1){warn += "Use finer yarn. This sweater has no shoulders. "}

if(0<regions){ 
    incRepSmall=Math.floor(shapeOps/ regions);
    incRepLarge=Math.ceil(shapeOps/ regions);

    largeReps= shapeOps%regions;
    smallReps=regions-largeReps;
}
else{incRepSmall=0;incRepLarge=0;largeReps=0;smallReps=1;
}
 
 p.slowShoulderTimes1.value=largeReps;  p.slowShoulderTimes1M.value=p.slowShoulderTimes1.value
 p.fastShoulderTimes.value=smallReps-1; p.fastShoulderTimesM.value=p.fastShoulderTimes.value
 
 p.slowShoulderRows.value=incRepLarge*2;   p.slowShoulderRowsM.value=sub( p.slowShoulderRows.value,0); 
 p.fastShoulderRows.value=incRepSmall*2;   p.fastShoulderRowsM.value=sub(p.fastShoulderRows.value,0); 
 
 fastShoulderFirstHalf=Math.ceil((incRepSmall+1)); p.fastShoulderFirstHalf.value=fastShoulderFirstHalf; p.fastShoulderFirstHalfM.value=p.fastShoulderFirstHalf.value
 fastShoulderSecondHalf=sub(2*(incRepSmall+1), fastShoulderFirstHalf);
  
 p.fastShoulderSecondHalf.value=  fastShoulderSecondHalf; p.fastShoulderSecondHalfM.value =p.fastShoulderSecondHalf.value// the -1 is for the purl row.

if(regions==0){
 p.fastShoulderFirstHalf.value=shoulderRows-1; p.fastShoulderFirstHalfM.value=p.fastShoulderFirstHalf.value; p.fastShoulderSecondHalf.value=0
 }
 
// armhole
 //p.sideRowsLength.value= Math.round( (lengthFactor*(divide(p.chest.value,4)-trimAdjust))*10)/10;
 //p.sideRowsLengthM.value= Math.round( (lengthFactor*(divide(p.chest.value,4)))*10)/10;
 
 quarterRows =Math.round(mult(sub(p.chest.value,trimAdjust),p.mainRowIn.value)/4);
 p.underArmRow.value=quarterRows;
 
 firstShapeRow=rowsToNeckShape;
 preShoulder=mult( p.neckInc.value,2)+2;
 
 rowsToEdge= quarterRows-totalShoulderRows;
//alert(" firstShapeRow"+ firstShapeRow + " + preShoulder" + preShoulder+" + shoulderRows"+ shoulderRows +"= rowsToEdge"+ rowsToEdge + " <  quarterRows"+ quarterRows);
 
  //alert("first = "+ firstShapeRow +": preShoulder = "+preShoulder +  " : rowsToEdge " + rowsToEdge);
  
 sideRowsHalf = quarterRows-  totalShoulderRows; 
 //alert("sideRowsHalf "+ sideRowsHalf +" : = "+  quarterRows +" :- "+  totalShoulderRows);
 
   p.sideRowsHalf.value=sideRowsHalf; p.sideRowsHalf2.value=p.sideRowsHalf.value
 afterArmRow= quarterRows+rowsToEdge;  p.afterArmRow.value= afterArmRow;
 
 p.rowsToEndSh2.value=add(p.afterArmRow.value, shoulderRows);
 p.afterSecondNeck.value=add( p.rowsToEndSh2.value,  rowsForNeckShape);
 p.centerBackRows.value=add( p.afterSecondNeck.value,p.rowsToNeckShape.value)
// p.one.value=Math.round(two/2)+1 // value for trim plus reductin row.
// p.two3.value=p.two.value
 

 //p.backLength.value=Math.round(10*(mult(lengthFactor,p.chest.value)/2-trimAdjust) )/10;
 //p.backLengthM.value=p.backLength.value;
 
 p.armholeStitches.value=Math.round(mult(p.armHoleDepth.value,p.mainStIn.value)); p.armholeStitchesRaise.value=p.armholeStitches.value;
 p.bottomStitches.value=sub(p.afterShoulderStitches.value,p.armholeStitches.value) 


 if(eval(p.sideRowsHalf.value)<1){warn="Use finer yarn for a vest in this size. There aren't enough rows under the arm to do the shaping.  If you want to use yarn this thick, either increase the chest dimension or decrease the shoulder dimension below."}
 p.tooFewStitches.value=warn;
 
 // trim at end.
  
widthArmOpening=sub( divide(p.chest.value,2),p.shoulderWidth.value);
//alert(widthArmOpening);

 
 // the little neckInc bit is add two things, multiply by two, divide by two yada, yada.
 // count teh bind offs! 
 armStitchPickUp=mult(p.sideRowsHalf.value,7/8);// both 1 st/2 rows--but bothsides each armhole;
 armHoleTrimStitches= Math.round( mult(p.armholeStitches.value,2*7/8) + armStitchPickUp);
 totalStitchesKnit= (totalStitches * quarterRows); // +1 is the reduction row.
 totalStitchesKnit =  totalStitchesKnit-(shoulderRows*redShoulderStitches)/2 - rowsToNeckShape*neckInc- (2*neckInc-2);
  totalStitchesKnit=totalStitchesKnit*4;
  hemStitches=Math.round(mult(p.centerBackRows.value,2)); //
  neckTrimStitches=Math.round(2*mult(p.neckWidth.value,p.mainStIn.value));
  // add bindoffs and any reduction rows -- figure out after chain. 

totalStitchesKnit += castOn*(2)*2  + hemStitches*2 +2*armHoleTrimStitches*2 + neckTrimStitches*2; // 2 for a row of sc
 
 //alert(totalStitchesKnit +"  :  "+ totalStitches +"  :  "+ quarterRows);
  
 p.totalStitchesKnit.value=totalStitchesKnit;
 
 inchPerStitch=divide(p.widthAfter.value,p.stitches.value); 
 inchPerRow=divide(p.lengthAfter.value,p.rows.value)
 normalizedInch= Math.sqrt(inchPerStitch*inchPerStitch+ inchPerRow*inchPerRow);
 p.normInSt.value= normalizedInch;
 p.inSt.value=inchPerStitch;

  
 luMeters=375; luNormalizedInch=0.377;
 recStitch= Math.max(Math.ceil(mult(4.5,p.mainStIn.value)+6),40); 
 recRows=  Math.max(Math.ceil((mult(4.5,p.mainStIn.value),p.mainRowIn.value) + 8),60); 
 stitchesForGaugeSwatch=2* (recStitch * recRows); // I've never knit fewer than 2 gauge swatches!

 
yardageFactor=Math.PI*1.02 // current factor.  about pi * some fudge
 //alert(recStitch + ":"+ recRows+ ":"+ yardageFactor + ":"+ stitchesForGaugeSwatch);
 
inchesReq=(yardageFactor*(totalStitchesKnit + stitchesForGaugeSwatch)*normalizedInch) 
p.ydsRequired.value=Math.ceil(1.02* inchesReq /36);
p.metersRequired.value=Math.ceil( 1.02* (inchesReq *2.54/100));
/* 
*/
 }
/* 
@copyright 2004 Lucia Liljegren
*/
