function calcPurse(){
/* @copyright 2004 Lucia Liljegren*/


pester = document.location;
p =document.purseForm;

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.stPerIn.value=0.01;
    p.rowPerIn.value=0.01;
    alert(" Please run my programs from my site at www.thedietdiary.com!" + pesterZero + " : " + pesterAway  ) } ;

//===================
if(pester == "no"){
/* @copyright 2004 Lucia Liljegren*/


}

if(eval(p.stPerIn.value) < 0.00001) {p.stPerIn.value = 0.001; }
if(eval(p.rowPerIn.value) < 0.00001) {p.rowPerIn.value = 0.001; }
p.tooFewStitches.value = "Calculating" ;

ponchoFormCalcs();

}
// End main function
//============================================================================
/* 
@copyright 2004 Lucia Liljegren */
//======================================================
function ponchoFormCalcs(){

p.tooFewStitches.value = "filling"; 
minWidth= Math.round(divide(4,p.stPerIn.value)*10)/10;
p.wide.value=Math.max(eval(p.wide.value), minWidth);
p.deep.value=Math.max(eval(p.deep.value), minWidth/2);

circumference= 2* add(p.deep.value,p.wide.value); 

p.bodyStitches.value 	= roundTwo(mult( circumference, p.stPerIn.value),2);
castOn=roundTwo(mult( p.bodyStitches.value, 0.90),2)
    p.castOn.value		=castOn
p.strapLengthB.value	=Math.round(mult(p.strapLength.value,0.85)*10)/10;
incStitches= sub(p.bodyStitches.value,p.castOn.value);
     p.incStitches.value= incStitches;
     p.incStitches2.value=incStitches;
between= Math.floor(divide(p.castOn.value,incStitches+1)); // plus1 because I pad.
     p.between.value =between;
standard=between*(incStitches+1);
extra = castOn-standard;

preStitches = Math.round(extra/2);
postStitches= extra-preStitches;
p.preStitches.value=preStitches+between;
p.postStitches.value=postStitches;


lengthRatio = divide(p.rowPerIn.value,p.rowPerInB.value);
p.tallB.value=Math.round(mult(p.tall.value, lengthRatio)*10)/10;
p.tallBRows.value=Math.round(mult(p.tall.value,p.rowPerIn.value)/2)*2;
p.oneInch.value= Math.round(mult(1, lengthRatio)*10)/10;
p.oneInchRows.value=Math.round(mult(1,p.rowPerIn.value)/2)*2;

p.bottomStitches.value=Math.floor(mult(p.deep.value,p.stPerIn.value))-1;
p.strapStitches.value=p.bottomStitches.value;
p.bottomStitches2.value =p.bottomStitches.value
p.bottomStitchesP2.value = add(p.bottomStitches.value,2);
p.tooFewStitches.value = "filled directions"; 
p.doubleBottomStitchesP2.value=mult(p.bottomStitches.value,2)+4

p.strapStitches.value=add(p.bottomStitches.value,1);

}

//filled===================================

function roundTwo(unrounded,two){
   var rounded;
   rounded = Math.round( eval(unrounded)/two  )*two;
   return rounded
}