function forcenumbers(theobject, theminvalue, thetype, themax){if (!themax){themax=9999999999999999;}if(1*theobject.value>1*themax){theobject.value=themax;}if (!theminvalue){theminvalue=0.0;}if (!thetype){thetype='integer';}notnum=/[^0-9]/gi;if(thetype == 'integer'){theobject.value=theobject.value.replace(notnum, '');theobject.value=theobject.value*1;}else{decimal=theobject.value.indexOf('.');if(decimal > 0){wholepart=theobject.value.substring(0, decimal);decimalpart=theobject.value.substring(decimal+1, theobject.value.length);wholepart=wholepart.replace(notnum, '');decimalpart=decimalpart.replace(notnum, '');theobject.value=wholepart+'.'+decimalpart;theobject.value=theobject.value*1.00;}else{theobject.value=theobject.value.replace(notnum, '');theobject.value=theobject.value*1.00;}}if ((1*theminvalue) > 0.0){if (theobject.value < (theminvalue*1)){theobject.value=(theminvalue*1);}}return theobject;}
function doitnow3(x){var df=document.f1;df.elements['usetypecolor'].value=1;df.elements['usetypecolor'].checked=1;thetd=document.getElementById('td'+df.typecolor.value);thetd.style.backgroundColor="#ffffff";thetd.style.border="2px solid white";thetd=document.getElementById('td'+x.name);thetd.style.backgroundColor="#eeeeee";thetd.style.border="2px black solid";df.typecolor.value=x.name;}
function xOn3(img){y=1;thetd=document.getElementById('td'+img.name);thearrowpic=document.getElementById('typecolor');y=(thetd.id == thearrowpic.value);if (!y){thetd.style.backgroundColor="#cccccc";}}
function xOut3(img){thetd=document.getElementById('td'+img.name);y=1;thearrowpic=document.getElementById('typecolor');y=(thetd.id == thearrowpic.value);if (!y){thetd.style.backgroundColor="#ffffff";}}

function doitnow2(x){var df=document.f1;df.elements['usebackground'].value=1;df.elements['usebackground'].checked=1;thetd=document.getElementById('td'+df.background.value);thetd.style.backgroundColor="#ffffff";thetd.style.border="2px solid white";thetd=document.getElementById('td'+x.name);thetd.style.backgroundColor="#eeeeee";thetd.style.border="2px black solid";thearrowpic=document.getElementById('background');df.background.value=x.name;}
function xOn2(img){y=1;thetd=document.getElementById('td'+img.name);thearrowpic=document.getElementById('background');y=(thetd.id == thearrowpic.value);if (!y){thetd.style.backgroundColor="#cccccc";}}
function xOut2(img){thetd=document.getElementById('td'+img.name);y=1;thearrowpic=document.getElementById('background');y=(thetd.id == thearrowpic.value);if (!y){thetd.style.backgroundColor="#ffffff";}}
function fixradio(thecheckbox){df=document.f1;radiostate=!thecheckbox.checked;i=0;thetest=1;x='df.'+thecheckbox.value+'['+i+']';thetest=eval(x);while (thetest){x='df.'+thecheckbox.value+'['+i+']';if (eval(x)){x=x+'.disabled='+radiostate+';';eval(x);i++;}else{thetest=0;}}}
function xOn(img){y=1;
thetd=document.getElementById(img.name);
thearrowpic=document.getElementById('arrowpic');
y=(thetd.id == thearrowpic.value);
if (!y){thetd.style.backgroundColor="#cccccc";
}}function xOut(img){thetd=document.getElementById(img.name);
y=1;
thearrowpic=document.getElementById('arrowpic');
y=(thetd.id == thearrowpic.value);
if (!y){thetd.style.backgroundColor="#ffffff";
}}function checktd(td){td.style.backgroundColor="#ff0000";
}function doitnow(x){

var df=document.f1;
df.elements['usearrow'].value=1;
df.elements['usearrow'].checked=1;
thearrowpic=document.getElementById('arrowpic');
thetd=document.getElementById(thearrowpic.value);
thetd.style.backgroundColor="#ffffff";
thetd.style.border="2px solid white";
thetd=document.getElementById(x.name);
thetd.style.backgroundColor="#eeeeee";
thetd.style.border="2px black solid";
thearrowpic=document.getElementById('arrowpic');
thearrowpic.value=x.name;
}
function validate(f, theevent){
//    alert(theevent);
  //  var upload;var ext;
    //x=bw_check();

  //  itsie=(x.ie == 1);
//    alert('first test '+itsie);
    itsie=navigator.appVersion.indexOf("MSIE") > -1
//    alert('second test '+itsie);
 //   alert(x.ie);
    if (!itsie){
        if (theevent == 'click'){dothis(f);}
    }

    else{
        if (theevent == 'change'){dothis(f);}
    }
}

function fixautorenew(check){if (check.checked){document.getElementById('times').innerHTML='Renew Every';}else{document.getElementById('times').innerHTML='Times to Run';}}
function dothis(f) {
      upload = f.value;
    df = document.f1;
    checkbox=document.getElementById('checkupload');
    if(upload.length==0){return;}
    if (upload.indexOf(".") == -1) {
       //alert("Sorry, This file can't be uploaded. Only image files may be uploaded. (File types: jpg, jpeg, gif, png, bmp, tif).");

    }
    ext = upload.substr(upload.lastIndexOf(".")).toLowerCase();
    if ((ext == ".jpg") || (ext == ".png") || (ext == ".jpeg")|| (ext == ".pdf")|| (ext == ".psd")|| (ext == ".gif")|| (ext == ".tif")) {
        df.elements['dothumbnail'].disabled = false;
        df.elements['dothumbnail'].checked = true;
        df.elements['dothumbnail'].value = 1;
        checkbox.checked=true;
        checkbox.value=1;
        picurl = getpicurl(upload);
        showpicurl(picurl);
    }
    else {
        alert("Sorry, This file can't be uploaded. Only image files may be uploaded. (File types: jpg, jpeg, gif, png, bmp, tif).");
        upload='';
        f.blur();
        f.focus();
        return 0;
    }
    return 1;
}

function showpicurl(picurl){x=document.getElementById('Picture');x.innerHTML=picurl;}function getpicurl(upload){imgURL=' file:///'+upload;var img=new Image();if (document.layers && location.protocol.toLowerCase() != 'file:' && navigator.javaEnabled())netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead' );img.src=imgURL;var ywidth=img.width;var yheight=img.height;var inchandahalf=df.elements['picwidth'].value;if((ywidth > inchandahalf) && ((inchandahalf/ywidth) < ((inchandahalf)/yheight))){newscale=inchandahalf/ywidth;}else{if (yheight > inchandahalf){newscale=inchandahalf/yheight;}else{newscale=1;}}ywidth=ywidth*newscale;yheight=yheight*newscale;url="<img src="+img.src+" height="+yheight+" width="+ywidth+">";df.elements['showpictureurl'].value=url;return url;}
function bw_check(){
    var is_major=parseInt(navigator.appVersion);
    this.nver=is_major;
    this.ver=navigator.appVersion;
    this.agent=navigator.userAgent;
    this.dom=document.getElementById?1:0;
    this.opera=window.opera?1:0;
    this.ie =(this.ver.indexOf("MSIE") > -1 && this.dom && !this.opera)?1:0;
    this.mac=this.agent.indexOf("Mac") > -1;
    this.ns6=(this.dom && parseInt(this.ver) >= 5)?1:0;
    this.ie3=(this.ver.indexOf("MSIE") && (is_major < 4));
    this.hotjava=(this.agent.toLowerCase().indexOf('hotjava') != -1)?1:0;this.ns4=(document.layers && !this.dom && !this.hotjava)?1:0;this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera);this.ver3=(this.hotjava || this.ie3);this.opera7=((this.agent.toLowerCase().indexOf('opera 7') > -1) || (this.agent.toLowerCase().indexOf('opera/7') > -1));this.operaOld=this.opera && !this.opera7;return this;};function fixcash(cashobject, calledbycheckbox){df=document.f1;proceed=true;returnfalse=false;notnum=/[^0-9\.]/gi;cashobject.value=cashobject.value.replace(notnum, '');if (cashobject.value.length == 0){df.cashreceived.value='0';proceed=false;}else{cashobject.value=cashobject.value*1.000;}if ((cashobject.value.length > 0) && (df.transid.checked == true || df.cardnumber.value.length > 0)){x=confirm('Pay by cash instead of credit card?');if (!x){df.cash.value='';df.cashreceived.value='0';proceed=false;}else{df.transid.checked=false;df.cardnumber.value='';df.expmonth.value='';df.expyear.value='';}}if (proceed){xprice=Math.round(df.pricetotal.value*100);xcash=Math.round(document.f1.cashreceived.value*100);if (xprice<xcash){x=alert('Cash received must not exceed value of ad.');df.cash.value=xprice*.01;df.cashreceived.value=df.cash.value;return false;}proceed=true;if (cashobject.value.length=0){df.cashreceived.value=0;proceed=false;}}if (proceed){cashobject=forcenumbers(cashobject, 0.000, 'decimal');df.cashreceived.value=cashobject.value*1.000;}y=document.forms[0].elements;xxx=0;hasaffils=false;while (y[xxx]){if (y[xxx].name == 'forcehold'){}else{if ((y[xxx].type == 'checkbox') && (y[xxx].checked)){hasaffils=true;thischecked=xxx;}}xxx++;}if (false){if ((hasaffils) && (df.cashreceived.value > 0.001)){alert('Sorry...Cash payment allowed for originating newspaper only. Please uncheck special offers, or pay by credit card.');cashobject.value='';df.cashreceived.value=0;proceed=false;return false;}}if (proceed){if (parseFloat(df.cashreceived.value) >= 0){cashobject.value=currency(cashobject.value, 'cashobject');}}if (returnfalse){return false;}else{return true;}}
function fixprice(priceobject,key){df=document.f1; if (typeof df.transid=="undefined"){
    df.transid=false;
    }var calledbyreturn;if (calledbyreturn){calledbyreturn=false;return false;}notnum=/[^0-9\.]/gi;priceobject.value=priceobject.value.replace(notnum, '');priceobject.value=priceobject.value*1.000;if (!key){calledbyreturn=false;}else{calledbyreturn=true;}
if (document.getElementById){
    total=df.pricetotal.value;oldtotal=total;priceobject.value=priceobject.value*1.000;
xoldbaseprice=df.oldbaseprice.value;
priceobject=forcenumbers(priceobject, 0.000, 'decimal');
priceobject.value=priceobject.value*1.000;
df.oldbaseprice.value=df.oldbaseprice.value*1.000;
newvalue=priceobject.value;
total=total*1.000;
var xdiscount;
var didthiscredit=false;
xdiscount=parseFloat(newvalue)*parseFloat(df.discountrate.value*-1);
xoldtax=df.salestax.value;
newbaseprice=newvalue*1.000+xdiscount;
oldcreditbalance=df.creditbalance.value;
if(df.maxbalance.value*1.00>0.0001){

    if(newbaseprice>df.maxbalance.value){
        inhousecredit=df.maxbalance.value;
    }
    else{
        inhousecredit=newbaseprice;
    }

newbaseprice=newbaseprice-inhousecredit;
formatcredit=currency(inhousecredit);

                document.getElementById('creditbalanceinfo').innerHTML = formatcredit;

}
else{inhousecredit=0;}
df.creditbalance.value=inhousecredit;
xtotal=total;
if(false){
total=total-(df.oldbaseprice.value*1);
}
else{

    total=total-(df.oldbaseprice.value-oldcreditbalance);
    didthiscredit=true;
}

total=(1*df.webextras.value)+(1.0*newbaseprice);
oldcreditbalance=df.creditbalance.value;
df.oldbaseprice.value=newbaseprice;
discstring=currency(xdiscount);
df.salestax.value=parseFloat(df.taxrate.value)*parseFloat(df.oldbaseprice.value);
taxstring=currency(df.salestax.value, 'salestax total');
t=parseFloat(df.taxrate.value);
if (document.getElementById('discount').type == 'hidden'){}
else{document.getElementById('discount').innerHTML=discstring;}
xoldtax=decimalround(xoldtax);
if (xoldtax == df.salestax.value){}
else{if (document.getElementById('tax').type == 'hidden'){}
else{
    //total=total-xoldtax;
    x=decimalround(df.salestax.value);

    total=(total*1.000)+(x*1.000);
    document.getElementById('tax').textAlign='right';
    document.getElementById('tax').fontWeight='bold';
    document.getElementById('tax').innerHTML=taxstring;}
}
total=total*1.000;
if (total <.005){total=0;}
currstring=currency(total, 'curstring total');
priceobj=document.getElementById('totalprice');
priceobj.style.textAlign='right';priceobj.style.fontWeight='bold';
priceobj.innerHTML=currstring;
df.pricetotal.value=total;
whichbutton=df.buttoname.value;
eval("thisobj=df."+whichbutton+";");

if (total == 0){thisobj.value='Save ad - no charge';}
else{thisobj.value='Record Payment Method';}
priceobject.value=currency(priceobject.value, 'priceobject');}
//document all...don't worry about it

else{if (document.all){total=document.all.update.pricetotal.value;adminbase=document.all.update.adminbaseprice.value;oldbase=document.all.update.oldbaseprice.value;total=total-oldbase+adminbase;document.all.update.oldbaseprice.value=total;document.all.update.totalprice.innerHTML=currency(total, 'something total');document.all.update.pricetotal.value=total;}}if (df.cash.value.length > 0){fixcash(df.cash);}}
function affiliate(someparam){df=document.f1;if (typeof df.transid=="undefined"){
    df.transid=false;
}if (someparam.id == 'x'){someparam.id='true';}if (document.getElementById){total=df.pricetotal.value*1.000;eval("priceid=df.price"+someparam.value+";");clickedprice=priceid.value*1.000;if (someparam.id == 'true'){total=total+clickedprice;}else{total=total-clickedprice;}currstring=currency(total, 'ANOTHER currestring total');priceobj=document.getElementById('totalprice');priceobj.innerHTML=currstring;priceobj .style.textAlign='right';priceobj.style.fontWeight='bold';df.pricetotal.value=total;if (total == 0){df.savead.value='Save ad - no charge';}else{df.savead.value='Record Payment';}}else if(document.all){total=document.all.update.pricetotal.value;priceid='otherprices['+someparam.value+']';clickedprice=document.all.update.priceid.value;total=total*1.000;clickedprice=parseFloat(clickedprice);if (someparam.checked){total=total+clickedprice;}else{total=total-clickedprice;}document.all.update.totalprice.innerHTML=currency(total, 'currency total');document.all.update.pricetotal.value=total;}if (someparam.id == 'false'){someparam.id='true';someparam.checked=false;}else{someparam.id='false';someparam.checked=true;}if (df.cash.value.length > 0){fixcash(df.cash, 'checkbox');}}function fixmonth(){df=document.f1;if (df.expmonth.value.length < 1){alert(Pleaseenteranexpirationmont);return false;}forcenumbers(df.expmonth, 1);if ((df.expmonth.value-0 > 12) || (df.expmonth.value-0 < 1)){df.expmonth.value='12';alert(Pleaseenteravalidmonth);df.expmonth.focus();df.expmonth.select();return false;}if ((df.expmonth.value.length < 2) && (df.expmonth.value-0 < 10)){df.expmonth.value='0'+df.expmonth.value;}return true;}function fixyear(){df=document.f1;today=new Date();year=today.getYear();if (year < 1900){year += 1900 };year=year-2000;if (df.expyear.value.length < 1){alert(Pleaseenteranexpirationyear);return false;}forcenumbers(df.expyear, 1);if ((df.expyear.value-0 < year)){df.expyear.value=year;alert(Pleaseenteravalidyear);df.expyear.select();df.expyear.focus();}if ((df.expyear.value.length < 2) && (df.expyear.value-0 < 10)){df.expyear.value='0'+df.expyear.value;}if((df.cvn.type!='hidden')&&(df.cvn.value.length<3)){alert('Please enter a valid verification code.');return false;};return true;}



function fixcc(){df=document.f1;if (df.transid.type == 'checkbox') {} else {df.transid.checked = false;}if(df.cardnumber.value=='4222222222222'){return true;}if((df.transid.checked==false)&&((df.cardnumber.value == '0') || (df.cardnumber.value == ''))){df.cardnumber.value='';return false;}if ((df.cash.value.length > 0)){x=confirm('Pay by credit card instead of cash?');if (x){df.cash.value='';df.cashreceived.value=0.0;}else{df.cardnumber.value='';df.expmonth.value='';df.expyear.value='';return false;}}forcenumbers(df.cardnumber,'','integer',9999999999999999);itsabadcc=false;if (df.cardnumber.value.length > 0 && df.cardnumber.value.length < 15){itsabadcc=true;}if (!luhnCheck(df.cardnumber.value)){itsabadcc=true;}if (itsabadcc){alert(Pleaseenteravalidcreditcard);if (df.cardnumber.value == '0'){df.cardnumber.value='';}df.cardnumber.focus();df.cardnumber.select();return false;}return true;}function luhnCheck(CardNumber){var no_digit=CardNumber.length;var oddoeven=no_digit&1;var sum=0;for(var count=0;count < no_digit;count++){var digit=parseInt(CardNumber.charAt(count));if (!((count&1)^oddoeven)){digit *= 2;}if (digit > 9){digit -= 9;}sum += digit;}if (sum%10 == 0){return true;}else{return false;}}function checkcontent(){lackscontent=false;y=document.forms[0].elements;i=0;while (y[i]){if (y[i].type == 'text' || y[i].type == 'textarea'){if (y[i].name == 'key0' || y[i].name == 'key0' || y[i].name == 'key1' || y[i].name == 'key2' || y[i].name == 'key3' || y[i].name == 'body'){if (y[i].value == ''){lackscontent=true;}}}i++;}return lackscontent;}function checkad(){df=document.f1;unsubmitted=df.notsubmitted.value;check=true;if (df.notsubmitted.value == 'submitted'){alert('Ad is being submitted');return false;}lackscontent=checkcontent();if (lackscontent){check=confirm(somefields);}if (check){aposfix();df.notsubmitted.value='submitted';df.submitad2.disabled=true;df.submitad.disabled=true;if (df.checkupload.checked==true){df.submitad.value='Submitting. Please be patient...picture upload';df.submitad2.value='Submitting. Please be patient...picture upload';}else{df.submitad.value='Submitting. Please wait...processing';df.submitad2.value='Submitting. Please wait...processing';}return true;}else{return false;}}function doadsave(){df=document.f1;if (df.billme.type == 'checkbox'){if (df.billme.checked == true){return true;}}if (df.transid.type == 'checkbox'){}else{df.transid.checked=false;}if (df.dontdothis.value == 'true') {return false;}x=fixcash(df.cash);if (!x){return false;};if (df.transid.checked){df.x_Amount.value=decimalround(df.pricetotal.value);return true;}else{}
if (df.pricetotal.value == 0){df.dontdothis.value='true';return true;}
if ((df.cash.value.length == 0) && (df.cardnumber.value.length == 0)&&(!df.dobillme.checked)){
 alert(Pleaseenterpayment);return false;}
if (df.dobillme.checked||(df.cash.value.length > 0) && ((df.pricetotal.value*1.000) > (df.cashreceived.value*1.000)))
{
billthisamount=currency((df.pricetotal.value*1.000)-(df.cashreceived.value*1.000));
x=confirm('Remaining balance of '+billthisamount+' will be billed to customer. OK to proceed?');
if (!x){return false;}else{df.dontdothis.value='true';return true;}}xprice=Math.round(df.pricetotal.value*100);xcash=Math.round(document.f1.cashreceived.value*100);if (xprice<xcash){x=alert('Cash received must not exceed value of ad.');df.cash.value=df.pricetotal.value*1.000;df.cashreceived.value=df.pricetotal.value*1.000;fixcash(df.cash);return false;}if (!df.cash.value == ''){df.dontdothis.value='true';return true;}else{if (!fixcc()){return false;}if (!fixmonth()){return false;}if (!fixyear()){return false;}df.x_Card_Num.value=df.cardnumber.value;df.x_Exp_Date.value=df.expmonth.value+df.expyear.value;df.x_Amount.value=decimalround(df.pricetotal.value);aposfix();df.dontdothis.value='true';return true;}}function changeclass(someparam, currentid){if(document.getElementById){document.getElementById('classname').innerHTML=someparam.options[someparam.selectedIndex].innerHTML;return;}if(document.all){document.all['classname'].innerHTML=someparam.options[someparam.selectedIndex].innerHTML;}}
function dotemplate(someparam, currentid){
    ratefixerframe=document.getElementById('ratefixer');
 ratefixerurl='ratefixer.php?templateid='+document.f1.templateid.value+'&rateid='+document.f1.rateid.value+'&changed=1';

ratefixerframe.src=ratefixerurl;
hasdoupload=document.getElementById('doupload');
type1=typeof(hasdoupload);
if(type1=='undefined'){
  itsundefined=true;
}
else{
    type2=typeof(hasdoupload.value);
    itsundefined=type2=='undefined';
}

var docontinue=false;
if (!itsundefined){docontinue=true;}
if(!docontinue){
    if (hasdoupload.value == ''){
    docontinue=true;
    }
    else{
    x='If you change templates, you will need to reselect your picture...OK to proceed?';
    docontinue=confirm(x);
    }
}

if (docontinue){newadpage();}else{i=0;while(i < someparam.options.length){if (someparam.options[i].value == currentid){someparam.selectedIndex=i;}i++;}}}
function newadpage(){y=getvars();x='index.php?changed=template&action=adminad&adminad=true&templateid='+document.forms[0].templateid.value+'&'+y;window.location=x;}function getvars(){y=document.forms[0].elements;i=0;var get='';newvaluectr=0;while(y[i]){if (y[i].name == 'newvalue[]'){if (newvaluectr){get=get+'xtempadarray[startdate]='+y[i].value+'&';}else{get=get+'xtempadarray[classid]='+y[i].value+'&';}newvaluectr++;}if (y[i].name == 'country' && y[i].type == 'select-one'){myselected=y[i].selectedIndex;myvalue=y[i].options[myselected].value;get=get+'country='+myvalue+'&';}if (y[i].name == 'firstname' || y[i].name == 'lastname' || y[i].name == 'street' || y[i].name == 'street2' || y[i].name == 'city' || y[i].name == 'state' || y[i].name == 'areacode' || y[i].name == 'phone' || y[i].name == 'email' || y[i].name == 'type' || y[i].name == 'bizname'){get=get+y[i].name+'='+y[i].value+'&';}if (y[i].name == 'zipcode'){get=get+'zip='+y[i].value+'&';}if (y[i].name == 'doemail'){if (y[i].checked){get=get+'xtempadarray[hasemail]='+y[i].value+'&';}}if (y[i].name == 'counter'){if (y[i].checked){get=get+'xtempadarray[hascounter]='+y[i].value+'&';}}if (y[i].name == 'key0' || y[i].name == 'key1' || y[i].name == 'key2' || y[i].name == 'key4' || y[i].name == 'body' || y[i].name == 'classid' || y[i].name == 'startdate' || y[i] .name == 'formatted' || y[i].name == 'templateid' || y[i].name == 'rateid' || y[i].name == 'insertions' || y[i].name == 'autorenew' || y[i].name == 'featured' || y[i].name == 'hasemail' || y[i].name == 'emailtype' || y[i].name == 'url' || y[i].name == 'hasmap' || y[i].name == 'mapaddr' || y[i].name == 'mapzip' || y[i].name == 'customerid'){if (y[i].type == 'checkbox' || y[i].type == 'radio'){if (y[i].checked){get=get+'xtempadarray['+y[i].name+']='+y[i].value+'&';}}else{get=get+'xtempadarray['+y[i].name+']='+y[i].value+'&';}}i++;}if (document.forms[0].usearrow.checked){if (document.forms[0].arrowpic.value == ''){}else{get=get+'xtempadarray[featuredicon]='+document.forms[0].arrowpic.value+'&';}}get=get+'closethis=true';get=get+'&ag='+document.getElementById('ag').value;return get;}


//this is the part that stays on separate lines


function currency(val, calledby){val=''+val;x=decimalround(val);return"$ "+x;}


function decimalround(val){val=''+val;thelength=val.length;i=0;thefinalstr='';decimalpoint=0;hasdecimal=false;for(i=0;i < thelength;i++){charval=val.charCodeAt(i);if(!decimalpoint){if (charval == 46){thefinalstr += val.charAt(i);decimalpoint=thefinalstr.length-1;hasdecimal=true;}}if ((charval < 58) && (charval > 47)){thefinalstr += val.charAt(i);}}val=thefinalstr;wholepart=val.substring(0, decimalpoint);if(val == ''){val='0';}if (!hasdecimal){returnval=val+'.00';}else{wholepart=val.substring(0, decimalpoint);if(parseInt(wholepart, 10) == 0){wholepart='0';}decimalpart=val.substring(decimalpoint+1, val.length);i=decimalpart.length;if(parseInt(decimalpart, 10) == 0){i=0;returnval=wholepart+'.00';}if (i == 1){returnval=val+'0';}if (i == 2){returnval=val;}while (i > 2){i--;test=decimalpart.charAt(i);rest=decimalpart.substring(0, i);decimalpart=''+decimalpart;olddecimal=decimalpart;decimalpart=parseInt(rest, 10);if(test >= 5){decimalpart++;}decimalpart=''+decimalpart;newdecimal=decimalpart;if(decimalpart.length > (olddecimal.length-1)){decimalpart='00';wholepart++;}while (decimalpart.length < rest.length){decimalpart='0'+decimalpart;}}while (decimalpart.length < 2){decimalpart=decimalpart+'0';}returnval=wholepart+'.'+decimalpart;}if (returnval.indexOf('.') == 0){returnval='0'+returnval;}return returnval;}function reusefix(){var df=document.f1;if (df.transid.checked == true){if ((df.cash.value.length > 0)){x=confirm('Pay by credit card instead of cash?');if(x){df.cash.value='';df.cashreceived.value=0.0;df.cardnumber.value='';df.expmonth.value='';df.expyear.value='';return false;}else{df.transid.checked=false;}}}}



