function loadRating(pagename) {
	
	$('starList').hide();
	$('starLoader').show();
	
	//----------- URL anpassen ---------
	new Ajax.Request('http://pluginwiki.markus-zondler.de/extensions/RateThis/update.php',
  		{
    	method:'get',
    	parameters: {ratingfor: pagename},
    	onSuccess: updateRating,
    	onFailure: function(){ 
    		alert('Rating for this site could not be retrieved!'); 
    	}
  	});
  	
}

function rateThis(rating, pagename) {
	
	$('starList').hide();
	$('starLoader').show();
	
	//----------- URL anpassen ---------
	new Ajax.Request('http://pluginwiki.markus-zondler.de/extensions/RateThis/update.php',
  		{
    	method:'get',
    	parameters: {rating: rating, page: pagename},
    	onSuccess: updateRating,
    	onFailure: function(){ 
    		alert('Your vote could not be transmitted!'); 
    	}
  	});
}

function updateRating(response) {
	var ajaxResponse = Try.these(
			function() { return new DOMParser().parseFromString(response.responseText, 'text/xml'); },
			function() { var xmldom = new ActiveXObject('Microsoft.XMLDOM'); xmldom.loadXML(response.responseText); return xmldom; }
      	);
      			
    var votenr = ajaxResponse.getElementsByTagName('votenr')[0].firstChild.nodeValue;
	var rating = ajaxResponse.getElementsByTagName('rating')[0].firstChild.nodeValue;
	var percentage = ajaxResponse.getElementsByTagName('percentage')[0].firstChild.nodeValue;
			
	$('voteCount').update(votenr);
	$('currentRatingValue').update(rating);
	$('ratingPercentage').setStyle({width: ''+percentage+'%;'});
	
	$('starLoader').hide();
	$('starList').show();
}