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.  Thanks! I can calculate.";
p.Tension2.value=p.Tension.value;
  
  circumference = mult(p.headCircumference.value, 1-eval(p.tightnessFactor.value)/100);
  p.hatBand.value=Math.round(circumference*10)/10;

    castOn2=2*Math.round(mult( circumference, p.mainStIn.value)/2);
  incStitch=Math.round(0.05*castOn2);
  castOn=castOn2-incStitch;

 
p.castOn.value=castOn+1;
p.castOn3.value= castOn;
p.castOn2.value= castOn2;
p.incStitch.value=incStitch;
p.inc2.value=incStitch;

hatDiameter=circumference/Math.PI;
hemDepth= Math.max(1.0,hatDiameter/2.3);
hemRows=2*Math.round(mult(hemDepth,p.mainRowIn.value)/2);
p.hemRows.value=hemRows;
p.hemRows2.value=hemRows;
p.hemLength.value=Math.round(10*divide(p.hemRows.value,p.mainRowIn.value))/10;

earFlapStitches= 2*Math.round((castOn2/5)/2)+2;// +2 because the last two aren't in the earflap! they are slipped.
p.flapStitches.value=earFlapStitches;
p.flapStitches2.value=earFlapStitches;

firstEarFlapStitch = Math.round(castOn2/4.8)-1;
lastEarFlapStitch=firstEarFlapStitch+earFlapStitches;

p.lowFlapNeedle.value=firstEarFlapStitch;
p.lowFlapNeedle2.value=p.lowFlapNeedle.value

p.highFlapNeedle.value=castOn2/2-lastEarFlapStitch;
p.highFlapNeedle2.value=p.highFlapNeedle.value;

hatHeight= hatDiameter*1.25; // this is the height to the divide.
totalHatRows=Math.round(mult(hatHeight,p.mainRowIn.value))-1; // -1 because of prep round

//p.hatRows.value=Math.round((totalHatRows-hemRows));

// 
numberBetween= Math.floor(castOn2/6);
extra=(castOn2/2)%3;


if(extra==0){
    p.numberBetween.value=numberBetween
    p.numberBetween2.value=numberBetween;
    p.numberBetween3.value=numberBetween; }
else if(extra==1){
    p.numberBetween.value=numberBetween
    p.numberBetween2.value=numberBetween;
    p.numberBetween3.value=numberBetween+1;  
    }
 else{
    p.numberBetween.value=numberBetween
    p.numberBetween2.value=numberBetween +1;
    p.numberBetween3.value=numberBetween+1;
    }
    
    numTimesDec= (numberBetween-1)/2; //accounts for k2tog, k1, k2 tog rounds also.
    numRoundDec=numTimesDec*3;
    hatRows= totalHatRows-numRoundDec; // 
    p.hatRows.value=hatRows;
    p.hatLength.value=Math.round(divide(p.hatRows.value,p.mainRowIn.value)*10)/10;
}

