﻿$(document).ready(function() {
    var apptoshow;
    var content;
    $(".approvedstat").hover(
      function() {
          var mantoget = $(this).attr("id");
          apptoshow = $(this).children("span");
          if ($(this).hasClass("two")) {
              if (mantoget == -1) {
                  onGetApprovedFailed();
              } else {
                  //call service to retrieve approved status content - show content in callback
                  GetApprovedStatusRolloverContent(mantoget,
        onGetApprovedSucceeded,
        onGetApprovedFailed
        );
              }
          } else {
              $(apptoshow).html("<br clear='left' /><p class='tt_footer'>All vehicles displayed on Carmony are Approved. <a href=\"" + BuildJSUrl() + "approved/explained\">learn more</a>...");
          }

          function onGetApprovedSucceeded(result) {
              //only load the content if the user hasn't rolled out before the content could be retrieved
              content = "";
              content += result;
              content += "<p class='tt_footer'>All vehicles displayed on Carmony are Approved. <a href=\"" + BuildJSUrl() + "approved/explained\">learn more</a>...";
              $(apptoshow).html(content);
              $(apptoshow).css("display", "block");
              $("#mainImage").css("position", "static");

          }
          function onGetApprovedFailed() {
              $(apptoshow).html("<br clear='left' /><p class='tt_footer'>All vehicles displayed on Carmony are Approved. <a href=\"" + BuildJSUrl() + "approved/explained\">learn more</a>...");
          }
      },
      function() {
          $(apptoshow).html("");
          $(apptoshow).css("display", "none");
          $("#mainImage").css("position", "relative");
      });


});