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

  circumference = eval(p.hatCircumference.value);
  hatDiameter=  circumference/Math.PI;
  hatLength=eval(p.hatLength.value);
  

//baseStitches = Math.round(mult(p.mainStIn.value,hatDiameter)/8)*4;

//alert(hatRadius + " - " + headRadius +  " = " +difRadius)
//I want the left
castOn=4*Math.round(mult(circumference, p.mainStIn.value)/4);

p.castOn.value=castOn;
p.castOn2.value= castOn;

hemDepth= Math.max(1,hatDiameter/4);
p.depthHem.value=Math.round(hemDepth*10)/10;
hemRows=2*Math.round(mult(hemDepth,p.mainRowIn.value));
p.hemRowsM2.value=hemRows-3;

hatHeight= hatDiameter*1.25; // this is the height to the divide.
p.hatHeight.value=Math.round(hatHeight*10)/10;
totalHatRows=2*Math.round(mult(hatHeight,p.mainRowIn.value)/2);
p.hatRows.value=Math.round((totalHatRows-hemRows));

hatLength=eval(p.hatLength.value);

minRowsPerRed=2;

halfWidth=circumference/2
tanTheta=halfWidth/hatLength;
minHeightPerRed=divide(minRowsPerRed,p.mainRowIn.value);

numDecreases=Math.ceil( ((castOn/2)-11)/4);  // because 4 stitches per reduction. 
minHeight=minHeightPerRed*(numDecreases+1);

tailLength=Math.max(hatLength-hatHeight,minHeight);

p.hatLength.value=Math.ceil( (tailLength+hatHeight)*10)/10;
hatLength=eval(p.hatLength.value);// make sure the same to avoid rounding problems.
// now actual
widthFourStitches= divide(4,p.mainStIn.value)

heightBetweenRed= widthFourStitches*tailLength/halfWidth;
totalRows= Math.round(mult(tailLength,p.mainRowIn.value)*2)/2;

rowsBetweenRed=Math.round(totalRows/(numDecreases+1)/2)*2;

rowsBetweenRed=Math.max(rowsBetweenRed,2);
p.slantRows.value=rowsBetweenRed-1;
p.slantRows2.value=p.slantRows.value;

slantStitches = (castOn/2 - 12)
p.slantStitches.value=slantStitches;
//p.slantStitches2.value=p.slantStitches.value;
//alert(rowsBetweenRed + "stitches = " + slantStitches);
actualHatLength =  (numDecreases+1) * divide(rowsBetweenRed,p.mainRowIn.value) + hatHeight ;
extraRows=Math.round(mult(hatLength-actualHatLength,p.mainRowIn.value)/2)*2; // just add if too short.  


p.extraRows.value=Math.max(extraRows,0);
p.extraRows2.value = p.extraRows.value

actualHatLength =  actualHatLength +divide(p.extraRows.value,p.mainRowIn.value) ;
p.actualhatLength.value= Math.round(actualHatLength*10)/10;
}

