

var countdownstart;
var epochtimemilliseconds = GetCookie();
var nowdate = new Date();
var nowtime = nowdate.getTime();
var redirect_url = "http://www.taxliensmadeeasy.com/indxtmsup.php?pv=1";
var daystoexp = "3";

if (epochtimemilliseconds > 0)
{
	milliseconds_elapsed = nowtime - epochtimemilliseconds;
	if (milliseconds_elapsed >= (86400000 * daystoexp)) //86400 seconds in 1 day, times 1000 milliseconds/second
	{
		location.replace(redirect_url);
	}
	else { countdownstart = Math.round(((86400000 * daystoexp) - milliseconds_elapsed)); } //boda-change
}
else
{
	countdownstart = 86400 *1000 * daystoexp;//boda-change
	WriteCookie("etmindx", nowtime);
}

function WriteCookie(name,value) 
{
	var exp = '';
	var cookieExpiration = 365; // days
	var today = nowdate;
	var expdate = nowtime + (cookieExpiration * 24 * 60 * 60 * 1000);
	today.setTime(expdate);
	exp = '; expires=' + today.toGMTString();
	document.cookie = name + "=" + value + '; path=/;domain=taxliensmadeeasy.com' + exp;
}

function GetCookie()
{
	var cookiecontent;
	if(document.cookie.length > 0) 
	{
		var cookiename = 'etmindx=';
		var cookiebegin = document.cookie.indexOf(cookiename);
		var cookieend = 0;
		if(cookiebegin > -1) 
  		{
      			cookiebegin += 8;
      			cookieend = document.cookie.indexOf(";",cookiebegin);
      			if(cookieend < cookiebegin) 
      			{ 
      				cookieend = document.cookie.length; 
			}
			cookiecontent = document.cookie.substring(cookiebegin,cookieend);
		}
		else { cookiecontent = 0; }
	}
	else { cookiecontent = 0; }
	return cookiecontent;
}


var _countDowncontainer=0;
var _currentMilliseconds=0; //boda-change

function ActivateCountDown(strContainerID, initialValue) 
{ 
_countDowncontainer = document.getElementById(strContainerID);

if (!_countDowncontainer) {
alert("count down error: container does not exist: "+strContainerID+"\nmake sure html element with this ID exists");
return;
}

SetCountdownText(initialValue);
window.setTimeout("CountDownTick()", 100); //boda-change
}

function CountDownTick() 
{
if (_currentMilliseconds <= 0) { //boda-change
location.replace(redirect_url); //alert("your time has expired!");
return;
}

SetCountdownText(_currentMilliseconds); //boda-change
window.setTimeout("CountDownTick()", 100); //boda-change
}

function SetCountdownText(milliseconds) {
//store:
if (milliseconds < 1) { location.replace(redirect_url); }

// Calculate the interval since the last update and adjust currentMilliseconds.
var currentDate = new Date();
var currentTime = currentDate.getTime();
var elapsed = currentTime - nowtime;
_currentMilliseconds = milliseconds - elapsed;

// Don't double-count the elapsed time; update the 'nowtime' to the current time
nowtime = currentTime;

// New calculation code
var days = Math.floor(milliseconds / (24 * 60 * 60 * 1000));
milliseconds -= days * (24 * 60 * 60 * 1000);
var hours = Math.floor(milliseconds / (60 * 60 * 1000));
milliseconds -= hours * (60 * 60 * 1000);
var minutes = Math.floor(milliseconds / (60 * 1000));
milliseconds -= minutes * (60 * 1000);
var seconds = Math.floor(milliseconds / 1000);
milliseconds -= seconds * 1000;
var tenths = Math.floor(milliseconds / 100);

//build text:
var strText = "<span style='color:#000'>You will NOT be able to order after: <br></span> " + AddZero(days) + " <span style='color:#c00000'>days</span> | " + AddZero(hours) + " <span style='color:#c00000'>hours</span> | " + AddZero(minutes) + " <span style='color:#c00000'>minutes</span> | " + AddZero(seconds) + "." + tenths + " <span style='color:#c00000'>seconds</span>"; //Dave-change

//apply:
_countDowncontainer.innerHTML = strText;
}

function AddZero(num) {
return ((num >= 0)&&(num < 10))?"0"+num:num+"";
}


function WindowLoad(event) { ActivateCountDown("CountDownPanel", countdownstart); } 

