function daysBetween(today,laterDate){
	var earlySecs=today.getTime()
	var laterSecs=laterDate.getTime()
	return Math.floor ((((((earlySecs-laterSecs)/1000)/60)/60)/24))
}

var clockID = 0;

function UpdateClock() {
	if(clockID) {
      clearTimeout(clockID);
      clockID  = 0;
	}

	// Retrieving Current date   
	var today = new Date()    
	var laterDate = new Date("1 Jan 2006") 

	//Number of days between Jan 1 2006 and current date multiplied by the amount the revenue rises per day  
	var dayAmt = daysBetween(today,laterDate) * 36736.19;

	//Time is split up and calculated with the amount the revenue rises
	var hrAmt = today.getHours() * 1530.67; 
	var minAmt = today.getMinutes() * 25.51;
	var secAmt = today.getSeconds() * 0.43;

	document.RevenueClockForm.theRevenue.value = currency(6043776 + dayAmt + hrAmt + minAmt + secAmt);
//	document.RevenueClockForm.theRevenue.value = currency(dayAmt);	
	clockID = setTimeout("UpdateClock()", 1000);
}

function currency(anynum) {
	//-- Returns passed number as string in $xxx,xxx.xx format.
	anynum=eval(anynum)
	workNum=Math.abs((Math.round(anynum*100)/100));workStr=""+workNum
	if (workStr.indexOf(".")==-1){workStr+=".00"}
	dStr=workStr.substr(0,workStr.indexOf("."));dNum=dStr-0
	pStr=workStr.substr(workStr.indexOf("."))
	while (pStr.length<3){pStr+="0"}
	
	//--- Adds comma in thousands place.
	if (dNum>=1000) {
	  dLen=dStr.length
		dStr=parseInt(""+(dNum/1000))+","+dStr.substring(dLen-3,dLen)
	}
	
	//-- Adds comma in millions place.
	if (dNum>=1000000) {
		dLen=dStr.length
		dStr=parseInt(""+(dNum/1000000))+","+dStr.substring(dLen-7,dLen)
	}
	
	if (dNum>=1000000000) {
		dLen=dStr.length
		dStr=parseInt(""+(dNum/1000000000))+","+dStr.substring(dLen-11,dLen)
	}
	
	retval = dStr + pStr 
	//-- Put numbers in parentheses if negative.
	if (anynum<0) {retval="("+retval+")"}
	return "$"+retval
}

function StartClock() {
	if (document.RevenueClockForm != null) {
		clockID = setTimeout("UpdateClock()", 500);
	}
}

function KillClock() {
	if(clockID) {
		clearTimeout(clockID);
		clockID  = 0;
	}
}