/*
	Author:		Robert Hashemian (http://www.hashemian.com/)
	Modified by:	Munsifali Rashid (http://www.munit.co.uk/)
*/


function countdown(obj)
{
	this.obj		= obj;
	this.Div		= "clock";
	this.BackColor		= "white";
	this.ForeColor		= "black";
	this.TargetDate		= "12/31/2020 5:00 AM";
	this.DisplayFormat	= "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
	this.CountActive	= true;
	
	this.DisplayStr;

	this.Calcage		= cd_Calcage;
	this.CountBack		= cd_CountBack;
	this.Setup		= cd_Setup;
}

function cd_Calcage(secs, num1, num2)
{
  s = ((Math.floor(secs/num1))%num2).toString();
  if (s.length < 2) s = "0" + s;
  return (s);
}
function cd_CountBack(secs)
{
  this.DisplayStr = this.DisplayFormat.replace(/%%D%%/g,	this.Calcage(secs,86400,100000));
  this.DisplayStr = this.DisplayStr.replace(/%%H%%/g,		this.Calcage(secs,3600,24));
  this.DisplayStr = this.DisplayStr.replace(/%%M%%/g,		this.Calcage(secs,60,60));
  this.DisplayStr = this.DisplayStr.replace(/%%S%%/g,		this.Calcage(secs,1,60));

  document.getElementById(this.Div).innerHTML = this.DisplayStr;
  if (this.CountActive) setTimeout(this.obj +".CountBack(" + (secs-1) + ")", 990);
}
function cd_Setup()
{
	var dthen	= new Date(this.TargetDate);
  	var dnow	= new Date();
	ddiff		= new Date(dthen-dnow);
	gsecs		= Math.floor(ddiff.valueOf()/1000);
	this.CountBack(gsecs);
}

		/* start module changes here */

		var cd1			= new countdown('cd1');
		cd1.Div			= "clock1";
		cd1.TargetDate		= "6/6/2010 11:59 PM";
		cd1.DisplayFormat	= "<span class=\"maindate\">%%D%%<\/span><br>days until <br><strong>My First-Next Triathlon<\/strong><br>on Jun. 6, 2010";
		
		var cd2			= new countdown('cd2');
		cd2.Div			= "clock2";
		cd2.TargetDate		= "10/3/2010 11:59 PM";
		cd2.DisplayFormat	= "<span class=\"maindate\">%%D%%<\/span><br>days until <br><strong>13.1 Half Marathon<\/strong><br>on Oct. 3, 2010";
		
		var cd3			= new countdown('cd3');
		cd3.Div			= "clock3";
		cd3.TargetDate		= "8/8/2010 11:59 PM";
		cd3.DisplayFormat	= "<span class=\"maindate\">%%D%%<\/span><br>days until the<br><strong>Acworth Women's Triathlon<\/strong><br>on Aug. 8, 2010";

		var cd4			= new countdown('cd4');
		cd4.Div			= "clock4";
		cd4.TargetDate		= "10/3/2010 11:59 PM";
		cd4.DisplayFormat	= "<span class=\"maindate\">%%D%%<\/span><br>days until <br><strong>Lake Lanier Island Triathlon<\/strong><br>on Oct. 3, 2010";
				
		var cd5		= new countdown('cd5');
		cd5.Div			= "clock5";
		cd5.TargetDate		= "10/30/2010 11:59 PM";
		cd5.DisplayFormat	= "<span class=\"maindate\">%%D%%<\/span><br>days until the<br><strong>Spinx Marathon and Half<\/strong><br>on Oct. 30, 2010";
		
		var cd6			= new countdown('cd6');
		cd6.Div			= "clock6";
		cd6.TargetDate		= "10/31/2010 11:59 PM";
		cd6.DisplayFormat	= "<span class=\"maindate\">%%D%%<\/span><br>days until the<br><strong>Marine Corps Marathon<\/strong><br>on Oct. 31, 2010";

		var cd7			= new countdown('cd7');
		cd7.Div			= "clock7";
		cd7.TargetDate		= "11/14/2010 11:59 PM";
		cd7.DisplayFormat	= "<span class=\"maindate\">%%D%%<\/span><br>days until the<br><strong>Outer Banks Marathon and Half<\/strong><br>on Nov. 14, 2010";
