function GetXmlHttpObject() {
	var objxmlHttp=null;
	try {
		objxmlHttp=new XMLHttpRequest();
	} catch (e) {
		try {
			objxmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
			  objxmlHttp =new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				objxmlHttp =null;
			}
		}
	}
	return objxmlHttp;
}

function formatCurrency(num) {
	num = num.toString().replace(/\$|\,/g,'');
	if(isNaN(num))
	num = "0";
	sign = (num == (num = Math.abs(num)));
	num = Math.floor(num*100+0.50000000001);
	cents = num%100;
	num = Math.floor(num/100).toString();
	if(cents<10)
	cents = "0" + cents;
	for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
	num = num.substring(0,num.length-(4*i+3))+','+
	num.substring(num.length-(4*i+3));
	return (((sign)?'':'-') + num + '.' + cents);
}

setCookie();

var startAmt;
var lastval = "";

var xmlHttp;

function setCookie(l1) {

	xmlHttp =GetXmlHttpObject();
	if (xmlHttp == null) {
		alert ("Browser does not support Http Request");
		return;
	}
	
	var randomnumber=Math.random();
	
	var url = "/assets/js/setcounter.aspx?rnd=" + randomnumber;

	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open ("GET", url, true);
	xmlHttp.send (null);
}

function stateChanged () {
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == "complete") {
		if(xmlHttp.responseText != "") {
			
			cookies = xmlHttp.responseText;

			//alert('Response Text - ' + xmlHttp.responseText);

			if(cookies != "" ) {
				startAmt = parseFloat(cookies);
				if(parseInt(startAmt)<=0) {
					startAmt = 56515923;
				}
			} else{
				startAmt = 56515923;
			}
		}  else {
			startAmt = 56515923;
		}
		timedMsg()
	}
}

function timedMsg() {
	var t = setInterval("amtcount()", 100);
}

function amtcount() {
	if (startAmt == 0)
	{
		startAmt = 56515923;
	} else {
		startAmt = startAmt + 0.04908;
	}	
	lastval = formatCurrency(startAmt);
	document.getElementById('count4').value = lastval;
}

