// JavaScript Document
<!-- 

// Welcome Visitors: I have tried to make the JavaScript here inviting
// so that you can read it and point out any mistakes I may have made
// in the calculation.  Feel free to e-mail me at niko@alum.mit.edu 
// if something is confusing or you think you have found a mistake.

// Set up some global variables:
var curamount=0;  	   // total amount spent on war in dollars
var curscale=0;   	   // number of dollars per alternate scale
var curunit="";   	   // name of the alternate scale
var geographicscale=1; // scale the final number by this amount



// ===========================================================================
// Custom Units (like "public housing")

// This function is called from the links below that change the unit.
// It updates the global variables above, which are in turn read by
// the function inc_totals() below which actually modifies the content
// of the web page that you see.
function set_unit (altscale, altunit) {
  curscale = altscale;
  curunit = altunit;
}



// ===========================================================================
// Number Display and Updater

// This function modifies the global variable 'curamount' 
// to contain the total number of dollars spent on the war so far given the 
// estimates described in numbers.html.  

function calc_amount () {
  // 'totalms' is the number of milliseconds between Apr 17, 2003 (at which 
  // point $50 billion had been spent) and Sep 30, 2004 (at which point 
  // we'll have spent $135 billion).
  //
  // We just accrue the amount linearly for now.  Close enough for government
  // work, as they say.
  //var totalms       = 53825644800;
  var totalms       = 80179200000;
  var initialdollars= 0;
  var totaldollars  = 204556261200 - initialdollars;
  var rateperms     = totaldollars / totalms;
          
  var startofwar = new Date ("Apr 17, 2003");
  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!");
  }
  
  // Do the actual calculations and get the amount before and after interest.
  // Note that we include the geographicscale as well.
  curamount = (initialdollars + diff * rateperms) * geographicscale;
}

// Converts a number 'n' to a string with commas every three characters.
function number_str (n) {
  //var x = n.toFixed (0);  this doesn't seem to work on some browsers
  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;
}

// This function actually modifies the web page --- first it determines
// the total dollars spent on the war via calc_amount(), then it modifies
// the two items in the web page, which are identified by their id ('raw'
// and 'alt').  It then sets itself up to be called again in 200 milliseconds
// so as to continuously update the page.
function inc_totals_at_rate(rate) {

  // first calculate total dollars spent.
  calc_amount ();

  // redisplay the raw total 
  document.getElementById ("raw").firstChild.nodeValue = 
  "$" + number_str(curamount);
  //firefox fix of original just above
  //document.getElementById ("raw").innerHTML =
  //"$" + number_str(curamount);

  // convert units to the scale selected by the user, if any, and display.
  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)
  {
     // ignore if there is no 'alt' element
  }

  // run this function again in 100 milliseconds 
  setTimeout('inc_totals_at_rate('+rate+');', rate);

}
function inc_totals_at_rate2(rate) {

  // first calculate total dollars spent.
  calc_amount ();

  // redisplay the raw total 
  document.getElementById ("raw").firstChild.nodeValue = 
  "$" + number_str(curamount);

  // convert units to the scale selected by the user, if any, and display.
  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)
  {
     // ignore if there is no 'alt' element
  }

  // run this function again in 100 milliseconds 
  setTimeout('inc_totals_at_rate('+rate+');', rate);

}

// For backwards compatibility, this function will cause the totals to
// increment at a rate of 100ms.
function inc_totals ()
{
  inc_totals_at_rate (100);
}

// ===========================================================================
// Geographic Scaling

var states = new Array("Entire U.S.", 
"Alabama", 
"Alaska", 
"Arizona", 
"Arkansas", 
"California", 
"Colorado", 
"Connecticut", 
"Delaware", 
"District of Columbia", 
"Florida", 
"Georgia", 
"Hawaii", 
"Idaho", 
"Illinois", 
"Indiana", 
"Iowa", 
"Kansas", 
"Kentucky", 
"Louisiana", 
"Maine", 
"Maryland", 
"Massachusetts", 
"Michigan", 
"Minnesota", 
"Mississippi", 
"Missouri", 
"Montana", 
"Nebraska", 
"Nevada", 
"New Hampshire", 
"New Jersey", 
"New Mexico", 
"New York", 
"North Carolina", 
"North Dakota", 
"Ohio", 
"Oklahoma", 
"Oregon", 
"Pennsylvania", 
"Rhode Island", 
"South Carolina", 
"South Dakota", 
"Tennessee", 
"Texas", 
"Utah", 
"Vermont", 
"Virginia", 
"Washington", 
"West Virginia", 
"Wisconsin", 
"Wyoming");

var geodata = new Array(
"Entire U.S.","Entire U.S.",1.000000000,
"Entire U.S.","Per Household",0.000000009,
"Entire U.S.","Per Person",0.000000004,
"Alabama","Entire State",0.009385552,
"Alabama","Birmingham",0.000401373,
"Alabama","Montgomery",0.000444001,
"Alaska","Entire State",0.001988017,
"Alaska","Anchorage",0.000888982,
"Alaska","Valdez",0.000016511,
"Arizona","Entire State",0.013151001,
"Arizona","Cochise County",0.000238926,
"Arizona","Phoenix",0.003440329,
"Arizona","Prescott",0.000076026,
"Arizona","Tucson",0.000952944,
"Arkansas","Entire State",0.008793570,
"Arkansas","Little Rock",0.000703265,
"Arkansas","Pulaski County",0.001408375,
"Arkansas","Rogers",0.000160628,
"California","Entire State",0.126226373,
"California","Arroyo Grande",0.000059995,
"California","Benicia",0.000142537,
"California","Berkeley",0.000358633,
"California","Brea",0.000166040,
"California","Butte County",0.000508936,
"California","Cambria",0.000022005,
"California","Campbell",0.000201142,
"California","Chico",0.000138116,
"California","Clayton",0.000085840,
"California","Fremnt",0.001222285,
"California","Goleta",0.000261260,
"California","Hayward",0.000562316,
"California","Humboldt County",0.000309994,
"California","Imperial County",0.000356006,
"California","Lodi",0.000176977,
"California","Los Angeles",0.010636277,
"California","Los Angeles County",0.031513029,
"California","Manteca",0.000180411,
"California","Marin County",0.001383614,
"California","Mendocino County",0.000243654,
"California","Modesto",0.000598593,
"California","Mount Shasta",0.000007529,
"California","Mountain View",0.000384835,
"California","Nevada City",0.000008634,
"California","Oakland",0.001255568,
"California","Orange County",0.013136758,
"California","Oxnard",0.000649695,
"California","Palo Alto",0.000415552,
"California","Pasadena",0.000483562,
"California","Paso Robles",0.000074767,
"California","Placer County",0.001121414,
"California","Redding",0.000216967,
"California","Richmond",0.000344181,
"California","Salinas",0.000518220,
"California","San Bernardino",0.000453017,
"California","San Bernardino County",0.005642450,
"California","Sacramento",0.001183244,
"California","San Diego",0.004390180,
"California","San Diego County",0.010391997,
"California","San Francisco",0.003365582,
"California","San Joaquin County",0.001825637,
"California","San Jose",0.004932676,
"California","San Luis Obispo",0.000110661,
"California","San Mateo County",0.003929635,
"California","San Rafael",0.000268317,
"California","Santa Barbara",0.000344095,
"California","Santa Clara City",0.000557784,
"California","Santa Clara County",0.009814192,
"California","Santa Cruz",0.000216778,
"California","Santa Rosa",0.000589845,
"California","Shasta County",0.000439836,
"California","Solano County",0.001674814,
"California","Sonoma County",0.001909984,
"California","Stockton",0.000675199,
"California","Tracy",0.000280058,
"California","Vallejo",0.000458362,
"California","Ventura County",0.003526303,
"California","Willits",0.000010462,
"California","Winters",0.000026521,
"California","Yolo County",0.000683187,
"Colorado","Entire State",0.015258038,
"Colorado","Boulder",0.000318371,
"Colorado","Colorado Springs",0.001222649,
"Colorado","Denver",0.001646412,
"Colorado","Durango",0.000036506,
"Colorado","Ft. Collins",0.000396431,
"Colorado","Glenwood Springs",0.000025542,
"Colorado","Greeley",0.000210522,
"Colorado","La Plata County",0.000132613,
"Colorado","Longmont",0.000273407,
"Colorado","Loveland",0.000179204,
"Colorado","New Castle",0.000008200,
"Colorado","Parachute",0.000002359,
"Colorado","Rifle",0.000021788,
"Colorado","Silt",0.000005836,
"Connecticut","Entire State",0.024117183,
"Connecticut","Danbury",0.000476989,
"Connecticut","Greenwich",0.000794927,
"Connecticut","Hartford",0.000396208,
"Connecticut","Madison",0.000205160,
"Connecticut","New Haven",0.000480537,
"Connecticut","New London ",0.000113957,
"Connecticut","Simsbury",0.000253191,
"Connecticut","Stamford",0.000930932,
"Connecticut","Westport",0.000405270,
"Delaware","Entire State",0.005658278,
"Delaware","Dover",0.000189377,
"Delaware","Wilmington",0.000388875,
"District of Columbia","Entire State",0.006729184,
"Florida","Entire State",0.052790892,
"Florida","Bradenton",0.000147016,
"Florida","Brevard County",0.001624888,
"Florida","Gainesville",0.000228734,
"Florida","Hillsborough County",0.003456333,
"Florida","Merritt Island CDP",0.000133681,
"Florida","Miami",0.000724267,
"Florida","Orange County",0.003596769,
"Florida","Palm Beach County",0.004337275,
"Florida","Sarasota",0.000152851,
"Florida","Seminole County",0.001767964,
"Florida","Tallahassee",0.000391811,
"Georgia","Entire State",0.028670679,
"Georgia","Atlanta",0.001195174,
"Georgia","Brunswick",0.000028676,
"Georgia","Gwinnet County",0.002940136,
"Georgia","Hinesville",0.000087827,
"Georgia","Pooler",0.000024306,
"Georgia","Richmond Hill",0.000027030,
"Georgia","Savannah",0.000315184,
"Georgia","Thunderbolt",0.000006919,
"Georgia","Tybee Island",0.000013925,
"Hawaii","Entire State",0.003092731,
"Hawaii","Hawaii County",0.000303238,
"Hawaii","Hilo",0.000081740,
"Hawaii","Honolulu",0.000859085,
"Hawaii","Kailua",0.000020562,
"Idaho","Entire State",0.002671695,
"Idaho","Boise",0.000433224,
"Idaho","Idaho Falls",0.000112941,
"Illinois","Entire State",0.053269432,
"Illinois","Chicago",0.010298120,
"Illinois","Dupage County",0.005650942,
"Illinois","Nashville",0.000012197,
"Illinois","Oak Park",0.000286183,
"Illinois","Wilmette",0.000267973,
"Indiana","Entire State",0.015236568,
"Indiana","Anderson",0.000117309,
"Indiana","Decatur",0.000021387,
"Indiana","Fort Wayne",0.000452896,
"Indiana","Indianapolis",0.001887766,
"Indiana","Madison County",0.000312931,
"Indiana","Richmond",0.000071252,
"Indiana","South Bend",0.000210786,
"Iowa","Entire State",0.007214186,
"Iowa","Coralville",0.000035970,
"Iowa","Des Moines",0.000476638,
"Iowa","Dubuque",0.000132541,
"Iowa","Dubuque County",0.000220391,
"Iowa","Iowa City",0.000135932,
"Iowa","Johnson County",0.000277758,
"Iowa","Mt. Vernon",0.000010847,
"Kansas","Entire State",0.008021480,
"Kansas","Allen County",0.000033261,
"Kansas","Bourbon County",0.000035241,
"Kansas","Fort Scott",0.000016375,
"Kansas","Hutchinson",0.000097794,
"Kansas","Iola",0.000013524,
"Kansas","Kansas City",0.000356086,
"Kansas","Smith Center",0.000003809,
"Kansas","Smith County",0.000009490,
"Kansas","Topeka",0.000322930,
"Kentucky","Entire State",0.008310536,
"Kentucky","Lexington-Fayette",0.000633346,
"Kentucky","Louisville",0.000451295,
"Kentucky","Mt. Sterling",0.000009706,
"Louisiana","Entire State",0.009170563,
"Louisiana","Baton Rouge",0.000435941,
"Louisiana","New Orleans",0.000828650,
"Maine","Entire State",0.002975661,
"Maine","Bangor",0.000058664,
"Maine","Benton",0.000006188,
"Maine","Brunswick",0.000053611,
"Maine","Fairfield",0.000015021,
"Maine","Freeport",0.000025432,
"Maine","Lewiston",0.000065296,
"Maine","Lincoln County",0.000081506,
"Maine","Oakland",0.000013047,
"Maine","Portland",0.000143554,
"Maine","Waterville",0.000026227,
"Maine","Winslow",0.000019208,
"Maryland","Entire State",0.019870146,
"Maryland","Baltimore",0.001389802,
"Maryland","Montgomery County",0.004434247,
"Maryland","Montgomery Village",0.000180445,
"Massachusetts","Entire State",0.028940809,
"Massachusetts","Adams",0.000025571,
"Massachusetts","Agawam",0.000125463,
"Massachusetts","Amherst",0.000125961,
"Massachusetts","Arlington",0.000246179,
"Massachusetts","Ashfield",0.000008590,
"Massachusetts","Barnstable",0.000198259,
"Massachusetts","Barnstable County",0.000938946,
"Massachusetts","Belchertown",0.000061411,
"Massachusetts","Bernardston",0.000008803,
"Massachusetts","Blandford",0.000005800,
"Massachusetts","Boston",0.002107281,
"Massachusetts","Bourne",0.000076229,
"Massachusetts","Bridgewater",0.000148479,
"Massachusetts","Brimfield",0.000015123,
"Massachusetts","Brockton",0.000336275,
"Massachusetts","Brookline",0.000343856,
"Massachusetts","Buckland",0.000008236,
"Massachusetts","Cambridge",0.000438921,
"Massachusetts","Charlemont",0.000005705,
"Massachusetts","Chatham",0.000027219,
"Massachusetts","Chester",0.000005173,
"Massachusetts","Chesterfield",0.000005318,
"Massachusetts","Chicopee",0.000175967,
"Massachusetts","Colrain",0.000006558,
"Massachusetts","Conway",0.000009159,
"Massachusetts","Cummington",0.000003730,
"Massachusetts","Deerfield",0.000021335,
"Massachusetts","Dennis",0.000012952,
"Massachusetts","East Bridgewater",0.000070625,
"Massachusetts","East Longmeadow",0.000079770,
"Massachusetts","Easthampton",0.000065229,
"Massachusetts","Erving",0.000005302,
"Massachusetts","Fall River",0.000240765,
"Massachusetts","Falmouth",0.000159459,
"Massachusetts","Framingham",0.000327857,
"Massachusetts","Franklin County",0.000263226,
"Massachusetts","Gill",0.000006243,
"Massachusetts","Goshen",0.000004122,
"Massachusetts","Granby",0.000030049,
"Massachusetts","Granville",0.000007296,
"Massachusetts","Great Barrington",0.000030905,
"Massachusetts","Greenfield",0.000054295,
"Massachusetts","Hadley",0.000022431,
"Massachusetts","Halifax",0.000038596,
"Massachusetts","Hampden",0.000030646,
"Massachusetts","Hampden County",0.001635533,
"Massachusetts","Hampshire County",0.000633479,
"Massachusetts","Harwich",0.000046453,
"Massachusetts","Hatfield",0.000014732,
"Massachusetts","Hawley",0.000001156,
"Massachusetts","Heath",0.000003672,
"Massachusetts","Holland",0.000011313,
"Massachusetts","Holyoke",0.000109458,
"Massachusetts","Huntington",0.000009607,
"Massachusetts","Lawrence",0.000181960,
"Massachusetts","Leverett",0.000009487,
"Massachusetts","Leyden",0.000003511,
"Massachusetts","Longmeadow",0.000106477,
"Massachusetts","Lowell",0.000372021,
"Massachusetts","Ludlow",0.000089976,
"Massachusetts","Mashpee",0.000004125,
"Massachusetts","Medford",0.000314123,
"Massachusetts","Middleborough",0.000094951,
"Massachusetts","Middlefield",0.000002492,
"Massachusetts","Monroe",0.000000214,
"Massachusetts","Monson",0.000039255,
"Massachusetts","Montague",0.000025860,
"Massachusetts","Montgomery",0.000003486,
"Massachusetts","Newburyport",0.000090849,
"Massachusetts","New Bedford",0.000233327,
"Massachusetts","New Salem",0.000004083,
"Massachusetts","North Adams",0.000036574,
"Massachusetts","Northampton",0.000109350,
"Massachusetts","Northfield",0.000013089,
"Massachusetts","Orange",0.000025004,
"Massachusetts","Orleans",0.000024378,
"Massachusetts","Palmer",0.000046746,
"Massachusetts","Peabody",0.000238181,
"Massachusetts","Pelham",0.000007768,
"Massachusetts","Pittsfield",0.000147370,
"Massachusetts","Plainfield",0.000001980,
"Massachusetts","Plainville",0.000039635,
"Massachusetts","Provincetown",0.000010131,
"Massachusetts","Raynham",0.000064049,
"Massachusetts","Rowe",0.000001329,
"Massachusetts","Russell",0.000006969,
"Massachusetts","Sandwich",0.000111319,
"Massachusetts","Shelburne",0.000007812,
"Massachusetts","Shutesbury",0.000009874,
"Massachusetts","South Hadley",0.000072449,
"Massachusetts","Southampton",0.000030064,
"Massachusetts","Southwick",0.000041703,
"Massachusetts","Springfield",0.000417527,
"Massachusetts","Sunderland",0.000012664,
"Massachusetts","Tolland",0.000002043,
"Massachusetts","Truro",0.000008096,
"Massachusetts","Wales",0.000007667,
"Massachusetts","Ware",0.000032308,
"Massachusetts","Warwick",0.000002849,
"Massachusetts","Wellesley",0.000273081,
"Massachusetts","Wellfleet",0.000010808,
"Massachusetts","Wendell",0.000003902,
"Massachusetts","West Bridgewater",0.000033506,
"Massachusetts","West Springfield",0.000101395,
"Massachusetts","Westfield",0.000163627,
"Massachusetts","Westhampton",0.000007962,
"Massachusetts","Westport",0.000070966,
"Massachusetts","Whately",0.000008367,
"Massachusetts","Wilbraham",0.000079061,
"Massachusetts","Williamsburg",0.000010351,
"Massachusetts","Williamstown",0.000039443,
"Massachusetts","Winchester",0.000176651,
"Massachusetts","Worcester",0.000555114,
"Massachusetts","Worthington",0.000006081,
"Massachusetts","Yarmouth",0.000089132,
"Massachusetts","1st Congressional District",0.002322433,
"Massachusetts","6th Congressional District",0.003309906,
"Michigan","Entire State",0.028105937,
"Michigan","Alger County",0.000022411,
"Michigan","Ann Arbor",0.000334242,
"Michigan","Baraga County",0.000018646,
"Michigan","Chelsea",0.000014238,
"Michigan","Crawford County",0.000030150,
"Michigan","Chippewa County",0.000084102,
"Michigan","Delta County",0.000086605,
"Michigan","Detroit",0.001778285,
"Michigan","Dickinson County",0.000060572,
"Michigan","Gogebic County",0.000030139,
"Michigan","Grand Rapids",0.000553831,
"Michigan","Grayling",0.000002997,
"Michigan","Houghton County",0.000065711,
"Michigan","Iron County",0.000023756,
"Michigan","Kalamazoo",0.000152336,
"Michigan","Keweenaw County",0.000004100,
"Michigan","Lansing",0.000262723,
"Michigan","Luce County",0.000014245,
"Michigan","Ludington",0.000014862,
"Michigan","Mackinac County",0.000025222,
"Michigan","Marquette County",0.000145469,
"Michigan","Menominee County",0.000052735,
"Michigan","Ontonagon County",0.000014628,
"Michigan","Pontiac",0.000131069,
"Michigan","Schoolcraft County",0.000017553,
"Michigan","Upper Peninsula",0.000665891,
"Minnesota","Entire State",0.023359841,
"Minnesota","Albert Lea",0.000060761,
"Minnesota","Duluth",0.000295813,
"Minnesota","Mankato",0.000110982,
"Minnesota","Minneapolis",0.001464469,
"Minnesota","Rochester",0.000424560,
"Minnesota","St. Paul",0.001122224,
"Minnesota","Winona",0.000089613,
"Mississippi","Entire State",0.004543523,
"Mississippi","Greenville",0.000055031,
"Mississippi","Jackson",0.000285692,
"Mississippi","Lee County",0.000139670,
"Mississippi","Tupelo",0.000066975,
"Mississippi","Washington County",0.000082695,
"Missouri","Entire State",0.018185272,
"Missouri","Kansas City",0.001407243,
"Missouri","Lafayette County",0.000107975,
"Missouri","Lexington",0.000012499,
"Missouri","St. Louis",0.000810132,
"Montana","Entire State",0.001624689,
"Montana","Butte",0.000056398,
"Montana","Helena",0.000048382,
"Nebraska","Entire State",0.007301984,
"Nebraska","Lincoln",0.000995787,
"Nebraska","Omaha",0.001696219,
"Nevada","Entire State",0.009100869,
"Nevada","Las Vegas",0.002153957,
"Nevada","Reno",0.000747287,
"New Hampshire","Entire State",0.004566790,
"New Hampshire","Alstead",0.000006273,
"New Hampshire","Cheshire County",0.000233742,
"New Hampshire","Chesterfield",0.000013588,
"New Hampshire","Concord",0.000129019,
"New Hampshire","Dublin",0.000005750,
"New Hampshire","Fitzwilliam",0.000007697,
"New Hampshire","Gilsum town",0.000002517,
"New Hampshire","Harrisville",0.000003905,
"New Hampshire","Hinsdale",0.000011016,
"New Hampshire","Jaffrey",0.000018422,
"New Hampshire","Keene",0.000062422,
"New Hampshire","Keene",0.000062422,
"New Hampshire","Manchester",0.000325944,
"New Hampshire","Marlborough",0.000006739,
"New Hampshire","Marlow",0.000002511,
"New Hampshire","Merrimack County",0.000493796,
"New Hampshire","Nashua",0.000336232,
"New Hampshire","Nelson",0.000001954,
"New Hampshire","Peterborough",0.000020824,
"New Hampshire","Richmond",0.000003954,
"New Hampshire","Rindge",0.000020562,
"New Hampshire","Roxbury",0.000000874,
"New Hampshire","Stoddard",0.000002609,
"New Hampshire","Sullivan",0.000002845,
"New Hampshire","Surry",0.000002864,
"New Hampshire","Swanzey",0.000022768,
"New Hampshire","Troy",0.000006138,
"New Hampshire","Walpole",0.000011994,
"New Hampshire","Westmoreland",0.000007292,
"New Hampshire","Winchester",0.000011567,
"New Jersey","Entire State",0.044226888,
"New Jersey","Jersey City",0.000866296,
"New Jersey","Maplewood",0.000181169,
"New Jersey","Newark",0.000701688,
"New Jersey","Ocean City",0.000064723,
"New Mexico","Entire State",0.003368009,
"New Mexico","Albuquerque",0.000931327,
"New Mexico","Las Cruces",0.000122724,
"New Mexico","Santa Fe",0.000136289,
"New Mexico","Taos",0.000006378,
"New York","Entire State",0.085530074,
"New York","Albany",0.000298483,
"New York","Ardsley",0.000046688,
"New York","Binghampton",0.000126305,
"New York","Broome County",0.000736256,
"New York","Buffalo",0.000745819,
"New York","Chautauqua County",0.000485664,
"New York","Dobbs Ferry",0.000077598,
"New York","Erie County",0.003806665,
"New York","East Hampton",0.000007844,
"New York","Greenburgh",0.000724380,
"New York","Hastings-on-Hudson",0.000066083,
"New York","Herkimer County",0.000220325,
"New York","Irvington",0.000066442,
"New York","Jamestown",0.000085152,
"New York","Madison County",0.000289837,
"New York","Monroe County",0.003428730,
"New York","Nassau County",0.009984667,
"New York","New Paltz",0.000013630,
"New York","New York City",0.031852430,
"New York","Oneida County",0.000878256,
"New York","Onondoga County",0.001944591,
"New York","Rockland County",0.002024490,
"New York","Rome",0.000122131,
"New York","Suffolk County",0.009625266,
"New York","Tarrytown",0.000079207,
"New York","Tompkins County",0.000373593,
"New York","Ulster County",0.000785599,
"New York","Utica",0.000156964,
"New York","Westchester County",0.006098680,
"North Carolina","Entire State",0.024042611,
"North Carolina","Chapel Hill",0.000145344,
"North Carolina","Hillsborough",0.000016652,
"North Carolina","Person County",0.000100904,
"North Carolina","Raleigh",0.000980996,
"North Carolina","Union County",0.000477397,
"North Dakota","Entire State",0.001300770,
"North Dakota","Bismarck",0.000128140,
"North Dakota","Grand Forks",0.000098716,
"Ohio","Entire State",0.037642513,
"Ohio","Akron",0.000559445,
"Ohio","Athens",0.000029582,
"Ohio","Cincinnati",0.001006876,
"Ohio","Cleveland",0.001004172,
"Ohio","Columbus",0.002182763,
"Ohio","Dayton",0.000368923,
"Ohio","Mansfield",0.000120548,
"Ohio","Toledo",0.000826314,
"Ohio","Youngstown",0.000160705,
"Oklahoma","Entire State",0.012196529,
"Oklahoma","Oklahoma City",0.001871811,
"Oklahoma","Tulsa",0.001468948,
"Oregon","Entire State",0.008150318,
"Oregon","Albany",0.000093732,
"Oregon","Coos County",0.000115287,
"Oregon","Corvallis",0.000101182,
"Oregon","Grants Pass",0.000039102,
"Oregon","Junction City",0.000009715,
"Oregon","Multnomah County",0.001587303,
"Oregon","Myrtle Creek",0.000006103,
"Oregon","Portland",0.001236730,
"Oregon","Roseburg",0.000036419,
"Oregon","Salem",0.000309952,
"Oregon","Yamhill County",0.000218274,
"Pennsylvania","Entire State",0.038304411,
"Pennsylvania","Allegheny Co.",0.003820376,
"Pennsylvania","Aliquippa",0.000022917,
"Pennsylvania","Barrett",0.000013166,
"Pennsylvania","Beaver County",0.000521931,
"Pennsylvania","Bethlehem",0.000198671,
"Pennsylvania","Chestnuthill",0.000056299,
"Pennsylvania","Coolbaugh",0.000055202,
"Pennsylvania","Delaware Water Gap Borough",0.000002182,
"Pennsylvania","East Stroudsburg Borough",0.000028145,
"Pennsylvania","Eldred",0.000008808,
"Pennsylvania","Erie",0.000228967,
"Pennsylvania","Huntingdon",0.000016818,
"Pennsylvania","Jackson",0.000024331,
"Pennsylvania","Ligonier Borough",0.000004211,
"Pennsylvania","Middle Smithfield",0.000045086,
"Pennsylvania","Monroe County",0.000498904,
"Pennsylvania","Montgomery County",0.003548395,
"Pennsylvania","Mt. Pocono Borough",0.000008577,
"Pennsylvania","Paradise",0.000010037,
"Pennsylvania","Philadelphia",0.003628569,
"Pennsylvania","Pittsburgh",0.000743816,
"Pennsylvania","Pocono",0.000034448,
"Pennsylvania","Polk",0.000022871,
"Pennsylvania","Price",0.000010344,
"Pennsylvania","Ross",0.000020597,
"Pennsylvania","Smithfield",0.000022764,
"Pennsylvania","Stroud",0.000058079,
"Pennsylvania","Stroudsburg Borough",0.000014507,
"Pennsylvania","Tobyhanna",0.000020674,
"Pennsylvania","Tunkhannock",0.000016449,
"Pennsylvania","York",0.000084132,
"Rhode Island","Entire State",0.004217784,
"Rhode Island","Little Compton",0.000019016,
"Rhode Island","Newport",0.000102923,
"Rhode Island","Providence",0.000445888,
"South Carolina","Entire State",0.007957078,
"South Carolina","Charleston",0.000182450,
"South Carolina","Columbia",0.000193668,
"South Dakota","Entire State",0.001639869,
"South Dakota","Rapid City",0.000132048,
"South Dakota","Sioux Falls",0.000314667,
"Tennessee","Entire State",0.015515204,
"Tennessee","Greene County",0.000143352,
"Tennessee","Greeneville",0.000029636,
"Tennessee","Knoxville",0.000358556,
"Tennessee","Memphis",0.001574190,
"Tennessee","Nashville",0.001605205,
"Tennessee","Obion County",0.000079742,
"Tennessee","Weakley County",0.000078537,
"Texas","Entire State",0.075358455,
"Texas","Amarillo",0.000549113,
"Texas","Arlington",0.001435267,
"Texas","Austin",0.002536957,
"Texas","Beaumont",0.000335573,
"Texas","Brownsville",0.000309446,
"Texas","Bryan",0.000188234,
"Texas","College Station",0.000130153,
"Texas","Dallas",0.004048190,
"Texas","Dripping Springs",0.000008110,
"Texas","Dripping Springs-Wimberly Sub-County Area",0.000128039,
"Texas","El Paso",0.001638965,
"Texas","Galveston",0.000149726,
"Texas","Georgetown",0.000138767,
"Texas","Hays County",0.000497199,
"Texas","Houston",0.006474925,
"Texas","Potter County",0.000303108,
"Texas","Randall County",0.000403279,
"Texas","Round Rock",0.000333983,
"Texas","San Antonio",0.003752054,
"Texas","San Marcos",0.000116678,
"Texas","Santa Fe",0.000041095,
"Texas","Tyler",0.000258668,
"Texas","Tyler County",0.000056312,
"Texas","Van Zandt Co.",0.000152635,
"Texas","Williamson County",0.001372074,
"Texas","Wimberley",0.000019559,
"Utah","Entire State",0.004752939,
"Utah","Ogden",0.000122383,
"Utah","Provo",0.000167962,
"Utah","Salt Lake City",0.000312521,
"Utah","Salt Lake County",0.002022758,
"Utah","Utah County",0.000786205,
"Utah","West Jordan",0.000177466,
"Utah","West Valley",0.000232006,
"Vermont","Entire State",0.001616981,
"Vermont","Burlington",0.000083602,
"Vermont","Brattleboro",0.000024970,
"Vermont","Montpelier",0.000019594,
"Vermont","Rutland County",0.000151432,
"Vermont","Strafford",0.000003173,
"Virginia","Entire State",0.029010827,
"Virginia","Nelson County",0.000046635,
"Virginia","Richmond",0.000540472,
"Washington","Entire State",0.023716799,
"Washington","Edmonds",0.000185906,
"Washington","Island County",0.000286281,
"Washington","Olympia",0.000152644,
"Washington","Thurston County",0.000856210,
"Washington","Seattle",0.002264927,
"Washington","Spokane",0.000554973,
"Washington","Vancouver",0.000525187,
"Washington","White Salmon",0.000006706,
"Washington","Yakima County",0.000681421,
"Washington","Yakima",0.000186144,
"West Virginia","Entire State",0.002905262,
"West Virginia","Charles Town",0.000005117,
"West Virginia","Charleston",0.000098291,
"West Virginia","Martinsburg",0.000023891,
"West Virginia","Mingo County",0.000032629,
"West Virginia","Wood County",0.000158441,
"Wisconsin","Entire State",0.016624909,
"Wisconsin","Beaver Dam",0.000040663,
"Wisconsin","Cedarburg",0.000043569,
"Wisconsin","5th Cong. Dist.",0.001278484,
"Wisconsin","Columbia County",0.000167354,
"Wisconsin","Eau Claire",0.000158970,
"Wisconsin","Grant County",0.000127139,
"Wisconsin","Green Bay",0.000281124,
"Wisconsin","Iowa County",0.000068555,
"Wisconsin","Lafayette County",0.000042512,
"Wisconsin","Madison",0.000617628,
"Wisconsin","Manitowoc",0.000092080,
"Wisconsin","Milwaukee",0.001361253,
"Wisconsin","Milwaukee County",0.002535365,
"Wisconsin","Ozaukee County",0.000365578,
"Wisconsin","Polk County",0.000120442,
"Wisconsin","Port Washington",0.000039878,
"Wisconsin","Portage",0.000024660,
"Wisconsin","Racine city",0.000215318,
"Wisconsin","Racine County",0.000642333,
"Wisconsin","Sauk County",0.000163941,
"Wisconsin","Shawano",0.000018528,
"Wyoming","Entire State",0.001845425,
"Wyoming","Casper",0.000179048,
"Wyoming","Cheyenne",0.000203160
);

// There are subpages of costofwar.com that display the cost of war just
// for individual parts of the country.  For example, Montgomery County, MD
// plays .0039 of the total taxes for the war.  Setting this value allows
// us to scale the numbers to account for that.
function set_custom_geographic (geoscale) {
  geographicscale = geoscale;
}

// Called on the change of a pulldown which selects a locale.  Just calls
// set_custom_geographic with the right scaling value.  The pulldown
// should have had its values created by fill_pulldown() below.
function choose_locale (states, cities) {

  set_custom_geographic (cities.options[cities.selectedIndex].value);

  var statename = states.options[states.selectedIndex].text;
  var cityname = cities.options[cities.selectedIndex].text;

  var local = "";
  var local2 = "";

  if (cityname == "Entire State") {
    local = " " + statename;
    local2 = " in " + statename;
  }
  else if (cityname == "Entire U.S.") {
    local = " the United States";
    local2 = "";
  }
  else if (cityname == "Per Person") {
    local = " (per Person)";
    local2 = " per person";
  }
  else if (cityname == "Per Household") {
    local = " (per Household)";
    local2 = " per household";
  }
  else {
    local = " " + cityname;
    local2 = " in " + cityname;
  }

  document.getElementById ("geo1").firstChild.nodeValue = local;

  try {
    document.getElementById ("geo2").firstChild.nodeValue = local2;
  } catch (e) {
    // ignore if no geo2 element
  }
}



// This function sets the options for the states pulldown menu.
function fill_states (slider) {
  var opts = slider.options;
  opts.length =  0; // remove all existing options
  for (var i = 0; i < states.length; i ++) {
    opts[opts.length] = new Option (states[i], states[i], false, false);
  }
}

// This function sets the options for the pulldown menu: the names are the
// names from the list above, and the value is the geographic scale.
function set_city_list (stateslider, cityslider) {
  var opts = cityslider.options;
  opts.length =  0; // remove all existing options

  state = stateslider.options[stateslider.selectedIndex].value
//where the list gets made where there should be by the household
  for (var i = 0; i < geodata.length; i += 3) {
    if (geodata[i] == state) {
      opts[opts.length] = 
        new Option (geodata[i+1], geodata[i+2], false, false);
    }
  }

  // Call choose_locale to set the scaling for the current state
  choose_locale (stateslider, cityslider);
}


// -->

