// UnMutual web site common javascript - Chris - 201105

// Ajax handler

var ajax = new Array();
var output = new Array();

function doAjax(php, div) {
	
	output[div] = document.getElementById(div);
	ajax[div] = null; 
	var flag = true;
	try {
		ajax[div] = new XMLHttpRequest();
	} catch (e) {
		try {
			ajax[div] = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				ajax[div] = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				flag = false;
			}
		}
	}

	if (flag) {
		ajax[div].onreadystatechange = function() {
			if (ajax[div].readyState == 4) {
				if (ajax[div].status == 200) {
					output[div].innerHTML = ajax[div].responseText;
				} else {
					output[div].innerHTML = "";
				}
			}
		}
		ajax[div].open("GET", php, true);
		ajax[div].send(null);
	} else {
		output[div].innerHTML = "";		
	}
}

// Server clock

function serverClock() {
	doAjax('get-time.php', 'serverclock');
	setTimeout('serverClock()', 1000);
}

// Image rollovers

function rollOver(which, image) {
	var id = document.getElementById(which);
	id.src = image;
}


