document.writeln(''); document.writeln(''); document.writeln('
'); document.writeln('
Amazon Royalties Estimator
'); document.writeln('
Change numbers in fields.
'); document.writeln('
Calculated results are rounded.
'); document.writeln('
'); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln('
Number of titles
Average —
Price
Royalty'); document.writeln(' 35%   70%'); document.writeln(''); document.writeln('
Delivery
Per book:
Books sold per title —
Per day
Per month
Per year*
Total royalty income —
Per day
Per month
Per year*
*365-day year.
'); document.writeln('
'); document.writeln('
With compliments of Will Bontrager
'); document.writeln(''); document.writeln('
'); document.writeln(''); document.writeln(''); document.writeln(''); document.writeln('var numtitles34400, price34400, rate34400, delivery34400, latestdelivery34400, readonly34400, numday34400, nummonth34400, numyear34400, royday34400, roymonth34400, royyear34400;'); document.writeln('InitialSetup34400();'); document.writeln(''); document.writeln('function InitialSetup34400()'); document.writeln('{'); document.writeln(' numtitles34400 = 3;'); document.writeln(' price34400 = 2.99;'); document.writeln(' delivery34400 = latestdelivery34400 = 0.06;'); document.writeln(' numday34400 = 10;'); document.writeln(' rate34400 = 0;'); document.writeln(' if( price34400 >= 2.99 && price34400 <= 9.99 )'); document.writeln(' {'); document.writeln(' rate34400 = 70;'); document.writeln(' doc'+'ument.getElementById("rate34400-35-amazon-royalties-estimator").checked = false;'); document.writeln(' doc'+'ument.getElementById("rate34400-70-amazon-royalties-estimator").checked = true;'); document.writeln(' doc'+'ument.getElementById("rate34400-amazon-royalties-estimator").value = 70;'); document.writeln(' }'); document.writeln(' else'); document.writeln(' {'); document.writeln(' rate34400 = 35;'); document.writeln(' doc'+'ument.getElementById("rate34400-35-amazon-royalties-estimator").checked = true;'); document.writeln(' doc'+'ument.getElementById("rate34400-70-amazon-royalties-estimator").checked = false;'); document.writeln(' doc'+'ument.getElementById("rate34400-amazon-royalties-estimator").value = 35;'); document.writeln(' }'); document.writeln(' doc'+'ument.getElementById("numtitles34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(numtitles34400,0);'); document.writeln(' doc'+'ument.getElementById("price34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(price34400,2);'); document.writeln(' doc'+'ument.getElementById("delivery34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(delivery34400,2);'); document.writeln(' doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(numday34400,2);'); document.writeln(' FinishCalculation34400();'); document.writeln('}'); document.writeln(''); document.writeln('function UpdateAll34400()'); document.writeln('{'); document.writeln(' numtitles34400 = doc'+'ument.getElementById("numtitles34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' numtitles34400 = parseInt(numtitles34400);'); document.writeln(' doc'+'ument.getElementById("numtitles34400-amazon-royalties-estimator").value = numtitles34400;'); document.writeln('// numtitles34400 = parseInt(doc'+'ument.getElementById("numtitles34400-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(numtitles34400) )'); document.writeln(' {'); document.writeln(' numtitles34400 = 0;'); document.writeln(' doc'+'ument.getElementById("numtitles34400-amazon-royalties-estimator").value = numtitles34400;'); document.writeln(' }'); document.writeln(' price34400 = doc'+'ument.getElementById("price34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' price34400 = parseFloat(price34400);'); document.writeln(' doc'+'ument.getElementById("price34400-amazon-royalties-estimator").value = price34400;'); document.writeln('// price34400 = parseFloat(doc'+'ument.getElementById("price34400-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(price34400) )'); document.writeln(' {'); document.writeln(' price34400 = \'0.0\';'); document.writeln(' doc'+'ument.getElementById("price34400-amazon-royalties-estimator").value = price34400;'); document.writeln(' }'); document.writeln(' rate34400 = doc'+'ument.getElementById("rate34400-70-amazon-royalties-estimator").checked ? 70 : 35;'); document.writeln(' doc'+'ument.getElementById("rate34400-amazon-royalties-estimator").value = rate34400;'); document.writeln(' delivery34400 = doc'+'ument.getElementById("delivery34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' delivery34400 = parseFloat(delivery34400);'); document.writeln(' doc'+'ument.getElementById("delivery34400-amazon-royalties-estimator").value = delivery34400;'); document.writeln('// delivery34400 = parseFloat(doc'+'ument.getElementById("delivery34400-amazon-royalties-estimator").value);'); document.writeln(' doc'+'ument.getElementById("delivery34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400( parseFloat(doc'+'ument.getElementById("delivery34400-amazon-royalties-estimator").value), 2 );'); document.writeln(' if( rate34400 < 70 )'); document.writeln(' {'); document.writeln(' if( delivery34400 > 0 ) { latestdelivery34400 = delivery34400; }'); document.writeln(' doc'+'ument.getElementById("delivery34400-amazon-royalties-estimator").value = \'0.00\';'); document.writeln(' delivery34400 = 0.0;'); document.writeln(' }'); document.writeln(' else'); document.writeln(' {'); document.writeln(' if( delivery34400 <= 0 && latestdelivery34400 > 0 )'); document.writeln(' {'); document.writeln(' delivery34400 = latestdelivery34400;'); document.writeln(' doc'+'ument.getElementById("delivery34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(delivery34400,2);'); document.writeln(' }'); document.writeln(' }'); document.writeln(''); document.writeln(' if( isNaN(delivery34400) )'); document.writeln(' {'); document.writeln(' delivery34400 = \'0.00\';'); document.writeln(' doc'+'ument.getElementById("delivery34400-amazon-royalties-estimator").value = delivery34400;'); document.writeln(' }'); document.writeln(' readonly34400 = ( numday34400 * (rate34400/100) ) - delivery34400;'); document.writeln(' numday34400 = doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' numday34400 = parseInt(numday34400);'); document.writeln(' doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value = numday34400;'); document.writeln('// numday34400 = parseInt(doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(numday34400) )'); document.writeln(' {'); document.writeln(' numday34400 = 0;'); document.writeln(' doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value = numday34400;'); document.writeln(' }'); document.writeln(' FinishCalculation34400();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromNumPerDay34400()'); document.writeln('{'); document.writeln(' numday34400 = doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' numday34400 = parseInt(numday34400);'); document.writeln(' doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value = numday34400;'); document.writeln('// numday34400 = parseInt(doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(numday34400) ) { numday34400 = 0; }'); document.writeln(' DetermineNumberSoldPerPeriods34400();'); document.writeln(' CalculateRoyaltyNumbers34400();'); document.writeln(' Update7Values34400();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromNumPerMonth34400()'); document.writeln('{'); document.writeln(' nummonth34400 = doc'+'ument.getElementById("nummonth34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' nummonth34400 = parseInt(nummonth34400);'); document.writeln(' doc'+'ument.getElementById("nummonth34400-amazon-royalties-estimator").value = nummonth34400;'); document.writeln('// nummonth34400 = parseInt(doc'+'ument.getElementById("nummonth34400-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(nummonth34400) ) { nummonth34400 = 0; }'); document.writeln(' numyear34400 = nummonth34400 * 12;'); document.writeln(' numday34400 = numyear34400 / 365;'); document.writeln(' doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value = numday34400;'); document.writeln(' doc'+'ument.getElementById("nummonth34400-amazon-royalties-estimator").value = nummonth34400;'); document.writeln(' doc'+'ument.getElementById("numyear34400-amazon-royalties-estimator").value = numyear34400;'); document.writeln(' CalculateRoyaltyNumbers34400();'); document.writeln(' Update7Values34400();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromNumPerYear34400()'); document.writeln('{'); document.writeln(' numyear34400 = doc'+'ument.getElementById("numyear34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' numyear34400 = parseInt(numyear34400);'); document.writeln(' doc'+'ument.getElementById("numyear34400-amazon-royalties-estimator").value = numyear34400;'); document.writeln('// numyear34400 = parseInt(doc'+'ument.getElementById("numyear34400-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(numyear34400) ) { numyear34400 = 0; }'); document.writeln(' numday34400 = numyear34400 / 365;'); document.writeln(' nummonth34400 = numyear34400 / 12;'); document.writeln(' doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value = numday34400;'); document.writeln(' doc'+'ument.getElementById("nummonth34400-amazon-royalties-estimator").value = nummonth34400;'); document.writeln(' doc'+'ument.getElementById("numyear34400-amazon-royalties-estimator").value = numyear34400;'); document.writeln(' CalculateRoyaltyNumbers34400();'); document.writeln(' Update7Values34400();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromRoyaltyPerDay34400()'); document.writeln('{'); document.writeln(' royday34400 = doc'+'ument.getElementById("royday34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' royday34400 = parseFloat(royday34400);'); document.writeln(' doc'+'ument.getElementById("royday34400-amazon-royalties-estimator").value = royday34400;'); document.writeln('// royday34400 = parseFloat(doc'+'ument.getElementById("royday34400-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(royday34400) ) { royday34400 = 0; }'); document.writeln(' royyear34400 = royday34400 * 365;'); document.writeln(' roymonth34400 = royyear34400 / 12;'); document.writeln(' numday34400 = royday34400 / (readonly34400 * numtitles34400);'); document.writeln(' DetermineNumberSoldPerPeriods34400()'); document.writeln(' Update7Values34400();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromRoyaltyPerMonth34400()'); document.writeln('{'); document.writeln(' roymonth34400 = doc'+'ument.getElementById("roymonth34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' roymonth34400 = parseFloat(roymonth34400);'); document.writeln(' doc'+'ument.getElementById("roymonth34400-amazon-royalties-estimator").value = roymonth34400;'); document.writeln('// roymonth34400 = parseFloat(doc'+'ument.getElementById("roymonth34400-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(roymonth34400) ) { roymonth34400 = 0; }'); document.writeln(' royyear34400 = roymonth34400 * 12;'); document.writeln(' royday34400 = royyear34400 / 365;'); document.writeln(' numday34400 = royday34400 / (readonly34400 * numtitles34400);'); document.writeln(' DetermineNumberSoldPerPeriods34400()'); document.writeln(' Update7Values34400();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromRoyaltyPerYear34400()'); document.writeln('{'); document.writeln(' royyear34400 = doc'+'ument.getElementById("royyear34400-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' royyear34400 = parseFloat(royyear34400);'); document.writeln(' doc'+'ument.getElementById("royyear34400-amazon-royalties-estimator").value = royyear34400;'); document.writeln('// royyear34400 = parseFloat(doc'+'ument.getElementById("royyear34400-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(royyear34400) ) { royyear34400 = 0; }'); document.writeln(' royday34400 = royyear34400 / 365;'); document.writeln(' roymonth34400 = royyear34400 / 12;'); document.writeln(' numday34400 = royday34400 / (readonly34400 * numtitles34400);'); document.writeln(' DetermineNumberSoldPerPeriods34400()'); document.writeln(' Update7Values34400();'); document.writeln('}'); document.writeln(''); document.writeln('function DetermineNumberSoldPerPeriods34400()'); document.writeln('{'); document.writeln(' numyear34400 = numday34400 * 365;'); document.writeln(' nummonth34400 = numyear34400 / 12;'); document.writeln('}'); document.writeln(''); document.writeln('function FinishCalculation34400()'); document.writeln('{'); document.writeln(' Calculate6Numbers34400();'); document.writeln(' Update7Values34400();'); document.writeln('}'); document.writeln(''); document.writeln('function Calculate6Numbers34400()'); document.writeln('{'); document.writeln(' // numday34400 is assumed to be have the correct value.'); document.writeln(' readonly34400 = ( price34400 * (rate34400/100) ) - delivery34400;'); document.writeln(' DetermineNumberSoldPerPeriods34400();'); document.writeln(' royday34400 = numtitles34400 * readonly34400 * numday34400;'); document.writeln(' royyear34400 = royday34400 * 365;'); document.writeln(' roymonth34400 = royyear34400 / 12;'); document.writeln('}'); document.writeln(''); document.writeln('function CalculateRoyaltyNumbers34400()'); document.writeln('{'); document.writeln(' // numday34400 is assumed to be have the correct value.'); document.writeln(' readonly34400 = ( price34400 * (rate34400/100) ) - delivery34400;'); document.writeln(' royday34400 = numtitles34400 * readonly34400 * numday34400;'); document.writeln(' royyear34400 = royday34400 * 365;'); document.writeln(' roymonth34400 = royyear34400 / 12;'); document.writeln('}'); document.writeln(''); document.writeln('function Update7Values34400()'); document.writeln('{'); document.writeln('//rate34400-35-amazon-royalties-estimator'); document.writeln(' doc'+'ument.getElementById("readonly34400-amazon-royalties-estimator").innerHTML = ReturnCurrencyNumberCommaized34400(readonly34400,2);'); document.writeln(' doc'+'ument.getElementById("numday34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(numday34400,0);'); document.writeln(' doc'+'ument.getElementById("nummonth34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(nummonth34400,0);'); document.writeln(' doc'+'ument.getElementById("numyear34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(numyear34400,0);'); document.writeln(' doc'+'ument.getElementById("royday34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(royday34400,2);'); document.writeln(' doc'+'ument.getElementById("roymonth34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(roymonth34400,2);'); document.writeln(' doc'+'ument.getElementById("royyear34400-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized34400(royyear34400,2);'); document.writeln('}'); document.writeln(''); document.writeln('function ReturnCurrencyNumber34400(n,d) { return n.toFixed(d); }'); document.writeln(''); document.writeln('function ReturnCurrencyNumberCommaized34400(n,d)'); document.writeln('{'); document.writeln(' var number = ReturnCurrencyNumber34400(n,d);'); document.writeln('return number;'); document.writeln(' var ta = number.split(\'.\',2);'); document.writeln(' if( ta[0] < 10000 ) { return number; }'); document.writeln(' var holder = new Array();'); document.writeln(' while( ta[0] > 999 )'); document.writeln(' {'); document.writeln('alert(n + "***" + number + \'***\' + ta[0]);'); document.writeln(' holder.unshift( ta[0].substr(-3) );'); document.writeln(' ta[0] = ta[0].substr(0,ta[0].length-3);'); document.writeln('alert( ta[0] + "---" + holder.join(\',\') );'); document.writeln(' }'); document.writeln(' ta[0] = holder.join(",");'); document.writeln(' return ta.join(".");'); document.writeln('}'); document.writeln(''); document.writeln(''); document.writeln('');