var xmlHttp

function getValue(radioGroupName) {
	radios = document.getElementsByName(radioGroupName);
	for (i = 0; i < radios.length; i++) {
		if (radios[i].checked) return radios[i].value;
	}
}
		
function addToMyCourses(starsID) { 
	xmlHttp=GetXmlHttpObject()
	var gettime = new Date();
	var currentTime = gettime.getDate();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="processTFC.cfm?action=add&starsID="+starsID+"&time="+currentTime;
	xmlHttp.onreadystatechange=stateChangedItemSpecAddToMyCourses
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedItemSpecAddToMyCourses() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		 document.getElementById("resultsDiv").innerHTML=xmlHttp.responseText;
		 appear("resultsDiv");
	 } 
}

function removeCourse(starsID) { 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="processTFC.cfm?action=remove&starsID="+starsID
	xmlHttp.onreadystatechange=stateChangedItemSpecAddToMyCourses
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function updateLocation(location) {
	xmlHttp=GetXmlHttpObject()
	var gettime = new Date();
	var currentTime = gettime.getDate();
	//var location = getValue('location');
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="myCourses.cfm?location="+location+"&time="+currentTime;
	xmlHttp.onreadystatechange=stateChangedItemSpecShowMyCourses
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function updateSenior(senior) {
	xmlHttp=GetXmlHttpObject()
	var gettime = new Date();
	var currentTime = gettime.getDate();
	//var senior = getValue('senior');
	
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="myCourses.cfm?senior="+senior+"&time="+currentTime;
	xmlHttp.onreadystatechange=stateChangedItemSpecShowMyCourses
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function showMyCourses() { 
	xmlHttp=GetXmlHttpObject()
	var gettime = new Date();
	var currentTime = gettime.getDate();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var url="myCourses.cfm?time="+currentTime;
	xmlHttp.onreadystatechange=stateChangedItemSpecShowMyCourses
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function stateChangedItemSpecShowMyCourses() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
		 document.getElementById("myCourses").innerHTML=xmlHttp.responseText;
		 appear("myCourses");
	 } 
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e) {
		//Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
