function pospop(e) {
    $('#popup').css('left',e.pageX)
    $('#popup').css('top', e.pageY)
}
function get_post(e) {
    pospop(e);
    $.post('/portal/ajax/post/', {'id':e.data.id}, function(json) { displaypost(json) }, "json");
  }

function get_topic(e) {
  pospop(e);
  $.post('/portal/ajax/topic/', {'id':e.data.id }, function(json) { displaytopic(json) }, "json");
}

function get_profile(e) {
  pospop(e);
  $.post('/portal/ajax/profile/', {'id':e.data.id }, function(json) { displayprofile(json) }, "json");
}

function displaytopic(json) {
  $("#popup").html('<h4>'+json.name+'</h4><div class="subtitle_right_align style="margin-top:5px;">      <span class="nobold">replies: </span>'+json.reply_count+' <span class="nobold">views: </span>'+json.views+'</div><div class="clear"></div><div class="left_align_no_float">'+json.html+'</div><div class="sig">'+json.user+'</div>');
  showpop();
}
function displaypost(json) {
  $("#popup").html ('<h4>'+json.topic+'</h4><div class="subtitle_right_align">'+json.updated+'</div><div class="left_align_no_float" style="margin-top:5px;">'+json.html+'</div><div class="sig">'+json.user+'</div>');
  showpop();
}

function displayprofile(json) {
  $("#popup").html('<h4>'+json.user.username+'</h4><div class="subtitle_right_align">posts: '+json.forum.post_count+'</div><div class="left_align_no_float" style="margin-top:5px;">'+json.user.signature+'</div><div class="sig">'+json.user.status+'</div>');
  showpop();
};

function showpop() {
  $("#popup").show("slow");
}

function closepop() {
      $("#popup").fadeOut("slow");
      $("#popup").html(' ');
}

function togglepop() {
  if ($("#popup").is(':visible')) {
    closepop();
  } else {
    showpop();
  }
}

function addhandlers() {
    $("#popup_close").click(function() {closepop() });
    $("#popup").hide();
}
