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" }

// 

//make sure the toggle doesn't fill with letters! 


if(p.changeG.selectedIndex==0){ p.widthAfter.value=p.widthBefore.value; p.lengthAfter.value=p.lengthBefore.value; }// tighten for "yes"

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;

lengthFactor=divide(p.lengthBefore.value,p.lengthAfter.value);
widthFactor=divide(p.widthBefore,p.widthAfter.value);

garterFactor=(1-1/6);
//

// 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;
  incStitches=Math.round(totalStitches*(1-garterFactor)); 
 castOn=totalStitches-incStitches; //p.castOn.value=castOn;

 
 two= Math.max(Math.round(2.25*totalStitches/63),2); p.two.value=two; // 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.neckIncM.value=p.neckInc.value; // approximation. may change later.


beforeNeckStitches=totalStitches-neckInc;

p.beforeNeckStitches.value =beforeNeckStitches; p.beforeNeckStitchesM1.value= sub(p.beforeNeckStitches.value,1); 
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(lengthFactor*10*trimAdjust)/10;// half of trim plus reduction row.

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

 
 rowsToNeckShape=2*Math.ceil(mult(halfNeckWidthAfter, p.mainRowIn.value)/2);  p.rowsToNeckShape.value= rowsToNeckShape

// 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;
 

 // 
 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--------------
 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(1,p.mainRowIn.value);
  halfShoulderWidth=lengthFactor*(divide( p.shoulderWidth.value,2)-trimAdjust)-lengthOneRow; 
    halfShoulderWidthBack=lengthFactor*(divide(p.shoulderWidth.value,2)); 
p.halfShoulderWidth.value=Math.round(halfShoulderWidth*10)/10; p.halfShoulderWidth2.value=Math.round(halfShoulderWidthBack*10)/10;
    
 sideShoulderWidth=divide(  sub(p.shoulderWidth.value,p.neckWidth.value),2 ) -lengthOneRow;
 shoulderRows=2*Math.round(mult(sideShoulderWidth,p.mainRowIn.value)/2);
 redShoulderStitches=Math.round(mult(p.shoulderSlope.value,p.mainStIn.value));
 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,1); 
 p.fastShoulderRows.value=incRepSmall*2;   p.fastShoulderRowsM.value=sub(p.fastShoulderRows.value,1); 
 
 fastShoulderFirstHalf=2*Math.ceil((incRepSmall+1)/2); p.fastShoulderFirstHalf.value=fastShoulderFirstHalf-1; p.fastShoulderFirstHalfM.value=p.fastShoulderFirstHalf.value
 p.fastShoulderSecondHalf.value=sub(2*(incRepSmall+1), fastShoulderFirstHalf) // 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
 }
 // 

 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);
 
 firstShapeRow=rowsToNeckShape;
 preShoulder=mult( p.neckInc.value,2)+2;
 
 rowsToEdge= firstShapeRow+preShoulder+shoulderRows
 //alert(" firstShapeRow"+ firstShapeRow + " + preShoulder" + preShoulder+" + shoulderRows"+ shoulderRows +"= rowsToEdge"+ rowsToEdge + " <  quarterRows"+ quarterRows);
 
  //alert("first = "+ firstShapeRow +": preShoulder = "+preShoulder +  " : rowsToEdge " + rowsToEdge);
  
 sideRowsHalf = quarterRows- rowsToEdge;  p.sideRowsHalf.value=sideRowsHalf
 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.bottomStitches.value=sub(p.afterShoulderStitches.value,p.armholeStitches.value);
 
 if(eval(p.sideRowsHalf.value)<3){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.
 hemStitches= Math.round(mult(p.chest.value,p.mainStIn.value)*garterFactor/2)*2; 
 p.hemStitches.value=hemStitches;
 hemRows=Math.round(mult(p.chest.value,p.mainRowIn.value)/2)*2; 
  p.hemRows.value=hemRows;
  
widthArmOpening=sub( divide(p.chest.value,2),p.shoulderWidth.value);
//alert(widthArmOpening);
//armHoleTrimStitches=Math.round((mult(widthArmOpening,p.mainStIn.value)*7/8));  p.armHoleTrimStitches.value=armHoleTrimStitches;

neckTrimStitches=Math.round(mult(p.neckWidth.value,p.mainStIn.value)*garterFactor)*2; p.neckTrimStitches.value=neckTrimStitches;
 p.twoArm.value=two;
 p.twoHem.value=two+1;
 p.twoNeck.value=two;
 
 // 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;
  // add bindoffs and any reduction rows.
 totalStitchesKnit += castOn*(two+2)*2 +neckTrimStitches *(eval(p.twoNeck.value)+1) + hemStitches*(eval(p.twoHem.value)+1) +2*armHoleTrimStitches*(eval(p.twoArm.value)+1)
 
 //alert(totalStitchesKnit +"  :  "+ totalStitches +"  :  "+ quarterRows);
  
 p.totalStitchesKnit.value=totalStitchesKnit;
 
 inchPerStitch=divide(p.widthBefore.value,p.stitches.value); 
 inchPerRow=divide(p.lengthBefore.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.ceil(mult(4.5,p.mainStIn.value)+6); 
 recRows= Math.ceil((mult(4.5,p.mainStIn.value),p.mainRowIn.value) + 8); 
 stitchesForGaugeSwatch=(recStitch * recRows);

 
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
*/
