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

pester = document.location;
p =document.capeForm;

expireDate = new Date;
expireDate.setMonth(expireDate.getMonth()+6);
username = pester;

document.cookie="pester=" + username + "expires="+ expireDate.toGMTString(); 

if(document.cookie ==""){
/* @copyright 2004 Lucia Liljegren
*/

    alert("Please set your browser to accept cookies. You must accept cookies to run this page.");
}
else {
    pesterZero=document.cookie.split("/")[0];  //figure out if local or away.    
    pesterRead = document.cookie.split("/")[4];
    pesterAway=document.cookie.split("/")[2];    
}
pester = "yes";
    if(pesterZero == "pester=file" || pesterRead =="lucia"){pester="no"}
else if( pesterAway == "www.thedietdiary.com"){pester="no"}
else if( pesterAway == "thedietdiary.com"){pester="no"}
 
else{ pester = "yes"; 
   p.mainStIn.value=0.01;
    p.mainRowIn.value=0.01;
    alert(" Please run my programs from my site at www.thedietdiary.com!"  ) } ;
//===================
if(pester == "no"){
p.tooFewStitches.value="javascript is on";

/* @copyright 2004 Lucia Liljegren*/

    var shoulderDrop = 1;
    
    // mimic other code as much as possible.
    
    if(eval(p.mainStIn.value) < 0.00001) {p.mainStIn.value = 0.001; }
    if(eval(p.mainRowIn.value) < 0.00001) {p.mainRowIn.value = 0.001; }
    
     numTrap=8.
     // I tested. 330 is just a bit too small for the total  angle. 
     // my green with pink I cord collar is 8* 30 + 2*45 = 240 + 90 = 330.
     // it  doesn't open up *quite* fast enough over the shoulders. 
     //360 would be table cloth like.
     //  So, I'm going to make totalAngleDeg = 340 as the target. 
     ponchoAngleDeg=330*numTrap/(numTrap+2); // This is the flare below the shoulders.
     ponchoAngleRad=ponchoAngleDeg*Math.PI/180;
     // number of rows between shaping 
widthChangePerShape=divide(numTrap*2,p.mainStIn.value);
lengthChangePerShape=divide(widthChangePerShape,ponchoAngleRad);
rowsPerShape=Math.ceil(mult(lengthChangePerShape,p.mainRowIn.value));// angle is always less than requested.
// fill in all rows having to do with increasing:
p.incRows.value=rowsPerShape;
//p.incRows1.value=rowsPerShape;
p.incRow2.value=rowsPerShape;
p.incRow3.value=rowsPerShape;

row8=rowsPerShape+3
row7=row8-1

p.row7.value=row7;
p.row8.value=row8;

row4=Math.round(rowsPerShape/2)*2-1
p.incRow4.value=Math.round(rowsPerShape/2)*2;
p.row4.value=row4;

// find true poncho angle

ponchoAngleRadOld=ponchoAngleRad;
ponchoAngleDegOld=ponchoAngleDeg;
lengthChangePerShape= divide(rowsPerShape,p.mainRowIn.value);
ponchoAngleRad=divide(widthChangePerShape,lengthChangePerShape);
ponchoAngleDeg = ponchoAngleRad*180/Math.PI;

//alert("new "+ ponchoAngleDeg + " old " + ponchoAngleDegOld);
     
    realThetaDeg=ponchoAngleDeg/numTrap
    realThetaRad=realThetaDeg*Math.PI/180;  // this will be changed when I do more calculations. It is affected by the stitch/row gauge ratio,
    //shoulderAngleDeg= (totalAngleDeg - numTrap*realThetaDeg)/2;
    shoulderAngleDeg= (360-ponchoAngleDeg*(numTrap+2)/numTrap)/4;
    shoulderAngleRad=shoulderAngleDeg*Math.PI/180;
    totalAngleRad = ponchoAngleRad*(numTrap+2)/numTrap
   
    
//  Calculate rows from center of imaginary circle to shoulder edge.
    shoulderWidth=eval(p.shoulderWidth.value)
    
    neckOpening=eval(p.neckOpening.value);
    ovalFactor = 0 // I shouldn't need this if I calculate things correctly.
  
    
    widthOfTwo=divide(1,p.mainStIn.value); // this is to try to keep beginning from ever being -2 due to cumulative rounding. (There is a certain randomness to roudning. This is two at cast on and bind off, then two at the end.
    trapWidth= (neckOpening-widthOfTwo)/(5+2*Math.cos(realThetaRad)+Math.cos(2*realThetaRad)+2 );
    b = trapWidth/( 2*Math.tan(realThetaRad/2) );// I want one circle of radius b plus a space of "b",then the back edge straight..  This worked with my newspaper. I need to scale by the num trap+2 because I realy knit this many num traps!    
     
    dropFraction=0.75;
    neckDif=dropFraction*b; // the back will rise  this much, 
    innerRadius= b ; // this is the radius after workign the short rows to increase
     	
    stitchesPerTrap= Math.round(mult(trapWidth, p.mainStIn.value));
    trapWidth=divide(stitchesPerTrap,p.mainStIn.value);

    
    widthBackNeck=(trapWidth*2 + 2*trapWidth*Math.cos(realThetaRad) +trapWidth*Math.cos(2*realThetaRad) )
    frontNeckPerimPlus=(numTrap+2)*trapWidth/2
    neckPerim=widthBackNeck+frontNeckPerimPlus; //+2 for four halves of front and back.
    
   //alert(neckOpening +" - " + neckPerim );
    
    halfExtraStitches=Math.round(mult((neckOpening-neckPerim),p.mainStIn.value)/4)*2;
   // alert("halfExtra=" + halfExtraStitches+ "stitchesPerTrap" + stitchesPerTrap)
    
    baseFrontTrap=Math.ceil(stitchesPerTrap/2);  
    neckTrap=Math.floor(stitchesPerTrap/2);
    extraBack=Math.floor(halfExtraStitches/2);
    extraFront=halfExtraStitches-extraBack;
    
    totalNeckStitches=(numTrap-4)*stitchesPerTrap+4*neckTrap +4*baseFrontTrap+ 2*halfExtraStitches; 
    p.topNeckStitches.value=totalNeckStitches;
    p.topNeckStitchesM1.value=totalNeckStitches-1;
    p.endRow3St.value=totalNeckStitches+20;
    
  // insert final short row arrangement.  
  
  if(neckTrap<2){p.tooFewStitches.value="Warning: You need to use finer yarn or design a cape with a larger neck.";}
	
    stitchBetweenMarker= new Array
    stitchBetweenMarker[0]=baseFrontTrap+extraFront;
    stitchBetweenMarker[1]=stitchesPerTrap;
    stitchBetweenMarker[2]=neckTrap;
    stitchBetweenMarker[3]=neckTrap;
    stitchBetweenMarker[4]=stitchesPerTrap;
    stitchBetweenMarker[5]=baseFrontTrap+extraBack;
    
    p.endneckPanelStitch0.value=stitchBetweenMarker[0];
    p.endneckPanelStitch1.value=stitchBetweenMarker[1];
    p.endneckPanelStitch2.value=stitchBetweenMarker[2];
    p.endneckPanelStitch3.value=stitchBetweenMarker[3];
    p.endneckPanelStitch4.value=stitchBetweenMarker[4];
    p.endneckPanelStitch5.value=stitchBetweenMarker[5];
    
    // figure out how many are lost each "trick row".
    

	 horizontalShoulder= 0.5* (shoulderWidth-widthBackNeck);
	lengthToShoulder=horizontalShoulder/Math.cos(shoulderAngleRad/2);
	trapHeigthToShoulder=lengthToShoulder*Math.cos(realThetaRad/2)
	rowsToShoulder= Math.round(mult(trapHeigthToShoulder,p.mainRowIn.value));
         numShapes=Math.floor((rowsToShoulder-3)/rowsPerShape)+1;
	 p.rowsToShoulder.value=rowsToShoulder;
	 p.numShapes.value=numShapes;
	 p.lengthToShoulder.value=Math.round(lengthToShoulder*10)/10;
	 
	 
         p.totalLength.value=Math.max(p.totalLength.value,Math.ceil((lengthToShoulder)/10)*10);

length4Garter=divide(3,p.mainRowIn.value);
// Estimate total number of rows, and stitches, neglecting the shoulder and extension stitches.
p.frontLength2.value=Math.round(sub(p.totalLength.value,length4Garter)*10)/10;

garterHemRows=4
totalRows= Math.round(mult(p.totalLength.value,p.mainRowIn.value))-garterHemRows;
totalIncreaseTimes=Math.floor((totalRows-1)/rowsPerShape);
totalEndStitches=totalNeckStitches+20*numShapes+16*(totalIncreaseTimes-numShapes);
maxExtraLength=Math.min(divide(p.shoulderWidth.value,5),divide(p.totalLength.value,5));
endShortRows=Math.ceil(mult(maxExtraLength,p.mainRowIn.value)/2)*2;
maxShortStitch=Math.round((totalEndStitches/2)/(endShortRows));
//alert(maxShortStitch);
p.eight.value=Math.max(8,maxShortStitch);
p.eight2.value= p.eight.value;
p.eight3.value= p.eight.value;
p.eight5.value=p.eight.value;
p.sixteen.value=2*Math.max(8,maxShortStitch);
p.sixteen2.value=p.sixteen.value
}
}