   

	// function to send XML request for updating the article rating
	function updateRating(humourID,rating) {
		
		var url = "humorDetail.do?HumourMethod=Rating&humourID=" + humourID + "&rating="+ rating;
		
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		req.open("POST", url, true);
		
		req.onreadystatechange = getStatusRating;
		
		req.send(null);	
	}

 	// function to check the status of XML request
	function getStatusRating() {
	
		if (req.readyState == 4) {
		
			if (req.status == 200) {
		
				populateRating();
			}
		}
	}

	// function to populate the html table with XML request details
	function populateRating(){
		
		myTable = document.getElementById("rating_humour");
		
		myTable.innerHTML="";
		var childDiv1 = document.createElement("DIV");
		childDiv1.id= "rating_humour";
	    childDiv1.innerHTML="";
	
		var updateRating =  req.responseXML.getElementsByTagName("updateRating")[0];
		var rating = (updateRating.getElementsByTagName("rating")[0]).firstChild.nodeValue;
		var totalVotes = (updateRating.getElementsByTagName("totalVotes")[0]).firstChild.nodeValue;

		var noOfFullImage = (updateRating.getElementsByTagName("noOfFullImage")[0]).firstChild.nodeValue;
		var noOfBlankImage = (updateRating.getElementsByTagName("noOfBlankImage")[0]).firstChild.nodeValue;
		var smallStar =  (updateRating.getElementsByTagName("smallStar")[0]).firstChild.nodeValue;
		var mediumStar = (updateRating.getElementsByTagName("mediumStar")[0]).firstChild.nodeValue;
		var bigStar = (updateRating.getElementsByTagName("bigStar")[0]).firstChild.nodeValue;
		
		content = '';
		var i = 0;
		
	
		for(i = 0; i < noOfFullImage; i++){
			content += '<IMG SRC="/mnc/images/s_f.gif" name="imgWhite12" border="0" >';
		}
		if(smallStar != 'null'){
			content += '<IMG SRC="/mnc/images/s_lh.gif" name="imgWhite12" border="0" >';
		}
		if(mediumStar != 'null'){
			content += '<IMG SRC="/mnc/images/s_h.gif" name="imgWhite12" border="0" >';
		}
		if(bigStar != 'null'){
			content += '<IMG SRC="mnc/images/s_mh.gif" name="imgWhite12" border="0" >';
		}						
		var j = 0;
		for(j = 0; j < noOfBlankImage; j++){
			content += '<IMG SRC="mnc/images/s_e.gif" name="imgWhite12" border="0" >';
		}

		childDiv1.innerHTML += content;
		
        childDiv1.innerHTML += "&nbsp;Rating :" + rating + "&nbsp;out of " + totalVotes + " votes cast";
        myTable.appendChild(childDiv1);
     
 		
	}
       
       
       
       