
/* detect */

var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById);

/* show/hide */

function show(id){
  // Netscape 4
  if (id =='') return(0);
  if(ns4){
    document.layers[id].visibility = "show";
  }
  // Explorer 4
  else if(ie4){
    document.all[id].style.visibility = "visible";
  }
  // W3C - Explorer 5+ and Netscape 6+
  else if(ie5 || ns6){
    x = document.getElementById(id);
    if (x) {x.style.visibility = "visible";};
  }
}

function hide(id){
  if (id =='') return(0);
  // Netscape 4
  if(ns4){
    document.layers[id].visibility = "hide";
  }
  // Explorer 4
  else if(ie4){
    document.all[id].style.visibility = "hidden";
  }
  // W3C - Explorer 5+ and Netscape 6+
  else if(ie5 || ns6){
    x = document.getElementById(id);
    if (x) {x.style.visibility = "hidden";};
  }
}

function show2(id){
  // Netscape 4
  if (id =='') return(0);
  if(ns4){
    document.layers[id].display = "block";
  }
  // Explorer 4
  else if(ie4){
    document.all[id].style.display = "block";
  }
  // W3C - Explorer 5+ and Netscape 6+
  else if(ie5 || ns6){
    x = document.getElementById(id);
    if (x) {x.style.display = "block";};
  }
}
  
function hide2(id){
  if (id =='') return(0);
  // Netscape 4
  if(ns4){
    document.layers[id].display = "none";
  }
  // Explorer 4
  else if(ie4){
    document.all[id].style.display = "none";
  }
  // W3C - Explorer 5+ and Netscape 6+
  else if(ie5 || ns6){
    x = document.getElementById(id);
    if (x) {x.style.display = "none";};
  }
}


function clickItem(item) {
  location.href = item.cells(1).firstChild.href;
}

function img_load(name, url) {
  img_cache[name] = new Image();
  img_cache[name].src = url;
}

var img_cache = {};

// img_load("news"         ,"images/mb_news.gif");
// img_load("newsbottom"   ,"images/mb_newsbottom.gif");
img_load("production"         ,"/images/mb_production.gif");
img_load("productionbottom"   ,"/images/mb_productionbottom.gif");
img_load("company"      ,"/images/mb_company.gif");
img_load("clients"      ,"/images/mb_clients.gif");
img_load("partners"     ,"/images/mb_partners.gif");
// img_load("info"         ,"/images/mb_info.gif");
img_load("personal"     ,"/images/mb_personal.gif");
img_load("contacts"     ,"/images/mb_contacts.gif");
img_load("vacancies"    ,"/images/mb_vacancies.gif");

img_load("production_a"       ,"/images/mb_production_a.gif");
img_load("productionbottom_a" ,"/images/mb_productionbottom_a.gif");
// img_load("news_a"       ,"images/mb_news_a.gif");
// img_load("newsbottom_a" ,"images/mb_newsbottom_a.gif");
img_load("company_a"    ,"/images/mb_company_a.gif");
img_load("clients_a"    ,"/images/mb_clients_a.gif");
img_load("partners_a"   ,"/images/mb_partners_a.gif");
// img_load("info_a"       ,"/images/mb_info_a.gif");
img_load("personal_a"   ,"/images/mb_personal_a.gif");
img_load("contacts_a"   ,"/images/mb_contacts_a.gif");
img_load("vacancies_a"  ,"/images/mb_vacancies_a.gif");


/* flip */

function mi_mark(id, mode) {
  if (id=='') return(0);
  var suf = "";
  if (mode == 'on') {
    suf = "_a";
  };
  img = document.getElementById(id);
  img2 = document.getElementById(id + '2');
  img.src = img_cache[img.id + suf].src;
  if (id == 'production') {
    img2.src = img_cache[img.id + 'bottom' + suf].src;
  } else { 
    img2.src = img_cache[img.id + suf].src;
  }
}

/* current menu */

var mi_def = "";
var mi_cur = "";

function mi_toggle(name, state) {
  //if (ns6) {    
  //} else {
  //  var to = event.toElement;
  //}
  //if ((state == 'off') && to && to.id) {
  //alert('-> ' + name + state);
  var mi_old = mi_cur;
  if (state == 'off') {    
    if (mi_cur != mi_def) {
      mi_cur = mi_def;
      mi_mark(mi_old, 'off');
      mi_mark(mi_cur, 'on');
    }
  } else {            
    mi_cur = name;
    if (mi_old != mi_cur) {
      mi_mark(mi_old, 'off');
    }
    mi_mark(mi_cur, 'on');
  }
}

function id_to_name(id)  {
  switch(id) {
    case 1:  return 'production'; break;
    case 1:  return 'productionbottom'; break;
    case 13: return 'company'; break;
    case 14: return 'clients'; break;
    case 49: return 'partners'; break;
    case 27: return 'personal'; break;
    case 28: return 'contacts'; break;
    case 29: return 'vacancies'; break;
    default: return '';
  }
}

function mi_default(id) {
  name = id_to_name(id);
  if (name == '') {
    return 0;
  }
  mi_def = name;
  mi_cur = name;
  mi_toggle(mi_def, 'on');
}

