
// Get the HTTP Object

function getHTTPObject()
{
//Check for support of both IE and Mozzilla FF
if (navigator.appVersion.indexOf("MSIE 7.") != -1) return new XMLHttpRequest();
else if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Your browser does not support AJAX.")
return null;

}
}

// Change the value of the outputText field

function dooutput()
{
	if(httpObject.readyState == 4)
		{
			var x = httpObject.responseText;
			//parse info into sectors | [0] is date, [1] is pay amount
			var parse_ajax = new Array();
			var parse_ajax = x.split('|');
			
			//For date parse into sectors dd/mm/yy
			var datesplit = new Array();
			datesplit = parse_ajax[0].split('/');
			
			
			//Remove the extra zeroes if it is proceeding first.
			if (datesplit[0].charAt(0) == '0')
				{
					datesplit[0] = datesplit[0].replace("0",'');	
				}
			if (datesplit[1].charAt(0) == '0')
				{
					datesplit[1] = datesplit[1].replace("0",'');	
				}
			if (datesplit[2].charAt(0) == '0')
				{
					datesplit[2] = datesplit[2].replace("0",'');	
				}
			document.getElementById('startday').value = datesplit[0];
			document.getElementById('startmonth').value = datesplit[1];
			document.getElementById('startyear').value = datesplit[2];
			
			//Show pay amount
			document.getElementById('ttfee').value = parse_ajax[1];
		}
}

//Function to gather data

function dowork()
{
	
httpObject = getHTTPObject();
if (httpObject != null) 
{
var school = document.getElementById('school').value;
var term = document.getElementById('term').value;
//httpObject.open("GET", "ajaxfunctions.php?xschool="+school+"&xterm="+term, true);
httpObject.open('GET','includes/ajaxfunctions.php?xschool='+school+'&xterm='+term,true);
httpObject.send(null);
httpObject.onreadystatechange=dooutput;
}
}

var httpObject = null;