function mkBeret(){
p =document.hatForm;

pester = document.location;

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! " + " xaway  =" + pesterAway +":" ) } ;

//
p.tooFewStitches.value = "javascript is on";
p.diameterMultiple.value = Math.max(1.2, eval(p.diameterMultiple.value));
p.diameterMultiple.value=Math.min(eval(p.diameterMultiple.value),2);
p.tightnessFactor.value = Math.max(p.tightnessFactor.value, 0);

  p.hatBand.value= Math.round(mult(p.headCircumference.value, 1-eval(p.tightnessFactor.value)/100)*10)/10;
   circumference = mult(p.hatBand.value, p.diameterMultiple.value);
   headCircumference = eval(p.headCircumference.value); 
  headDiameter = headCircumference/Math.PI;
  


//alert(hatRadius + " - " + headRadius +  " = " +difRadius)
//I want the left needles to come 2/3 of the extra radius in.  that reduced the hat diameter some, but not completely.
numShape=6;
castOn= Math.round(mult(p.hatBand.value,p.mainStIn.value));// if multiple of 2, makes things easier.
   
p.castOn.value=castOn+1;
p.castOnM1.value=castOn;
p.castOnM2.value = castOn-1;

p.bandDepth2.value=p.bandDepth.value;

hatStitches = Math.round(mult(p.diameterMultiple.value,castOn)/numShape)*numShape;
circumference = divide(hatStitches,p.mainStIn.value);
p.hatCircumference.value =  Math.round(circumference*10)/10; 
hatDiameter=  circumference/Math.PI;

hatRadius= hatDiameter/2;
headRadius=headDiameter/2;
difRadius= hatRadius-headRadius


  p.hatDiameter.value= Math.round(hatDiameter*10)/10;

p.hatStitches.value=hatStitches;
totalInc=hatStitches-castOn;
p.totalInc.value=totalInc;

betweenInc = Math.floor(castOn/totalInc);
betweenInc2 = betweenInc + 1;
incTimes2 = castOn%totalInc;
incTimes = totalInc-incTimes2;

// adust for whatever is smaller.
incRep=Math.min(incTimes2,incTimes);
incMost=Math.max(incTimes2,incTimes);
incMost=Math.floor(divide(incMost,incRep));

p.betweenInc.value=betweenInc;
p.betweenInc2.value=betweenInc2
p.incTimes2.value=incTimes2
p.incTimes.value=incMost;

lengthThree= divide(3,p.mainRowIn.value)
p.threeInches.value=Math.round((hatRadius-headRadius + lengthThree)*10)/10;
p.fiveInches.value=Math.round(add(p.threeInches.value,p.bandDepth.value)*10)/10;

betDecFirst = hatStitches/numShape;
p.betDecFirst.value=betDecFirst;
p.betDecFirst2.value=betDecFirst;

between=betDecFirst-4; // 4 involved in reductios.
betDecFirstHalf =Math.round(between/2);
betDecFirstHalf2=between-betDecFirstHalf;
p.betDecFirstHalf.value=betDecFirstHalf;
p.betDecFirstHalf2.value=betDecFirstHalf2;
betDecSecond = betDecFirst-2
p.betDecSecond.value=betDecSecond;

p.betDecSecondHalf.value=betDecFirstHalf-1;
p.betDecSecondHalf2.value=betDecFirstHalf2-1;
betDecThird=betDecSecond-2
p.betDecThird.value=betDecThird;

rowsToCenter=Math.round(mult(hatRadius,p.mainRowIn.value))-2-3;  // 1 is for the actual final decrease, the extra is because it's stretchy, 3 is for the three before you start the repeats.
decToCenter=Math.round(rowsToCenter/4); // 4 rows between decreases.
finalBetween = Math.max(betDecFirst-2*decToCenter,4+between%2);  // 2 decreased per wedge.
p.finalBetween.value=finalBetween;

p.threeRows.value=Math.round(mult(p.threeInches.value,p.mainRowIn.value));

// find best shaping


}
//======================



