var RE_START = /^([\ \t\n]+)/;
var RE_END   = /^([\ \t\n]+)/;
var HEXA = Array('0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f');

function trim(s)	{return String(s).replace(RE_START,"").replace(RE_END,"");}
function ch(c)		{return String.fromCharCode(c);}
if (!document.getElementById) { document.getElementById = function() { return null; }}

function generalWindow(windowName, url, prp)
 {
  try
   {
    if ((typeof navigator[windowName] != "undefined") && (navigator[windowName] != null))
     {
      if (navigator[windowName].closed) navigator[windowName] = window.open(url,"",prp);
      else navigator[windowName].location.href = url;
     }
    else navigator[windowName] = window.open(url,"",prp);
   }
  catch (err)
   {
    if ((typeof navigator[windowName] == "undefined") || (navigator[windowName]==null)) navigator[windowName] = window.open(url,"",prp);
    else navigator[windowName].location.href = url;
   }
  navigator[windowName].focus();
 }

function DV(key,def)
 {
  return ((typeof key != "undefined") && (key != null) && (typeof DICTIONARY != "undefined") && (DICTIONARY != null) && (typeof DICTIONARY[key] != "undefined")) ? DICTIONARY[key] : ((typeof def != "undefined" && def!=null) ? def : key);
 }

function AlertMessage(key,ret)
 {
  alert(DV(key,key));
  return ret;
 }
 
function underConstruction()
 {
  AlertMessage('UnderConstruction');
 }

function RefreshOpener()
 {
  var op = window.opener;
  window.opener.location.href = window.opener.location.href;
 }


function initializeMenu(menuId, RootMenuId) {
	var menu = document.getElementById(menuId);
	var RootMenu = document.getElementById(RootMenuId);

	if (menu == null || RootMenu == null) return;

	RootMenu.onmouseover = function() {
		menu.style.visibility = "visible";
	}	

	RootMenu.onmouseout = function (e) {
		var relatedTarget = null;
		if (e) { 
			relatedTarget = e.relatedTarget; 
		} else if (window.event) { 
			relatedTarget = window.event.toElement; 
		}

		if (elementContains(this, relatedTarget)) return false;
	
		for (i = 0; i < this.childNodes.length; i++) {
			if ((node = this.childNodes[i]).nodeName.toLowerCase() == "ul") {
				node.style.visibility = "hidden";
			}
		}
		return false;
  }
}

function elementContains(elmOuter, elmInner) {
	while (elmInner && elmInner != elmOuter) {
		elmInner = elmInner.parentNode;
	}
	return (elmInner == elmOuter);
}

function setStyle(val) {
	if(val == 1) document.getElementById("hirlevelinpt").style.border = "1px solid #F53725";
	else document.getElementById("hirlevelinpt").style.border = "1px solid #DDDFDF"
}

function goPage(id)
 {
  var url = "";
 
  switch(id)
   {
    case 	"p1"	: 	url = "/Alkategoriatermekek/213/214"; break;
    case	"p5"	:	url = "/Alkategoriatermekek/102/103"; break;
    default		:	underConstruction();
   }    
  if (url != "") window.location.href=url;
 }				

function SendPage(url)
 {
  underConstruction();
 }

function PrintPage(url)  
 {
  underConstruction();
 }
  
 function SetOffset(off,lim)
 	{
 		window.location.href = URLPREFIX+off+"/"+lim;
 	}
 	
function ArchiveShow(item,itemimg)
{
	if(document.getElementById(item).style.display == "none")
	{
		document.getElementById(item).style.display = "block";
		document.getElementById(itemimg).src = "images/nyitott.jpg";
	}
	else
	{
		document.getElementById(item).style.display = "none";
		document.getElementById(itemimg).src= "images/csukott.jpg";
	}
}

function check_search(string) {
	if(string.length < 2) {
		document.getElementById("searchinput").value =""
		alert('Search term should be more than 1 character.');
		return false;
	}
	return true;
}

