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(){

p.tooFewStitches.value = "filling"; 
p.deepRows.value 	= roundTwo(mult( p.deep.value, p.rowPerIn.value),4);
p.tallStitches.value	=roundTwo(mult(p.tall.value,p.stPerIn.value ),1);
p.wideRows.value	=roundTwo(mult(p.wide.value,p.rowPerIn.value),2);
p.shortRowStitches.value=roundTwo(divide(p.deepRows.value,4),1);

p.castOn.value		=add(p.tallStitches.value,p.shortRowStitches.value)
p.straightRows.value	=sub(p.wideRows.value,p.deepRows.value)

p.strapRows.value	=roundTwo(mult(p.strapLength.value,p.rowPerIn.value),2)

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.castOn2.value=p.castOn.value;

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"; 


if(eval(p.wide.value) < eval(p.deep.value) ){     
    p.tooFewStitches.value = "Error: The purse width must be greater than the depth. You must either increase W or decrease D";
    }

//filled
}

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