// JavaScript Document
function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(Course,Action) {
    http.open('GET', 'ajax/courseinfo.php?course='+Course+"&Action="+Action, true);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();
		
        if(response.indexOf('|' != -1)) {
            update = response.split('|');
			if (document.getElementById(update[0]).innerHTML == "") {
				//If the div is not already displayed, display it now.
				document.getElementById(update[0]).style.display = "";
				document.getElementById(update[0]).innerHTML = update[1];
				document.getElementById("Link-"+update[0]).href = "javascript:sndReq('"+update[0]+"','hide')";
			} else {
				//Else remove the content from the element and hide.
				document.getElementById(update[0]).style.display = "none";  //This seems to be necessary to completely remove the item in IE
				document.getElementById(update[0]).innerHTML = "";
				document.getElementById("Link-"+update[0]).href = "javascript:sndReq('"+update[0]+"','show')";
			}  //end if
        }// end if
	}//end if
}//end function