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/825"; break;
    case	"p2"	:	url = "/Alkategoriatermekek/836"; break;
    case	"p3"	:	url = "/Alkategoriatermekek/844"; break;
    case	"p4"	:	url = "/Alkategoriatermekek/848"; break;
    case	"p5"	:	url = "/Alkategoriatermekek/855"; break;
    case	"p6"	:	url = "/Alkategoriatermekek/842"; break;    
    default		:	underConstruction();
   }    
  if (url != "") window.location.href=url;
 }				

function SendPage(url)
 {
  generalWindow("SENDPAGEWIDNOW","/sendPage/F"+url,"width=550,height=320");
 }

function PrintPage(url)  
 {
  generalWindow("PRINTPAGEWINDOW","/printPage"+url,"width=700,height=500,scrollbars=yes");
  //underConstruction();
 }
  
 function SetOffset(off,lim)
 	{
 		window.location.href = URLPREFIX+off+"/"+lim;
 	}

 function SetOffset2(off,lim)
 	{
 		window.location.href = URLPREFIX+off+"/"+lim+URLPOSTFIX;
 	}
 	
 function check_search(string) {
  	text = trim(string.length)
	if(text.lenght < 2) {
		document.getElementById("searchinput").value =""
		alert('A keresési szövegnek 1 karakternél hosszabnak kell lennie.');
		return false;
	}
	return true;
}

function trim(stringToTrim) {
	stringToTrim = String(stringToTrim);
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}




