
var secs_left = 462395;
var _countDowncontainer=0;
var _currentSeconds=0;

function ActivateCountDown(strContainerID, initialValue) {
	_countDowncontainer = document.getElementById(strContainerID);
	
	if (initialValue <= 0) {
		_countDowncontainer.innerHTML = "The Mini Digiclipse has begun.";
		return;
	} else {
	SetCountdownText(initialValue);
	}

	window.setTimeout("CountDownTick()", 1000);
}

function CountDownTick() {
	if (_currentSeconds <= 0) {
		_countDowncontainer.innerHTML = "The Mini Digiclipse has begun.";
		return;
	}
	
	SetCountdownText(_currentSeconds-1);
	window.setTimeout("CountDownTick()", 1000);
}

function SetCountdownText(seconds) {
	//store:
	_currentSeconds = seconds;
	
	// Calculate the number of days left
	var days=Math.floor(seconds / 86400);
	// After deducting the days calculate the number of hours left
	var hours = Math.floor((seconds - (days * 86400 ))/3600)
	// After days and hours , how many minutes are left
	var minutes = Math.floor((seconds - (days * 86400 ) - (hours *3600 ))/60)
	// Finally how many seconds left after removing days, hours and minutes.
	var secs = Math.floor((seconds - (days * 86400 ) - (hours *3600 ) - (minutes*60)))
	
	//build text:
	var strText = "This minidigiclipse will begin in : <strong>" + days + "</strong> day : <strong>" + hours + "</strong> hr : <strong>" + minutes + "</strong> min : <strong>" + secs + "</strong> sec";
	
	//apply:
	_countDowncontainer.innerHTML = strText;
}
