

//function to send XML request for updating the article rating
function updateRatingg(articleId,rating) {

	var url = '/article.do?detail=SetRating&articleID=' + articleId + '&rating='+ rating;
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		req = new ActiveXObject('Microsoft.XMLHTTP');
	}
	
	req.open('POST', url, true);

	
	req.onreadystatechange = getStatusRatingg;
	
	
	req.send(null);	
	
}

function getStatusRatingg() {
 
	if (req.readyState == 4) {
		
		if (req.status == 200) {
			//alert('--1------')
			var updateRating =  req.responseXML.getElementsByTagName('updateRating')[0];
			var rating = (updateRating.getElementsByTagName('rating')[0]).firstChild.nodeValue;
			document.getElementById('rating').innerHTML=rating+'/5';
		//alert('--------')
			
			var str="";
			 if(rating<=0.0 ){ 

			str="<ul id='star1' class='rating nostar' style='display:block'>"+
			"<li class='one'><a href = '#'   title='1 Star'>1</a></li>"+
			"<li class='two'><a href = '#'   title='2 Stars'>2</a></li>"+
			"<li class='three'><a href = '#' title='3 Stars'>3</a></li>"+
			"<li class='four'><a href = '#'  title='4 Stars'>4</a></li>"+
			"<li class='five'><a href = '#'  title='5 Stars'>5</a></li>"+
		"</ul>";
		
			

			}else if(rating>0.0 && rating<=1.0){ 
			
				str="<ul id='star2' class='rating onestar' style='display:block'>"+
			"<li class='one'><a href = '#'   title='1 Star'>1</a></li>"+
			"<li class='two'><a href = '#'   title='2 Stars'>2</a></li>"+
			"<li class='three'><a href = '#' title='3 Stars'>3</a></li>"+
			"<li class='four'><a href = '#'  title='4 Stars'>4</a></li>"+
			"<li class='five'><a href = '#'  title='5 Stars'>5</a></li>"+
		"</ul>";
		
			
			}else if(rating>1.0 && rating<=2.0){  
		
				str="<ul id='star3' class='rating twostar' style='display:block'>"+
			"<li class='one'><a href = '#'   title='1 Star'>1</a></li>"+
			"<li class='two'><a href = '#'   title='2 Stars'>2</a></li>"+
			"<li class='three'><a href = '#' title='3 Stars'>3</a></li>"+
			"<li class='four'><a href = '#'  title='4 Stars'>4</a></li>"+
			"<li class='five'><a href = '#'  title='5 Stars'>5</a></li>"+
		"</ul>";
		
			}else if(rating>2.0 && rating<=3.0){  
			
				str="<ul id='star4' class='rating threestar' style='display:block'>"+
			"<li class='one'><a href = '#'   title='1 Star'>1</a></li>"+
			"<li class='two'><a href = '#'   title='2 Stars'>2</a></li>"+
			"<li class='three'><a href = '#' title='3 Stars'>3</a></li>"+
			"<li class='four'><a href = '#'  title='4 Stars'>4</a></li>"+
			"<li class='five'><a href = '#'  title='5 Stars'>5</a></li>"+
		"</ul>";
		
			}else if(rating>3.0 && rating<=4.0){  
			
				str="<ul id='star5' class='rating fourstar' style='display:block'>"+
			"<li class='one'><a href = '#'   title='1 Star'>1</a></li>"+
			"<li class='two'><a href = '#'   title='2 Stars'>2</a></li>"+
			"<li class='three'><a href = '#' title='3 Stars'>3</a></li>"+
			"<li class='four'><a href = '#'  title='4 Stars'>4</a></li>"+
			"<li class='five'><a href = '#'  title='5 Stars'>5</a></li>"+
		"</ul>";
		
			}else if(rating>4.0 && rating<=5.0){  
			
				str="<ul id='star6' class='rating fivestar' style='display:block'>"+
			"<li class='one'><a href = '#'   title='1 Star'>1</a></li>"+
			"<li class='two'><a href = '#'   title='2 Stars'>2</a></li>"+
			"<li class='three'><a href = '#' title='3 Stars'>3</a></li>"+
			"<li class='four'><a href = '#'  title='4 Stars'>4</a></li>"+
			"<li class='five'><a href = '#'  title='5 Stars'>5</a></li>"+
		"</ul>";
		
			} 	
			 document.getElementById('starId').innerHTML=str;
		}
	}
}


