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(pesterZero == "pester=http:" || pesterAway == "www.thedietdiary.com"){pester="no"}
else if(pesterZero == "pester=http:" || 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(){
numWedges = 6
halfWedges=numWedges/2

p.tooFewStitches.value = "filling"; 
halfRows=roundTwo(mult( p.deep.value, p.rowPerIn.value)/2,2);
//alert(halfRows); // must be even.
quarterRows=halfRows/2; //maybe be even or odd

p.deepActual.value=Math.round(10* divide(halfRows,p.rowPerIn.value)*2)/10;
p.totalRows.value=2*halfRows;

p.deepRows1.value 	= 2*Math.floor(divide(quarterRows,halfWedges))-2; // -2 because of extra at the end.
extraRows=quarterRows%halfWedges
//alert(extraRows);

extra=Math.min(extraRows,1);
p.deepRows3.value =  add(p.deepRows1.value, 2*extra);

extraRows = extraRows-extra;
extra=Math.min(extraRows,1);

p.deepRows2.value =  add(p.deepRows1.value, 2*extra);
p.needlesTop.value=Math.round(mult(p.deep.value,p.stPerIn.value));

tallStitches	=roundTwo(mult(p.tall.value,p.stPerIn.value ),1);
diameter=divide( p.deep.value, Math.PI);
radius=diameter/2;

idealShortRowStitches=roundTwo(mult(radius,p.stPerIn.value)-1,1);  
shortRowStitches=divide(p.deepRows1.value,2);

p.shortRowStitches.value=shortRowStitches;

p.numWedges.value=numWedges;
p.castOn.value		=add(tallStitches,idealShortRowStitches); // This makes the can tall enough, well be cinching up the extra junk in the center.

/*
p.shortRowPairs.value=roundTwo(divide(p.straightRows.value,20),1)
var shortRowPairM1= sub(p.shortRowPairs.value,1);

if( shortRowPairM1 <= 0){
    p.pairRows.value ="XX"
    p.firstRow.value = roundTwo(divide(p.straightRows.value,2)-1,2)    
    }
else{
    p.pairRows.value=roundTwo(  divide(  sub(p.straightRows.value,6) , shortRowPairM1  ),2)
    p.firstRow.value=roundTwo(p.straightRows.value - mult(p.pairRows.value,shortRowPairM1)-3 ,2)
    }


//p..value=roundTwo(mult(p..value,p..value),1)
//p..value=roundTwo(mult(p..value,p..value),1)
*/

p.tooFewStitches.value = "calculated -- filling directions"; 

/*
p.shortRowStitches2.value	=p.shortRowStitches.value;
p.deepRows2.value		=p.deepRows.value;
p.deepRows3.value		=p.deepRows.value;
p.straightRows2.value		=p.straightRows.value
p.shortRowPairs2.value		=p.shortRowPairs.value

p.pairRows2.value	=p.pairRows.value;
p.firstRow1.value	=p.firstRow.value;
p.firstRowP1.value	=add(p.firstRow.value,1);
p.stPerIn1.value	=p.stPerIn.value

p.strapStitches2.value	=p.strapStitches.value
p.strapRows2.value	=p.strapRows.value
*/

p.tooFewStitches.value = "filled directions"; 


//filled
}

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