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; 
     
    lengthFour=divide(4,p.mainRowIn.value);
    ribLength=Math.max(lengthFour, stdLength/3);
    p.ribRows.value = 2*Math.round(mult(ribLength,p.mainRowIn.value)); // 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;
    
    thumbGussetLength=Math.max(circumference/4,lengthFour);
    thumbStitches = Math.round(mult(thumbGussetLength,p.mainRowIn.value)/2)+1+ felted;
    thumbGussetRows=2*thumbStitches;
    p.thumbStitches.value=thumbStitches;
    p.thumbGussetRows.value= 2*thumbStitches;
    
    totalRows=Math.ceil(mult(stdLength,p.mainRowIn.value));
    
    p.afterThumbRows.value= totalRows-preThumbRows-thumbGussetRows;
    
    p.ThumbStitchesP2.value=2*thumbStitches;
    thumbLength= Math.max(stdLength/3.2,lengthFour);
    p.thumbRows.value=Math.round(mult(thumbLength,p.mainRowIn.value))-2;
    
    //

p.Tension2.value=p.Tension.value;
p.TensionM2.value= sub(p.Tension.value,2);

castOn=Math.round(mult(circumference, p.mainStIn.value));
p.castOn.value= castOn;



}

