

var DDSPEED = 10;
var DDTIMER = 15;


function getSize(){
  var agt = navigator.userAgent.toLowerCase();
  var ie = ((agt.indexOf ("msie") != -1)&&(agt.indexOf ("opera") == -1));
  var h = (self.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || 0) - 100;
  var delta = ie?650:670;
  document.getElementById('gallery_div').style.height = (h < delta?delta:h) - 40 + 'px';
}

function setLang(lang){
  if(lang == 'ru_lang'){
    document.getElementById('eng_lang').style.display = 'none';
    document.getElementById('eng_lang_link').className = 'lang';
    document.getElementById('ru_lang').style.display = 'block';
    document.getElementById('ru_lang_link').className = 'lang cur_lang';
  }else{
    document.getElementById('ru_lang').style.display = 'none';
    document.getElementById('ru_lang_link').className = 'lang';
    document.getElementById('eng_lang').style.display = 'block';
    document.getElementById('eng_lang_link').className = 'lang cur_lang';
  }
}

//2011-06-08 Добавлено меню навигации{

// main function to handle the mouse events //
function ddMenu(id,dir) {
  var head = document.getElementById(id + '-ddheader');
  var cont = document.getElementById(id + '-ddcontent');
  clearInterval(cont.timer);
  if(dir == 1) {
    clearTimeout(head.timer);
    if(cont.maxh && cont.maxh <= cont.offsetHeight) {
      return;
    } else if(!cont.maxh) {
      cont.style.display = 'block';
      cont.style.height = 'auto';
      cont.maxh = cont.offsetHeight;
      cont.style.height = '0px';
    }
    cont.timer = setInterval("ddSlide('" + id + "-ddcontent', 1)", DDTIMER);
  } else {
    head.timer = setTimeout('ddCollapse(\'' + id + '-ddcontent\')', 50);
  }
}

// collapse the menu //
function ddCollapse(id) {
  var cont = document.getElementById(id);
  cont.timer = setInterval("ddSlide('" + id + "', -1)", DDTIMER);
}

// cancel the collapse if a user rolls over the dropdown content //
function cancelHide(id) {
  var head = document.getElementById(id + '-ddheader');
  var cont = document.getElementById(id + '-ddcontent');
  clearTimeout(head.timer);
  clearInterval(cont.timer);
  if(cont.offsetHeight < cont.maxh) {
    cont.timer = setInterval("ddSlide('" + id + "-ddcontent', 1)", DDTIMER);
  }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(id,dir) {
  var cont = document.getElementById(id);
  var currheight = cont.offsetHeight;
  var dist;
  if(dir == 1) {
    dist = (Math.round((cont.maxh - currheight) / DDSPEED));
  } else {
    dist = (Math.round(currheight / DDSPEED));
  }
  if(dist <= 1) {
    dist = 1;
  }
  cont.style.height = currheight + (dist * dir) + 'px';
  cont.style.opacity = currheight / cont.maxh;
  cont.style.filter = 'alpha(opacity=' + (currheight * 100 / cont.maxh) + ')';
  if((currheight < 2 && dir != 1) || (currheight > (cont.maxh - 2) && dir == 1)) {
    clearInterval(cont.timer);
  }
}
//2011-06-08 Добавлено меню навигации}
