var gLanguage = 0;  // HU = 1(Default language) GE = 2    EN = 0
var gSpeaker_on = true; // The speaker is off

// Preload and play audio files with event handler (MouseOver sound)
// designed by JavaScript Archive, (c)1999
// Get more free javascripts at http://jsarchive.8m.com


//----------- Popup menu  -------------------------------
var ie	= document.all
var ns6	= document.getElementById&&!document.all

var isMenu 	= false ; /ha a menü felett van a cursor, akkor true/

var overpopupmenu = false;
var overpopupmenu_id = 0;


//alert(navigator.appName);
//alert(navigator.appVersion);

if ((navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 3) || (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) >= 3))
  rollOvers = 1;
else
  rollOvers = 0;


function delete_Popup()
{
      var x = document.getElementById('HirPopup'); 
      if ( x.offsetWidth != 0)
      {
        x.style.display = "none" ;
      }

      x = document.getElementById('InfoPopup');

      if ( x.offsetWidth != 0)
      {
        //document.getElementById(PopupName).style.display = "none" ;
        x.style.display = "none" ;
      }

	  x = document.getElementById('KeresoPopup');

      if ( x.offsetWidth != 0)
      {
        //document.getElementById(PopupName).style.display = "none" ;
        x.style.display = "none" ;
      }

      //running = false;
}

function mouseSelect()
{
  //alert('mouseSelect');

  if( isMenu )
  {
    //Ki van nyitva a popup 	
    //alert(overpopupmenu_id);	

    if( overpopupmenu == false)
    {
      //Cursor elment a popup menüröl
      //alert('overpopupmenu = false');
      isMenu = false ;
      overpopupmenu = false; // ?? biztos, ami biztos...
			
      //gondolom itt szedi le a popup menüt
      //x = document.getElementById(PopupName); 
      //alert(x.offsetWidth);

      delete_Popup();

      return true ;
    }
    else
    {
      ;//alert('overpopupmenu = true');
    }
    return true ;
  }
  else
  {
    ;//alert('isMenu = false');	
  }

  return false;
}

var last_popup ="";

// POP UP MENU
function	ItemSelMenu(e,PopupName)
{
  var left;
  var top;
  var width;
  var height;
  var PupupId;

 if ( PopupName != last_popup )
  {
    last_popup = PopupName;
    // !!! nevvel ellatni
    delete_Popup();
  }
  
  try
  {	
    if (ns6)
    {
      //alert('Netscape');
      if ( PopupName == 'HirPopup')
      {
        left = 210;
        width = 113;
      }
      else if (PopupName == 'InfoPopup')
      {
        left = 319;
        width = 77;
      } else {
      	left = 357;
        width = 166;
      }
      top = 104;       
      height =  39;

//alert("left= "+left+" top= "+top+" width= "+width +" height= "+height);
      
    } 
    else
    {
      //alert('Other');
      
      if ( PopupName == 'HirPopup')
      {
        left = DL_GetElementLeft(menu1);
        top = DL_GetElementTop(menu1);
        width = document.all['menu1'].width; 
        height =  document.all['menu1'].height; 
      }
      else if (PopupName == 'InfoPopup')
      {
        left = DL_GetElementLeft(menu2);
        top = DL_GetElementTop(menu2);
        width = document.all['menu2'].width; 
        height =  document.all['menu2'].height; 
      } else {
      	left = DL_GetElementLeft(menu3);
        top = DL_GetElementTop(menu3);
        width = document.all['menu3'].width; 
        height =  document.all['menu3'].height; 
      }
    }		
	

    top = top -1; 
    //alert("left= "+left+" top= "+top+" width= "+width +" height= "+height);
  
    x = document.getElementById(PopupName).style.left = left + 30;
    y = document.getElementById(PopupName).style.top = top + height;
	//alert("x= "+x+" y= "+y );

    // Style beállítás.. gondom it teszi ki a menüt
    document.getElementById(PopupName).style.display = "";
 
    isMenu = true;

    return false ;
	
  }
  catch(e)
  {
	  alert("Error occured : " + e.description);
  }
}

function errorbox()
{
/* errorwindow=window.open("","","width=250,height=125")
errorwindow.document.write('<title>Error Window</title><center><b>A JavaScript error(s) has occurred on this page</b><Br><form><input type="button" value="Close window" onClick="window.close()"></form></center>')
errorwindow.document.close()
errorwindow.document.bgColor="white" */
return true
}
window.onerror=errorbox


function DL_GetElementLeft(eElement)
{
    if (!eElement && this)                       // if argument is invalid
    {                                            // (not specified, is null or is 0)
        eElement = this;                         // and function is a method
    }                                            // identify the element as the method owner
    
    var nLeftPos = eElement.offsetLeft;          // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nLeftPos += eParElement.offsetLeft;      // appending left offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nLeftPos;                             // return the number calculated
}
 
function DL_GetElementTop(eElement)
{
    if (!eElement && this)                       // if argument is invalid
    {                                            // (not specified, is null or is 0)
        eElement = this;                         // and function is a method
    }                                            // identify the element as the method owner

    var nTopPos = eElement.offsetTop;            // initialize var to store calculations
    var eParElement = eElement.offsetParent;     // identify first offset parent element  
    while (eParElement != null)
    {                                            // move up through element hierarchy
        nTopPos += eParElement.offsetTop;        // appending top offset of each parent
        eParElement = eParElement.offsetParent;  // until no more offset parents exist
    }
    return nTopPos;                              // return the number calculated
}



//document.onmousedown 	= mouseSelect; // menü item kiválasztása
//document.oncontextmenu 	= ItemSelMenu; //on right click erre jön fel a popup
//----------- END OF Popup menu  -------------------



//----------- Sound on menue --------------------------------
var aySound = new Array();
// Below: source for sound files to be preloaded
aySound[0] = "sounds/click.wav";

// DO NOT edit below this line
document.write('<BGSOUND ID="auIEContainer">')
IE = (navigator.appVersion.indexOf("MSIE")!=-1 && document.all)? 1:0;
NS = (navigator.appName=="Netscape" && navigator.plugins["LiveAudio"])? 1:0;
ver4 = IE||NS? 1:0;
onload=auPreload;


function auPreload() 
{
  if (!ver4) 
    return;

  if (NS) 
    auEmb = new Layer(0,window);
  else 
  {
    Str = "<DIV ID='auEmb' STYLE='position:absolute;'></DIV>";
    document.body.insertAdjacentHTML("BeforeEnd",Str);
  }

  var Str = '';
  for (i=0;i<aySound.length;i++)
   Str += "<EMBED SRC='"+aySound[i]+"' AUTOSTART='FALSE' HIDDEN='TRUE'>"

  if (IE) 
    auEmb.innerHTML = Str;
  else 
  {
    auEmb.document.open();
    auEmb.document.write(Str);
    auEmb.document.close();
  }
  auCon = IE? document.all.auIEContainer:auEmb;
  auCon.control = auCtrl;
}

function auCtrl(whSound,play) 
{
  if (IE) 
    this.src = play? aySound[whSound]:'';
  else 
    eval("this.document.embeds[whSound]." + (play? "play()":"stop()"))
}

function playSound(whSound) 
{ 
  //alert('playSound()');

  if ( !gSpeaker_on) // Speaker is not switched on
     return;


  if (window.auCon) 
    auCon.control(whSound,true); 
  //else
    //alert('playSound() **** else');
}

function stopSound(whSound) 
{ 
  if (window.auCon) 
    auCon.control(whSound,false); 
}



//----------- END OF Sound on menue --------------------------


//------------- top horizontal menue -------------------------
  function get_gif(gif_name)
  {
    //alert("get_gif");
    if ( gLanguage == 2 ) // DE German
    {
      gif_name = gif_name.replace("_HU/","_DE/");
      gif_name = gif_name.replace("_EN/","_DE/");
    }

    if ( gLanguage == 1 ) // HU Hungarian
    {
      gif_name = gif_name.replace("_DE/","_HU/");
      gif_name = gif_name.replace("_EN/","_HU/");
    }

    if ( gLanguage == 0 ) // EN English
    {
      gif_name = gif_name.replace("_DE/","_EN/");
      gif_name = gif_name.replace("_HU/","_EN/");
    }
    return gif_name;
  }


	function langsel(lang) {
		if (lang == "EN") gLanguage = 0;
		else if (lang == "DE") gLanguage = 2;
		else gLanguage = 1;
		set_gif_source();
	}

    function hungarian()
    {
      var datei;

      if ( gLanguage != 1 ) // not hungarian
      {
        //datei= parent.frames.left_menu_top.location.href;
        //Frame1.location.href = get_lang_url(URI1);
        gLanguage = 1;
        set_gif_source();
        //alert('Hungarian language');
      }
    }

    function german()
    {
      var datei;

      if ( gLanguage != 2 ) // not german
      {
        //datei= parent.frames.left_menu_top.location.href;
        //Frame1.location.href = get_lang_url(URI1);
        gLanguage = 2;
        set_gif_source();
        //alert('German language');
      }
    }

    function english()
    {
      var datei;

      if ( gLanguage != 0 ) // not english
      {
        //datei= parent.frames.left_menu_top.location.href;
        //Frame1.location.href = get_lang_url(URI1);
        gLanguage = 0;
        set_gif_source();
        //alert('English language');
      }
    }


  function set_gif_source()
  {
    // Top menu vizszintes - OFF
    menu1Off.src = get_gif("images/menu_HU/Top_hirek.png");
    menu2Off.src = get_gif("images/menu_HU/Top_info.png");
    menu3Off.src = get_gif("images/menu_HU/Top_kereso.png");
    menu4Off.src = get_gif("images/menu_HU/Top_fomenu.png");
    menu5Off.src = "images/menu/Top_envelope.png";
    if ( gSpeaker_on )   
      menu6Off.src = "images/menu/Top_speaker.png";
    else
      menu6Off.src = "images/menu/Top_speaker_off.png";

    // Top menu Hir popup - OFF
    menu1_1Off.src = get_gif("images/menu_HU/Top_hirek_aktualis_hirek.png");
    menu1_2Off.src = get_gif("images/menu_HU/Top_hirek_esemenynaptar.png");

    // Top menu Info popup - OFF
    menu2_1Off.src = get_gif("images/menu_HU/Top_info_vendeg.png");
    menu2_2Off.src = get_gif("images/menu_HU/Top_info_muvesz.png");
    menu2_3Off.src = get_gif("images/menu_HU/Top_info_site_map.png");
    menu2_4Off.src = get_gif("images/menu_HU/Top_info_kapcsolat.png");

	menu3_1Off.src = get_gif("images/menu_HU/Top_kereso_referencia.png");
    menu3_2Off.src = get_gif("images/menu_HU/Top_kereso_alkotoi.png");
    menu3_3Off.src = get_gif("images/menu_HU/Top_kereso_nev.png");
    menu3_4Off.src = get_gif("images/menu_HU/Top_kereso_muvesz.png");

    //-------------------------------------------------

    // Top menu vizszintes - ON
    menu1On.src = get_gif("images/menu_HU/Top_hirek_on.png");
    menu2On.src = get_gif("images/menu_HU/Top_info_on.png");
    menu3On.src = get_gif("images/menu_HU/Top_kereso_on.png");
    menu4On.src = get_gif("images/menu_HU/Top_fomenu_on.png");
    menu5On.src = "images/menu/Top_envelope_on.png";	
    if ( gSpeaker_on )   
      menu6On.src = "images/menu/Top_speaker_on.png";
    else
      menu6On.src = "images/menu/Top_speaker_off_on.png";
    

    // Top menu Hir popup - ON
    menu1_1On.src = get_gif("images/menu_HU/Top_hirek_aktualis_hirek_on.png");
    menu1_2On.src = get_gif("images/menu_HU/Top_hirek_esemenynaptar_on.png");

    // Top menu Info popup - ON
    menu2_1On.src = get_gif("images/menu_HU/Top_info_vendeg_on.png");
    menu2_2On.src = get_gif("images/menu_HU/Top_info_muvesz_on.png");
    menu2_3On.src = get_gif("images/menu_HU/Top_info_site_map_on.png");
    menu2_4On.src = get_gif("images/menu_HU/Top_info_kapcsolat_on.png");
    
	menu3_1On.src = get_gif("images/menu_HU/Top_kereso_referencia_on.png");
    menu3_2On.src = get_gif("images/menu_HU/Top_kereso_alkotoi_on.png");
    menu3_3On.src = get_gif("images/menu_HU/Top_kereso_nev_on.png");
    menu3_4On.src = get_gif("images/menu_HU/Top_kereso_muvesz_on.png");
  }


  if (rollOvers)
  {
    //alert("rollovers")
    menu1Off = new Image(113,39); // Hírek
    menu2Off = new Image(77,39); // Információ
    menu3Off = new Image(108,39);// Kereső 
    menu4Off = new Image(125,39); // Főmenü
    menu5Off = new Image(60,39); // Boríték
    menu6Off = new Image(49,39); // Hangszóró		
    menu1_1Off = new Image(119,33); // Aktuális hírek
    menu1_2Off = new Image(119,36); // Eseménynaptár
    menu2_1Off = new Image(119,29); // Vendégeknek
    menu2_2Off = new Image(119,20); // Művészeknek
    menu2_3Off = new Image(119,22); // Honlap térkép
    menu2_4Off = new Image(119,29); // Kapcsolat
	menu3_1Off = new Image(166,28); 
    menu3_2Off = new Image(166,24); 
    menu3_3Off = new Image(166,22); 
    menu3_4Off = new Image(166,32); 
									
    menu1On = new Image(113,39); 
    menu2On = new Image(77,39); 
    menu3On = new Image(108,39); 
    menu4On = new Image(125,39); 
    menu5On = new Image(60,39); 
    menu6On = new Image(49,19); 
    menu1_1On = new Image(119,33);
    menu1_2On = new Image(119,36);
    menu2_1On = new Image(119,29);
    menu2_2On = new Image(119,20);
    menu2_3On = new Image(119,22);
    menu2_4On = new Image(119,29);
	menu3_1On = new Image(166,28); 
    menu3_2On = new Image(166,24); 
    menu3_3On = new Image(166,22); 
    menu3_4On = new Image(166,32);
    set_gif_source();
  }
  		

function switchOn(imgName)
{
    if (rollOvers)
    {
      //alert("switchOn");
      //mouseSelect();
      playSound(0);
      imgOn = eval(imgName + "On.src");
      //alert(imgName);
      //alert("switchOn"+imgOn);
      document [imgName].src = imgOn;
    }
}

function Wr(msg) 
{
  alert(msg);
}

	
  function switchOff(imgName)
  {
    if (rollOvers)
    {  
      imgOff = eval(imgName + "Off.src");
      //alert(imgName);
      //alert("switchOff"+imgOff);
      document [imgName].src = imgOff;
    }
  }

  function speaker_on_off()
  {
    imgName = 'menu6';

    gSpeaker_on = !gSpeaker_on;


    set_gif_source();

  }




//------------- END OF top horizontal menue -------------------------
var timerID;
//var running = false;

  function ResetCounter_old()
  {
    count = 0;
    if (timerID != 0)
    {
      clearTimeout(timerID);
      timerID = 0;
    }
    running = false;
  }
  
  function mouse_out_Popup()
  {
	start_timer();
  }

  function stop_timer()
  {
    if (timerID != 0)
    {
      clearTimeout(timerID);
      timerID = 0;
    }
  }

  function start_timer()
  {
    if (timerID != 0)
    {
      clearTimeout(timerID);
    }
    timerID =setTimeout("chk_menu()",300);
  }


  function chk_menu()
  {
    //alert("chk_menu()");

    if (overpopupmenu_id == 0)
    {
      delete_Popup();
    }
  }