﻿$(document).ready(function () {

  $("#insulated_covers").hover(
    function () { this.src = this.src.replace("_off", "_on"); },
    function () { this.src = this.src.replace("_on", "_off"); }
  );

  $("#replacement").hover(
    function () { this.src = this.src.replace("_off", "_on"); },
    function () { this.src = this.src.replace("_on", "_off"); }
  );

  $("#accessories").hover(
    function () { this.src = this.src.replace("_off", "_on"); },
    function () { this.src = this.src.replace("_on", "_off"); }
  );

  $("#piston_preheat").hover(
    function () { this.src = this.src.replace("_off", "_on"); },
    function () { this.src = this.src.replace("_on", "_off"); }
  );

  $("#turbine_preheat").hover(
    function () { this.src = this.src.replace("_off", "_on"); },
    function () { this.src = this.src.replace("_on", "_off"); }
  );

  $("#rotor_wing_preheat").hover(
    function () { this.src = this.src.replace("_off", "_on"); },
    function () { this.src = this.src.replace("_on", "_off"); }
  );

  // get rid of the right bar on this page.
  var pageName = window.location.pathname;
  if (pageName.indexOf('RotorwingPreheat.aspx') != -1 && window.location.search == '') {
    $('#mybody').css('background-image', 'none');
  }

  $(window).resize(function () {
    resetBrowseParts();
  });

  resetBrowseParts();

});

function resetBrowseParts() {
  var pageName = window.location.pathname;
  var pos = 0;
  var lft = 0;

  if (pageName.indexOf('PistonPreheat.aspx') != -1 || pageName.indexOf('TurbinePreheat.aspx') != -1 || pageName.indexOf('Parts.aspx') != -1) {

    if (window.location.href.indexOf('Parts.aspx?mfg=ALL') != -1) {
      // don't do it
    } else {
      pos = parseInt($('#mybody').offset().top) + 650;
      lft = parseInt($('#mybody').offset().left) + parseInt($('#mybody').width()) - 277;

      $('#browse_parts').css('top', pos + 'px');
      $('#browse_parts').css('left', lft + 'px');
      $('#browse_parts').show();
    }

  }

}

function toggleMore(theid) {
  $('#ctl00_ContentPlaceHolder1_more' + theid).toggle();

  var myarrow = $('#arrow_' + theid);

  if (myarrow.attr("src") == '/images/arrow.png') {
    myarrow.attr("src", "/images/arrow_down.png");
  } else {
    myarrow.attr("src", "/images/arrow.png");
  }

}

