// how many minutes
var mins = 4;

// how many seconds (don't change this)
var secs = mins * 60;
function countdown() {
	setTimeout('Decrement()',1000);
}
function Decrement() {
	if(document.getElementById) {
		var time = $("#countdown").html().split(":");
		var out = "";
		minutes = time[0];
		seconds = time[1];

		// if less than a minute remaining
		if (secs < 59) {
			out = "0:" + zeroPad(secs,2);	
		} else {
			out = getminutes() + ":" + getseconds();
		}

		$("#countdown").html(out);
		if(secs) {
			setTimeout('Decrement()', 1000);
		} else {
			showAlert();
		}
		secs--;
	}
}
function getminutes() {
	// minutes is seconds divided by 60, rounded down
	mins = Math.floor(secs / 60);
	return mins;
}
function getseconds() {
	// take mins remaining (as seconds) away from total seconds remaining
	return zeroPad(secs-Math.round(mins *60), 2);
}

function zeroPad(num,count)
{
  var numZeropad = num + '';
  while(numZeropad.length < count) {
    numZeropad = "0" + numZeropad;
  }
  return numZeropad;
}

function showAlert() {
	alert("Warning: The Free Trial Timer has run out! You still have a chance to receive your Free Trial of Boom Boom but you must act now. Note: After time expires we cannot guarantee supplies will still be available!");
}

