imageNums = new Array() ;
valuesArray = new Array() ;
var thisnum ;
var currentvalue ;

// Create an array containing all the number image sources

function imageArray()
{
        imageNums[0] = new Image() ;
        imageNums[1] = new Image() ;
        imageNums[2] = new Image() ;
        imageNums[3] = new Image() ;
        imageNums[4] = new Image() ;
        imageNums[5] = new Image() ;
        imageNums[6] = new Image() ;
        imageNums[7] = new Image() ;
        imageNums[8] = new Image() ;
        imageNums[9] = new Image() ;

        imageNums[0].src = "/images/0.gif" ;
        imageNums[1].src = "/images/1.gif" ;
        imageNums[2].src = "/images/2.gif" ;
        imageNums[3].src = "/images/3.gif" ;
        imageNums[4].src = "/images/4.gif" ;
        imageNums[5].src = "/images/5.gif" ;
        imageNums[6].src = "/images/6.gif" ;
        imageNums[7].src = "/images/7.gif" ;
        imageNums[8].src = "/images/8.gif" ;
        imageNums[9].src = "/images/9.gif" ;
}

// update the image sources to reflect the new tally
function setImages(thevalue)
{
        // caters for an 8 digit number only
        for(y=0;y<thevalue.length;y++)
        {
                valuesArray[y] = thevalue.substring(y,y+1) ;
        }

        for(x=0;x<8;x++)
        {
                thisnum = valuesArray[x] ;
                if(document['tallynum' + x].src != imageNums[thisnum].src)
                {
                        document['tallynum' + x].src = imageNums[thisnum].src ;
                }
        }
}

// set the start value for the tally

function setValues()

// set the start value for the tally function setValues()

{
// Amended by Andy Proyer andy@bravenewway.com on 18th June 2003
// multiply by 3000000 (amount of deaths in 2000, best known rate) 
// add 21.8 million to ensure that all deaths between start of 1970 and end of 2001 are included
 
	  var now = new Date();
// get today's date in milliseconds since start of 1970
// divide by number of milliseconds in a year to get number of years since start of 1970
	  var total = (now.getTime() / (365*24*60*60*1000));
// subtract 33.483875 years to start rate calculation from mid-June 2003
// (as per request from SAC in mid-June 2003 that clock should read 42,000,000)
	  var total = (total-33.483875);
// multiply by 4,993,200 (amount of infections per year [June 2003]) 
	  var total = (total*4993200);
// add 40 million 
// (as per request from SAC in mid-June 2003 that clock should read 42,000,000)	  
	  var total = (total+40000000);
	  
//	  This was the old calculation: var total = (((now.getTime() / (365*24*60*60*1000)) - 32 ) * 3000000) + 28800000 ;
	  
	  var startvalue = total;
	
        document.forms.thecounter.counterValue.value = startvalue ; 
        currentvalue = parseInt(startvalue) ;
}

// update the number of deaths every minute, and refresh the numbers
function setDeaths()

{
        currentvalue = parseInt(currentvalue) + 1 ;
        setImages(currentvalue.toString()) ;
        document.forms.thecounter.counterValue.value = currentvalue ;
		// Line below changed June 2003 to represent 9.5 people infected every minute
        setTimeout("setDeaths()",6315) ;
}

function navigate(thePage)
{
	window.document.location = thePage + "?" + document.forms.thecounter.counterValue.value ;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

