var start = new Date();
var curr = new Date();

/* SET THE FOLLOWING VALUES */
// set start date
start.setMonth(7);			// 0 = january, 11 = december
start.setDate(13);			// 1 = 1, 31=31
start.setFullYear(2010);
// set start time
start.setHours(0);			// 0 = 12 am, 23 = 11pm
start.setMinutes(0);
start.setSeconds(0);
// set sign up variables
var rate = 8000;			// sign up per month
var initial = 846244;		// initial amount of members before 
counter
/*+++++++++++++++++++++++++++++++++++*/

// start date
var startMo = start.getMonth();
var startD = start.getDate();
var startY = start.getFullYear();
// start time
var startH = start.getHours();
var startMi = start.getMinutes();
var startS = start.getSeconds();
var startZ = -300; // start is east coast
// current date
var currMo = curr.getMonth();
var currD = curr.getDate();
var currY = curr.getFullYear();
// current time
var currH = curr.getHours();
var currMi = curr.getMinutes();
var currS = curr.getSeconds();
var currZ = curr.getTimezoneOffset();
// find rate in seconds
var minMon = 43800;
var mins = 43800 / rate;
var secs = mins * 60;

function display() {
	document.write('Start is: ' + startMo + '/' + startD + '/' + startY);
	document.write('<br>');
	document.write(start.toLocaleString());
	document.write('<br><br><br>');
	document.write('Today is: ' + currMo + '/' + currD + '/' + currY);
	document.write('<br>');
	document.write(curr.toLocaleString());
}

function counter() {
	var diff = (curr.getTime() - start.getTime()) / 1000;	// difference in seconds between current time and start time
	var blocks = diff / secs; 								// amount of X minute intervals in time difference
	var change = (currZ - 300) * 60;						// seconds between time zone difference
	var adds = change / rate;								// members to add that signed up in time zone difference
	var mem = Math.round(blocks) + Math.round(adds);		// members signed up since start time
	mem+=initial;
	
	mem = convert(mem);
	return mem;
}

function convert(x)
{
	x = x.toString();
	/*var len = x.length;
	var ret = "";
  
	for(var i = len; i > 0; i--) {
		var check = ((len-i)%3)
		if(check == 0)
			ret = "," + ret;
		ret = x.charAt(i-1) + ret;
	}
	
	ret = ret.substr(0,ret.length-1);
  
	return ret;*/
  var numArray = new Array();
  numArray = x.split("");
  var retString = new String("");
  for ( n=0; n<numArray.length; n++){
    var addString = '<img src="/images/' + numArray[n] + '.gif" />';
    retString = retString.concat(addString);
  }
  return retString;
}



// IGNORE UNLESS CHANGING NUMBER BY REFRESH
var members = counter();
var t;
function timer() {
	document.getElementById('txt').value = members;
	members++;
	t = setTimeout("timer()",2000);
}

var sURL = unescape(window.location.pathname);

function doLoad()
{
    // the timeout value should be the same as in the "refresh" meta-tag
    setTimeout( "refresh()", 240*1000 );
}

function refresh()
{
    //  This version of the refresh function will cause a new
    //  entry in the visitor's history.  It is provided for
    //  those browsers that only support JavaScript 1.0.
    //
    window.location.href = sURL;
}

function refresh()
{
    //  This version does NOT cause an entry in the browser's
    //  page view history.  Most browsers will always retrieve
    //  the document from the web-server whether it is already
    //  in the browsers page-cache or not.
    //  
    window.location.replace( sURL );
}

function refresh()
{
    //  This version of the refresh function will be invoked
    //  for browsers that support JavaScript version 1.2
    //
    
    //  The argument to the location.reload function determines
    //  if the browser should retrieve the document from the
    //  web-server.  In our example all we need to do is cause
    //  the JavaScript block in the document body to be
    //  re-evaluated.  If we needed to pull the document from
    //  the web-server again (such as where the document contents
    //  change dynamically) we would pass the argument as 'true'.
    //  
    window.location.reload( false );
}
