<!-- Personalization Script
// ©2001-2004 G.E. Masana

RATE = 3.50;


//////
function currency(anynum) {
   anynum=eval(anynum);
   workNum=Math.abs((Math.round(anynum*100)/100));workStr=""+workNum
   if (workStr.indexOf(".")==-1){workStr+=".00"}
   dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0
   pStr=workStr.substr(workStr.indexOf("."))
   while (pStr.length<3){pStr+="0"}
      if (dNum>=1000) {
      dLen=dStr.length
      dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)
   }
   if (dNum>=1000000) {
      dLen=dStr.length
      dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)
   }
   retval = dStr + pStr 
   //-- Put numbers in parentheses if negative.
   if (anynum<0) {retval="("+retval+")"}
   return retval
}
function CharacterCount(theForm){

 var text = theForm.text.value;
 var i;
 var total = 0;

 for (i = 0; i < text.length; i++)
 {
  // Count anything with an ASCII value higher than a space
//  if (text.charAt(i) > ' ')
  {
   total++;
  }
 }

 return total;
}


function PerformCalculation(theForm){
price=0;

 // Compute the RATE as a decimal number
 fee = CharacterCount(theForm) * RATE;

// Update the cost display field
 theForm.cost.value = currency(fee);
 
 }

function Final(theForm){

PerformCalculation(theForm);

if (theForm.text.value){if(confirm('Please Check Your Personalisation for Accuracy:\n\n'+theForm.text.value+'\n\nIs This Correct?')){

 // Update form fields
price=eval(theForm.price.value)+eval(fee);
theForm.price.value=currency(price);
if (theForm['product\[\]']){
theForm['product\[\]'].value += "{br}{b}Personalised:{/b}{br}"+theForm.text.value;
}

return true;
}

else {theForm.text.select();return false;}

}

}
//-->