
// FIGYELEM! Krressel ra a "hu" szora, mert van egy ket hardcoded link is benne!

/****************/
/* Kommentekhez */
/****************/
var clickedB    = 0;
var clickedI    = 0;
var clickedURL  = 0;
var komment_t   = window.location.href.split("#");
var komment_url = komment_t[0];
var focusTextarea = false; // valaszerre (reply) -nel hasznaljuk smoothscrolling-hoz

var KOMMENTJS = {

	clickB: function() {

		if (clickedB) {
			clickedB = 0;
			document.komment.comment_text.value += "[/b]";
			document.komment.b.value = "F";
			document.komment.comment_text.focus();
		} else {
			clickedB = 1;
			document.komment.comment_text.value += "[b]";
			document.komment.b.value = "F*";
			document.komment.comment_text.focus();
		}
	},

	clickI: function() {
		if (clickedI) {
			clickedI = 0;
			document.komment.comment_text.value += "[/i]";
			document.komment.i.value = "D";
			document.komment.comment_text.focus();
		} else {
			clickedI = 1;
			document.komment.comment_text.value += "[i]";
			document.komment.i.value = "D*";
			document.komment.comment_text.focus();
		}
	},

	clickURL: function() {
		var link = prompt("Add meg a linket:", "http://");
		if (link!=null && link!="" && link!="http://") {
			var linkname = prompt("Írd ide a szót amit linkelni akarsz:", "");
			if (linkname!=null && linkname!="") {
				document.komment.comment_text.value += "[url="+link+"]"+linkname+"[/url]";
			} else {
				alert("Hibás név!");
			}
		} else {
			alert("Hibás link!");
		}

		//clickedURL
	},

	closeAll: function() {
		if (clickedURL) { // direkt van elobb az url
			clickedURL = 0;
			document.komment.comment_text.value += "[/url]";
			document.komment.url.value = "Link";
			document.komment.comment_text.focus();
		}
		if (clickedB) {
			clickedB = 0;
			document.komment.comment_text.value += "[/b]";
			document.komment.b.value = "F";
			document.komment.comment_text.focus();
		}
		if (clickedI) {
			clickedI = 0;
			document.komment.comment_text.value += "[/i]";
			document.komment.i.value = "D";
			document.komment.comment_text.focus();
		}
	},

	submitKomment: function() {
		this.closeAll();
		document.komment.submit();
	},


	ins: function(smiley) {
		document.komment.comment_text.value += smiley;
	},

	gotoKomment: function(kid,url) {
		i=0;
		megvan=0;

		while (i<uzenetek.length && megvan==0) {
			if (uzenetek[i] == kid) megvan = 1;
			else i++;
		}

		if (megvan == 1) {
			window.location.href = komment_url+"#"+kid;
		} else {
			//location.replace("/kommentek.php?cmd=goto&sid="+goto_sid+"&kid="+kid);
			location.replace("/"+url+"?cmd=goto&kid="+kid);
		}
	},

	reply: function(i,j) {
		document.komment.reply.value = i;
		document.komment.reply_id.value = j;
		//windows.location.replace(komment_url+"#"+i);
		//document.komment.comment_text.focus(); // smoothscrolling-al megoldjuk e helyett
		focusTextarea = true;
	},

	smiley: function() {
		smwin = window.open(komment_url+'?cmd=smileywin','smwin','resizable=no, scrollbars=yes, menubar=no');
	},

	ins: function(smiley) {
		document.komment.comment_text.value += smiley;
	}
}


/* Smooth scrolling
   Changes links that link to other parts of this page to scroll
   smoothly to those links rather than jump to them directly, which
   can be a little disorienting.

   sil, http://www.kryogenix.org/

   v1.0 2003-11-11
   v1.1 2005-06-16 wrap it up in an object
*/

var ss = {
  fixAllLinks: function() {
    // Get a list of all links in the page
    var allLinks = document.getElementsByTagName('a');
    // Walk through the list
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if ((lnk.href && lnk.href.indexOf('#') != -1) && 
          ( (lnk.pathname == location.pathname) ||
	    ('/'+lnk.pathname == location.pathname) ) && 
          (lnk.search == location.search)) {
        // If the link is internal to the page (begins in #)
        // then attach the smoothScroll function as an onclick
        // event handler
        ss.addEvent(lnk,'click',ss.smoothScroll);
      }
    }
  },

  smoothScroll: function(e) {
    // This is an event handler; get the clicked on element,
    // in a cross-browser fashion
    if (window.event) {
      target = window.event.srcElement;
    } else if (e) {
      target = e.target;
    } else return;

    // Make sure that the target is an element, not a text node
    // within an element
    if (target.nodeType == 3) {
      target = target.parentNode;
    }

    // If the clicked element is an IMG then we use it's parent element which is A probably :)
    //  by O.G
    if (target.nodeName.toLowerCase() == 'img') {
      target = target.parentNode;
    }

    // Paranoia; check this is an A tag
    if (target.nodeName.toLowerCase() != 'a') return;

    // Find the <a name> tag corresponding to this href
    // First strip off the hash (first character)
    anchor = target.hash.substr(1);
    // Now loop all A tags until we find one with that name
    var allLinks = document.getElementsByTagName('a');
    var allDivs = document.getElementsByTagName('div');
    var all = [allLinks, allDivs];
    var destinationLink = null;
    for (var j=0; j<all.length; j++) {
      for (var i=0;i<all[j].length;i++) {
        var lnk = all[j][i];
        if (lnk.name && (lnk.name == anchor)) {
          destinationLink = lnk;
          break;
        } else if (lnk.id && (lnk.id == anchor)){
	  destinationLink = lnk;
          break;
	}
      }
    }
    /*
    var allLinks = document.getElementsByTagName('a');
    var destinationLink = null;
    for (var i=0;i<allLinks.length;i++) {
      var lnk = allLinks[i];
      if (lnk.name && (lnk.name == anchor)) {
        destinationLink = lnk;
        break;
      }
    }
    */

    // If we didn't find a destination, give up and let the browser do
    // its thing
    if (!destinationLink) return true;

    // Find the destination's position
    var destx = destinationLink.offsetLeft; 
    var desty = destinationLink.offsetTop;
    var thisNode = destinationLink;
    while (thisNode.offsetParent && 
          (thisNode.offsetParent != document.body)) {
      thisNode = thisNode.offsetParent;
      destx += thisNode.offsetLeft;
      desty += thisNode.offsetTop;
    }

    // Stop any current scrolling
    clearInterval(ss.INTERVAL);

    cypos = ss.getCurrentYPos();

    ss_stepsize = parseInt((desty-cypos)/ss.STEPS);
    ss.INTERVAL = setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10);

    // And stop the actual click happening
    if (window.event) {
      window.event.cancelBubble = true;
      window.event.returnValue = false;
    }
    if (e && e.preventDefault && e.stopPropagation) {
      e.preventDefault();
      e.stopPropagation();
    }
  },

  scrollWindow: function(scramount,dest,anchor) {
    wascypos = ss.getCurrentYPos();
    isAbove = (wascypos < dest);
    window.scrollTo(0,wascypos + scramount);
    iscypos = ss.getCurrentYPos();
    isAboveNow = (iscypos < dest);
    if ((isAbove != isAboveNow) || (wascypos == iscypos)) {
      // if we've just scrolled past the destination, or
      // we haven't moved from the last scroll (i.e., we're at the
      // bottom of the page) then scroll exactly to the link
      window.scrollTo(0,dest);
      // cancel the repeating timer
      clearInterval(ss.INTERVAL);
      // and jump to the link directly so the URL's right
      location.hash = anchor;

	// komment textarea focus by O.G
	try {
		if (focusTextarea == true) {
			document.komment.comment_text.focus();
			focusTextarea = false;
		}
	} catch(err) {}

    }
  },

  getCurrentYPos: function() {
    if (document.body && document.body.scrollTop)
      return document.body.scrollTop;
    if (document.documentElement && document.documentElement.scrollTop)
      return document.documentElement.scrollTop;
    if (window.pageYOffset)
      return window.pageYOffset;
    return 0;
  },

  addEvent: function(elm, evType, fn, useCapture) {
    // addEvent and removeEvent
    // cross-browser event handling for IE5+,  NS6 and Mozilla
    // By Scott Andrew
    if (elm.addEventListener){
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } else if (elm.attachEvent){
      var r = elm.attachEvent("on"+evType, fn);
      return r;
    } else {
      alert("Handler could not be removed");
    }
  } 
}

ss.STEPS = 25;

ss.addEvent(window,"load",ss.fixAllLinks);


// Scrolls the window to the element identified by the given parameter: "id"
// Actually it's a simple "jump to" thing, no fancy scroll effect :)
// Vertical jump only!
function jumpToElement(id) {

	// Get element
	try {
		e = document.getElementById(id);
	} catch(err) {
		return false;
	}

	// Find the element's position
	var destx = e.offsetLeft; 
	var desty = e.offsetTop;
	var thisNode = e;
	while (thisNode.offsetParent && (thisNode.offsetParent != document.body)) {
		thisNode = thisNode.offsetParent;
		destx += thisNode.offsetLeft;
		desty += thisNode.offsetTop;
	}

	window.scrollTo(0,desty);

	return false;
}


// Cookie Handling (handler)
var CookieHandler = {

	SetCookie : function(name, value) {
		var argv = this.SetCookie.arguments;  
		var argc = this.SetCookie.arguments.length;  
		var expires = (argc > 2) ? argv[2] : null;  
		var path = "/";
		var domain = (argc > 4) ? argv[4] : null;  
		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" : "");
	},

	getCookieVal : function(offset) {  
		var endstr = document.cookie.indexOf (";", offset);  
		if (endstr == -1) endstr = document.cookie.length;  
		return unescape(document.cookie.substring(offset, endstr));
	},

	GetCookie : function(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 this.getCookieVal (j);
			i = document.cookie.indexOf(" ", i) + 1;    
			if (i == 0) break;   
		}
		return null;
	}
}
// Not necessary, but useful
CookieHandler.expDays = 365;
CookieHandler.exp = new Date();
CookieHandler.exp.setTime(CookieHandler.exp.getTime() + (CookieHandler.expDays*24*60*60*1000));


// Sliding ToolTip by O.G (og@og.hu) - 2007.10.14
//   Able to go over flash movies even if no wmode="transparent" is defined, thanks to
//   the iframe trick (doesn't work on Opera)
//
// Tested on: IE6,IE7,FF2,Opera8.54,Opera9
//
// Usage:
//	STT.addEvent(window,"load",function() { STT.initialize('.ize2'); });
//	or
//	STT.initialize('.ize2');
//	Parameter: css class name(s)
//
//  HTML:
//   <div id="stt" style="position: absolute; left: 0px; top: 0px; display: none; z-index: 20; overflow: hidden; margin: 0px; padding: 0px; border: 1px solid #000;"></div>
//   <iframe id="stt_iframe" style="position: absolute; left: 0px; top: 0px; display: none; z-index:19;" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>
//
//   <span class="ize2" title="Example text :: 250 :: 50">move your mouse onto this text</span>
//
//   Parameters in "title" attribute: text[ :: width][ :: height]
//     width and height are optional (if not defined, default values will be used)
//     parameter separator: " :: " (without quotes, with surrounding spaces)
//
var STT = {
	initialize: function(classdef) {
		// Tooltip settings (public)
		STT.STEPS      = 2;   // px (slide, moving)
		STT.DELAY      = 10;  // ms (slide, moving)
		STT.OMO_DELAY  = 150; // ms (onmouseover delay. prevents accidental onmousover events)
		STT.CORRECTION = 20;  // px (for a smoother show/hide)
		STT.DEF_WIDTH  = 400; // px
		STT.DEF_HEIGHT = 15;  // px
		STT.POSITION   = "topcenter"; // topleft, topcenter, bottomleft, bottomcenter

		// IFRAME size correction (public)
		// If you give additional style information to the "stt" element then please manually correct these variables
		STT.IFRAME_WIDTH_CORRECTION  = 20; // px ("stt" element's: padding-left/right + margin-left/right + border-left/right)
		STT.IFRAME_HEIGHT_CORRECTION = 14; // px ("stt" element's: padding-top/bottom + margin-top/bottom + border-top/bottom)

		var elems = $$(classdef); // mootools specific!

		// private
		STT.running = false;
		STT.opened  = false;
		STT.showTimerID  = null;
		STT.hideTimerID  = null;
		STT.slideTimerID = null;
		STT.privfunc     = new Array();
		STT.current_height = 0;
		STT.tt_width  = 0;
		STT.tt_height = 0;

		// Opera detection (is it an older or newer version?) Old: 7 & 8, New: 9 or above
		STT.old_opera = false;
		var agt = navigator.userAgent.toLowerCase();
		if (
			agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1 ||
			agt.indexOf("opera 8") != -1 || agt.indexOf("opera/8") != -1
		   )
		{
			STT.old_opera = true;
		}

		// Element check
		if (document.getElementById("stt")) {
		} else { alert("Tooltip element error: 'stt' not found"); return; }

		if (document.getElementById("stt_iframe")) {
		} else { alert("Tooltip element error: 'stt_iframe' not found"); return; }

		var t, html, w, h;
		for (var i=0; i < elems.length; i++) {
			try {
				if (elems[i].title != undefined) {
					t = elems[i].title.split(" :: ");
					html = t[0];
					elems[i].title = ""; // remove title
					w    = ((t[1] != undefined) && t[1] == parseInt(t[1])) ? t[1] : STT.DEF_WIDTH;
					h    = ((t[2] != undefined) && t[2] == parseInt(t[2])) ? t[2] : STT.DEF_HEIGHT;
				} else {
					html = "Tooltip not defined!";
					w    = STT.DEF_WIDTH;
					h    = STT.DEF_HEIGHT;
				}

				eval("STT.privfunc["+(i*2)+"]   = function() { TTstarter"+i+" = setTimeout(\"STT.showTooltip('"+html+"',"+w+","+h+")\", "+STT.OMO_DELAY+"); }");
				eval("STT.privfunc["+(i*2+1)+"] = function() { clearTimeout(TTstarter"+i+"); STT.hideTooltip("+w+","+h+"); }");

				STT.addEvent(elems[i],'mouseover', STT.privfunc[(i*2)] );
				STT.addEvent(elems[i],'mouseout', STT.privfunc[(i*2+1)] );

			} catch(err) {
				alert("Tooltip error: "+err);
			}
		}

	},

	addEvent: function(elm, evType, fn, useCapture) {
		// addEvent and removeEvent
		// cross-browser event handling for IE5+,  NS6 and Mozilla
		// By Scott Andrew
		if (elm.addEventListener){
			elm.addEventListener(evType, fn, useCapture);
			return true;
		} else if (elm.attachEvent){
			var r = elm.attachEvent("on"+evType, fn);
			return r;
		} else {
			alert("Handler could not be removed");
		}
	},

	showTooltip : function(html,width,height) {
		if (STT.running || STT.opened) {
			// Ha fut valami vagy ha nyitva van a tooltip, akkor nem inditjuk el a kinyitasi muveletet
			// Helyette eltaroljuk (buffereljuk), hogy ha vege az aktualis muveletnek, akkor ezt nyissa meg
			STT.showTimerID = setTimeout("STT.showTooltip('"+html+"',"+width+","+height+")", 20);
		} else {
			// Nem fut semmi, nincs még nyitva a Tooltip

			STT.running = true; // gyorsan elkezdunk futni
			STT.opened  = true; // gyorsan jelezzuk, hogy a cuccot kinyitottuk (vagyis pontosabban belekezdtunk a kinyitas folyamatba)

			STT.tt_width  = width;  // eltaroljuk az aktualis tooltip mereteit
			STT.tt_height = height; // eltaroljuk az aktualis tooltip mereteit

			// Elkeszitjuk az uj Tooltip-et
			document.getElementById("stt").innerHTML = html;

			// Beallitjuk a meretet a ToolTip-nek
			document.getElementById("stt").style.width  = width+"px";
			document.getElementById("stt").style.height = height+"px";

			document.getElementById("stt_iframe").style.width  = width+STT.IFRAME_WIDTH_CORRECTION+"px";
			document.getElementById("stt_iframe").style.height = height+STT.IFRAME_HEIGHT_CORRECTION+"px";

			// Korrekcios tenyezo
			var pos = 0;
			if (STT.POSITION == "topleft" || STT.POSITION == "topcenter") {
				height = height + STT.CORRECTION;
			} else {
				pos = pos - STT.CORRECTION;
			}

			// Elhelyezzuk a lathato teruleten kivulre
			document.getElementById("stt").style.left = "-1000px";
			document.getElementById("stt").style.top  = "-1000px";

			document.getElementById("stt_iframe").style.left = "-1000px";
			document.getElementById("stt_iframe").style.top  = "-1000px";

			// Megmutatjuk
			document.getElementById("stt").style.display = "block";
			if (!STT.old_opera) {
				// If we have a newer opera or any other browser
				document.getElementById("stt_iframe").style.display = "block";
			}

			// Elinditjuk a lenyitast
			STT.slideOut(width,height,pos);
		}
	},

	hideTooltip : function(width,height) {

		var suddenhide = false;

		if (STT.running && STT.opened) {
			// Ha eppen fut egy kinyitas, akkor azt gyorsan megszakitjuk es hirtelen elinditjuk az eltuntetest.
			clearTimeout(STT.slideTimerID);
			STT.running = false;
			suddenhide = true;
		}

		if (STT.running || !STT.opened) {
			// Ha fut valami vagy ha nincs nyitva a tooltip, akkor nem kezdjuk el a bezaro muveletet
			// Viszont a bufferelt "kinyitasi" muveletet eltavolitjuk
			clearTimeout(STT.showTimerID);
		} else {
			// Nem fut semmi, nincs meg nyitva a Tooltip

			STT.running = true; // gyorsan elkezdunk futni
			STT.opened  = false; // gyorsan jelezzuk, hogy a cuccot bezartuk (vagyis pontosabban belekezdtunk a bezaras folyamataba)

			// Korrekcios tenyezo
			var pos = 0;
			if (STT.POSITION == "topleft" || STT.POSITION == "topcenter") {
				height = height + STT.CORRECTION;
			} else {
				// Nincs szukseg a korrigalasra
				pos = height;
			}

			if (suddenhide) {
				// Ezzel elkeruljuk a "rángás"-t. (vagyis ha felig van csak meg nyitva es mi pont be akarjuk zarni)
				pos = STT.current_height;
			}

			// Elinditjuk a bezarast
			STT.slideIn(width,height,pos);
		}
	},

	// Kimozgatas (show)
	slideOut : function(width,height,pos) {
		// Lathato terulet meretei: x,y
		var x, y;
		if (self.innerHeight) {
			// all except Explorer
			x = self.innerWidth;
			y = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			// Explorer 6 Strict Mode
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		} else if (document.body) {
			// other Explorers
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}

		// Lathato teruleten beluli scrollozas x,y koordinatai (balfelso sarokbol): sx,sy
		var sx, sy;
		if (self.pageYOffset) {
			// all except Explorer
			sx = self.pageXOffset;
			sy = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			// Explorer 6 Strict
			sx = document.documentElement.scrollLeft;
			sy = document.documentElement.scrollTop;
		} else if (document.body) {
			// all other Explorers
			sx = document.body.scrollLeft;
			sy = document.body.scrollTop;
		}

		/***
		// A weboldal teljes merete
		var pagex,pagey;
		var test1 = document.body.scrollHeight;
		var test2 = document.body.offsetHeight
		if (test1 > test2) {
			// all but Explorer Mac
			pagex = document.body.scrollWidth;
			pagey = document.body.scrollHeight;
		} else {
			// Explorer Mac;
			//would also work in Explorer 6 Strict, Mozilla and Safari
			pagex = document.body.offsetWidth;
			pagey = document.body.offsetHeight;
		}
		***/

		var brs=navigator.userAgent.toLowerCase();
		if (brs.search(/firefox[\/\s](\d+([\.-]\d)*)/) != -1) {
			sx = sx - 16; // 16px a scrollbar FF alatt
		}

		var left, top;
		if (STT.POSITION == "topleft" || STT.POSITION == "topcenter") {
			if (STT.POSITION == "topleft") {
				left = 0;
			} else {
				left = sx+Math.round(x/2 - parseInt(width)/2 ); // document.getElementById("stt").style.width
			}
			top  = sy; //+Math.round(y/2);

			height = height-STT.STEPS;
			if (height < 0) height = 0;

			STT.current_height = height; // ha eppen kinyilas van es hirtelen be kell zarni a Tooltip-et, akkor a "rángás"-t ezzel kikuszoboljuk. (a rangas annyit tesz, hogy egy pillanatra "jobban megnyilik" a tooltip, mindezt azert, mert a "teljes" merettol kezdené el becsukni, de mivel a lenyilas kozben vagyunk, ezert nincs teljesen lenyitva meg a tooltip. Igy egy pillanatra kinyilik teljes mereture (ráng egyet), majd elkezd szepen becsukodni.

			top = top-height;
		
		} else if (STT.POSITION == "bottomleft" || STT.POSITION == "bottomcenter") {

			if (STT.POSITION == "bottomleft") {
				left = 0;
			} else {
				left = sx+Math.round(x/2 - parseInt(width)/2 ); // document.getElementById("stt").style.width
			}
			top  = y+sy;

			pos = pos+STT.STEPS;
			if (pos > height) pos = height;

			top = top-pos;

			STT.current_height = pos; // ha eppen kinyilas van es hirtelen be kell zarni a Tooltip-et, akkor a "rángás"-t ezzel kikuszoboljuk. (a rangas annyit tesz, hogy egy pillanatra "jobban megnyilik" a tooltip, mindezt azert, mert a "teljes" merettol kezdené el becsukni, de mivel a lenyilas kozben vagyunk, ezert nincs teljesen lenyitva meg a tooltip. Igy egy pillanatra kinyilik teljes mereture (ráng egyet), majd elkezd szepen becsukodni.

			document.getElementById("stt").style.height = (pos < 0) ? "0px" : pos+"px";

			document.getElementById("stt_iframe").style.height = (pos < 0) ? "0px" : pos+"px";

		} else {
			alert("Tooltip error: no position defined!");
			height = 0;
		}

		document.getElementById("stt").style.left = left+"px";
		document.getElementById("stt").style.top  = top+"px";

		document.getElementById("stt_iframe").style.left = left+"px";
		document.getElementById("stt_iframe").style.top  = top+"px";

		if (height == 0 || pos == height) {
			// befejeztuk a futast
			STT.running = false;
		} else {
			STT.slideTimerID = setTimeout("STT.slideOut("+width+","+height+","+pos+")", STT.DELAY);
		}
	},

	// Bemozgatas (hide)
	slideIn : function(width, height, pos) {

		// Lathato terulet meretei: x,y
		var x, y;
		if (self.innerHeight) {
			// all except Explorer
			x = self.innerWidth;
			y = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) {
			// Explorer 6 Strict Mode
			x = document.documentElement.clientWidth;
			y = document.documentElement.clientHeight;
		} else if (document.body) {
			// other Explorers
			x = document.body.clientWidth;
			y = document.body.clientHeight;
		}

		// Lathato teruleten beluli scrollozas x,y koordinatai (balfelso sarokbol): sx,sy
		var sx, sy;
		if (self.pageYOffset) {
			// all except Explorer
			sx = self.pageXOffset;
			sy = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			// Explorer 6 Strict
			sx = document.documentElement.scrollLeft;
			sy = document.documentElement.scrollTop;
		} else if (document.body) {
			// all other Explorers
			sx = document.body.scrollLeft;
			sy = document.body.scrollTop;
		}

		var brs=navigator.userAgent.toLowerCase();
		if (brs.search(/firefox[\/\s](\d+([\.-]\d)*)/) != -1) {
			sx = sx - 16; // 16px a scrollbar FF alatt
		}

		var left, top;
		if (STT.POSITION == "topleft" || STT.POSITION == "topcenter") {
			if (STT.POSITION == "topleft") {
				left = 0;
			} else {
				left = sx+Math.round(x/2 - parseInt(width)/2 ); // document.getElementById("stt").style.width
			}
			top  = sy; //+Math.round(y/2);

			pos = pos+STT.STEPS;
			if (pos > height) pos = height;

			top = top-pos;

		} else if (STT.POSITION == "bottomleft" || STT.POSITION == "bottomcenter") {
			if (STT.POSITION == "bottomleft") {
				left = 0;
			} else {
				left = sx+Math.round(x/2 - parseInt(width)/2 ); // document.getElementById("stt").style.width
			}
			top  = y+sy; //+Math.round(y/2);

			pos = pos-STT.STEPS;
			if (pos < 0) pos = 0;

			top = top-pos;

			document.getElementById("stt").style.height = (pos < 0) ? "0px" : pos+"px";

			document.getElementById("stt_iframe").style.height = (pos < 0) ? "0px" : pos+"px";

		} else {
			alert("Tooltip error: no position defined!");
			pos = height;
		}

		document.getElementById("stt").style.left = left+"px";
		document.getElementById("stt").style.top  = top+"px";

		document.getElementById("stt_iframe").style.left = left+"px";
		document.getElementById("stt_iframe").style.top  = top+"px";

		if (pos == height || pos == 0) {
			// befejeztuk a futast
			document.getElementById("stt").style.display = "none";
			document.getElementById("stt_iframe").style.display = "none";
			// itt esetleg lathato teruleten kivulre is helyezhetnenk...
			STT.running = false;
		} else {
			STT.slideTimerID = setTimeout("STT.slideIn("+width+","+height+","+pos+")", STT.DELAY);
		}
	}
}
//footer: STT.addEvent(window,"load",function() { STT.initialize('.ize2'); });

/// *** GOURL ***
var CanGo = true; // vedelem, ha van egy megelozo onclick
function gourl(url) {
	if (CanGo) {
		var mainsite = "";
		document.location.href = mainsite + url;
		return true;
	}
	CanGo = true;
}


function more(id) {
	CanGo = false;
	document.getElementById("game"+id+"_remain").style.display = "inline";
	document.getElementById("game"+id+"_more").style.display = "none";
	document.getElementById("game"+id+"_less").style.display = "inline";
	return false;
}

function less(id) {
	CanGo = false;
	document.getElementById("game"+id+"_remain").style.display = "none";
	document.getElementById("game"+id+"_more").style.display = "inline";
	document.getElementById("game"+id+"_less").style.display = "none";
	return false;
}

/////////////// AJAX ////////////////////

	// http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4
	// http://www.w3schools.com/jsref/jsref_escape.asp
	// http://www.w3schools.com/jsref/jsref_encodeURI.asp

	function tippekAjax() {
		this.init();
	}

	tippekAjax.prototype = {
		init : function() {
			this.userloggedin     = 0; // 0-false
			this.authInProgress   = false;
			this.pagingInProgress = false;
			this.savedragInProgress = false;
			this.saveboxcontentInProgress = false;
			this.labelInProgress  = false;
			this.feedbackInProgress = false;
			this.contactInProgress = false;
			this.tovabbkuldesInProgress = false;
			this.favoritesInProgress = false;
			this.rateInProgress = false;
		},

		// "Loading..." functions
		showLoading : function() {
			// Lathato terulet meretei: x,y
			var x, y;
			if (self.innerHeight) {
				// all except Explorer
				x = self.innerWidth;
				y = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) {
				// Explorer 6 Strict Mode
				x = document.documentElement.clientWidth;
				y = document.documentElement.clientHeight;
			} else if (document.body) {
				// other Explorers
				x = document.body.clientWidth;
				y = document.body.clientHeight;
			}

			// Lathato teruleten beluli scrollozas x,y koordinatai (balfelso sarokbol): sx,sy
			var sx, sy;
			if (self.pageYOffset) {
				// all except Explorer
				sx = self.pageXOffset;
				sy = self.pageYOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {
				// Explorer 6 Strict
				sx = document.documentElement.scrollLeft;
				sy = document.documentElement.scrollTop;
			} else if (document.body) {
				// all other Explorers
				sx = document.body.scrollLeft;
				sy = document.body.scrollTop;
			}

			// A weboldal teljes merete
			var pagex,pagey;
			var test1 = document.body.scrollHeight;
			var test2 = document.body.offsetHeight
			if (test1 > test2) {
				// all but Explorer Mac
				pagex = document.body.scrollWidth;
				pagey = document.body.scrollHeight;
			} else {
				// Explorer Mac;
				//would also work in Explorer 6 Strict, Mozilla and Safari
				pagex = document.body.offsetWidth;
				pagey = document.body.offsetHeight;
			}

			var brs=navigator.userAgent.toLowerCase();
			if (brs.search(/firefox[\/\s](\d+([\.-]\d)*)/) != -1) {
				sx = sx - 16; // 16px a scrollbar FF alatt
			}

			//document.getElementById("loading").innerHTML = "Töltés..."; // ez elobb legyen mint a pozicionalas ha nem adsz meg direktbe meretet a div-nek!
			document.getElementById("loading").innerHTML = "<img src='/skin/hu/gfx/loading.gif' alt='' />"; // ez elobb legyen mint a pozicionalas ha nem adsz meg direktbe meretet a div-nek!
			  //Eredeti kod: (jobb felso sarok)
			  //document.getElementById("loading").style.left = sx+x-parseInt(document.getElementById("loading").style.width)+"px";
			   //document.getElementById("loading").style.left = sx+pagex-parseInt(document.getElementById("loading").style.width)+"px";

			// Center

			document.getElementById("loading").style.left = sx+Math.round(x/2 - parseInt(document.getElementById("loading").style.width)/2 )+"px";
			document.getElementById("loading").style.top  = sy+Math.round(y/2)+"px";
			document.getElementById("loading").style.display = "block";
		},

		hideLoading : function() {
			document.getElementById("loading").style.display = "none";
		},

		// Login
		auth : function() {

			// Sarissa + Mootools (replaceable with document.getElementById())

			var xmlhttp = new XMLHttpRequest();
			var timer = null;
			var timerLoading = null;

			if (this.authInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {

				this.authInProgress = true;

				if (this.userloggedin == 1) {

					// Logout

					xmlhttp.open('POST', '/ajax/logout', true); // lehetne GET-elni is de a POST biztosabb :)

					xmlhttp.onreadystatechange = function() {
						if (xmlhttp.readyState == 4) { // loaded (complete)
							if (xmlhttp.status == 200) {
								// 200 OK

								// We are in a deeper level now, so we must use "TA" instead of "this" where its needed.
								clearTimeout(timer);
								clearTimeout(timerLoading);
								TAJAX.hideLoading();

								var u = "";
								TAJAX.userloggedin = xmlhttp.responseXML.getElementsByTagName('loggedin')[0].firstChild.data;
								if (xmlhttp.responseXML.getElementsByTagName('username')[0].firstChild) {
									// Ha 'nincs/ures' a visszadott adat, akkor ez hajlamos szetfagyni, de igy a fentebbivel if-el mar nem
									u = xmlhttp.responseXML.getElementsByTagName('username')[0].firstChild.data;
								}

								if (TAJAX.userloggedin == 1) {
									// Meg mindig be vagyun lepve, valami gond volt...
									alert("A kijelentkezés nem sikerült!");

								} else {
									// Sikerult a kilepes
									window.location.href = "/"; // sikeresen kilepett, irany a fooldal
								}

								TAJAX.authInProgress = false;
							}
						}
					}

					xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
					xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					xmlhttp.send(""); // Opera suxx when it is "null"! Always add a param or an empty string

					timer = setTimeout(function(){
						xmlhttp.abort();
						clearTimeout(timerLoading);
						this.hideLoading();
						this.authInProgress = false;
						alert("A kilépés nem sikerült! Próbáld újra!");
					}, 10000);

					timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.

				} else {

					// Login

					//$("loginbutton").value = 'Várj...';
					$("loginbutton").disabled = true;

					xmlhttp.open('POST', '/ajax/login', true);

					xmlhttp.onreadystatechange = function() {
						if (xmlhttp.readyState == 4) { // loaded (complete)
							if (xmlhttp.status == 200) {
								// 200 OK

								// We are in a deeper level now, so we must use "TA" instead of "this" where its needed.
								clearTimeout(timer);
								clearTimeout(timerLoading);
								TAJAX.hideLoading();

								var u  = "";
								var bu = "";
								TAJAX.userloggedin = xmlhttp.responseXML.getElementsByTagName('loggedin')[0].firstChild.data;
								if (xmlhttp.responseXML.getElementsByTagName('username')[0].firstChild) {
									// Ha 'nincs/ures' a visszadott adat, akkor ez hajlamos szetfagyni, de igy a fentebbivel if-el mar nem
									u = xmlhttp.responseXML.getElementsByTagName('username')[0].firstChild.data;
								}

								if (TAJAX.userloggedin == 1) {
									if (xmlhttp.responseXML.getElementsByTagName('backurl')[0].firstChild) {
										bu = xmlhttp.responseXML.getElementsByTagName('backurl')[0].firstChild.data;
										window.location.href = bu; // sikeresen belepett, irany back_url
									} else {
										window.location.href = "/"; // sikeresen belepett, irany a fooldal
									}
								} else {
									// nyomunk egy effektet
									//var msgFx = new Fx.Style('msg', 'opacity').set(0); // opacity-t leveszi azonnal 0-ara

									//$("msg").style.display = '';
									//$("msg").innerHTML = '<strong>Hibás felhasználónév vagy jelszó!</strong>';
									//$("usr").value = '';
									$("usr").disabled = false;
									$("usr").focus();
									$("pwd").value = '';
									$("pwd").disabled = false;
									//$("loginbutton").value = "Belépés";
									$("loginbutton").disabled = false;

									//msgFx.custom(0,1); // from-to
									STT.showTooltip("Hibás felhasználónév vagy jelszó!",400,15);
									setTimeout("STT.hideTooltip(400,15)", 5000);

								}

								TAJAX.authInProgress = false;
							}
						}
					}

					xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
					xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					var chb = ($("remember").checked) ? "&remember=on" : "";
					xmlhttp.send('usr=' + $("usr").value + '&pwd=' + $("pwd").value + chb); // Opera suxx when it is "null"! Always add a param or an empty string

					timer = setTimeout(function(){
						xmlhttp.abort();
						clearTimeout(timerLoading);
						this.hideLoading();
						this.authInProgress = false;
						alert("A belépés nem sikerült! Próbáld újra!");
					}, 10000);

					timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
				}
			}

			return false;
		},

		// Feedback
		feedback : function(url) {

			//$('msg').setStyle('display', 'none');

			if (this.feedbackInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {
				this.feedbackInProgress = true;

				var xmlhttp = new XMLHttpRequest();
				var timer = null;
				var timerLoading = null;

				var baseurl = "";
				if (window.location.href.indexOf("#") != -1 && url.substr(0,1) == "?") {
					// Internet Explorer 6 has a bug, so we need to remove everything after # (fragment)
					// This bug causes/effects in the special case when we use ajax and a url starting with "?" down here.
					// Solution: Dont use url starting with "?" :) or use this small javascript code.
					var t = window.location.href.split("#");
					baseurl = t[0];
				}

				xmlhttp.open('POST', baseurl+url, true); // use encodeURI() for parameter

				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4) { // loaded (complete)
						if (xmlhttp.status == 200) {
							// 200 OK
							clearTimeout(timer);
							clearTimeout(timerLoading);
							TAJAX.hideLoading();

							try {
								if (xmlhttp.responseXML.getElementsByTagName('htmlcode').length) { // Elvileg ez a .length csak Opera 9-tol supported
									if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "1") {
										alert("Köszönjük segítséged!");
										document.fr_feedback.idea.value = "";
									} else {
										alert("Nem írtál be szöveget!");
									}
								}
							} catch(err) {
								alert("Error: HTML code");
							}

							TAJAX.feedbackInProgress = false;
						}
					}
				}

				xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xmlhttp.send("idea="+encodeURI(document.fr_feedback.idea.value)); // Opera suxx when it is "null"! Always add a param or an empty string

				timer = setTimeout(function(){
					xmlhttp.abort();
					clearTimeout(timerLoading);
					this.hideLoading();
					this.feedbackInProgress = false;
					alert("A feedback elküldése nem sikerült! Próbáld újra!");
				}, 10000);

				timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
			}

			return false;
		},

		// Contact - kapcsolatfelvetel
		contact : function(url) {

			//$('msg').setStyle('display', 'none');

			if (this.contactInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {
				this.contactInProgress = true;

				var xmlhttp = new XMLHttpRequest();
				var timer = null;
				var timerLoading = null;

				var baseurl = "";
				if (window.location.href.indexOf("#") != -1 && url.substr(0,1) == "?") {
					// Internet Explorer 6 has a bug, so we need to remove everything after # (fragment)
					// This bug causes/effects in the special case when we use ajax and a url starting with "?" down here.
					// Solution: Dont use url starting with "?" :) or use this small javascript code.
					var t = window.location.href.split("#");
					baseurl = t[0];
				}

				xmlhttp.open('POST', baseurl+url, true); // use encodeURI() for parameter

				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4) { // loaded (complete)
						if (xmlhttp.status == 200) {
							// 200 OK
							clearTimeout(timer);
							clearTimeout(timerLoading);
							TAJAX.hideLoading();

							try {
								if (xmlhttp.responseXML.getElementsByTagName('htmlcode').length) { // Elvileg ez a .length csak Opera 9-tol supported
									if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "1") {
										alert("Üzeneted sikeresen elküldésre került!");
										document.fr_contact.from.value = "";
										document.fr_contact.text.value = "";
										document.fr_contact.code.value = "";
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0f") {
										alert("Hibás e-mail cím!");
										document.fr_contact.from.focus();
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0te") {
										alert("Nincs megadva szöveg!");
										document.fr_contact.text.focus();
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0ttl") {
										alert("Túl hosszú szöveg! (5000 karakter)");
										document.fr_contact.text.focus();
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0c") {
										alert("Hibás ellenőrzőkód!");
										document.fr_contact.code.focus();
									} else {
										alert("Hiba az üzenetküldés során!");
									}
								}
							} catch(err) {
								alert("Error: HTML code");
							}

							TAJAX.contactInProgress = false;
						}
					}
				}

				xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xmlhttp.send("from="+encodeURI(document.fr_contact.from.value)+"&text="+encodeURI(document.fr_contact.text.value)+"&code="+encodeURI(document.fr_contact.code.value)); // Opera suxx when it is "null"! Always add a param or an empty string

				timer = setTimeout(function(){
					xmlhttp.abort();
					clearTimeout(timerLoading);
					this.hideLoading();
					this.contactInProgress = false;
					alert("Az üzenet elküldése nem sikerült! Próbáld újra!");
				}, 10000);

				timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
			}

			return false;
		},

		// Tovabbkuldes
		tovabbkuldes : function(url) {

			//$('msg').setStyle('display', 'none');

			if (this.tovabbkuldesInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {
				this.tovabbkuldesInProgress = true;

				var xmlhttp = new XMLHttpRequest();
				var timer = null;
				var timerLoading = null;

				var baseurl = "";
				if (window.location.href.indexOf("#") != -1 && url.substr(0,1) == "?") {
					// Internet Explorer 6 has a bug, so we need to remove everything after # (fragment)
					// This bug causes/effects in the special case when we use ajax and a url starting with "?" down here.
					// Solution: Dont use url starting with "?" :) or use this small javascript code.
					var t = window.location.href.split("#");
					baseurl = t[0];
				}

				xmlhttp.open('POST', baseurl+url, true); // use encodeURI() for parameter

				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4) { // loaded (complete)
						if (xmlhttp.status == 200) {
							// 200 OK
							clearTimeout(timer);
							clearTimeout(timerLoading);
							TAJAX.hideLoading();

							try {
								if (xmlhttp.responseXML.getElementsByTagName('htmlcode').length) { // Elvileg ez a .length csak Opera 9-tol supported
									if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "1") {
										alert("A továbbküldés sikeresen megtörtént!");
										document.fr_tovabbkuldes.from_name.value = "";
										document.fr_tovabbkuldes.from.value = "";
										document.fr_tovabbkuldes.to.value = "";
										document.fr_tovabbkuldes.text.value = "";
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0fne") {
										alert("Nincs megadva a neved!");
										document.fr_tovabbkuldes.from_name.focus();
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0fntl") {
										alert("Túl hosszú a neved!");
										document.fr_tovabbkuldes.from_name.focus();
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0f") {
										alert("Hibás az e-mail címed!");
										document.fr_tovabbkuldes.from.focus();
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0t") {
										alert("Hibás a címzett e-mail címe!");
										document.fr_tovabbkuldes.to.focus();
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0ttl") {
										alert("Túl hosszú a szöveg! (max 500 karakter)");
										document.fr_tovabbkuldes.text.focus();
									} else {
										alert("Hiba a továbbküldés során!");
									}
								}
							} catch(err) {
								alert("Error: HTML code");
							}

							TAJAX.tovabbkuldesInProgress = false;
						}
					}
				}

				xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xmlhttp.send("from_name="+encodeURI(document.fr_tovabbkuldes.from_name.value)+"&from="+encodeURI(document.fr_tovabbkuldes.from.value)+"&to="+encodeURI(document.fr_tovabbkuldes.to.value)+"&text="+encodeURI(document.fr_tovabbkuldes.text.value)); // Opera suxx when it is "null"! Always add a param or an empty string
				// utf-8-ban kuldi a dolgokat! erre ugyeljunk!

				timer = setTimeout(function(){
					xmlhttp.abort();
					clearTimeout(timerLoading);
					this.hideLoading();
					this.tovabbkuldesInProgress = false;
					alert("A továbbküldés nem sikerült! Próbáld újra!");
				}, 10000);

				timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
			}

			return false;
		},

		// Favorites / Kedvencekhez
		favorites : function(url) {

			//$('msg').setStyle('display', 'none');

			if (this.favoritesInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {
				this.favoritesInProgress = true;

				var xmlhttp = new XMLHttpRequest();
				var timer = null;
				var timerLoading = null;

				var baseurl = "";
				if (window.location.href.indexOf("#") != -1 && url.substr(0,1) == "?") {
					// Internet Explorer 6 has a bug, so we need to remove everything after # (fragment)
					// This bug causes/effects in the special case when we use ajax and a url starting with "?" down here.
					// Solution: Dont use url starting with "?" :) or use this small javascript code.
					var t = window.location.href.split("#");
					baseurl = t[0];
				}

				xmlhttp.open('POST', baseurl+url, true); // use encodeURI() for parameter

				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4) { // loaded (complete)
						if (xmlhttp.status == 200) {
							// 200 OK
							clearTimeout(timer);
							clearTimeout(timerLoading);
							TAJAX.hideLoading();

							try {
								if (xmlhttp.responseXML.getElementsByTagName('htmlcode').length) { // Elvileg ez a .length csak Opera 9-tol supported
									if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "1") {
										alert("A játék a kedvencekhez sikeresen hozzáadva!");
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0l") {
										alert("Nem vagy belépve!");
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0ve") {
										alert("Hibás játék!");
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0e") {
										alert("Ez a játék már szerepel a kedvenceid között!");
										//STT.hideTooltip(STT.tt_width,STT.tt_height);
										//STT.showTooltip("Ez a játék már szerepel a kedvenceid között!",400,15);
										//setTimeout("STT.hideTooltip(400,15)", 5000);
									} else {
										alert("Hiba a kedvencekhez során!");
									}
								}
							} catch(err) {
								alert("Error: HTML code");
							}

							TAJAX.favoritesInProgress = false;
						}
					}
				}

				xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xmlhttp.send(""); // Opera suxx when it is "null"! Always add a param or an empty string
				// utf-8-ban kuldi a dolgokat! erre ugyeljunk!

				timer = setTimeout(function(){
					xmlhttp.abort();
					clearTimeout(timerLoading);
					this.hideLoading();
					this.favoritesInProgress = false;
					alert("A kedvencekhez hozzáadás nem sikerült! Próbáld újra!");
				}, 10000);

				timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
			}

			return false;
		},

		// Rate / Rating / Ertekeles
		rate : function(url) {

			//$('msg').setStyle('display', 'none');

			if (this.rateInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {
				this.rateInProgress = true;

				var xmlhttp = new XMLHttpRequest();
				var timer = null;
				var timerLoading = null;

				var baseurl = "";
				if (window.location.href.indexOf("#") != -1 && url.substr(0,1) == "?") {
					// Internet Explorer 6 has a bug, so we need to remove everything after # (fragment)
					// This bug causes/effects in the special case when we use ajax and a url starting with "?" down here.
					// Solution: Dont use url starting with "?" :) or use this small javascript code.
					var t = window.location.href.split("#");
					baseurl = t[0];
				}

				xmlhttp.open('POST', baseurl+url, true); // use encodeURI() for parameter

				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4) { // loaded (complete)
						if (xmlhttp.status == 200) {
							// 200 OK
							clearTimeout(timer);
							clearTimeout(timerLoading);
							TAJAX.hideLoading();

							try {
								if (xmlhttp.responseXML.getElementsByTagName('htmlcode').length) { // Elvileg ez a .length csak Opera 9-tol supported
									if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data.search(/^[0-9]|(-)?[0-9]|(-)?[0-9]$/) != -1) {
										var t = xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data.split("|");
										// t[0] = komment_id
										// t[1] = -1 vagy 1 (rating)
										// t[2] = komment jelenlegi ossz rating-je

										//if (t[1] == "1") {
										//	document.getElementById("krate_imgup"+t[0]).src = "nemtudom_up.gif";
										//} else {
										//	document.getElementById("krate_imgdown"+t[0]).src = "nemtudom_down.gif";
										//}

										$("krate_imgup"+t[0]).addClass('denied_good');
										$("krate_imgdown"+t[0]).addClass('denied_bad');
										$("krate_aup"+t[0]).onclick = function() { return false };
										$("krate_adown"+t[0]).onclick = function() { return false };

										document.getElementById("krate_rating"+t[0]).innerHTML = (t[2] > 0) ? "+" + t[2] : t[2];
										if (t[2] < 0) $("krate_rating"+t[0]).addClass('negative');
										else if (t[2] >= 0) $("krate_rating"+t[0]).addClass('positive');
										//alert("Értékelés eltárolva!");
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "loginreq") {
										alert("Nem vagy belépve!");
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "ratingerror") {
										alert("Hibás érték!");
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "kiderror") {
										alert("Nincs ilyen komment!");
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "ownerror") {
										alert("A saját kommentedet nem értékelheted!");
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "alreadyrated") {
										alert("Már értékelted a kommentet!");
									} else {
										alert("Hiba történt az értékelés során!");
									}
								}
							} catch(err) {
								alert("Error: HTML code "+err);
							}

							TAJAX.rateInProgress = false;
						}
					}
				}

				xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xmlhttp.send(""); // Opera suxx when it is "null"! Always add a param or an empty string

				timer = setTimeout(function(){
					xmlhttp.abort();
					clearTimeout(timerLoading);
					this.hideLoading();
					this.rateInProgress = false;
					alert("Az értékelés elérése nem sikerült! Próbáld újra!");
				}, 10000);

				timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
			}

			return false;
		},

		// Paging
		loadPage : function(url, destination_element_id, fn) {

			//$('msg').setStyle('display', 'none');

			if (this.pagingInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {
				this.pagingInProgress = true;

				var xmlhttp = new XMLHttpRequest();
				var timer = null;
				var timerLoading = null;

				var baseurl = "";
				if (window.location.href.indexOf("#") != -1 && url.substr(0,1) == "?") {
					// Internet Explorer 6 has a bug, so we need to remove everything after # (fragment)
					// This bug causes/effects in the special case when we use ajax and a url starting with "?" down here.
					// Solution: Dont use url starting with "?" :) or use this small javascript code.
					var t = window.location.href.split("#");
					baseurl = t[0];
				}

				xmlhttp.open('POST', baseurl+url, true); // use encodeURI() for parameter

				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4) { // loaded (complete)
						if (xmlhttp.status == 200) {
							// 200 OK
							clearTimeout(timer);
							clearTimeout(timerLoading);
							TAJAX.hideLoading();

							try {
								if (xmlhttp.responseXML.getElementsByTagName('htmlcode').length) { // Elvileg ez a .length csak Opera 9-tol supported
									$(destination_element_id).innerHTML = xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data;
								}
							} catch(err) {
								alert("Error: HTML code");
							}

							try {
								if (xmlhttp.responseXML.getElementsByTagName('javascriptcode').length) { // Elvileg ez a .length csak Opera 9-tol supported
									eval(xmlhttp.responseXML.getElementsByTagName('javascriptcode')[0].firstChild.data);
								}
							} catch(err) {
								alert("Error: JavaScript code");
							}

							try {
								fn();
							} catch(err) {
								//alert("Error: function() failed");
							}

							TAJAX.pagingInProgress = false;
						}
					}
				}

				xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xmlhttp.send(""); // Opera suxx when it is "null"! Always add a param or an empty string

				timer = setTimeout(function(){
					xmlhttp.abort();
					clearTimeout(timerLoading);
					this.hideLoading();
					this.pagingInProgress = false;
					alert("Az oldal betöltése nem sikerült! Próbáld újra!");
				}, 10000);

				timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
			}

			return false;
		},

		// Save drag
		savedrag : function(url, fn) {

			//$('msg').setStyle('display', 'none');

			if (this.savedragInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {
				this.savedragInProgress = true;

				var xmlhttp = new XMLHttpRequest();
				var timer = null;
				var timerLoading = null;

				var baseurl = "";
				if (window.location.href.indexOf("#") != -1 && url.substr(0,1) == "?") {
					// Internet Explorer 6 has a bug, so we need to remove everything after # (fragment)
					// This bug causes/effects in the special case when we use ajax and a url starting with "?" down here.
					// Solution: Dont use url starting with "?" :) or use this small javascript code.
					var t = window.location.href.split("#");
					baseurl = t[0];
				}

				xmlhttp.open('POST', baseurl+url, true); // use encodeURI() for parameter

				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4) { // loaded (complete)
						if (xmlhttp.status == 200) {
							// 200 OK
							clearTimeout(timer);
							clearTimeout(timerLoading);
							TAJAX.hideLoading();

							try {
								var ok = xmlhttp.responseXML.getElementsByTagName('ok')[0].firstChild.data;
								if (xmlhttp.responseXML.getElementsByTagName('msg')[0].firstChild) {
									// Ha valami hibauzenet volt.
									// TAJAX.msg = ???
									if (xmlhttp.responseXML.getElementsByTagName('msg')[0].firstChild.data != "") {
										alert(xmlhttp.responseXML.getElementsByTagName('msg')[0].firstChild.data);
									}
								}
							} catch(err) {
								alert("Error occured while saving!");
							}

							try {
								fn();
							} catch(err) {
								//alert("Error: function() failed");
							}

							TAJAX.savedragInProgress = false;
						}
					}
				}

				xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xmlhttp.send(""); // Opera suxx when it is "null"! Always add a param or an empty string

				timer = setTimeout(function(){
					xmlhttp.abort();
					clearTimeout(timerLoading);
					this.hideLoading();
					this.savedragInProgress = false;
					alert("Az oldal betöltése nem sikerült! Próbáld újra!");
				}, 10000);

				timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
			}

			return false;
		},

		// Save box content
		saveboxcontent : function(url, form, fn) {

			//$('msg').setStyle('display', 'none');

			if (this.saveboxcontentInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {
				this.saveboxcontentInProgress = true;

				var xmlhttp = new XMLHttpRequest();
				var timer = null;
				var timerLoading = null;

				var baseurl = "";
				if (window.location.href.indexOf("#") != -1 && url.substr(0,1) == "?") {
					// Internet Explorer 6 has a bug, so we need to remove everything after # (fragment)
					// This bug causes/effects in the special case when we use ajax and a url starting with "?" down here.
					// Solution: Dont use url starting with "?" :) or use this small javascript code.
					var t = window.location.href.split("#");
					baseurl = t[0];
				}

				xmlhttp.open('POST', baseurl+url, true); // use encodeURI() for parameter

				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4) { // loaded (complete)
						if (xmlhttp.status == 200) {
							// 200 OK
							clearTimeout(timer);
							clearTimeout(timerLoading);
							TAJAX.hideLoading();

							try {
								var ok = xmlhttp.responseXML.getElementsByTagName('ok')[0].firstChild.data;
								if (xmlhttp.responseXML.getElementsByTagName('msg')[0].firstChild) {
									// Ha valami hibauzenet volt.
									// TAJAX.msg = ???
									if (xmlhttp.responseXML.getElementsByTagName('msg')[0].firstChild.data != "") {
										alert(xmlhttp.responseXML.getElementsByTagName('msg')[0].firstChild.data);
									}
								}
							} catch(err) {
								alert("Error occured while saving!");
							}

							try {
								fn();
							} catch(err) {
								//alert("Error: function() failed");
							}

							TAJAX.saveboxcontentInProgress = false;
						}
					}
				}

				xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
				xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				if (url.search(/category/) != -1) {
					// category box
					xmlhttp.send("box_id="+form.box_id.value+"&box_name="+encodeURIComponent(form.box_name.value)+"&box_order="+form.box_order.options[form.box_order.selectedIndex].value+"&box_target="+form.box_target.options[form.box_target.selectedIndex].value); // Opera suxx when it is "null"! Always add a param or an empty string
				} else {
					// featured box
					xmlhttp.send("box_id="+form.box_id.value+"&box_name="+encodeURIComponent(form.box_name.value)+"&box_content="+form.box_content.options[form.box_content.selectedIndex].value+"&game1_name="+encodeURIComponent(form.game1_name.value)+"&game2_name="+encodeURIComponent(form.game2_name.value)+"&game3_name="+encodeURIComponent(form.game3_name.value)+"&game4_name="+encodeURIComponent(form.game4_name.value)); // Opera suxx when it is "null"! Always add a param or an empty string
				}

				timer = setTimeout(function(){
					xmlhttp.abort();
					clearTimeout(timerLoading);
					this.hideLoading();
					this.saveboxcontentInProgress = false;
					alert("Az oldal betöltése nem sikerült! Próbáld újra!");
				}, 10000);

				timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
			}

			return false;
		},

		// Add/Remove Label (apply/remove)
		label : function(cmd, ids, fn) {

			// Sarissa + Mootools (replaceable with document.getElementById())

			var xmlhttp = new XMLHttpRequest();
			var timer = null;
			var timerLoading = null;

			// The followings are for later use
			this.msg = "";
			this.tutorials = new Array();
			this.labelcmd = cmd;

			if (this.labelInProgress) {
				//alert("éppen töltödik egy oldal, picit várj!");
			} else {

				this.labelInProgress = true;

				if (this.userloggedin == 1) {

					xmlhttp.open('POST', '/ajax/label/'+cmd, true); // lehetne GET-elni is de a POST biztosabb :)

					xmlhttp.onreadystatechange = function() {
						if (xmlhttp.readyState == 4) { // loaded (complete)
							if (xmlhttp.status == 200) {
								// 200 OK

								// We are in a deeper level now, so we must use "TA" instead of "this" where its needed.
								clearTimeout(timer);
								clearTimeout(timerLoading);
								TAJAX.hideLoading();

								var ok = xmlhttp.responseXML.getElementsByTagName('ok')[0].firstChild.data;
								if (xmlhttp.responseXML.getElementsByTagName('msg')[0].firstChild) {
									// Ha valami hibauzenet volt.
									TAJAX.msg = xmlhttp.responseXML.getElementsByTagName('msg')[0].firstChild.data;
								}

								// Convert xml data into array
								var i, j, tutorial_id;
								for (i=0; i < xmlhttp.responseXML.getElementsByTagName('tutorial').length; i++) {
									for (j=0; j < xmlhttp.responseXML.getElementsByTagName('tutorial')[i].childNodes.length; j++) {
										if (xmlhttp.responseXML.getElementsByTagName('tutorial')[i].childNodes[j].nodeName == "id") {
											tutorial_id = xmlhttp.responseXML.getElementsByTagName('tutorial')[i].childNodes[j].firstChild.data;
											TAJAX.tutorials[tutorial_id] = new Array();
										} else if (xmlhttp.responseXML.getElementsByTagName('tutorial')[i].childNodes[j].nodeName == "label_id") {
											label_id = xmlhttp.responseXML.getElementsByTagName('tutorial')[i].childNodes[j].firstChild.data;
											TAJAX.tutorials[tutorial_id][label_id] = label_id;
										}
									}
								}

								fn();

								TAJAX.labelInProgress = false;
							}
						}
					}

					xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
					xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					xmlhttp.send('ids='+ids); // Opera suxx when it is "null"! Always add a param or an empty string

					timer = setTimeout(function(){
						xmlhttp.abort();
						clearTimeout(timerLoading);
						this.hideLoading();
						this.labelInProgress = false;
						alert("Error occurred while accessing server (timed out). Please try again!");
					}, 10000);

					timerLoading = setTimeout("TAJAX.showLoading()", 500); // csak X ido eltelte utan mutatjuk, mert idegesito amik csak fel-fel villan a gyors kommunikacio miatt.
				}
			}

			return false;
		}
	};

	var TAJAX = new tippekAjax(); // plz always use "TAJAX" as the variable name, because it's hardcoded into the code, thx :)

/////////////// COOKIE ////////////////////

	var expDays = 365;
	var exp = new Date(); 
	exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

	function SetCookie(name, value) {
		var argv = SetCookie.arguments;  
		var argc = SetCookie.arguments.length;  
		var expires = (argc > 2) ? argv[2] : null;  
		var path = "/";
		var domain = (argc > 4) ? argv[4] : null;  
		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" : "");
	}

	function getCookieVal(offset) {  
		var endstr = document.cookie.indexOf (";", offset);  
		if (endstr == -1) endstr = document.cookie.length;  
		return unescape(document.cookie.substring(offset, endstr));
	}

	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;
	}

/////////////// GAME ///////////////////
	function createWindow(adr) {
		var width  = Math.floor( parseInt(screen.width)/4*3);
		var height = Math.floor( parseInt(screen.height)/4*3);
		var pWin=window.open(adr, "jatekozonWin", "width="+width+",height="+height+",left=100,top=100,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=no,toolbar=no");
		pWin.focus();
	}

/////////////// CONTENT ///////////////////

	 // removes "act" class from all LIs which already have it.
	function deActCategory() {
		$$('li.act').each(function(e, i){
			e.removeClass('act');
		});
	}

/////////////// FOOTER ////////////////////

	function menuchanged(id) {
		if (GetCookie("menu") == id) {
			SetCookie("menu", "");
		} else {
			SetCookie("menu", id);
		}
		return false;
	}

	// Egy "hidden"-elo resz a menu ala lett rakva kozvetlenul.

	var presetToggler; // we set it later if necessary
	var presetTogglerID; // we set it later if necessary

	//window.onload = function(){ //safari cannot get style if window isnt fully loaded
	//window.onDomReady(function(){ //ez az onDomReady lehet nem megy safari alatt, mert lasd egy sorral feljeb.
	window.addEvent('domready', function() {

		function getActiveCategoryAccordionByCookie() {
			var toggler = -1;

			var cookieValue = GetCookie("menu");

			$$('h3.toggler a').each(function(link, i){
				if (cookieValue == link.id) {
					toggler = i;
					//myAccordion.showThisHideOpen(i);
				}
			});
			return toggler;
		}

		if (presetToggler!=undefined) {
			// presetToggler is set by server side programming language :)
			actToggler = presetToggler;
			menuchanged(presetTogglerID); // set cookie
		} else {
			actToggler = getActiveCategoryAccordionByCookie();
		}


		var togglers = $$('h3.toggler');
		
		togglers.each(function(toggler, i){
			toggler.defaultColor = toggler.getStyle('background-color');

			toggler.myEffect = new Fx.Style(toggler, 'background-color', {duration:400, transition: Fx.Transitions.linear});
		});
	
		//var myAccordion = new Fx.Accordion(togglers, stretchers, {
		var myAccordion = new Fx.Accordion("h3.atStart", "div.atStart", {
			opacity: false,
			//start: false,
			//transition: Fx.Transitions.quadOut,			
			alwaysHide: true,
			display: actToggler,

			onActive: function(toggler, element){
				toggler.setStyle('color', '#ff3300');
			},
 
			onBackground: function(toggler, element){
				toggler.setStyle('color', '#222');
			}
		});

	});
	//};
	
	//try {
	//	window.disableImageCache();
	//}catch(e){}


