
// 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 = {

	// v1.1 - form-ot is meghatarozunk (van par kivetel: reply, goKomment, stb)

	clickB: function(fr) {

		if (fr == undefined || !fr) fr = document.komment;

		if (clickedB) {
			clickedB = 0;
			fr.comment_text.value += "[/b]";
			fr.b.value = "F";
			fr.comment_text.focus();
		} else {
			clickedB = 1;
			fr.comment_text.value += "[b]";
			fr.b.value = "F*";
			fr.comment_text.focus();
		}
	},

	clickI: function(fr) {

		if (fr == undefined || !fr) fr = document.komment;

		if (clickedI) {
			clickedI = 0;
			fr.comment_text.value += "[/i]";
			fr.i.value = "D";
			fr.comment_text.focus();
		} else {
			clickedI = 1;
			fr.comment_text.value += "[i]";
			fr.i.value = "D*";
			fr.comment_text.focus();
		}
	},

	clickURL: function(fr) {

		if (fr == undefined || !fr) fr = document.komment;

		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!="") {
				fr.comment_text.value += "[url="+link+"]"+linkname+"[/url]";
			} else {
				alert("Hibás név!");
			}
		} else {
			alert("Hibás link!");
		}

		//clickedURL
	},

	closeAll: function(fr) {

		if (fr == undefined || !fr) fr = document.komment;

		if (clickedURL) { // direkt van elobb az url
			clickedURL = 0;
			fr.comment_text.value += "[/url]";
			fr.url.value = "Link";
			fr.comment_text.focus();
		}
		if (clickedB) {
			clickedB = 0;
			fr.comment_text.value += "[/b]";
			fr.b.value = "F";
			fr.comment_text.focus();
		}
		if (clickedI) {
			clickedI = 0;
			fr.comment_text.value += "[/i]";
			fr.i.value = "D";
			fr.comment_text.focus();
		}
	},

	submitKomment: function(fr) {

		if (fr == undefined || !fr) fr = document.komment;

		this.closeAll(fr);
		fr.submit();
	},


	ins: function(smiley, fr) { // Figyelem! Forditva van az fr parameter!

		if (fr == undefined || !fr) fr = document.komment;

		fr.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');
	}
}


/* 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'); });


// ModalWin v0.1 (inline popup box) by O.G
//  - iframe support (with close button)
//  - css classes (mw_modalwin, mw_iframe, mw_close)
//
// Based on Widget.Dialog (formerly pprompt.js)
// http://www.openjsan.org/doc/k/ko/komagata/Widget/Dialog/0.01/index.html
// http://p0t.jp/pprompt/
// 

var ModalWin = {
  iframe: function(title, src, options) {
    var options = this._extend(this.getOptions(), options || {});
    this.addOverlay();

    var pwindow = this.getWindow(options.height, options.width, options);

    // close div
    var pdiv = document.createElement('div');
    pdiv.className = 'mw_close';
    pdiv.appendChild(document.createTextNode(title)); // title

      // close anchor
      var panchor = document.createElement('a');
      panchor.appendChild(document.createTextNode('ablak bezárása'));
      panchor.setAttribute("href", '');
      panchor.onclick = function() { options.onOk(); return false; }

        // close img
        var pimg = document.createElement('img');
        pimg.setAttribute("src", '/skin/common/gfx/nixel.gif');
        pimg.setAttribute("alt", 'Embed bezárás');

        panchor.appendChild(pimg); // add img to anchor

      pdiv.appendChild(panchor); // add anchor to div
    
    pwindow.appendChild(pdiv); // add "all" to modal window

    // clear div
    //var pclear = document.createElement('div');
    //pclear.className = 'lclear';
    //pwindow.appendChild(pclear);

    // iframe
    var piframe = document.createElement('iframe');
    piframe.className = 'mw_iframe';
    piframe.src = src;
    piframe.setAttribute("frameborder", 0);
    piframe.frameBorder = 0; // IE rulz
    piframe.setAttribute("scrolling", options.iframe_scrolling);
    //piframe.scrolling = options.iframe_scrolling;

    pwindow.appendChild(piframe);

    //pwindow.innerHTML = "<div class='mw_close'>...</div>";

    document.body.appendChild(pwindow);

    // hack (az ertekelo csillagok FF3-ban a modalwin felett)
    //document.getElementById('vote').style.display = "none";

  },
  alert: function(msg, options) {
    var options = this._extend(this.getOptions(), options || {});
    this.addOverlay();

    var pwindow = this.getWindow(options.height+options.css_correction_height, options.width+options.css_correction_width, options);

    // msg
    var pmsg = document.createElement('div');
    pmsg.className = 'pmsg';
    pmsg.style.padding = '6px';
    pmsg.appendChild(document.createTextNode(msg));

    pwindow.appendChild(pmsg);

    // buttons
    var pbuttons = document.createElement('div');
    pbuttons.id = 'pbuttons';
    pbuttons.style.padding = '6px';

    // ok
    var pbuttonOk = document.createElement('button');
    pbuttonOk.className = 'pbutton';
    pbuttonOk.appendChild(document.createTextNode(options.labelOk));
    pbuttonOk.onclick = options.onOk;
    pbuttons.appendChild(pbuttonOk);

    pwindow.appendChild(pbuttons);
    document.body.appendChild(pwindow);
    pbuttonOk.focus();
  },
  confirm: function(msg, options) {
    var options = this._extend(this.getOptions(), options || {});
    this.addOverlay();

    var pwindow = this.getWindow(options.height+options.css_correction_height, options.width+options.css_correction_width, options);

    // msg
    var pmsg = document.createElement('div');
    pmsg.className = 'pmsg';
    pmsg.style.padding = '6px';
    pmsg.appendChild(document.createTextNode(msg));
    pwindow.appendChild(pmsg);

    // buttons
    var pbuttons = document.createElement('div');
    pbuttons.id = 'pbuttons';
    pbuttons.style.padding = '6px';

    // ok
    var pbuttonOk = document.createElement('button');
    pbuttonOk.className = 'pbutton';
    pbuttonOk.appendChild(document.createTextNode(options.labelOk));
    pbuttonOk.onclick = options.onOk;
    pbuttons.appendChild(pbuttonOk);

    // cancel
    var pbuttonCancel = document.createElement('button');
    pbuttonCancel.className = 'pbutton';
    pbuttonCancel.appendChild(document.createTextNode(options.labelCancel));
    pbuttonCancel.onclick = options.onCancel;
    pbuttons.appendChild(pbuttonCancel);

    pwindow.appendChild(pbuttons);
    document.body.appendChild(pwindow);
    pbuttonOk.focus();
  },
  prompt: function(msg, options) {
    var opt = this.getOptions();
    opt.height = 100;
    var options = this._extend(opt, options || {});

    this.addOverlay();

    var pwindow = this.getWindow(options.height+options.css_correction_height, options.width+options.css_correction_width, options);

    // msg
    var pmsg = document.createElement('div');
    pmsg.className = 'pmsg';
    pmsg.style.padding = '6px';
    pmsg.appendChild(document.createTextNode(msg));
    pwindow.appendChild(pmsg);

    // buttons
    var pbuttons = document.createElement('div');
    pbuttons.id = 'pbuttons';
    pbuttons.style.padding = '6px';

    // input
    var pinput = document.createElement('input');
    pinput.id = 'pinput';
    pinput.style.width = '260px';
    pinput.setAttribute('type', 'text');
    pwindow.appendChild(pinput);

    // ok
    var pbuttonOk = document.createElement('button');
    pbuttonOk.className = 'pbutton';
    pbuttonOk.appendChild(document.createTextNode(options.labelOk));
    pbuttonOk.onclick = function() {
        options.onOk(pinput.value);
    };
    pbuttons.appendChild(pbuttonOk);

    // cancel
    var pbuttonCancel = document.createElement('button');
    pbuttonCancel.className = 'pbutton';
    pbuttonCancel.appendChild(document.createTextNode(options.labelCancel));
    pbuttonCancel.onclick = options.onCancel;
    pbuttons.appendChild(pbuttonCancel);

    pwindow.appendChild(pbuttons);
    document.body.appendChild(pwindow);
    pinput.focus();
  },
  addOverlay: function() {
    var poverlay = document.createElement('div');
    poverlay.id = 'poverlay';
    poverlay.style.top = '0px';
    poverlay.style.left = '0px';
    poverlay.style.position = 'absolute';
    poverlay.style.background = '#000';

    this._setOpacity(poverlay, 0.5);
    var pageSize = this._getPageSize();
    poverlay.style.height = pageSize.pageHeight+'px';
    poverlay.style.width = '100%';
    document.body.appendChild(poverlay);
  },
  removeOverlay: function() {
    document.body.removeChild(document.getElementById('poverlay'));
  },
  getWindow: function(height, width, options) {
    document.body.style.padding = '0';
    var pwindow = document.createElement('div');
    pwindow.id = 'pwindow';
    var pageSize = this._getPageSize();
    var pos = this._realOffset(document.body);
    pwindow.style.top = (pageSize.windowHeight/2 - (height+options.css_correction_height)/2 + pos[1])+'px';
    pwindow.style.left = (pageSize.windowWidth/2 - (width+options.css_correction_width)/2 + pos[0])+'px';
    pwindow.style.height = height+'px';
    pwindow.style.width = width+'px';
    pwindow.style.position = 'absolute';
    pwindow.className = 'mw_modalwin';
    document.body.appendChild(pwindow);

    // Elerakunk egy iframe-et, hogy a flash es hasonlok fole tudjon megjelenni a modalwin
    document.body.style.padding = '0';
    var pbgiframe = document.createElement('iframe');
    pbgiframe.id = 'pbgiframe';
    var pageSize = this._getPageSize();
    var pos = this._realOffset(document.body);
    pbgiframe.style.top = (pageSize.windowHeight/2 - height/2 + pos[1])+options.hiframe_correction_top+'px';
    pbgiframe.style.left = (pageSize.windowWidth/2 - width/2 + pos[0])+options.hiframe_correction_left+'px';
    pbgiframe.style.height = height+options.hiframe_correction_height+'px';
    pbgiframe.style.width = width+options.hiframe_correction_width+'px';
    pbgiframe.style.position = 'absolute';
    //pbgiframe.className = 'mw_modaliframe';
    pbgiframe.setAttribute("frameborder", 0); // fontos!
    pbgiframe.frameBorder = 0; // IE rulz
    document.body.appendChild(pbgiframe);

    return pwindow;
  },
  close: function(close_fn) {
    this.removeOverlay();
    document.body.removeChild(document.getElementById('pwindow'));
    document.body.removeChild(document.getElementById('pbgiframe'));

    // hack (az ertekelo csillagok FF3-ban a modalwin felett)
    //document.getElementById('vote').style.display = "block";

    try {
      close_fn();
    } catch(err) {
      //alert("Error: function() failed");
    }

  },
  getOptions: function() {
    return {
      'height'      : 70,
      'width'       : 300,
      'css_correction_height' : 0, // how css properties affect the div's layout
      'css_correction_width'  : 0, // how css properties affect the div's layout
      'iframe_scrolling' : 'yes', // if iframe

      'labelOk'     : 'OK',
      'labelCancel' : 'Mégsem',
      'onOk'        : function(fn) {
        ModalWin.close(fn);
      },
      'onCancel'    : function(fn) {
        ModalWin.close(fn);
      },

      // "iframe hack" settings (css properties can affect the close div's layout)
      'hiframe_correction_width'  : 0,
      'hiframe_correction_height' : 0,
      'hiframe_correction_top'    : 0,
      'hiframe_correction_left'   : 0,
      'close_fn' : ''
    };
  },
  _extend: function(destination, source) {
    for (var property in source) {
      destination[property] = source[property];
    }
    return destination;
  },
  _realOffset: function(element) {
    var valueT = 0, valueL = 0;
    do {
      valueT += element.scrollTop  || 0;
      valueL += element.scrollLeft || 0;
      element = element.parentNode;
    } while (element);
    return [valueL, valueT];
  },
  _setOpacity: function(element, value){
    if (typeof element == 'string')
      element= $(element);
    if (value == 1){
      element.style.opacity = (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0 ;
      if(/MSIE/.test(navigator.userAgent) && !window.opera)
        element.style.filter = element.style.filter.replace(/alpha\([^\)]*\)/gi,'');
    } else {
      if(value < 0.00001) value = 0;
      element.style.opacity = value;
      if(/MSIE/.test(navigator.userAgent) && !window.opera)
        element.style.filter = element.style.filter.replace(/alpha\([^\)]*\)/gi,'') + 'alpha(opacity='+value*100+')';
    }
    return element;
  },
  _getPageSize: function() {
    var xScroll, yScroll;
    if (window.innerHeight && window.scrollMaxY) {
      xScroll = document.body.scrollWidth;
      yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){
      // all but Explorer Mac
      xScroll = document.body.scrollWidth;
      yScroll = document.body.scrollHeight;
    } else {
      // Explorer Mac...would also work in Explorer 6 Strict,
      // Mozilla and Safari
      xScroll = document.body.offsetWidth;
      yScroll = document.body.offsetHeight;
    }

    var windowWidth, windowHeight;
    if (self.innerHeight) {      // all except Explorer
      windowWidth = self.innerWidth;
      windowHeight = self.innerHeight;
    } else if (document.documentElement
    && document.documentElement.clientHeight) {
      // Explorer 6 Strict Mode
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight;
    }

	// Small hack
	var brs=navigator.userAgent.toLowerCase();
	if (brs.search(/firefox[\/\s](\d+([\.-]\d)*)/) != -1) {
		windowWidth = windowWidth - 19; // 19px a scrollbar FF alatt (16px is volt)
	}

    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
      pageHeight = windowHeight;
    } else {
      pageHeight = yScroll;
    }

    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){
      pageWidth = windowWidth;
    } else {
      pageWidth = xScroll;
    }

    return {
      'pageWidth':pageWidth,
      'pageHeight':pageHeight,
      'windowWidth':windowWidth,
      'windowHeight':windowHeight,
      'yScroll':yScroll,
      'xScroll':xScroll
    };
  }
};


/// *** 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("video"+id+"_remain").style.display = "inline";
	document.getElementById("video"+id+"_more").style.display = "none";
	document.getElementById("video"+id+"_less").style.display = "inline";
	return false;
}

function less(id) {
	CanGo = false;
	document.getElementById("video"+id+"_remain").style.display = "none";
	document.getElementById("video"+id+"_more").style.display = "inline";
	document.getElementById("video"+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.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 video 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 video!");
									} else if (xmlhttp.responseXML.getElementsByTagName('htmlcode')[0].firstChild.data == "0e") {
										alert("Ez a video már szerepel a kedvenceid között!");
										//STT.hideTooltip(STT.tt_width,STT.tt_height);
										//STT.showTooltip("Ez a video 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;
		},

		// 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;
	}


/////////////// LABELS ////////////////////

	function tippekLabel() {
		this.select_element;
	}

	tippekLabel.prototype = {
		create : function(fr) {
			if (fr.name.value == "") { alert("Nincs megadva név!"); fr.name.focus(); }
			else if (fr.name.value.length > 40) { alert("Túl hosszú címke!"); fr.name.focus(); }
			else {
				fr.submit();
			}
			return false;
		},

		onTyping : function(fr) { // executed when typing label name
			// Fejlesszuk bele, hogy ha csak space-bol all a cucc akkor ne engedelyezze a gombot
			fr.createbutton.disabled = (fr.name.value != "") ? false : true;
		},

		rename : function(url, label) {
			var reply = prompt("Címke új neve:", label);
			var ok = false;
			while (!ok) {
				if (reply == null) ok = true; // pushed cancel
				else if (reply.length == 0) reply = prompt("Nem adtál meg címke nevet:", "");
				else if (reply.length > 40) reply = prompt("Túl hosszú címke név, próbálj meg egy másikat:", reply);
				else ok = true;
			}

			if (reply != null) {
				window.location.href = url + "/" + escape(reply);
			}
			return false;
		},

		remove : function(url, label) {
			var answer = confirm("Biztos hogy törölni akarod a(z) \"" + label + "\" címkét?");
			if (answer) {
				window.location.href = url;
			}
			return false;
		},

		// called when clicked on a checkbox at tutorial list (if you're logged in)
		check : function(id) {
			// it's called "after" onclick, so the checkbox's value is set before this
			if ($('tutorial_checkbox'+id).checked) {
				$('tutorial'+id).addClass('lofasz'); // Nem megy FF alatt (FF1.5 alatt tesztelve)
			} else {
				$('tutorial'+id).removeClass('lofasz'); // Nem megy FF alatt (FF1.5 alatt tesztelve)
			}

			this.create_select("action_select1");
			this.create_select("action_select2");
		},

		create_select : function(select_id) {

			var inputs = $$('input');
			var addable_labels   = new Array();
			var removable_labels = new Array();
			var x, label_id;

			// Mootools' Array handling functions are pretty bad in this special case, so we have to use a trick

			// Collecting removable labels
			inputs.each(function(input, i){
				if (input.type == "checkbox" && input.id.substr(0, 17) == "tutorial_checkbox") {
					if (input.checked) {
						var x;
						var tutorial_id = input.id.substr(17, input.id.length);

						var tl = tutorial_labels[tutorial_id];
					
						if (tl.length != "") {
							tl = tl.split(",");
							for (x in tl) {
								if (!isNaN(x)) {
									removable_labels[ tl[x] ] = tl[x];
								}
							}
						}
					}
				}
			});

			// Collecting addable labels
			for (label_id in labels) {
				if (!isNaN(label_id)) {

					inputs.each(function(input, i){
						if (input.type == "checkbox" && input.id.substr(0, 17) == "tutorial_checkbox") {
							if (input.checked) {
								var x;
								var tutorial_id = input.id.substr(17, input.id.length);

								var tl = tutorial_labels[tutorial_id];
								var exists = false;

								if (tl.length != "") {
									tl = tl.split(",");
									for (y in tl) {
										if (!isNaN(y)) {
											if (tl[y] == label_id) {
												exists = true;
											}
										}
									}
								}

								if (!exists) {
									addable_labels[ label_id ] = label_id;
								}
							}
						}
					});
				}
			}

			// ReCreate the SELECT element because Opera is a bit buggy without this
			var o = document.createElement("SELECT");
			o.name  = $(select_id).name;
			o.id    = $(select_id).id;
			o.className = $(select_id).className;
			o.onchange = function() { TLABEL.onchange($(select_id)); };

			/** not necessary
			// Removes all options from SELECT
			while ($(select_id).options.length > 0) {
				$(select_id).options[0] = null;
			}

			// Removes all optgroups from SELECT
			var optgroups = $(select_id).childNodes;
			for(i = optgroups.length - 1 ; i >= 0 ; i--) {
				$(select_id).removeChild(optgroups[i]);
			}
			**/

			// Replace "select" element with a new one (because of Opera's buggy behaviour)
			$(select_id).parentNode.replaceChild(o, $(select_id));

			// Refilling "select" element
			$(select_id).options[$(select_id).options.length] = new Option("További lehetőségek...", "-");

			// Add "Addable labels" (apply)
			var s2 = "";
			exists = false;
			for (x in addable_labels) {
				if (!isNaN(x)) {
					if (!exists) {
						exists = true;
						optgroup = document.createElement('optgroup');
						optgroup.label = "Címke hozzáadása:";
						$(select_id).appendChild(optgroup);
					}
					s2 = s2+addable_labels[x]+",";
					$(select_id).options[$(select_id).options.length] = new Option(String.fromCharCode(160, 160)+labels[ addable_labels[x] ], "a"+addable_labels[x]);
				}
			}

			// Add "Removable labels" (remove)
			var s = "";
			var exists = false;
			var optgroup;
			for (x in removable_labels) {
				if (!isNaN(x)) {
					if (!exists) {
						exists = true;
						optgroup = document.createElement('optgroup');
						optgroup.label = "Címke eltávolítása:";
						$(select_id).appendChild(optgroup);
					}
					s = s+removable_labels[x]+",";
					$(select_id).options[$(select_id).options.length] = new Option(String.fromCharCode(160, 160)+labels[ removable_labels[x] ], "r"+removable_labels[x]);
				}
			}
		},

		// executed when onchange event occurred in a "select" element
		onchange : function(e) {

			//$('msg').setStyle('display', 'none');

			// Get "command"
			var cmd  = e.options[e.selectedIndex].value;

			var inputs = $$('input');
			var ids = "";

			// Mootools' Array handling functions are pretty bad in this special case, so we have to use a trick

			// Collecting removable labels
			inputs.each(function(input, i){
				if (input.type == "checkbox" && input.id.substr(0, 17) == "tutorial_checkbox") {
					if (input.checked) {
						var tutorial_id = input.id.substr(17, input.id.length);
						ids += (ids.length == 0) ? tutorial_id : ","+tutorial_id;
					}
				}
			});

			// called when server replied something after AJAX. Creates HTML code to show/hide label names
			var fn = function() {
				// We get this params back from Ajax call: TAJAX.labelcmd, TAJAX.msg, TAJAX.tutorials

				if (TAJAX.msg != "") alert(TAJAX.msg); // something went wrong
				else {
					var c = TAJAX.labelcmd.substr(0, 1);
					var c_label_id = TAJAX.labelcmd.substr(1, TAJAX.labelcmd.length-1); // itt erre most nincs szuksegunk
					var tutorial_id;
					var label_id;
					var tl;
					var html;
					var affected = 0; // not "real". counts all tutorials not just that ones which really changed. gmail works the same way :)

					for (tutorial_id in TAJAX.tutorials) {
						if (!isNaN(tutorial_id)) {
							affected++;
							tutorial_labels[tutorial_id] = "";
							html = "";
							for (label_id in TAJAX.tutorials[tutorial_id]) {
								if (!isNaN(label_id)) {
									tutorial_labels[tutorial_id] += (tutorial_labels[tutorial_id].length == 0) ? label_id : ","+label_id;
									html += (html.length == 0) ? "&nbsp;" : ", ";
									html += "<a href='/nemtudom/label_id="+label_id+"' class='l'>"+labels[label_id]+"</a>";
								}
							}
							$("tutorial_labels"+tutorial_id).innerHTML = html;
						}
					}

					TLABEL.create_select(e.id);

					// Recreates the other "select" element
					if (e.id == "action_select1") {
						TLABEL.create_select("action_select2");
					} else {
						TLABEL.create_select("action_select1");
					}

					switch (c) {
						case "a":
							$("msg").innerHTML = "\""+labels[c_label_id]+"\" címke hozzáadva "+affected+" tutorialhoz";
							break;
						case "r":
							$("msg").innerHTML = "\""+labels[c_label_id]+"\" címke eltávolítva "+affected+" tutorialról";
							break;
					}
					$('msg').setStyle('display', '');
					var msgFx = new Fx.Style('msg', 'opacity', {duration:800}).set(0); // opacity-t leveszi azonnal 0-ara
					msgFx.custom(0,1); // from-to
				}
			};

			TAJAX.label(cmd, ids, fn);
		}
	};

	var TLABEL = new tippekLabel();


/////////////// 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){}


