
function superVote(rating){
	var currentURL = window.location;

	var live_site = currentURL.protocol+'//'+currentURL.host+sfolder;
	
	var lsXmlHttp;
	
	var div = document.getElementById('ratetext_'+rating.rating_id);
	div.innerHTML='<img src="' + live_site +'/plugins/community/superrate/images/loading.gif" border="0" align="absmiddle" /> '+'<small>'+TT['LOADING']+'</small>';
		
	var new_total = rating.current_count + 1;
	var new_rating = ( (rating.current_rating * rating.current_count) + rating.user_rating) / new_total;
		
	try	{
		lsXmlHttp=new XMLHttpRequest();
	} catch (e) {
		try	{ lsXmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try { lsXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				alert(TT['NO AJAX']);
				return false;
			}
		}
	}	
	
	lsXmlHttp.onreadystatechange=function() {
		var response;
		
		if(lsXmlHttp.readyState==4){

			setTimeout(function(){ 
				
				response = lsXmlHttp.responseText;
				
				if(response.indexOf('thanks') != -1) div.innerHTML='<small>'+TT['THANK_YOU']+'</small>';
				if(response.indexOf('login') != -1) div.innerHTML='<small>'+TT['NEED_LOGIN']+'</small>';
				if(response.indexOf('voted') != -1) div.innerHTML='<small>'+TT['ALREADY_VOTED']+'</small>';
				if(response.indexOf('ownvote') != -1) div.innerHTML='<small>'+TT['RESTRICT_OWN_VOTE']+'</small>';

			}, 500);
			
			setTimeout(function(){
								
				if(response.indexOf('thanks') != -1){
					document.getElementById('rating_'+rating.rating_id).style.width = parseInt(new_rating * rating.factor) + '%';
				}
				else new_total = rating.current_count;
				
				var votes = '';
				if (new_total == 1) votes = new_total+' '+TT['VOTE'];
				else votes = new_total+' '+TT['VOTES'];
				
				div.innerHTML = '<small>('+votes+')</small>';
				
			},2000);
		}
	};
	
	lsXmlHttp.open("POST",live_site+"/plugins/community/superrate/ajax.php?task=vote&user_rating="+rating.user_rating+"&item_id="+rating.item_id+"&app="+rating.app+"&new_total="+new_total+"&new_rating="+new_rating+"&owner_id="+rating.owner_id, true);
	lsXmlHttp.send(null);
}
