function vote_load_show (curelement, color) {
	var bplus=$(curelement).parent().parent().children(".ivotep").children("[onclick]");
	var bminus=$(curelement).parent().parent().children(".ivotem").children("[onclick]");
	
	$(curelement).attr("src","/images/loading_16_"+color+".gif");
	
	bplus.attr("onclick","return false;");
	bminus.attr("onclick","return false;");
}

function vote_load_hide (curelement,ok) {
	$(curelement).attr("src","/images/blank.gif");
}

function vote(curelement, plus_minus, object_type, object_id, color) {
	
	vote_load_show(curelement, color);
	
	$.ajax({type: "POST", 
		    url: "/common/ajax_vote.php",
			data: "plus_minus="+plus_minus+"&object_type="+object_type+"&object_id="+object_id,
		    success: function(msg){
		    	if (jQuery.trim(msg)=="OK")	{
		    		//alert ('Голос принят');
		    		var bplus=$(curelement).parent().parent().children(".ivotep").children("[onclick]");
					var bminus=$(curelement).parent().parent().children(".ivotem").children("[onclick]");
		
		    		$(curelement).parent().next().text(parseInt($(curelement).parent().next().text())+1)
		    		bplus.attr('title','Вы уже проголосовали');
		    		bminus.attr('title','Вы уже проголосовали');
		    		vote_load_hide(curelement,true);
		    	}else {
		    		alert ('Ошибка голосования:'+msg);	
		    		vote_load_hide(curelement,false);
		    	}
		    }, 
			error:function(msg){
				vote_load_hide(curelement,false);
				alert ('Ошибка голосования:'+msg);
			}
   	});
}