function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();




/* $Revision: 1.3 $ */
var menuTimeout;
var currentMenu;
var theMenu;
var submenuTimeout;
var currentSubMenu;
var timing=600;


function menuOn(ev,menuName) {


if (browser.isIE)
    button = window.event.srcElement;
  else
    button = ev.currentTarget;
		
/*		
 if (ev.currentTarget!= null){
	 button = ev.currentTarget;
 }else{
	 button = ev.fromElement;
 }
 */
	 x = getPageOffsetLeft(button);
 	 y = getPageOffsetTop(button) + button.offsetHeight;
	 
	
		if (menuTimeout) clearTimeout(menuTimeout);	// clear the timeout
		if (currentMenu) {			// hide the current menu
			hideMenu(currentMenu)
		}
		currentMenu = menuName;	
		
		subMenu=findObj(menuName)
		subMenu.style.left = x + "px";
    subMenu.style.top  = (y+8) + "px";
		
		showHideLayers(menuName,'','show');
		menuTimeout = setTimeout('menuOff('+menuName+')', timing);		// set the timeout 
	
}
function menuOff(menuName){
	if (menuTimeout) clearTimeout(menuTimeout)	// clear the current timeout
	menuTimeout = setTimeout("hideMenu('"+menuName+"')", 3000);	
}

function hideMenu(menuName){
	if (currentSubMenu) {			// hide the current menu
			hideSubMenu(currentSubMenu)
		}
	if (menuTimeout) clearTimeout(menuTimeout)	// clear the current timeout
	showHideLayers(menuName,'','hide');
}

// submenu fuggvenyek:

function SubMenuOn(ev,SubMenuName) {
	if (browser.isIE)
    button = window.event.srcElement;
  else
    button = ev.currentTarget;

	// x = getPageOffsetLeft(button)+ button.offsetWidth;
	x = getPageOffsetLeft(button)+130;
 	 y = getPageOffsetTop(button) ;
	 
	 
	 if (submenuTimeout) clearTimeout(submenuTimeout);	// clear the timeout
		if (currentSubMenu) {			// hide the current menu
			hideSubMenu(currentSubMenu)
		}
		currentSubMenu = SubMenuName;	
	 
	 subMenu=findObj(SubMenuName)
		subMenu.style.left = (x+3) + "px";
    subMenu.style.top  = y + "px";
	 
	
		showHideLayers(SubMenuName,'','show');
		submenuTimeout = setTimeout('SubMenuOff('+SubMenuName+')', timing);		// set the timeout 
		/*
		if (SubMenuTimeout) clearTimeout(SubMenuTimeout);	// clear the timeout
		if (currentSubMenu) {			// hide the current menu
			hideSubMenu(currentSubMenu)
		}
		currentSubMenu = SubMenuName;	
		showHideLayers(SubMenuName,'','show');
		SubMenuTimeout = setTimeout('SubMenuOff('+SubMenuName+')', timing);		// set the timeout 
		*/
	
}
function SubMenuOff(SubMenuName){
	if (submenuTimeout) clearTimeout(submenuTimeout)	// clear the current timeout
	//showHideLayers(SubMenuName,'','hide');
	submenuTimeout = setTimeout("hideSubMenu('"+SubMenuName+"')", 3000);
	/*
	menuOff(menuName)
	if (SubMenuTimeout) clearTimeout(SubMenuTimeout)	// clear the current timeout
	SubMenuTimeout = setTimeout("hideMenu('"+SubMenuName+"')", 500);	
	*/
	/*
	if (SubMenuTimeout) clearTimeout(SubMenuTimeout)	// clear the current timeout
	SubMenuTimeout = setTimeout("hideSubMenu('"+SubMenuName+"')", 500);	
	if (menuTimeout) clearTimeout(menuTimeout)	// clear the current timeout
	menuTimeout = setTimeout("hidemenu('"+menuName+"')", 500);	
	*/
}

function hideSubMenu(SubMenuName){
	if (submenuTimeout) clearTimeout(submenuTimeout)	// clear the current timeout
	showHideLayers(SubMenuName,'','hide');
	/*
	if (SubMenuTimeout) clearTimeout(SubMenuTimeout)	// clear the current timeout
	showHideLayers(SubMenuName,'','hide');
	*/
}

function ClearSubmenuTimeout(menuTimeout){
	
	clearTimeout(menuTimeout);
	clearTimeout(SubMenuTimeout);
	
	}
	
	
function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}
 
 
 
 
// * Dependencies * 
// this function requires the following snippets:
// JavaScript/readable_MM_functions/findObj
//
// Accepts a variable number of arguments, in triplets as follows:
// arg 1: simple name of a layer object, such as "Layer1"
// arg 2: ignored (for backward compatibility)
// arg 3: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'','show',Layer2,'','hide');

function showHideLayers()
{ 
  var i, visStr, obj, args = showHideLayers.arguments;
  
 
  for (i=0; i<(args.length-2); i+=3)
  {
    if ((obj = findObj(args[i])) != null)
    {
      visStr = args[i+2];
      if (obj.style)
      {
        obj = obj.style;
        if(visStr == 'show'){
					visStr = 'visible';
					displayStr='block';
				}
        else if(visStr == 'hide'){
					visStr = 'hidden';
					displayStr='none';
					}
      }
       obj.visibility = visStr;
	   obj.display = displayStr;
    }
  }
}


// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;


  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}


function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
		thefield.value = ""
}

