function closeBlocks ()
{
  var content = $('content');
  var blocks = content.select('.ajax-closed');

  if (blocks.length > 0) {
    for(var i = 0; i < blocks.length; i++) {
      // get 1st firstDescendant
      var firstDesc = blocks[i].firstDescendant();
      if (!firstDesc) {
        continue;
      }
      var switcher = firstDesc.remove();
      var newElement = new Element('div');
      newElement.id = 'id__article_block_' + i;
      newElement.hide();
      newElement.update(blocks[i].innerHTML);

      if (!Prototype.Browser.IE) {
        switcher.writeAttribute ('onclick', '$(\'' + newElement.id + '\').toggle()' );
      } else {
        switcher.setAttribute('blockid', i);
        switcher.onclick = function () {
          e = event.srcElement;
          while(true) {
            if (e.tagName == 'BODY' || e.tagName == 'HTML' || e.blockid !== undefined ) {
              break;
            }
            e = e.parentNode;
          }
          if (e.blockid !== undefined) {
            $('id__article_block_' + e.blockid).toggle();
          }
        }
      }
      var wrapper = new Element('div');
      wrapper.appendChild(switcher);
      wrapper.appendChild(newElement);
      blocks[i].replace(wrapper);
    }
  }
}

var cur=0;
function showpic(id)
{

	var a=pictures.length-1;
	if(a==id)
	{
		document.getElementById('picN').style.display='none';
	}else
	{
		document.getElementById('picN').style.display='';
	}
	if(id==1)
	{
		document.getElementById('picP').style.display='none';
	}else
	{
		document.getElementById('picP').style.display='';
	}
	document.getElementById('fl').style.display='';
	document.getElementById('big_img').src=pictures[id];
	cur=id;
}

function showN()
{
	showpic(parseInt(cur)+1);
}

function showP()
{
	showpic(parseInt(cur)-1);
}

var al='';
function showSub(alias)
{
	 // Create new JsHttpRequest object.
  var req = new JsHttpRequest();
  // Code automatically called on load finishing.
  req.onreadystatechange = function() {
    if (req.readyState == 4) {
      // Write result to page element (_RESULT becomes responseJS).
     document.getElementById('article-main').innerHTML = req.responseJS.ajax_result;
     document.getElementById('art_' + alias).className = 'active';
     if(al){
     	  document.getElementById('art_' + al).className = '';
     }
     al = alias;
    }
  }
  // Prepare request object (automatically choose GET or POST).
  req.open(null, '/ajax/city/', true);
  // Send data to backend.

  req.send({ alias:alias});
}
