	
 
	function REClass() {
		this.feedback_elment_id;
	}

	var Class = new REClass();
		
	/* Method that gives instand feedback to user */
    function giveInstantFeedback(element_id){
   //   alert("make ajax call feedback");
  		Class.feedback_element_id = element_id;
        document.getElementById(element_id).innerHTML= '<center> <img src="/images/loading.gif"> Saving...<\/center>';
    }
    
    /* Method called from the Review Evaluation helper */
    function makeAJAXCall(element_replace_id,url,params){
   //	alert("make ajax call 2..params");
        makeRequest(element_replace_id,url,params);
    }
    

	/* Creates the XMLHTTPObject that is used to perform AJAX call */
	function getXMLHTTPObject(){
		var http_request = false
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http_request = new XMLHttpRequest();
            if (http_request.overrideMimeType) {
                http_request.overrideMimeType('text/xml');
                // See note below about this line
            }
        } else if (window.ActiveXObject) { // IE
            try {
                http_request = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
                try {
                    http_request = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e) {}
            }
        }

        if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return null;
        }
        return http_request
	}
	    
	/* Makes the real AJAX request using url and params. Does POST. There is a commented code for GET */
    function makeRequest(element_id,url,params) {

        var http_request = getXMLHTTPObject();
        if (http_request == null) {
			alert('Giving up :( Cannot create an XMLHTTP instance');
        	return false;
        }
        http_request.onreadystatechange = function() { processResponse(http_request,element_id); };
/*      alert("sending request")
        http_request.open('GET', url+"?"+params, true);
        http_request.send(null);
*/

		http_request.open( "POST", url, true); 
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
		http_request.send(params)
    }

	/* method that stops the feedback to user in case of error */
	function markError(){
	  	element_id = Class.feedback_element_id;
		document.getElementById(element_id).innerHTML= '<B>Error..</B>';
	}

	/* Processes the response from the AJAX call...In this case replaces the element_id with the html passed
	from the call
	*/
    function processResponse(http_request,element_id) {

   //   alert("processRESPONSE . http_request ready state"+http_request.readyState+" status " + http_request.status);
        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
   //           alert(http_request.responseText);
                document.getElementById(element_id).innerHTML= http_request.responseText;
            }
            else if (http_request.status == 302){
//            	alert("redirecting to " + http_request.getResponseHeader('location'));
            	document.location = http_request.getResponseHeader('location');  
            } 
            else {
              alert("There was a problem with the request. http_request ready state"+http_request.readyState+" status " + http_request.status);
                alert("Sorry.There was a problem with the request")
                markError()
            }
        }
    }

    /* Debugging functions */
    /*
	function alertContents(http_request) {

        if (http_request.readyState == 4) {
            if (http_request.status == 200) {
                alert(http_request.responseText);
            } 
            else {
                alert('There was a problem with the request.');
            }
        }
    }
*/
    