if (typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement) {
  HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode)
	{
	  switch (where){
		case 'beforeBegin':
			this.parentNode.insertBefore(parsedNode,this)
			break;
		case 'afterBegin':
			this.insertBefore(parsedNode,this.firstChild);
			break;
		case 'beforeEnd':
			this.appendChild(parsedNode);
			break;
		case 'afterEnd':
			if (this.nextSibling) 
		      this.parentNode.insertBefore(parsedNode,this.nextSibling);
			else this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function (where,htmlStr)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}


	HTMLElement.prototype.insertAdjacentText = function (where,txtStr)
	{
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
};
//---------------------------------------------------------
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
//---------------------------------------------------------
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
//---------------------------------------------------------
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
//---------------------------------------------------------
function addEvent(obj, type, fn) {
 if (obj.addEventListener) obj.addEventListener(type, fn, false);
 else if (obj.attachEvent) {
  obj["e"+type+fn] = fn;
  obj[type+fn] = function() {
   obj["e"+type+fn]( window.event );
  };
  obj.attachEvent( "on"+type, obj[type+fn] );
 }
}
//---------------------------------------------------------
function getObject(evt)
{
 if (!evt) evt = window.event;
 var objectFired;
 var object;
 if (evt.srcElement) object = evt.srcElement;
 else object = evt.target;
 objectFired = object.id;
 if (objectFired.nodeType == 3) {
  object = objectFired.parentNode;
  objectFired = object.id;
 }
 /*var tomb = new Array();
 tomb[0] = object;
 tomb[1] = objectFired; */
 return object;
}
//---------------------------------------------------------
function getPressedKey(e) {
 if (!e) e = window.event;
 var kod = -1;
 if (e) {
    if (e.which) kod = e.which;
    if (e.keyCode) kod = e.keyCode;
 }
 return kod;
}
function ol()
{
}
//-----------------------------------------------------------------------------------------------------------
function OpenPrintWindow(url, x, y) {
 var options = "toolbar=no,menubar=yes,scrollbars=yes,resizable=yes,width=" + x + ",height=" + y;
 msgWindow=window.open(url,"", options);
}
//-----------------------------------------------------------------------------------------------------------
function openWindow(url, x, y) {
 var options = "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=" + x + ",height=" + y;
 msgWindow=window.open(url,"", options);
}
//-----------------------------------------------------------------------------------------------------------
function OpenNewWindowNoScroll(url, x, y) {
 var options = "toolbar=no,menubar=no,scrollbars=no,resizable=yes,width=" + x + ",height=" + y;
 msgWindow=window.open(url,"", options);
}
//-----------------------------------------------------------------------------------------------------------
// Get Cookie Value    
	function getCookieVal (offset) {
	   var endstr = document.cookie.indexOf (";", offset);
	   if (endstr == -1)
	      endstr = document.cookie.length;
	   return unescape(document.cookie.substring(offset, endstr));
	}

//-----------------------------------------------------------------------------------------------------------
// Read Cookie
	function GetCookie (name) {
	        var arg = name + "=";
	        var alen = arg.length;
	        var clen = document.cookie.length;
	        var i = 0;
	        while (i < clen) {
	                var j = i + alen;
	                if (document.cookie.substring(i, j) == arg)
	                        return getCookieVal (j);
	                i = document.cookie.indexOf(" ", i) + 1;
	                        if (i == 0)
	                                break;
	                }
	   return null;
	}

//-----------------------------------------------------------------------------------------------------------
// Set Cookie     	
	function SetCookie (name, value) {
	        var argv = SetCookie.arguments;
	   	    var argc = SetCookie.arguments.length;
	        var expires = (argc > 2) ? argv[2] : null;
	        var path = (argc > 3) ? argv[3] : null;
	        var domain = (argc > 4) ? argv[4] : "epitoipariajanlatok.hu";
	        var secure = (argc > 5) ? argv[5] : false;
	        document.cookie = name + "=" + escape (value) +
	                ((expires == null) ? "" : ("; expires=" +
						expires.toGMTString())) +
	                ((path == null) ? "" : ("; path=" + path)) +
	                ((domain == null) ? "" : ("; domain=" + domain)) +
	                ((secure == true) ? "; secure" : "");
	}



var js_acceptsCookies = false;
if(document.cookie == '') {
    document.cookie = 'js_acceptsCookies=yes'; // Try to set a cookie.
    if(document.cookie.indexOf('js_acceptsCookies=yes') != -1) {
	js_acceptsCookies = true; 
    }// If it succeeds, set variable
} else { // there was already a cookie
  js_acceptsCookies = true;
}


function js_setCookie (name, value, hours, path, domain, secure) {
    if (js_acceptsCookies) { // Don't waste your time if the browser doesn't accept cookies.
	var not_NN2 = (navigator && navigator.appName 
		       && (navigator.appName == 'Netscape') 
		       && navigator.appVersion 
		       && (parseInt(navigator.appVersion) == 2))?false:true;

	if(hours && not_NN2) { // NN2 cannot handle Dates, so skip this part
	    if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
		var numHours = hours;
	    } else if (typeof(hours) == 'number') { // calculate Date from number of hours
		var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	    }
	}
	document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
    }
} // js_setCookie


function js_readCookie(name) {
    if(document.cookie == '') { // there's no cookie, so go no further
	return false; 
    } else { // there is a cookie
	var firstChar, lastChar;
	var theBigCookie = document.cookie;
	firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
	var NN2Hack = firstChar + name.length;
	if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) { // if you found the cookie
	    firstChar += name.length + 1; // skip 'name' and '='
	    lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
	    if(lastChar == -1) lastChar = theBigCookie.length;
	    return unescape(theBigCookie.substring(firstChar, lastChar));
	} else { // If there was no cookie of that name, return false.
	    return false;
	}
    }	
} // js_readCookie

function js_killCookie(name, path, domain) {
  var theValue = js_readCookie(name); // We need the value to kill the cookie
  if(theValue) {
      document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
  }
} // js_killCookie
//-----------------------------------------------------------

function taLimit(e) {
 if (!e) e = window.event;
 var taObj = getObject(e);
 var stop = false;
// if (taObj.value.length >= taObj.maxLength * 1) stop = true;
 if (stop) {
  if (e.preventDefault) {
   e.stopPropagation();
   e.preventDefault();
  }
  else {
   e.returnValue = false;
   e.cancelBubble = true;
  }
 }
}
//-----------------------------------------------------------
function taCount(e, maxL) { 
 if (!e) e = window.event;
 var taObj = getObject(e);
 if (taObj.value.length > maxL) taObj.value = taObj.value.substring(0, maxL * 1);
 var vo = document.getElementById(taObj.id + "C");
 if (vo) {
  vo.innerHTML = "" + (taObj.value.length);
 }
}
function havalasztott(e, id) {
 if (!e) e = window.event;
 var stop = false;
 if (document.getElementById(id).selectedIndex < 1) {
  alert("Kérjük, előbb válassza ki az Ön státuszát!");
  stop = true;
 }
 if (stop) {
  if (e.preventDefault) {
   e.stopPropagation();
   e.preventDefault();
  }
  else {
   e.returnValue = false;
   e.cancelBubble = true;
  }
 }
}
/*function setPage(pageIndex)
{
 document.navig.side.value = pageIndex;
 document.navig.submit();
} */
function nxtpg(pageIndex)
{
 next(1, pageIndex);
}
function hirdeteslista_change(obj, on, id, imgdir, colors)
{
 var tol = "", col = colors[0];/"#ffffff"/
 if (on) {
  tol = "_mo";
  col = colors[1]; //"#fff8da";
 }

 var a = new Array("lt" + tol, "rt" + tol, "lb" + tol, "rb" + tol);
 var b = new Array(1, 3, 7, 9);
 var c = new Array(2, 4, 5, 6, 8);

 for(var i = 0; i < 4; i++) {
   document.getElementById(id + "_" + b[i]).style.backgroundImage = "url('" + imgdir + "/hirdetes_border_"+a[i]+".png')";
 }
 for(var i = 0; i < 5; i++) {
   document.getElementById(id + "_" + c[i]).style.backgroundColor = col;
 }

}
function selectAll(tomb)
{
 var j = 0;
 if (document.forms[0].name == "search") j=1;
 var x, y;
 if ( typeof document.forms[0].elements[tomb+"[]"] == "undefined") {
  x = document.getElementsByName(tomb+"[]").length;
  y = document.getElementsByName(tomb+"[]");
 }
 else {
  x=document.forms[j].elements[tomb+"[]"].length;
  y=document.forms[j].elements[tomb+"[]"];
 }
 for (i = 0; i < x; i++) {
  y[i].checked = true;
 }
}
function deselectAll(tomb)
{
 var j = 0;
 if (document.forms[0].name == "search") j=1;
 var x, y;
 if ( typeof document.forms[0].elements[tomb+"[]"] == "undefined") {
  x = document.getElementsByName(tomb+"[]").length;
  y = document.getElementsByName(tomb+"[]");
 }
 else {
  x=document.forms[j].elements[tomb+"[]"].length;
  y=document.forms[j].elements[tomb+"[]"];
 }
 for (i = 0; i < x; i++){
  y[i].checked = false;
 }
}
function invers(tomb)
{
 var j = 0;
 if (document.forms[0].name == "search") j=1;
 var x, y;
 if ( typeof document.forms[0].elements[tomb+"[]"] == "undefined") {
  x = document.getElementsByName(tomb+"[]").length;
  y = document.getElementsByName(tomb+"[]");
 }
 else {
  x=document.forms[j].elements[tomb+"[]"].length;
  y=document.forms[j].elements[tomb+"[]"];
 }
 for (i = 0; i < x; i++){
  y[i].checked = !y[i].checked;
 }
}
function countOfChecked(tomb)
{
 var db = 0;
 for (i = 0; i < document.forms[0].elements[tomb+"[]"].length; i++){
  if (document.forms[0].elements[tomb+"[]"][i].checked) db++;
 }
 return db;
}
function getChecked(tomb)
{
 var res = "";
 var elems = document.getElementsByName(tomb+"[]");
 var x = elems.length;
 for (i = 0; i < x; i++){
  if (elems[i].checked) {
   if (res.length > 0) res += ",";
   res += elems[i].value;
  }
 }
 return res;
}
function firstRun()
{
}

function bookmark_us(url, title) {
 if (window.sidebar) // firefox
  window.sidebar.addPanel(title, url, "");
 else if(window.opera && window.print){ // opera
  var elem = document.createElement('a');
  elem.setAttribute('href',url);
  elem.setAttribute('title',title);
  elem.setAttribute('rel','sidebar');
  elem.click();
 }
 else if(document.all)// ie
  window.external.AddFavorite(url, title);
}
function hasFoc(inp, col, lost)
{
 var text = 'Kulcsszó, gyorskeresés';
 if (!lost) {
  if (inp.value==text) {
   inp.value= "";
   inp.style.color=col;
  }
 }
 else {
  if (inp.value=="") {
   inp.value= text;
   inp.style.color=col;
  }
 }
}

function changeStyleOnA(o, e, st)
{
 var obj = o;//getObject(e);
 /*if (obj == null) obj = o;
 obj = getParentID(obj);*/
 if (obj == null) return;
 if (obj.tagName != "TR" && obj.tagName != "tr") return;
 if (obj.className.indexOf("_se") < 0 && obj.className.indexOf("_on") < 0) {
  obj.className = obj.className + "_on";
 }
}
//---------------------------------------------------
function changeStyleOffA(o, e)
{
 var obj = o;//getObject(e);
/* if (obj == null) obj = o;
 obj = getParentID(obj);*/
 if (obj == null) return;
 if (obj.tagName != "TR" && obj.tagName != "tr") return;
 if (obj.className.indexOf("_se") < 0) {
  obj.className = obj.className.substring(0, 6);
 }
}
var selectedRowA = null;
function changeStyleOnCl(o, e)
{
 var obj = o;//getObject(e);
 /*if (obj == null) obj = o;
 obj = getParentID(obj);*/
 if (obj == null || selectedRowA == obj) return;
 if (selectedRowA != null) {
  selectedRowA.className = selectedRowA.className.replace("_se", "");
 }
 if (obj.tagName != "TR" && obj.tagName != "tr") return;
 obj.className = obj.className.replace("_on", "");
 obj.className = obj.className.replace("_se", "");
 obj.className = obj.className + "_se";
 selectedRowA = obj;
}

function setSelectedRowA(rowid)
{
 selectedRowA = document.getElementById(rowid);
}


function setPage(pageIndex)
{
 if (document.data.side) document.data.side.value = pageIndex;
 if (document.data.nav_Side) document.data.nav_Side.value = pageIndex;
 document.data.submit();
}
function setPage2(pageIndex)
{
 document.data.side2.value = pageIndex;
 document.data.submit();
}
function order(ob, arrow)
{
 document.data.act.value = 2;
 document.data.OrderBy.value = ob;
 document.data.AscDesc.value = arrow;
 document.data.submit();
}

function isValid(val)
{
 if (trim(val).length == 0) return true;
 var e = parseInt(val.substring(0,4), 10);
 var h = parseInt(val.substring(5,7), 10);
 var n = parseInt(val.substring(8,10), 10);
 var d = new Date(e, h-1, n);
 return (e == d.getFullYear() && h == d.getMonth() + 1 && n == d.getDate());
}
function mywin(tid, w, h)
{
 if (typeof w == "undefined") w = 630;
 if (typeof h == "undefined") h = 600;
 var url = "index.php?skeleton=dbtext&tID="+tid;
 window.open(url, '', 'width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no, resizable=no');
}
function galEditWindow(w, h, fej, maxkepszam, minkepszam, kepmod)
{
 if (typeof w == "undefined") w = 630;
 if (typeof h == "undefined") h = 600;
 var url = "index.php?fromarticle=1&skeleton=of_cikk_galedit&picmode="+kepmod+"&minpiccount="+minkepszam+"&maxpiccount="+maxkepszam+"&fej="+fej;
 window.open(url, '', 'width='+w+',height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no, resizable=no');
}
function UnderDevelopment()
{
 alert("Jelenleg karbantartás zajlik, kérjük, térjen vissza később! Köszönjük a Bizalmát!");
}
function urlencode(x)
{
 x = x.replace(/=/g, "_equal_");
 x = x.replace(/\?/g, "_quest_");
 x = x.replace(/&/g, "_and_");
 return x;
}
