// JavaScript Document
xAddEventListener(window, 'load', initializeCollapsible, false);

function initializeCollapsible()
{
  var i, icon, headings = xGetElementsByClassName('expandable');
  for (i = 0; i < headings.length; i++) {
    icon = document.createElement('div');
    icon.expandableSection = xNextSib(headings[i]);
    icon.onclick = iconOnClick;
    icon.expandableSection.style.display = 'block';
    icon.onclick();    
    icon.onmouseover = iconOnMouseover;
    icon.onmouseout = iconOnMouseout;
    headings[i].appendChild(icon);
  }
  headings = xGetElementsByClassName('collapsible');
  for (i = 0; i < headings.length; i++) {
    icon = document.createElement('div');
    icon.collapsibleSection = xNextSib(headings[i]);
    icon.onclick = iconOnClick2;
    icon.onclick();        
    icon.onmouseover = iconOnMouseover2;
    icon.onmouseout = iconOnMouseout2;
    headings[i].appendChild(icon);
  }
}

function iconOnClick()
{
  var section = this.expandableSection; 
  if (section.style.display == 'block') {
    section.style.display = 'none';
    this.className = 'ExpandIcon';
    this.title = 'Показать текст';
  }
  else {
    section.style.display = 'block';
    this.className = 'CollapseIcon';
    this.title = 'Свернуть текст';    
  }  
}

function iconOnClick2()
{
  var section = this.collapsibleSection; 
  if (section.style.display != 'block') {
    section.style.display = 'block';
    this.className = 'CollapseIcon';
    this.title = 'Свернуть текст';    
  }
  else {
    section.style.display = 'none';
    this.className = 'ExpandIcon';
    this.title = 'Показать текст';    
  }  
}

function iconOnMouseover()
{   
  this.expandableSection.style.backgroundColor = '#EAF2FF';
}

function iconOnMouseout()
{   
  this.expandableSection.style.backgroundColor = 'transparent';
}

function iconOnMouseover2()
{
  this.collapsibleSection.style.backgroundColor = '#EAF2FF';
}

function iconOnMouseout2()
{   
  this.collapsibleSection.style.backgroundColor = 'transparent';
}
