var Vote = Class.create({
	initialize: function (id, username, api_key, url, title){
		var url = '/ajax/vote/' + id + '/';
		var username = username;
		var api_key = api_key;
		var url = url;
		var title = title;
		new Ajax.Request(url, {
		  method: 'get',
		  onSuccess: function(transport) {
		    //alert(transport.responseText);
			//$('voteimage-' + id).src = "http://static.padiri.com/images/likeSelez.jpg";
			var name = "voteimage-" + id;
			var elem = document.getElementById(name);
			elem.src = "http://static.padiri.com/images/LIKE3.gif"; 
			if (transport.responseText == 'ok'){
				//var count = $('replycount-' + id).innerHTML;
				//count = count + 1;
				//$('replycount-' + id).innerHTML = '';
				
				
				FB_RequireFeatures(["Api","XFBML"], function() {
					FB.Facebook.init(this.api_key, '/xd_receiver.htm');					
					this.api = FB.Facebook.apiClient;
					var users = new Array();
					users.push(username);
					this.api.notifications_send(users, 'ha appena votato la tua risposta! per vedere il suo voto <a href="' + url + '">clicca qui</a>', function(result, exception){});
					

				});
				
				
			}
			if (transport.responseText == 'best'){
				//best reply
				FB_RequireFeatures(["Api","XFBML"], function() {
					FB.Facebook.init(this.api_key, '/xd_receiver.htm');					
					this.api = FB.Facebook.apiClient;
					var users = new Array();
					users.push(username);
					this.api.notifications_send(users, 'pensa che la tua risposta sia la migliore! sai come <a href="' + url + '">' + title + '</a>', function(result, exception){});
					

				});
			}
		  }
		});
	}

	
});







