/************************************************************
/* L2 main.js */
/**/

function initPage(menu) {
  if (menu == "welcome") {
    var myEffect = new Fx.Morph('welcome', {duration: 3000, transition: Fx.Transitions.Sine.easeOut});
    myEffect.start({
      'color': ['#48160b', '#e6e6e6']
    });
  }
}

function switchOnOff(id,on,off) {
  var element;
  element = document.getElementById(id);
  if (element.className == on) {
    element.className = off;
  }
  else {
    element.className = on;
  }
}

function switchOnOffOver(id,on,on_over,off,off_over) {
  var element;
  element = document.getElementById(id);
  if (element.className == on) {
    element.className = on_over;
  }
  else if (element.className == on_over) {
    element.className = on;
  }
  else if (element.className == off) {
    element.className = off_over;
  }
  else {
    element.className = off;
  }
}

function switchMainMenu(mainmenu) {
  var i = 0;

  if ($('welcome').className == 'welcome_on')
    $('welcome').className = 'welcome_off';

  for (i = 0; i < sitemap_mainmenu.length; i++) {
    if (mainmenu == sitemap_mainmenu[i]) {
      document.getElementById(sitemap_mainmenu[i]).className = 'menu_box_on';
      document.getElementById('mainmenu_'+sitemap_mainmenu[i]).className = 'mainmenu_on';
    } else {
      document.getElementById(sitemap_mainmenu[i]).className = 'menu_box_off';
      document.getElementById('mainmenu_'+sitemap_mainmenu[i]).className = 'mainmenu_off';
    }
  }
  top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&load=iframe';
}

function switchMenu(mainmenu, menu) {
  for (i = 0; i < sitemap_mainmenu.length; i++) {
    if (mainmenu == sitemap_mainmenu[i]) {
      for (j = 0; j < sitemap_menu[i].length; j++) {
        if (menu == sitemap_menu[i][j]) {
          if (document.getElementById(sitemap_menu[i][j]) != null)
            document.getElementById(sitemap_menu[i][j]).className = 'submenus_on';
          if (document.getElementById('m_'+menu) != null)
            document.getElementById('m_'+menu).className = 'menu_on';
        } else {
          if (document.getElementById(sitemap_menu[i][j]) != null)
            document.getElementById(sitemap_menu[i][j]).className = 'submenus_off';
	      if (document.getElementById('m_'+sitemap_menu[i][j]) != null)
            document.getElementById('m_'+sitemap_menu[i][j]).className = 'menu_off';
        }
      }
    }
  }

    if (menu == 'hirek') {
      var submenu = "";
      top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&menu='+menu+'&submenu='+submenu+'&load=iframe';
    }
    if (menu == 'bemutatkozas') {
      var submenu = "";
      top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&menu='+menu+'&submenu='+submenu+'&load=iframe';
    }
    if (menu == 'elerhetoseg') {
      var submenu = "";
      top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&menu='+menu+'&submenu='+submenu+'&load=iframe';
    }
    if (menu == 'allas') {
      var submenu = "";
      top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&menu='+menu+'&submenu='+submenu+'&load=iframe';
    }
    if (menu == 'impresszum') {
      var submenu = "";
      top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&menu='+menu+'&submenu='+submenu+'&load=iframe';
    }
    if (menu == 'adattar') {
      var submenu = "";
      top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&menu='+menu+'&submenu='+submenu+'&load=iframe';
    }
    if (menu == 'impresszum') {
      var submenu = "";
      top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&menu='+menu+'&submenu='+submenu+'&load=iframe';
    }
    if (menu == 'levelezes') {
      var submenu = "";
      top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&menu='+menu+'&submenu='+submenu+'&load=iframe';
    }
}

function switchSubMenu(mainmenu, menu, submenu, num) {
  var i = 1;
  var el = document.getElementById('sm_'+menu+'_'+i);
  while(el != null) {
    if (i == num)
      el.className = 'submenu_on';
    else  
      el.className = 'submenu_off';
    i++;
    el = document.getElementById('sm_'+menu+'_'+i);
  }

  top.frames['main_iframe'].location.href = base_url+'?mainmenu='+mainmenu+'&menu='+menu+'&submenu='+submenu+'&load=iframe';
}

function switchInfoTable() {
  if (document.getElementById('body_box') != null) {
    if (document.getElementById('body_box').className == 'infotable_on') {
      $('info_control').set('opacity','.95');
      $('info_header').set('opacity','0');
      $('body_box').set('opacity','0');
      document.getElementById('info_header').className = 'infoheader_off';
      document.getElementById('body_box').className = 'infotable_off';
      document.getElementById('info_box').className = 'infoheader_off';
    }
    else {
      $('info_header').set('opacity','.95');
      $('body_box').set('opacity','.90');
      document.getElementById('info_header').className = 'infoheader_on';
      document.getElementById('body_box').className = 'infotable_on';
      document.getElementById('info_box').className = 'infoheader_on';
    }
  }
}

function switchSlider() {
  var slide = $$('.slideshow-thumbnails');

  if (slide != null) {
    if (slide.get('opacity') == '0')
      slide.set('opacity','100');
    else
      slide.set('opacity','0');
  }
}

function switchGiant(div_id, link, menu, max) {
  var counter = 0;

  if (top.document.getElementById('popup').className == 'popup_off') {
    top.document.getElementById('main').className = 'popup_off';
    top.document.getElementById('popup').className = 'popup_on';
    counter = (eval(menu + 'SlideShow.slide') - 1);
	if (counter < 0) counter = (max - 1);
    eval(menu + 'SlideShow.destroy()');
    top.document.getElementById('popup_iframe').src = link + "&page=" + counter;
    top.document.getElementById('main_iframe').src = '';
    }
  else {
    counter = (eval(menu + 'GiantSlideShow.slide') - 1);
	if (counter < 0) counter = (max - 1);
    eval(menu + 'GiantSlideShow.destroy()');
    top.document.getElementById('popup').className = 'popup_off';
    top.document.getElementById('main').className = 'popup_on';
    top.document.getElementById('popup_iframe').src = '';
    top.document.getElementById('main_iframe').src = link + "&page=" + counter;
  }
}

function initMenu() {
  if (document.getElementById('info_header') != null)
    $('info_header').set('opacity','.95');    
  if (document.getElementById('info_box') != null)
    $('info_box').set('opacity','.90');    
  if (document.getElementById('body_box') != null)
    $('body_box').set('opacity','.90');    
}
