﻿// see http://kpumuk.info/asp-net/using-panel-defaultbutton-property-with-linkbutton-control-in-asp-net/
function clickButton(e, buttonid) {
  if (e.keyCode == 13) {
    var b = document.getElementById(buttonid);
    if (b) {
      if (typeof (b.click) == 'undefined') {
        b.click = function () {
          var result = true;
          if (b.onclick) result = b.onclick();
          if (typeof (result) == 'undefined' || result) {
            eval(b.getAttribute('href'));
          }
        }
      }

      if (typeof (b.click) != "undefined") {
        b.click();
        e.cancelBubble = true;
        if (e.stopPropagation) e.stopPropagation();
        return false;
      }
    }
  }
  return true;
}



// Utility functions that require jQuery
$(function () {
  // This implements target="_blank" for XHTML-Strict for all external URLs.  See http://www.badlydrawntoy.com/2009/03/03/replacing-target_blank-for-strict-xhtml-using-jquery-redux/
  $("a[href*='http://']:not([href*='" + location.hostname + "'])").click(function () { window.open(this.href); return false; });

  // Implement zebra-striping (when table or list has class="zebra")
  $("table.zebra tr:even").addClass("alt");
  $("ul.zebra li:odd").addClass("alt");

  // Highlight 2nd-level parent of 3rd-level quicknav selection
  $("#cstm-quicknav .s4-ql a.selected").parent().parent().closest("li").children(".menu-item").removeClass("active").addClass("active");

  // Hide right-side divider if nothing in contentsub section
  if ($("#cstm-contentsub").length === 0 || $("#cstm-contentsub").text().trim() === "") {
    $("#s4-mainarea .divider .right").hide();
    $("#cstm-contentbody").removeClass("content-wide").addClass("content-wide");
  };
});


