/*------------------------

  Countdown Script
 
------------------------*/

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);
}

	
var cd1 = new countdown('cd1');
    cd1.Div			= "clock1";
    cd1.TargetDate		= "05/31/2009 7:00 AM";
    cd1.DisplayFormat	= "%%D%% days, %%H%% hours, %%M%% minutes";

var cd2			= new countdown('cd2');
    cd2.Div			= "clock2";
    cd2.TargetDate		= "06/20/2009 8:00 AM";
    cd2.DisplayFormat	= "%%D%% days, %%H%% hours, %%M%% minutes";

var cd3			= new countdown('cd3');
    cd3.Div			= "clock3";
    cd3.TargetDate		= "06/27/2009 8:00 AM";
    cd3.DisplayFormat	= "%%D%% days, %%H%% hours, %%M%% minutes";


 

    
/*------------------------

  JS for Analytics Outgoing
 
------------------------*/
    
// Cross-browser implementation of element.addEventListener()
function addListener(element, type, expression, bubbling)
{
bubbling = bubbling || false;

if(window.addEventListener)    { // Standard
element.addEventListener(type, expression, bubbling);
return true;
} else if(window.attachEvent) { // IE
element.attachEvent('on' + type, expression);
return true;
} else return false;
}

//This is what i want to do whenever someone clicks on the page
function itHappened(evt){

//Get the clicket element
var tg = (window.event) ? evt.srcElement : evt.target;
//If it is an A element
if(tg.nodeName == 'A'){
//And it is not an internal link
if(tg.href.indexOf(location.host) == -1){
//Replace all odd characters, so that it works with Analytics Niavgation analysis
var url = tg.href.replace(/[^a-z|A-Z]/g, "_");

var txt = tg.innerHTML.replace(/[^a-z|A-Z]/g, "_");
var str = '/outgoinglink/-' + txt + '-' + url;
try{
//Track it
urchinTracker(str);
}
catch(err){
//alert('error: ' + err);
}
}
}
}

//Add the click listener to the document
addListener(document, 'click', itHappened);
