﻿$jQuery(document).ready(function () {
  $jQuery("#TopicLetters a[href]").attr("href", "javascript:void(null)");
});

function showTopics(letterIndex, letter) {
  $jQuery(".ClassificationTopicIndex .Index .Active").removeClass("Active");
  $jQuery(".ClassificationTopicIndex .Index #" + letter).addClass("Active");
  var menuParams = "{letter:" + letterIndex + "}";
  $jQuery.ajax({
    type: "POST",
    url: "/Components/Classification/TopicIndexService.asmx/GetTopics",
    data: menuParams,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {
      var topics = (typeof msg.d) == 'string' ? eval('(' + msg.d + ')') : msg.d;
      $jQuery("#TopicIndex").empty();
      $jQuery("#TopicIndex").append('<ul id="List1">');
      var maxRows = 7
      if (topics.length > maxRows) {
        for (var i = 0; i < maxRows; i++) {
          $jQuery("#TopicIndex ul#List1").append('<li><a href="' + topics[i].UrlLink + '">' + topics[i].Title + '</a></li>');
        }
        $jQuery("#TopicIndex").append('<ul id="List2">');
        for (var i = maxRows; i < topics.length; i++) {
          $jQuery("#TopicIndex ul#List2").append('<li><a href="' + topics[i].UrlLink + '">' + topics[i].Title + '</a></li>');
        }
      }
      else {
        for (var i = 0; i < topics.length; i++) {
          $jQuery("#TopicIndex ul#List1").append('<li><a href="' + topics[i].UrlLink + '">' + topics[i].Title + '</a></li>');
        }
      }
    }
  });
}
