
function getDocumentHeight() {
   if($.browser.msie)
   {
       var $temp = $("<div>")
             .css("position","absolute")
             .css("left","-10000px")
             .append($("body").html());

       $("body").append($temp);
        var h = $temp.height();
        $temp.remove();
        return h;
    }
    return $("body").height();
}


//$(function() {



$("#calder-tv-close").live('click', function() {
  if (animation) clearInterval(animation);
  
  $("#tv-mode-container").remove();
  $("#tv-mode-background").remove();
  $("#calder-tv").show();
  
  $("#fdbk_tab").show();

});







$("#calder-tv").live('click', function() {


  // render initially based on where we were clicked
  var initialRender = $(this).attr("tvflag");
  
  $("body").append("<div id='tv-mode-background'><div align='center' id='tv-loading-div'>Loading TV Mode...<br /><img src='/images/module_loader.gif' /></div></div>");
  
  $("#tv-loading-div").css({
    position: "absolute",
    color: "#FFF",
    top: 200,
    left: "42%"
    
  });
  
  
  
  
  $("#tv-mode-background")
    .css({
      position: "absolute",
      top:  getDocumentHeight() * -1,
      left: 0,
      right: 0,
      height: getDocumentHeight(),
      background: "#010100",
      opacity: 0.9,
      zIndex: 10000,
      overflow: "hidden"
    
      });
      
  
      
  $("#tv-mode-background").animate({top: 0}, 300, "easeOutSine"); 
    
  




  
  $.get("/tv/render_tv/" + initialRender.replace("#", ""), {userflag: $("#calder-tv").attr('userflag')}, function(result) {
  
    
    
  
  
    $("body").append("<div id='tv-mode-container'>");
    
    
    
    $("#tv-mode-container")
      .css({ 
        position: "absolute",
        top: getDocumentHeight() * -1,  
        zIndex: "10002",
        left: 0,
        right: 0,
        height: getDocumentHeight()
      
      });
      
    
      $("#tv-mode-container").append(result);
      
      
      
      $("#tv-mode-container").animate({top: 0}, 300, "easeOutSine");
      $("#tv-loading-div").remove();
  
      $("#calder-tv").hide();
      $("#fdbk_tab").hide();
      
      
  
  });


  
  


});



  
  


