var url = "ecash/getXRate.asp"
var flagUp = false;
var timerID = null;

function displayAds() {
	var div = document.getElementById("adspace");
	var h4;

	if (ads.readyState == 4) {
		if (ads.status == 200) {
			div.innerHTML = "<h4>ADVERTISEMENT</h4>" + ads.responseText;
		}
	}
}//displayAds

function getHTTPObject() {
	if (typeof XMLHttpRequest != 'undefined') {
		return new XMLHttpRequest(); 
	} 
	try { 
		return new ActiveXObject("Msxml2.XMLHTTP"); 
	} 
	catch (e) { 
		try { 
			return new ActiveXObject("Microsoft.XMLHTTP"); 
		} 
		catch (e) {
			//do nothing
		} 
	} 
	return false; 
} //function getHTTPObject

function handleHttpResponse() {
	var dateToday;
	if (http.readyState == 4) {
		dateToday = new Date();
//		if (http.responseText.indexOf('invalid') == -1) { 
			results = http.responseText;
			document.getElementById('xrate').innerHTML = 
				"&nbsp;<span class=small><u>As of " + 
				(parseInt(dateToday.getMonth()) + 1) + "/" +
				dateToday.getDate() + "/" +
				dateToday.getFullYear() + " " +
				dateToday.getHours() + ":" +
				dateToday.getMinutes() + ":" +
				dateToday.getSeconds() + 
				"</u>:</span><br>" + 
				"&nbsp;(NZ) $1 = PHP" + results + "<br>";
			flagUp = false;
//    	}//if
	}//if readystate
}//function
 
function showAds() {
	//var adsURL = "http://www.cybertalk.co.nz/ecash/getads.asp";
	var adsURL = "ecash/getads.asp";
	if (ads) {
		ads.open("GET", adsURL, true);
		ads.onreadystatechange = displayAds;
		ads.send(null);
	}
} //showAds

function updateValues() {
//var myRand = parseInt(Math.random()*99999999);  // cache buster
	if (!flagUp && http) {
		//document.getElementById('msg').innerHTML = "updating...";
		//http.open("GET", url + "?x=" + myRand, true);
		http.open("GET", url, true);
		http.onreadystatechange = handleHttpResponse;
		flagUp = true;
		http.send(null);
	}//if
}//updateValues

var http = getHTTPObject(); // We create the HTTP Object
var ads = getHTTPObject();

//refresh every 15sec
timerID=window.setInterval("updateValues()", 60000);

