// $Id: costofwar.js,v 1 2009/04/14 brendan $
/**
 * @file
 * This file is for embedding the Cost of War counter for Iraq.
 *
 * Please note, this file is still served for legacy purposes only! 
 * Please see costofwar.com for instructions on how to update to the newest
 * version of the cost of war counter.
 *
 * 
 */


var curamount=0;var curscale=0;var curunit="";var geographicscale=1;function calc_amount(){var totalDollars=687000000000;var startOfWar=new Date("Mar 20, 2003");var budgetedThrough=new Date("Sept 30, 2009");var totalMS=budgetedThrough-startOfWar;var ratePerMS=totalDollars/totalMS;var curDate=new Date();var diff=curDate-startOfWar;if(diff<0){alert("costofwar.com uses your computers date to calculate the cost. "+"Yours must be wrong because according to your computer the war "+"hasn't even started yet!")}curamount=(diff*ratePerMS)*geographicscale}function number_str(n){var x=n.toString();var dot=x.lastIndexOf('.');x=x.substr(0,dot);var l=x.length;var res="";for(l-=3;l>0;l-=3){res=","+x.substr(l,3)+res}res=x.substr(0,l+3)+res;return res}function inc_totals_at_rate(rate){calc_amount();document.getElementById("raw").innerHTML="$"+number_str(curamount);try{if(curscale!=0){var altamount=curamount/curscale;document.getElementById("alt").firstChild.nodeValue=number_str(altamount)+curunit}else{document.getElementById("alt").firstChild.nodeValue=""}}catch(e){}setTimeout('inc_totals_at_rate('+rate+');',rate)}function inc_totals(){inc_totals_at_rate(100)}function setCurScale(scale){geographicscale=scale}