/*
 * jQuery v1.9.1 included
 */

$(document).ready(function() {
  
  $('#query').attr('placeholder','Введите ключевые слова вопроса / проблемы');
	$('.login').text('Войти');
  //$('.login').attr('href', '');
	$('.my-activities').text('Мои действия');

  // social share popups
  $(".share a").click(function(e) {
    e.preventDefault();
    window.open(this.href, "", "height = 500, width = 500");
  });

  // toggle the share dropdown in communities
  $(".share-label").on("click", function(e) {
    e.stopPropagation();
    var isSelected = this.getAttribute("aria-selected") == "true";
    this.setAttribute("aria-selected", !isSelected);
    $(".share-label").not(this).attr("aria-selected", "false");
  });

  $(document).on("click", function() {
    $(".share-label").attr("aria-selected", "false");
  });

  // show form controls when the textarea receives focus
  $(".answer-body textarea").one("focus", function() {
    $(".answer-form-controls").show();
  });

  $(".comment-container textarea").one("focus", function() {
    $(".comment-form-controls").show();
  });
  
});

(function(d, t) {
    var g = d.createElement(t),s = d.getElementsByTagName(t)[0];g.src = '//d1bvayotk7lhk7.cloudfront.net/js/zingayabutton.js';g.async = 'true';
        g.onload = g.onreadystatechange = function() {
        if (this.readyState && this.readyState != 'complete' && this.readyState != 'loaded') return;
        try {Zingaya.load(ZingayaConfig, 'zingayac5acc69235ac4bd08104ad8965c4f250'); if (!Zingaya.SVG()) {
                var p = d.createElement(t);p.src='//d1bvayotk7lhk7.cloudfront.net/PIE.js';p.async='true';s.parentNode.insertBefore(p, s);
                p.onload = p.onreadystatechange = function() {
                        if (this.readyState && this.readyState != 'complete' && this.readyState != 'loaded') return;
                        if (window.PIE) PIE.attach(document.getElementById("zingayaButton"+ZingayaConfig.callme_id)); 
        }}} catch (e) {}};
    s.parentNode.insertBefore(g, s);
}(document, 'script'));

// Change time and email

function changeTime() {
  var operatingHours = document.getElementById("operatingHours"),
  		email = document.getElementById("email"),
      emailOwnerLabel = document.getElementById('emailOwnerLabel'),
      extraCode = document.getElementById('extraCode'),
  		path = window.location.pathname;

  function setValue(el, text) {
    if (el) {
      el.innerHTML = text;
    }
    else return;
  }

  if(/^\/hc\/ru\/categories\/200167428/.test(path)) {
    setValue(operatingHours, "по будним дням с 9:00 - 18:00");
    setValue(email, "support-oo@company.dnevnik.ru");
  }

  else if(/^\/hc\/ru\/categories\/200167438/.test(path)){
    setValue(operatingHours, "по будним дням с 9:00 - 18:00");
    setValue(email, "support-conti@company.dnevnik.ru");
    emailOwnerLabel.innerHTML = '';
    extraCode.innerHTML = ', доб.209';
  }
  
  else if(/^\/hc\/ru\/categories\/200168187/.test(path)){
    setValue(operatingHours, "ежедневно с 9:00 - 21:00");
    setValue(email, "support-bbz@company.dnevnik.ru");
  }
  
  else if(/^\/hc\/ru\/categories\/201080738/.test(path)){
    setValue(operatingHours, "ежедневно с 9:00 - 21:00");
    setValue(email, "support-odo@company.dnevnik.ru");
  }
  
    else if(/^\/hc\/ru\/categories\/202286227/.test(path)){
    setValue(operatingHours, "ежедневно с 9:00 - 21:00");
    setValue(email, "support-spo@company.dnevnik.ru");
  }
  
   else if(/^\/hc\/ru\/categories\/202660448/.test(path)){
    setValue(operatingHours, "по будним дням с 9:00 - 18:00");
    setValue(email, "support-poo@company.dnevnik.ru");
  }
  
   else if(/^\/hc\/ru\/categories\/202735767/.test(path)){
    setValue(operatingHours, "по будним дням с 9:00 - 18:00");
    setValue(email, "support-dop@company.dnevnik.ru");
  }
  
}

document.addEventListener( "DOMContentLoaded", changeTime, false );