/*Общие для всего проекты виды-варианты отображения*/

function View () {};

/***********************************************************************************************/
/*Страница: список. Вид: портянка*/
View.List = function () {}

/***********************************************************************************************/
/*Страница: список. Вид: таблица*/
View.ListTable = function () {}

/***********************************************************************************************/
/*Страница: список. Тип списка: toggle (Разворачиваемые элементы, +)*/
View.ListToggling = function () {}
//Показать/Спрятать контент
View.ListToggling.toggleContent = function (objOpenLink, id, type) {
  if (!parseInt($(objOpenLink).attr("isDisabled"))) {
    $(objOpenLink).attr("isDisabled", 1);
    var parentTr = $(objOpenLink).parent().parent();
    if ($(parentTr).next().attr("class") == "loaded_content") {
      if (parseInt($(parentTr).next().attr("isShown")) == 1) {
        $(".list_toggling tr[@idEssence='" + id + "'][@essenceType='" + type + "'] a.title").css("font-weight", "normal");
        $(parentTr).removeClass("bottom_text");
        $(objOpenLink).attr("class", "toggle_plus");
        $(parentTr).next().hide();
         $(parentTr).next().attr("isShown", 0);
      }
      else {
        $(".list_toggling tr[@idEssence='" + id + "'][@essenceType='" + type + "'] a.title").css("font-weight", "bold");
        $(parentTr).addClass("bottom_text");
        $(objOpenLink).attr("class", "toggle_minus");
        $(parentTr).next().show();
        $(parentTr).next().attr("isShown", 1);
      }
      $(objOpenLink).attr("isDisabled", 0);
    } 
    else {
      $.ajax ({
        type: "POST",
    		url: W_AJAX + "getContentToggleList.php",
    		data: 'id=' + id + '&type=' + type,
    		success: function (responseText) {
    		  var arrResponse = (navigator.userAgent.indexOf ("Opera") != -1) ? eval('(' + responseText + ')') : JSON.parse(responseText);
          if (arrResponse['status']) {
            $(".list_toggling tr[@idEssence='" + id + "'][@essenceType='" + type + "'] a.title").css("font-weight", "bold");
            $(parentTr).addClass("bottom_text");
            $(objOpenLink).attr("class", "toggle_minus");
            var content = "<tr class='loaded_content' isShown='1'><td class='fist_colum'></td><td colspan='8'>" +
                           "<ul class='xtra-info'><li class='date'>" + arrResponse['creation'] + "</li>" +
              							  "<li class='user'><a class='green' href='" + W_ABSPATH + "user/" +  arrResponse['login'] + "/'>" + arrResponse['login'] + "</a></li>" +
            							  "</ul>" + 
                           tags.showTagsStatic(arrResponse['tags'], ', ', 5) +
                           "<div class='wysiwyg-content'>" +
                             arrResponse['text'] + 
                           "</div></td></tr>";
            content = $(content);
            content.find('.code').css('width', $('.list_toggling').width() - 100);
            /*
            if (type == 5) { //если это Вопросы-Ответы
              if ($(content).find(".code").length) {
                $(content).find(".code").each(function (i) {
                  $("<div id='question_code_" + i + "' style='display:none;'><div class='code'>" + $(this).html() + "</div></div>").insertAfter($(this));
                  $(this).replaceWith("<a href='" + W_ABSPATH + "question/#TB_inline?height=450&width=700&inlineId=question_code_" + i + "' title='Показать код' class='jsHref thickbox showQuestionCode'>Показать код</a>");
                })
              }
            }*/
            $(content).insertAfter(parentTr);
            /*if (type == 5) { //если это Вопросы-Ответы
              tb_init("a.showQuestionCode");
            }*/
          }
          else {
            alert(arrResponse['error']);
          }
          $(objOpenLink).attr("isDisabled", 0);
    		}
      });
    }
  }
}
/***********************************************************************************************/

