/* support.topo.com js file */

/*
document.observe("dom:loaded", function() {
  $('vote_thanks').observe("change", function () { thankForVote(); });
  $('vote_thanks').observe("click", function () { thankForVote(); });
});
*/



//wrap jquery
jQuery(function($){

  //for bugreport page
  $(".bug_report #add_product").click(function() {
    $(this).parent().parent().prev("tr").after($(this).parent().parent().prev("tr").clone());
    $(this).parent().parent().prev("tr").children("th").html("");
    $(".find_version:gt(0)").remove("");
    $(".find_version_text:gt(0)").remove("");
    
    if ($("input.product_version").size() >= 6)
    {
      $("#add_product").parent().parent().remove("");
    }
    
    
    return false;
    });
  
  //for ask question page
  $(".ask_question #add_product").click(function() {
   
    $(this).parent().prev("div").after($(this).parent().prev("div").clone());
    $("select.products_dropdown:last").val("-1");
    $("input.ask_question_versions:last").val("");
    $(".find_version:gt(0)").remove("");
    $(".find_version_text:gt(0)").remove("");
    
    if ($("input.ask_question_versions").size() >= 6)
    {
      $(".add_product").remove("");
    }
    
    
    //$("div.find_version_text:last").html('').removeClass("find_version_text");
    return false;
  });


  $('.find_version').click(function() {
    $('.find_version_text').toggle();
    return false;
  })

  $('.tracer_log_info_link').click(function() {
    $('.tracer_log_info').toggle();
    $('.tracer_log_info_link').toggle();
    return false;
  })
  
  $('.dxdiag_info_link').click(function() {
    $('.dxdiag_info').toggle();
    $('.dxdiag_info_link').toggle();
    return false;
  })


  // show a thanks when people vote on how helpful an article is
  $(".helpful_wrapper a").click(function() {
    $("#vote_thanks").append("Thanks!");
    $(".helpful_wrapper a").unbind("click");
    return true;
  })
  
  
  var searchTeaser = "Search here..";
  if (!$("#ajaxSearch_input").val())
  {
    $("#ajaxSearch_input").val(searchTeaser);
  }
  
  $("#ajaxSearch_input").focus(function() {
    if ($("#ajaxSearch_input").val() == searchTeaser)
    {
      $("#ajaxSearch_input").val("");
    }
  })

  $(".single_result").hover(function () {
    $(this).addClass("hover");
  }, function() {
    $(this).removeClass("hover");
  })
  
  
  $("#send_to_friend").click(function(){
    $(this).before("<br/>Email Sent!");
    $("#send_to_friend").unbind("click");
  })
})

