
var LAUNCH_DATE ="03/02/2009 00:00:00";
var INTERVAL_MSECONDS = 1000;
var EMPTIES_SECOND = 12; // ya that's right

function p (i){
return Math.floor(i / 10) + "" + i % 10;
}

function numempties(){
  numEmptyCount = numEmptyCount + (EMPTIES_SECOND * (INTERVAL_MSECONDS / 1000));
  return numEmptyCount;
}

function getInitialBottleCount(){
	var emptyCount = 0;
	var date = new Date();
	var currentDate =  p(date.getMonth() + 1) + "/" + p(date.getDate()) + "/" + date.getFullYear() + " " + p(date.getHours()) + ":" + p(date.getMinutes()) + ":" + p(date.getSeconds());

	var date1 = new Date(LAUNCH_DATE);
	var date2 = new Date(currentDate);
	var sec = date2.getTime() - date1.getTime();
	var second = 1000, minute = 60 * second, hour = 60 * minute, day = 24 * hour;

	if (isNaN(sec))
	{
	console.log("Input data is incorrect!");
	return;
	}
	if (sec < 0)
	{
	console.log("The second date occurred earlier than the first one!");
	return;
	}

	//this is the number of seconds since launch time the bottles tossed per second
	var emptyCount = (Math.floor(sec / second) * EMPTIES_SECOND );
	return emptyCount;
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

fbLogin = function()
{
	FB.login(function(response) {
		location.href = '/stampede_contest';
	});
};

fbLogout = function()
{
	FB.logout(function () {
		location.href = '/';
	});
};


//console.log($(this).html);