Try condensing the two into a single function. It's possible guaranteed (thanks Barmar!) that one handler is running before the other and then automatically switching it back to the undesired one. This way, it will check for isSelected==0
and isSelected==1
in one swoop.
$("td").click(function(){
if(isSelected==0)
{
$(this).removeClass('not_selected');
$(this).addClass('selected');
isSelected=1;
} else if(isSelected==1)
{
$(this).removeClass('selected');
$(this).addClass('not_selected');
isSelected=0;
}
});