function HeadSearchClick(inp,w) {
  if(w && inp.value == 'Keresés') inp.value = '';
  if(!w && inp.value == '') inp.value = 'Keresés';
}

function FindPos(obj) {
	var curleft = curtop = 0;
  if (obj.offsetParent) {
  do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
      } while (obj = obj.offsetParent);
  }
	return [curleft,curtop];
}


var ActiveDD = null;
var ShowDropdownTimer = new Array();
var HideDropdownTimer = new Array();

function ShowDropDown(id,sender) {
  if(HideDropdownTimer[id]) {
    clearTimeout(HideDropdownTimer[id]);
  }

  ShowDropdownTimer[id] = setTimeout(function () { DoShowDorpDown(id, sender); }, 50);
}

function HideDropDown(id,sender) {
  if(ShowDropdownTimer[id]) {
    clearTimeout(ShowDropdownTimer[id]);
  }

  HideDropdownTimer[id] = setTimeout(function () { DoHideDropDown(id, sender); }, 500);
}

function DoShowDorpDown(id,sender) {
  if(ActiveDD && ActiveDD != id) {
    DoHideDropDown(ActiveDD)
  }
  
  if(sender) {
    SenderPos = FindPos($(sender));
    dd = $('submenu'+id);

    dd.style.display = '';
    dd.style.top = SenderPos[1]+61+'px';
    dd.style.left = SenderPos[0]+'px';
  }

  ActiveDD = id;
}

function DoHideDropDown(id,sender) {
  $('submenu'+id).style.display = 'none';
}

function numericTest(e){
    var key = e.keyCode? e.keyCode : e.charCode
    if((key > 47 && key < 58) || key == 8 || key == 37 || key == 39 || key == 13 || key == 46) {
        return true;
    }
    else return false;
}

function MenuOver(menu) {
   m = menu.src.match(/menu_([0-9]+).jpg/)[1];
   menu.src = '/image/menupic/'+((menu.className == 'active' ? 'ahover':'hover'))+'/menu_'+m+'.jpg';
}

function MenuOut(menu) {
   m = menu.src.match(/menu_([0-9]+).jpg/)[1];
   menu.src = '/image/menupic/'+((menu.className == 'active' ? 'active':'def'))+'/menu_'+m+'.jpg';
}

function AddDiv(Id,Class,Display) {
  d = $(Id);
  if (!d)  {
    d = document.createElement('div');
    d.setAttribute('id', Id);
    d.setAttribute('class', Class);
    d.className = Class;
    d.style.display = Display;
    document.body.insertBefore(d, document.body.firstChild);
  }
  else {
    d.style.display = Display;
  }
  return d;
}

function ShowPopUp()  {
  ShowGray();
  d = AddDiv('popup','','');
  new Ajax.Updater('popup', '/popup-24.html?mod=ajax');
  d.style.left = parseInt((Element.getDimensions(document.body).width-Element.getDimensions(d).width)/2)+'px';
  SetScreenTop(d, 20);
}

function HidePopUp() {
  $('popup').hide();
  HideGray();
}

function ShowGray() {
  grayDiv = AddDiv('op','op','block');
  grayDiv.style.height =document.getHeight()+'px';
  Event.observe(grayDiv,'click',function(event) {HidePopUp();});
}

function HideGray() {
  $('op').remove();
}


document.getHeight = function ()
{
  var yScroll;
  if (window.innerHeight && window.scrollMaxY) {
    yScroll = window.innerHeight + window.scrollMaxY;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    yScroll = document.body.scrollHeight;
  } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    yScroll = document.body.offsetHeight;
  }

  var windowHeight;
  if (self.innerHeight) {  // all except Explorer
    windowHeight = self.innerHeight;
  } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    windowHeight = document.documentElement.clientHeight;
  } else if (document.body) { // other Explorers
    windowHeight = document.body.clientHeight;
  }
  var pageHeight;
  // for small pages with total height less then height of the viewport
  if(yScroll < windowHeight){
    pageHeight = windowHeight;
  } else {
    pageHeight = yScroll;
  }
  return pageHeight;
};

function GetScroll() {
  var x = 0, y = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    y = window.pageYOffset;
    x = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    y = document.body.scrollTop;
    x = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    y = document.documentElement.scrollTop;
    x = document.documentElement.scrollLeft;
  }
  return {x: x, y: y};
}

function SetScreenTop(Div, Top) {
  Div.style.top = (GetScroll().y + Top) + 'px';
}