function voting(hnd, id, hasKlapa){
	this.id = id;
	this.hnd = hnd;
	this.hasKlapa = hasKlapa;
	this.votedUp = false;
	this.votedDown = false;
	
	this.vote = function (val){
		if(val == 'up' && this.votedUp){
			return false;
		}else if(val == 'down' && this.votedDown){
			return false;
 		}
		var con = new rJSON();
		var params = {id: id, vote: val, module: "vote"};
		var result = con.getData("exec.php", params);
		if(result.error == 'OK'){
			if(val == 'up'){
				document.getElementById("j_imgVoteUp_" + hnd).src = "imgs/thumbUp2.png";
				this.votedUp = true;
			}else{
				document.getElementById("j_imgVoteDown_" + hnd).src = "imgs/thumbDown2.png";
				this.votedDown = true;
			}
			try{
				document.getElementById("j_voteRating_" + hnd).src = "imgs/rating" + result.rating + "ico.png";
				document.getElementById("j_voteRating_" + hnd).title = "Рейтинг: " + result.rating;
			}catch(e){
				try{
					/* A patch for the catalog_list_strips_html module - think about fixing it, because this is stupid */
					try{
						document.getElementById("j_prevRating_1_" + hnd).src = "imgs/rating" + result.rating + "ico.png";
						document.getElementById("j_prevRating_1_" + hnd).title = "Рейтинг: " + result.rating;
					}catch(e){
						document.getElementById("j_prevRating_0_" + hnd).src = "imgs/rating" + result.rating + "ico.png";
						document.getElementById("j_prevRating_0_" + hnd).title = "Рейтинг: " + result.rating;
					}
				}catch(e){}
			}
			document.getElementById("j_voteTdUp_" + hnd).innerHTML = "[" + result.votes_up + "]";
			document.getElementById("j_voteTdDown_" + hnd).innerHTML = "[" + result.votes_down + "]";
			if(this.hasKlapa){
				document.getElementById("klapaArea").setRating(result.rating);
			}
		}
		return true;
	}
} 
