$(function () {
  var timeoutSpeed = 15000;
  var timer;
  var banner_links = $("#banner_switcher a");
  var count = 2;

  var change_banner = function (banner_number) {
    banner_number = typeof(banner_number) != 'undefined' ? banner_number : count;
    banner_links.removeClass("current");
    $("#b_s" + count).addClass("current");
    var banners = [
      "<h1>Home Warranty</h1> \
       <p>HomeTec’s home warranty benefit helps you avoid unexpected costs for the repair \
         or replacement of covered appliances and systems in your home. Covered items include \
         air conditioning, electrical system, plumbing system, stove, refrigerator, dishwasher, \
         washing machine and dryer, and much more.</p>",
      "<h1>Auto Deductible Reimbursement</h1> \
       <p>Your auto insurance covers accidents, but what if you don’t have the \
         money to cover your deductible? HomeTec will reimburse your auto \
         insurance deductible up to $500. </p>\
       <p>Includes collisions, theft and vandalism if covered under your auto insurance policy.</p>",
      "<h1>Home Protection Benefits</h1> \
      <p>What will you do if disaster strikes? HomeTec’s protection benefits cover \
        you as a homeowner or renter when you’re faced with emergency situations. \
        Benefits include:</p> \
      <ul> \
        <li>Insurance Deductible Reimbursement</li> \
        <li>Emergency Cash</li> \
        <li>Emergency Lodging</li> \
        <li>Rent and Mortgage Reimbursement</li> \
      </ul>",
      "<h1>Extended Warranties</h1> \
       <p>HomeTec’s home warranty benefit helps you avoid unexpected costs for \
         the repair or replacement of covered appliances and systems in your home. \
         Covered items include air conditioning, electrical system, plumbing \
         system, stove, refrigerator, dishwasher, washing machine and dryer, and \
         much more.</p>",
      "<h1>Identity Theft Protection</h1> \
       <p>Tired of worrying about who’s looking over your shoulder? ID theft is \
         one of the fastest growing crimes in the U.S. Keep identity thieves from \
         ruining your credit and protect your bank account from unauthorized \
         transfers. Some ID Theft programs may cost $8 to $15 month per person. \
         HomeTec protects you and your families identity at no additional cost.</p>"
      ];
    var banner_content = '<img alt="Banner_image" src="/assets/banner_image_s' + banner_number + '.jpg">';
    banner_content += '<div id="banner_text">' + banners[banner_number - 1] + '</div>';
    $("#changer").html(banner_content);


    if (count < 5) {
      count++;
    } else {
      count = 1;
    }
    timer = setTimeout(change_banner, timeoutSpeed);
  };

  timer = setTimeout(change_banner, timeoutSpeed);

  banner_links.click(function (e) {
    var banner_number = $(this).attr("data-n");
    clearTimeout(timer);
    e.preventDefault();
    count = parseInt(banner_number, 10);
    change_banner(banner_number);
  });
});

$.fn.extend({
  disableSelection: function () {
    return this.each(function () {
      this.onselectstart = function () { return false; };
      this.unselectable = "on";
      $(this).css('user-select', 'none');
      $(this).css('-o-user-select', 'none');
      $(this).css('-moz-user-select', 'none');
      $(this).css('-khtml-user-select', 'none');
      $(this).css('-webkit-user-select', 'none');
    });
  }
});
$(function () {
  var benefits = $(".benefit");
  benefits.disableSelection();
  benefits.addClass("linkLook");
  $(".details").hide();
  benefits.bind({
    click: function () {
      $(this).next(".details").toggle();
      return false;
    },
    onselectstart: function () {
      return (false);
    },
    mouseenter: function () {
      $(this).addClass("highlight");
      $(this).children("th").addClass("hover");
    },
    mouseleave: function () {
      $(this).removeClass("highlight");
      $(this).children("th").removeClass("hover");
    }
  });
});

$(function () {
  $(".load_video").click(function (e) {
    $(this).unbind("click");
    if (!$.browser.msie) {
      $(this).addClass("sublime");
      $(this).after('<video style="display:none" id="cartoon" class="zoom" width="711" height="400"" src="/video/HomePro.m4v"></video>');
      sublimevideo.load();
      sublimevideo.ready(function () {
        sublimevideo.prepareAndPlay("cartoon");
      });
      e.preventDefault();
    }
  });
});

