function rollHat(){
p =document.mittenForm;
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.";


// guess for foot length based on shoe size.   
    var extra;
     var stdRatio = 1.8;
     
     extra= eval(p.size.selectedIndex);
     
	if(p.range.selectedIndex == 0){extra += 5;}	
	else if(p.range.selectedIndex == 1){ extra += 0;}
  if(p.felted.selectedIndex == 0){felted=1; }
        else{felted = 0; } 
   
//     if(p.size.selectedIndex==1){extra += 1}
//    else if(p.size.selectedIndex==2){extra += 2}
//    else if(p.size.selectedIndex==3){extra += 3}
//    else if(p.size.selectedIndex==4){extra += 4}

    
   normSize= extra;
    circumference = (5.4 + normSize/2.5) ;
    stdLength=.95*circumference;
    p.stdLength.value = Math.round(10*stdLength)/10; 
    
    castOn=Math.round(mult(circumference, p.mainStIn.value));
    p.castOn.value= castOn;
    p.castOn2.value=castOn;
    p.castOnM10.value=Math.round(mult(0.9*circumference, p.mainStIn.value));
    p.incStitches.value=sub(p.castOn.value,p.castOnM10.value)

     
    lengthFour=divide(4,p.mainRowIn.value);
    ribLength=Math.max(lengthFour, stdLength/3);

    p.ribLength.value = Math.round(ribLength*10)/10; // don't divide by two because I'm folding them!
   
    preThumbLength=Math.max(circumference/7,lengthFour);
    preThumbRows=Math.round( mult(preThumbLength,p.mainRowIn.value)/2-felted)*2;
    p.preThumbRows.value=preThumbRows;
    preThumbLength = divide(p.preThumbRows.value,p.mainRowIn.value);
    p.preThumbLength.value = Math.round( preThumbLength*10)/10;
    
    thumbGussetLength=Math.max(circumference/4,lengthFour);
    thumbStitches = Math.round(mult(thumbGussetLength,p.mainRowIn.value)/2)+1 + felted;
    thumbGussetRows=2*thumbStitches;
    p.thumbGussetRows.value=thumbGussetRows
    
    p.thumbStitches.value=thumbStitches;
    p.totalLength.value= Math.round(stdLength*10)/10;
    

    p.ThumbStitchesP2.value=2*thumbStitches;
    thumbLength= Math.max(stdLength/3.2,lengthFour);
    p.thumbLength.value=Math.round(thumbLength*10)/10;
    
    //





}

