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

//
p.tooFewStitches.value = "javascript is on";

  circumference = eval(p.hatCircumference.value);
p.hatCircumference.value =  Math.round(circumference*10)/10;
  hatDiameter=  circumference/Math.PI;
  
//baseStitches = Math.round(mult(p.mainStIn.value,hatDiameter)/8)*4;

numWedge=2;
p.repeatTimes.value = numWedge-1;
p.numWedge.value = numWedge;

hatHeight= hatDiameter*1.25;
hatLength = eval(p.hatLength.value)
rowsInHalfWedge= Math.floor( mult(p.hatCircumference.value,p.mainRowIn.value)/(2*numWedge));
if(rowsInHalfWedge%2 ==0){    preRow = 1; p.Right.value="right"; p.COR.value="COR" }
else{			preRow  =2; p.Right.value="left"; rowsInHalfWedge+=-1; p.COR.value="COL"}

//alert("rowsInHalfWedge= " + rowsInHalfWedge);
p.preRow.value=preRow

minTailLength=divide((rowsInHalfWedge+1)/2,p.mainStIn.value);// 2 st every two rows.

tailLength= Math.max(hatLength-hatHeight,minTailLength);
hatLength=Math.ceil((tailLength+hatHeight)*10)/10;
p.hatLength.value=Math.max(hatLength,eval(p.hatLength.value));


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


rightSideNeedle= Math.round(mult(tailLength,p.mainStIn.value));// extra added later if required.
leftSideNeedle = Math.round( mult(hatHeight,p.mainStIn.value));
castOn=rightSideNeedle+leftSideNeedle;


// find best shaping


//alert(rightSideNeedle);
operations=rowsInHalfWedge/2;
shortRow1= Math.ceil(rightSideNeedle/operations);

rightSideNeedle=operations*shortRow1;
leftSideNeedle=castOn-rightSideNeedle;
//alert(rightSideNeedle + " = "+ operations + " * " + shortRow1)

p.castOn.value=castOn;
p.rightSideNeedle.value=rightSideNeedle;
p.rightSideNeedle2.value=p.rightSideNeedle.value
p.rightSideNeedle3.value=p.rightSideNeedle.value

p.shortRow1.value=shortRow1;

p.rcMid.value= rowsInHalfWedge +preRow
p.rcEnd.value= 2*rowsInHalfWedge + 2*preRow;

p.needlesBrim.value=Math.round(0.95*mult(circumference,p.mainStIn.value));
depthBrim= Math.max(hatDiameter/12,1);
p.rowsBrim.value=2*Math.floor(mult(depthBrim,p.mainRowIn.value)/2);
}
//======================




