/**
 * @author Vlad_
 */

has_voted = 0;

var rank = new function() {
	
	this.voteit = function(id, source_id, url, fromurl) {
		if (!has_voted) {
			$.post(host + 'rank.php?t=v', {
				lid: id,
				source: source_id,
				file: url,
				from: fromurl
			}, function(response){
				has_voted = 1;
				value = parseInt($('#v' + id).text()) + 5;
				$('#r' + id).text(value);
				location.href = url;				
			})
		}
	}
	
	this.voteitInline = function(id, source_id, url) {
		$.post(host + 'rank.php?t=v', {
			lid: id,
			source: source_id,
			file: url
		}, function(response){
			value = parseInt($('#v' + id).text()) + 5;
			$('#r' + id).text(value);
			$('#v' + id).remove();
			$('#voteHolder').html('<span>'+value+'</span>');
		})
	}
	
}
