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 numtitles45421, price45421, rate45421, delivery45421, latestdelivery45421, readonly45421, numday45421, nummonth45421, numyear45421, royday45421, roymonth45421, royyear45421;'); document.writeln('InitialSetup45421();'); document.writeln(''); document.writeln('function InitialSetup45421()'); document.writeln('{'); document.writeln(' numtitles45421 = 3;'); document.writeln(' price45421 = 2.99;'); document.writeln(' delivery45421 = latestdelivery45421 = 0.06;'); document.writeln(' numday45421 = 10;'); document.writeln(' rate45421 = 0;'); document.writeln(' if( price45421 >= 2.99 && price45421 <= 9.99 )'); document.writeln(' {'); document.writeln(' rate45421 = 70;'); document.writeln(' doc'+'ument.getElementById("rate45421-35-amazon-royalties-estimator").checked = false;'); document.writeln(' doc'+'ument.getElementById("rate45421-70-amazon-royalties-estimator").checked = true;'); document.writeln(' doc'+'ument.getElementById("rate45421-amazon-royalties-estimator").value = 70;'); document.writeln(' }'); document.writeln(' else'); document.writeln(' {'); document.writeln(' rate45421 = 35;'); document.writeln(' doc'+'ument.getElementById("rate45421-35-amazon-royalties-estimator").checked = true;'); document.writeln(' doc'+'ument.getElementById("rate45421-70-amazon-royalties-estimator").checked = false;'); document.writeln(' doc'+'ument.getElementById("rate45421-amazon-royalties-estimator").value = 35;'); document.writeln(' }'); document.writeln(' doc'+'ument.getElementById("numtitles45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(numtitles45421,0);'); document.writeln(' doc'+'ument.getElementById("price45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(price45421,2);'); document.writeln(' doc'+'ument.getElementById("delivery45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(delivery45421,2);'); document.writeln(' doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(numday45421,2);'); document.writeln(' FinishCalculation45421();'); document.writeln('}'); document.writeln(''); document.writeln('function UpdateAll45421()'); document.writeln('{'); document.writeln(' numtitles45421 = doc'+'ument.getElementById("numtitles45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' numtitles45421 = parseInt(numtitles45421);'); document.writeln(' doc'+'ument.getElementById("numtitles45421-amazon-royalties-estimator").value = numtitles45421;'); document.writeln('// numtitles45421 = parseInt(doc'+'ument.getElementById("numtitles45421-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(numtitles45421) )'); document.writeln(' {'); document.writeln(' numtitles45421 = 0;'); document.writeln(' doc'+'ument.getElementById("numtitles45421-amazon-royalties-estimator").value = numtitles45421;'); document.writeln(' }'); document.writeln(' price45421 = doc'+'ument.getElementById("price45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' price45421 = parseFloat(price45421);'); document.writeln(' doc'+'ument.getElementById("price45421-amazon-royalties-estimator").value = price45421;'); document.writeln('// price45421 = parseFloat(doc'+'ument.getElementById("price45421-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(price45421) )'); document.writeln(' {'); document.writeln(' price45421 = \'0.0\';'); document.writeln(' doc'+'ument.getElementById("price45421-amazon-royalties-estimator").value = price45421;'); document.writeln(' }'); document.writeln(' rate45421 = doc'+'ument.getElementById("rate45421-70-amazon-royalties-estimator").checked ? 70 : 35;'); document.writeln(' doc'+'ument.getElementById("rate45421-amazon-royalties-estimator").value = rate45421;'); document.writeln(' delivery45421 = doc'+'ument.getElementById("delivery45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' delivery45421 = parseFloat(delivery45421);'); document.writeln(' doc'+'ument.getElementById("delivery45421-amazon-royalties-estimator").value = delivery45421;'); document.writeln('// delivery45421 = parseFloat(doc'+'ument.getElementById("delivery45421-amazon-royalties-estimator").value);'); document.writeln(' doc'+'ument.getElementById("delivery45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421( parseFloat(doc'+'ument.getElementById("delivery45421-amazon-royalties-estimator").value), 2 );'); document.writeln(' if( rate45421 < 70 )'); document.writeln(' {'); document.writeln(' if( delivery45421 > 0 ) { latestdelivery45421 = delivery45421; }'); document.writeln(' doc'+'ument.getElementById("delivery45421-amazon-royalties-estimator").value = \'0.00\';'); document.writeln(' delivery45421 = 0.0;'); document.writeln(' }'); document.writeln(' else'); document.writeln(' {'); document.writeln(' if( delivery45421 <= 0 && latestdelivery45421 > 0 )'); document.writeln(' {'); document.writeln(' delivery45421 = latestdelivery45421;'); document.writeln(' doc'+'ument.getElementById("delivery45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(delivery45421,2);'); document.writeln(' }'); document.writeln(' }'); document.writeln(''); document.writeln(' if( isNaN(delivery45421) )'); document.writeln(' {'); document.writeln(' delivery45421 = \'0.00\';'); document.writeln(' doc'+'ument.getElementById("delivery45421-amazon-royalties-estimator").value = delivery45421;'); document.writeln(' }'); document.writeln(' readonly45421 = ( numday45421 * (rate45421/100) ) - delivery45421;'); document.writeln(' numday45421 = doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' numday45421 = parseInt(numday45421);'); document.writeln(' doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value = numday45421;'); document.writeln('// numday45421 = parseInt(doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(numday45421) )'); document.writeln(' {'); document.writeln(' numday45421 = 0;'); document.writeln(' doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value = numday45421;'); document.writeln(' }'); document.writeln(' FinishCalculation45421();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromNumPerDay45421()'); document.writeln('{'); document.writeln(' numday45421 = doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' numday45421 = parseInt(numday45421);'); document.writeln(' doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value = numday45421;'); document.writeln('// numday45421 = parseInt(doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(numday45421) ) { numday45421 = 0; }'); document.writeln(' DetermineNumberSoldPerPeriods45421();'); document.writeln(' CalculateRoyaltyNumbers45421();'); document.writeln(' Update7Values45421();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromNumPerMonth45421()'); document.writeln('{'); document.writeln(' nummonth45421 = doc'+'ument.getElementById("nummonth45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' nummonth45421 = parseInt(nummonth45421);'); document.writeln(' doc'+'ument.getElementById("nummonth45421-amazon-royalties-estimator").value = nummonth45421;'); document.writeln('// nummonth45421 = parseInt(doc'+'ument.getElementById("nummonth45421-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(nummonth45421) ) { nummonth45421 = 0; }'); document.writeln(' numyear45421 = nummonth45421 * 12;'); document.writeln(' numday45421 = numyear45421 / 365;'); document.writeln(' doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value = numday45421;'); document.writeln(' doc'+'ument.getElementById("nummonth45421-amazon-royalties-estimator").value = nummonth45421;'); document.writeln(' doc'+'ument.getElementById("numyear45421-amazon-royalties-estimator").value = numyear45421;'); document.writeln(' CalculateRoyaltyNumbers45421();'); document.writeln(' Update7Values45421();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromNumPerYear45421()'); document.writeln('{'); document.writeln(' numyear45421 = doc'+'ument.getElementById("numyear45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' numyear45421 = parseInt(numyear45421);'); document.writeln(' doc'+'ument.getElementById("numyear45421-amazon-royalties-estimator").value = numyear45421;'); document.writeln('// numyear45421 = parseInt(doc'+'ument.getElementById("numyear45421-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(numyear45421) ) { numyear45421 = 0; }'); document.writeln(' numday45421 = numyear45421 / 365;'); document.writeln(' nummonth45421 = numyear45421 / 12;'); document.writeln(' doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value = numday45421;'); document.writeln(' doc'+'ument.getElementById("nummonth45421-amazon-royalties-estimator").value = nummonth45421;'); document.writeln(' doc'+'ument.getElementById("numyear45421-amazon-royalties-estimator").value = numyear45421;'); document.writeln(' CalculateRoyaltyNumbers45421();'); document.writeln(' Update7Values45421();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromRoyaltyPerDay45421()'); document.writeln('{'); document.writeln(' royday45421 = doc'+'ument.getElementById("royday45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' royday45421 = parseFloat(royday45421);'); document.writeln(' doc'+'ument.getElementById("royday45421-amazon-royalties-estimator").value = royday45421;'); document.writeln('// royday45421 = parseFloat(doc'+'ument.getElementById("royday45421-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(royday45421) ) { royday45421 = 0; }'); document.writeln(' royyear45421 = royday45421 * 365;'); document.writeln(' roymonth45421 = royyear45421 / 12;'); document.writeln(' numday45421 = royday45421 / (readonly45421 * numtitles45421);'); document.writeln(' DetermineNumberSoldPerPeriods45421()'); document.writeln(' Update7Values45421();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromRoyaltyPerMonth45421()'); document.writeln('{'); document.writeln(' roymonth45421 = doc'+'ument.getElementById("roymonth45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' roymonth45421 = parseFloat(roymonth45421);'); document.writeln(' doc'+'ument.getElementById("roymonth45421-amazon-royalties-estimator").value = roymonth45421;'); document.writeln('// roymonth45421 = parseFloat(doc'+'ument.getElementById("roymonth45421-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(roymonth45421) ) { roymonth45421 = 0; }'); document.writeln(' royyear45421 = roymonth45421 * 12;'); document.writeln(' royday45421 = royyear45421 / 365;'); document.writeln(' numday45421 = royday45421 / (readonly45421 * numtitles45421);'); document.writeln(' DetermineNumberSoldPerPeriods45421()'); document.writeln(' Update7Values45421();'); document.writeln('}'); document.writeln(''); document.writeln('function RecalculateFromRoyaltyPerYear45421()'); document.writeln('{'); document.writeln(' royyear45421 = doc'+'ument.getElementById("royyear45421-amazon-royalties-estimator").value.replace(/[^\\d\\.]/g,"");'); document.writeln(' royyear45421 = parseFloat(royyear45421);'); document.writeln(' doc'+'ument.getElementById("royyear45421-amazon-royalties-estimator").value = royyear45421;'); document.writeln('// royyear45421 = parseFloat(doc'+'ument.getElementById("royyear45421-amazon-royalties-estimator").value);'); document.writeln(' if( isNaN(royyear45421) ) { royyear45421 = 0; }'); document.writeln(' royday45421 = royyear45421 / 365;'); document.writeln(' roymonth45421 = royyear45421 / 12;'); document.writeln(' numday45421 = royday45421 / (readonly45421 * numtitles45421);'); document.writeln(' DetermineNumberSoldPerPeriods45421()'); document.writeln(' Update7Values45421();'); document.writeln('}'); document.writeln(''); document.writeln('function DetermineNumberSoldPerPeriods45421()'); document.writeln('{'); document.writeln(' numyear45421 = numday45421 * 365;'); document.writeln(' nummonth45421 = numyear45421 / 12;'); document.writeln('}'); document.writeln(''); document.writeln('function FinishCalculation45421()'); document.writeln('{'); document.writeln(' Calculate6Numbers45421();'); document.writeln(' Update7Values45421();'); document.writeln('}'); document.writeln(''); document.writeln('function Calculate6Numbers45421()'); document.writeln('{'); document.writeln(' // numday45421 is assumed to be have the correct value.'); document.writeln(' readonly45421 = ( price45421 * (rate45421/100) ) - delivery45421;'); document.writeln(' DetermineNumberSoldPerPeriods45421();'); document.writeln(' royday45421 = numtitles45421 * readonly45421 * numday45421;'); document.writeln(' royyear45421 = royday45421 * 365;'); document.writeln(' roymonth45421 = royyear45421 / 12;'); document.writeln('}'); document.writeln(''); document.writeln('function CalculateRoyaltyNumbers45421()'); document.writeln('{'); document.writeln(' // numday45421 is assumed to be have the correct value.'); document.writeln(' readonly45421 = ( price45421 * (rate45421/100) ) - delivery45421;'); document.writeln(' royday45421 = numtitles45421 * readonly45421 * numday45421;'); document.writeln(' royyear45421 = royday45421 * 365;'); document.writeln(' roymonth45421 = royyear45421 / 12;'); document.writeln('}'); document.writeln(''); document.writeln('function Update7Values45421()'); document.writeln('{'); document.writeln('//rate45421-35-amazon-royalties-estimator'); document.writeln(' doc'+'ument.getElementById("readonly45421-amazon-royalties-estimator").innerHTML = ReturnCurrencyNumberCommaized45421(readonly45421,2);'); document.writeln(' doc'+'ument.getElementById("numday45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(numday45421,0);'); document.writeln(' doc'+'ument.getElementById("nummonth45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(nummonth45421,0);'); document.writeln(' doc'+'ument.getElementById("numyear45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(numyear45421,0);'); document.writeln(' doc'+'ument.getElementById("royday45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(royday45421,2);'); document.writeln(' doc'+'ument.getElementById("roymonth45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(roymonth45421,2);'); document.writeln(' doc'+'ument.getElementById("royyear45421-amazon-royalties-estimator").value = ReturnCurrencyNumberCommaized45421(royyear45421,2);'); document.writeln('}'); document.writeln(''); document.writeln('function ReturnCurrencyNumber45421(n,d) { return n.toFixed(d); }'); document.writeln(''); document.writeln('function ReturnCurrencyNumberCommaized45421(n,d)'); document.writeln('{'); document.writeln(' var number = ReturnCurrencyNumber45421(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('');