

function changeImportance(id, imp) {
  questionService.setImportance(id, imp);
  hideAndShow(id, imp);
  changeClass(id, imp);
}

function hideAndShow(id, imp) {
  if (imp) {
    $('b' + id).hide();
    $('a' + id).show();
  } else {
    $('a' + id).hide();
    $('b' + id).show();
  }
}


function changeClass(id, imp) {
  if (imp) {
    $(id).className = "question-o";
  } else {
    $(id).className = "question";
  }
}

function sendToConsultantsHide(id) {
  $('rootDiv' + id).hide();
}

function sendToConsultantsShow(id) {
  $('rootDiv' + id).show();
  updateConsultants(id);
}

function sendToConsultants(id) {
  var ids = new Array();
  var specs = document.getElementsByName('boxesList' + id);

  var areaSelectId = 'send' + id;
  var areaSelect = document.getElementById(areaSelectId);
  var selected = areaSelect.selectedIndex;
  var tagId = areaSelect.options[selected].value;

  var j = 0;
  for (var i = 0; i < specs.length; i++) {
    if (specs[i].checked) {
      ids[j] = specs[i].value;
      j++;
    }
  }

  questionService.addConsultants(id, tagId, ids);
  sendToConsultantsHide(id);
}


function updateConsultants(id) {
  var areaSelectId = 'send' + id;
  var parentDivId = 'hhspecsprn' + id;
  var specsDivId = 'hhspecs' + id;
  var callback = function(data) {
    $(specsDivId).innerHTML = data;
    var parent = document.getElementById(parentDivId);
    if (data.length > 0) {
      parent.className = "choose-one";
    } else {
      parent.className = "choose";
    }
  };
  var areaSelect = document.getElementById(areaSelectId);
  var selected = areaSelect.selectedIndex;
  var selectedValue = areaSelect.options[selected].value;
  ajaxConsultantController.getConsultantsByTag(id, selectedValue, { callback: callback });
}


