 $(document).ready(function(){
 
$("#whocalled").hide();
$("#idontknow").attr('selected','selected');
	$("input[name='who']").click(function(){
		$("input[name='who']:checked").val() == 0 ? $("#whocalled").hide('slow') : $("#whocalled").show('slow');
	});
	
$(".karma").click(function(){
		var commentID = $(this).attr("id");
		var upordown = "down";
		//alert(commentID.indexOf('up'));
		if(commentID.indexOf('up') ==0)
		{
			upordown = "up";
			commentID = commentID.substring(3);
			
		}else{
			upordown = "down";
			commentID = commentID.substring(5);
		}
		var url = "/comment-rating/" + upordown + "/" + commentID;
			$.ajax({
				   url: url,
				   success:function(msg){
					   var response = msg.split('|');
					   if(response[0] == 'done'){
							if(response[1]){
								//Changes the thumbs to dull gray and disable the action
								$("#down-"+response[1]).attr('src','/a/i/gray_down.png');
								$("#down-"+response[1]).attr('enabled','false');
								$("#up-"+response[1]).attr('src','/a/i/gray_up.png');
								$("up-"+response[1]).attr('enabled','false');
								//Update the karma number display
								if(!response[2]){
									alert("Response has no value");
								}
								//var karmanumber = response[2];
								////The below line is commented out because there is no karma number atm.
								///document.getElementById("karma-"+response[1]+"-"+response[4]).innerHTML = karmanumber;
							} else {
								alert("WTF ?");
							}
					   }
				   },
				   error:function(){}		   
			
        });

		
	});
	
 

 
});