﻿var petitionAssesment=50,petitionHours=20,paypalConstFee=.3,paypalPercFee=.029,minimumWage=8.55,seniorHours=8,regHours=20,grandLodgeAssessment=15,seniorAge=65,lifeFees=[900,800,700,650,600,550],cutOffYears=[25,35,45,55,65,300],calcLifeFee,calcProrate,regularMemberRate=Math.round(regHours*minimumWage)+grandLodgeAssessment,seniorMemberRate=Math.round(seniorHours*minimumWage)+grandLodgeAssessment;function calculatePaypalFee(a){if(a<=0)return 0;else return (Math.round(((1+paypalPercFee)*a+paypalConstFee)*100)/100).toFixed(2)}function loadDues(){document.forms.regDues.amount.value=calculatePaypalFee(regularMemberRate);document.forms.seniorDues.amount.value=calculatePaypalFee(seniorMemberRate);document.forms.lifeDues.amount.value=calculatePaypalFee(grandLodgeAssessment)}function breakDown(b,a){output="<table style='width: 100%;background-color:#eee; border:3px solid #aaa; font-size:14pt;'><tr><td>";output+=b+":</td><td style='text-align:right;'>$"+a.toFixed(2);output+="</td></tr><tr style='border-bottom: 1px solid #000;'><td>Paypal Fee:</td>";output+="<td style='width: 20%;text-align:right;'>$"+(Math.round((paypalPercFee*a+paypalConstFee)*100)/100).toFixed(2)+"</td></tr><tr ><td >";output+="Total:</td><td style='border-top:1px solid #000; text-align:right;'><font style='background-color:#ee0;'>$"+calculatePaypalFee(a)+"</font></td></tr></table>";return output}function prorate(a,d){var e=12==a?12:12-a;if(d[0].checked)var c=(regularMemberRate-grandLodgeAssessment)/12;else var c=(seniorMemberRate-grandLodgeAssessment)/12;var b=Math.round(c*e*100)/100+(a==12?grandLodgeAssessment:0);document.forms.prorateDues.amount.value=calculatePaypalFee(b);if(a==12){document.getElementById("Proration").innerHTML=breakDown("Full Dues for Next Year",b);document.getElementById("prorateNotice").style.display="block"}else document.getElementById("Proration").innerHTML=breakDown("Prorated Membership Fee",b);document.getElementById("prorateDuesSubmit").style.display="block"}function calcAge(e,d,f){if(IsValidDate(f,d,e)){var b=new Date,a=new Date(e,d-1,f),c=b.getFullYear().valueOf()-a.getFullYear().valueOf();if(a.getMonth().valueOf()>b.getMonth().valueOf())c--;else if(a.getMonth().valueOf()==b.getMonth().valueOf()&&a.getDate().valueOf()>b.getDate().valueOf())c--;return c}}function lifeTimeFee(c,b,d){var e="Lifetime Membership Fee";if(IsValidDate(d,b,c)){var f=calcAge(c,b,d),a=0;for(i=0;i<lifeFees.length;i++)if(f<=cutOffYears[i]){a=i;break}document.forms.lifeDues.item_name.value=e;document.forms.lifeDues.amount.value=calculatePaypalFee(lifeFees[a]);document.getElementById("lifeFee").innerHTML=breakDown("Lifetime Membership",lifeFees[a]);document.getElementById("lifeDuesSubmit").style.display="block"}}function petitionFee(){document.getElementById("petition").innerHTML=breakDown("Petition Fee",petitionHours*minimumWage+petitionAssesment);document.forms.petitionFee.amount.value=calculatePaypalFee(petitionHours*minimumWage+petitionAssesment)}function IsValidDate(b,c,d){var e=c+"/"+b+"/"+d,a=new Date(e);if(a.getDate()!=b){alert("Invalid Date");return false}else if(a.getMonth()!=c-1){alert("Invalid Date");return false}else if(a.getFullYear()!=d){alert("Invalid Date");return false}return true}