//Luca Filosofi > {aSeptik} @gmail.com (c) '09 - 29.09.2009

var $J = jQuery.noConflict();

$J(document).ready( function() {
 
$J("a[id^='rater-']").click(function() {
      
      var match = this.id.match(/rater-(\d+)/); 
      //catch the id
      
      var parameterString = jQuery(this).attr('href');  
      //get the values
      
      var query = 'action=ratings&query=' + parameterString; 
      //php do the rest here!
    
      var base_url = document.location.href.substring(0, document.location.href.lastIndexOf('/')+1); 
      //get base url
      
      $J('#response-' + match[1]).hide();
      $J.ajax({
			type: 'POST', 
      url:  base_url + 'e107_plugins/ratings/e_ajax.php', 
      //send
      data: query,
			cache: false,
      complete: function(data){
      
      $J('#response-' + match[1]).html(data.responseText); 
      //display ratings
		  $J('#response-' + match[1]).fadeIn(2000);
				
      },
                 error: function(){
                 alert('Ajax Request ' + query + ' Error!'); 
                 //handle if error!
                    }
		});
		return false;	
  });

});