opera = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
dom = (document.getElementById)? true : false;
ie4 = (document.all && !dom)? true : false;
nn4 = (document.layers)? true : false;
isLoaded = false;

function getEById (id) {
 return document.getElementById(id);
}

function changeImages(div) {
  if (!document.getElementById) return
  var imgOriginSrc = new Array();
  var imgTemp = new Array();
  if (div) { doc = div; } else { doc = document; }
  var imgarr = doc.getElementsByTagName('img');
  for (var i = 0; i < imgarr.length; i++) {
    if (imgarr[i].getAttribute('hsrc')) {
        imgTemp[i] = new Image();
        imgTemp[i].src = imgarr[i].getAttribute('hsrc');
        imgarr[i].setAttribute('srctemp', imgarr[i].getAttribute('src'));
        imgarr[i].onmouseover = function() {
            this.setAttribute('src',this.getAttribute('hsrc'))
        }
        imgarr[i].onmouseout = function() {
            this.setAttribute('src',this.getAttribute('srctemp'))
        }
    }
  }
}

var submenuAr = [[10, ["Наша миссия","/center/"], ["Годовой отчет","/center/report.php"], ["Академический совет","/center/council.php"], ["Дирекция","/center/direction.php"]],
[73, ["Новости","/news/"], ["Объявления","/news/events.php"]],
[129, ["Грантовая программа 2008 года","/grant/grant_year.php"], /*["Конкурс для студентов 2007","/grant/rgrant_year.php"], ["Конкурс издательских проектов","/grant/izd_proekt.php"],*/["Результаты конкурсов 2003-2008","/grant/grant_arhiv.php"] /*["Результаты конкурса 2006","/grant/grant_result2006.php"]*/],
[241,["Методологический семинар","/projects/seminar.php"],["150 лет еврейской эмиграции","/projects/emigration.php"],["Документальное наследие Бунда","/projects/bund.php"],["Еврейская трибуна","/projects/tribune.php"],["Научная биография Дубнова","/projects/dubnov.php"]], 
[379, ["Ежегодные конференции","/conference/annual.php"], ["Наши конференции за рубежом","/conference/abroad.php"], ["Форум молодых ученых","/conference/forum.php"], ["Научные чтения","/conference/public.php"], ["VIII Конгресс EAJS","http://jewishstudies.ru/EAJS2006/"]],
[522, ["Научные центры при университетах","/colleague/center.php"], ["Персоналии","/colleague/personal.php"]],
[612],
[750, ["Календарь событий","/resources/calendar.php"], ["Книги","/resources/books.php"], ["Статьи","/resources/articles.php"], ["Ресурсы интернета","/resources/rec_inet.php"]],
[805, ["Контактная информация","/contact/"], ["Обратная связь","/contact/feedback.php"]],
[875]
];




var smShow = -1;
var mOpened = -1;
var smOpened = 1;

function submenuOpen (num) {
 var printHTML = '';
 sm = getEById('submenu');
 if (smShow != num) {
  printHTML = "<table cellpadding='0' cellspacing='0' border='0' class='submenu'>";
  for (var i=1; i<submenuAr[num].length; i++) {
   if (i == smOpened) {
    printHTML += "<tr><td background='/i/submenu-bg.gif' class='menu' nowrap bgcolor='#336699' obg='/i/submenu-bg-over.gif' olink='"+submenuAr[num][i][1]+"'><img src='/i/submenu-sep.gif' align='absmiddle'><a href='"+submenuAr[num][i][1]+"'>"+submenuAr[num][i][0]+"</a></td></tr>";
   } else {
    printHTML += "<tr><td background='/i/submenu-bg.gif' class='menu' nowrap bgcolor='#336699' obg='/i/submenu-bg-over.gif' olink='"+submenuAr[num][i][1]+"'><img src='/i/submenu-sep.gif' align='absmiddle'><a href='"+submenuAr[num][i][1]+"'>"+submenuAr[num][i][0]+"</a></td></tr>";
   }
  }
  printHTML += "</table>";
  sm.style.visibility = 'hidden';
  sm.innerHTML = printHTML;
  sm.onmouseover = function() {
   submenuOpen (num);
  }
  sm.onmouseout = function() {
   submenuClose (num);
  }
  changeImages(sm);
  sm.style.left = submenuAr[num][0];
  sm.style.visibility = 'visible';
  smShow = num;
  loadSubMenuBg ();
 }
}


function submenuClose (num) {
 if (num == mOpened) { return false; } else { sm = getEById('submenu'); }
 sm.style.visibility = 'hidden';
 smShow = -1;
}

var imgBgTemp = new Array();
imgBgTemp[0] = new Image();
imgBgTemp[0].src = '/i/menu-bg.gif';
imgBgTemp[1] = new Image();
imgBgTemp[1].src = '/i/menu-bg-over.gif';
imgBgTemp[2] = new Image();
imgBgTemp[2].src = '/i/submenu-bg.gif';
imgBgTemp[3] = new Image();
imgBgTemp[3].src = '/i/submenu-bg-over.gif';

function loadSubMenuBg () {
 if (!document.getElementById) return
 sm = getEById('submenu');
 var imgarr = sm.getElementsByTagName('td');
 for (var i = 0; i < imgarr.length; i++) {
  if (imgarr[i].getAttribute('obg')) {
   imgarr[i].onmouseover = function() {
    this.setAttribute('background','/i/submenu-bg-over.gif');
   }
   imgarr[i].onmouseout = function() {
    this.setAttribute('background','/i/submenu-bg.gif');
   }
   imgarr[i].onclick = function() {
    window.location.href = this.getAttribute('olink');
   }
  }
 }
}

function loadMenuBg () {
 if (!document.getElementById) return
 var imgarr = document.getElementsByTagName('td');
 for (var i = 0; i < imgarr.length; i++) {
  if (imgarr[i].getAttribute('obg')) {
   imgarr[i].onmouseover = function() {
    this.setAttribute('background',this.getAttribute('obg'));
    submenuOpen (this.getAttribute('menu')-1);
   }
   imgarr[i].onmouseout = function() {
    this.setAttribute('background','');
    submenuClose (this.getAttribute('menu')-1);
   }
   imgarr[i].onclick = function() {
    window.location.href = this.getAttribute('olink');
   }
  }
 }
}

function loadMenu () {
 if (!document.getElementById) return
 var imgarr = document.getElementsByTagName('img');
 for (var i = 0; i < imgarr.length; i++) {
  if (imgarr[i].getAttribute('menu')) {
   imgarr[i].setAttribute('srctemp', imgarr[i].getAttribute('src'));
   imgarr[i].onmouseover = function() {
    this.setAttribute('src',this.getAttribute('hsrc'));
    submenuOpen (this.getAttribute('menu')-1);
   }
   imgarr[i].onmouseout = function() {
    this.setAttribute('src',this.getAttribute('srctemp'));
    submenuClose (this.getAttribute('menu')-1);
   }
  }
 }
}

function init () {
 // submenuOpen (1);
 changeImages (false);
 loadMenu ();
 loadMenuBg ();
}

onload = init;
