Try to use the element's length
property to check its presence,
if($('.post-single').length) {
//exist
}
else {
//not exist
}
Full code,
single =($('.post-single').length) ? $('.post-single').height() : $('.wrap content').height();
tab = $('#tab');
tab_height = tab.height();
footer_height = $('footer').height();
max_top = (single + 323) - (tab_height);
tab_offset = tab.offset();