﻿var first_click = true;

var keynav_enabled = true;

var is_arrows = false;
var is_hotspots = false;
var hotspots;
var left_arrow;
var right_arrow;

		window.addEvent('domready', function() {
			var accordion = new Accordion('h2.atStart', 'div.atStart', {
			    display: -1,
				alwaysHide: true,
				opacity: false,
				onActive: function(toggler, element){
					toggler.setStyle('color', '#333333');
					toggler.setStyle('background', '#E28F33');
				},
				
				onBackground: function(toggler, element){
					toggler.setStyle('color', '#EEEEEE');
					toggler.setStyle('background', '#383838');
				}
			}, $('accordion'));
			}); 

window.onload = function() { initialize(); }

function initialize() {
  document.getElementById('search_text').onblur = function() {if (document.getElementById('search_text').value.replace(/^\s+|\s+$/g, '') == '') { document.getElementById('search_text').value = "keresés"; first_click = true;}; keynav_enabled = true;};
  document.getElementById('search_text').onfocus = function() {if (first_click) {document.getElementById('search_text').value = ""; first_click = false; }; keynav_enabled = false;};
  if ((document.getElementById('left_arrow') != undefined) && (document.getElementById('right_arrow') != undefined)) { is_arrows = true; left_arrow = document.getElementById('left_arrow'); right_arrow = document.getElementById('right_arrow');}
  if (document.getElementById('hotspots') != undefined) {is_hotspots = true; hotspots = document.getElementById('hotspots').getElementsByTagName('a');}
  if (is_arrows) {document.onkeydown = function(e) {if (keynav_enabled) {KeyNav(e);}};}
  if (is_arrows || is_hotspots) {
    document.getElementById('image_box').onmouseover = function() {AppearHotspots(true);};
    document.getElementById('image_box').onmouseout = function() {AppearHotspots(false);};
  }
}

function AppearHotspots(show) {
  if (is_arrows) {
    if (show) {left_arrow.style.display = "inline"; right_arrow.style.display = "block";
    } else {left_arrow.style.display = "none"; right_arrow.style.display = "none";}
  }

  if (is_hotspots) {
    for (i=0; i<hotspots.length; i++) {
      if (show) {hotspots[i].style.display = "list-item";} else {hotspots[i].style.display = "none";} 
    }
  }
}

function submitform() {document.SearchForm.submit();}

function KeyNav(e) {
  var key = e.keyCode;
  if (key == 37) {window.location.assign(document.getElementById('left_arrow').href);}
  if (key == 38) {window.location.assign(document.getElementById('forward').href);}
  if (key == 39) {window.location.assign(document.getElementById('right_arrow').href);}
}

function ShowPage(page_name){
  UnselectPages();
  document.getElementById(page_name+"_menu").style.color="#E28F33";
  document.getElementById(page_name).style.display="block";
}
function UnselectPages(){
  var pars=document.getElementById("page_menu").getElementsByTagName("A");
  for (var z=0;z<pars.length;z++){
    document.getElementById(pars[z].id).style.color="#999999";
  }
  var pars=document.getElementById("pages").getElementsByTagName("DIV");
  for (var z=0;z<pars.length;z++){
    if(pars[z].className=="module description"){pars[z].style.display="none";}
  }
}
function ShowFirstPage(){
  var pars=document.getElementById("pages").getElementsByTagName("DIV");
  ShowPage(pars[0].id);
}
