
	function sayhello(name) {
		var r = parseInt(Math.random()*10);
		switch (r) {
			case 0: alert("Üdv, a nevem "+name+"! \nIgazából már nagyon unatkozom! \nNincs kedved egy kis kalandhoz?"); break;
			case 1: alert("Igen, én vagyok az, "+name+"! \nEmlékszel még egyáltalán rám?"); break;
			case 2: alert("Szervusz gazdám! "+name+" vagyok! \nMár viszket a talpam a kalandhiánytól!"); break;
			case 3: alert("Hallló! Én "+name+" vagyok! \nMenjünk már valahova!"); break;
			case 4: alert("Te figy! Az én nevem "+name+"! \nRég láttalak! Kéne csinálni valami, nem?"); break;
			case 5: alert("Hahó, "+name+" vagyok \nNem hiszed el, hogy vártalak már!"); break;
			case 6: alert("Emlékszel még a "+name+" névre? \nIgen, még te adtad nekem!\nNem akarsz kalandozni kicsit?"); break;
			case 7: alert(""+name+" szolgálatodra! \nMi a következő küldetés?"); break;
			case 8: alert(""+name+" készen áll a harcra! \nMár indulhatunk is gazdám!"); break;
			case 9: alert("Hahaha, "+name+" vagyok, készen állok! \nIndulunk?"); break;
		}
	}
			
	function preloading(){
		img_count=preloading.arguments.length;
		for (i=0; i<img_count;i++){
			myimages[i] = new Image();
			myimages[i].src = preloading.arguments[i];
			loaded[i]=false;
		}
		checkLoad();
	}

    function checkLoad() {
		if (img_loaded == img_count || navigator.appName=='Microsoft Internet Explorer') {
			setheights();
            time = new Date();
            start.setTime(time.getTime());
			float_in();
			return;
		}
		for (i = 0; i <= img_count; i++) {
			if (loaded[i] == false && myimages[i].complete) {
				loaded[i] = true;
				img_loaded++;
			}
		}
		timerID = setTimeout("checkLoad()",10)
	}

	function animationready() {
		animation_ready=1;
        time = new Date();
        dif = time-start;
        $('animation_time').innerHTML='Hossz: '+dif+' msec';
	}

	function setheights() {
        setheights_core();
		setTimeout('setheights()',500);
	}

    function setheights_once() {
		setheights_core();
        return;
	}

function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
  	}
	arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return arrayPageSizeWithScroll;
}


    function setheights_core() {
	var docSize = getPageSizeWithScroll();
	var docHeight = docSize[0];

       main_content = document.getElementById('main_content'); 
	main = document.getElementById('main');
	container = document.getElementById('container'); 
	left_side = document.getElementById('left_side'); 
	right_shadow = document.getElementById('right_shadow'); 
	user_shadow = document.getElementById('user_shadow'); 
	kinyito = document.getElementById('kinyito');

	right_shadow.style.height = main.offsetHeight+"px";
	user_shadow.style.height = document.getElementById('user_content').offsetHeight+"px";
	kinyito.style.height = main.offsetHeight+"px";

	main_content.style.height='auto';
	main.style.height='auto';
	container.style.height='auto';
	left_side.style.height='auto';

	/*
	if (docHeight > main.offsetHeight)
		main.style.height = docHeight+"px";	

	if (docHeight > left_side.offsetHeight)
		left_side.style.height = docHeight+"px";	

	if (main_content.offsetHeight > main.offsetHeight)
		main.style.height = (main_content.offsetHeight+300)+"px";

	if (left_side.offsetHeight>main.offsetHeight) {
		main.style.height = left_side.offsetHeight+"px";
	} else {
		left_side.style.height = main.offsetHeight+"px";
	}*/

	
	if (left_side.offsetHeight>main.offsetHeight) {
		main.style.height = left_side.offsetHeight+"px";
		left_side.style.height = left_side.offsetHeight+"px";
	} else {
		left_side.style.height = main.offsetHeight+"px";
		main.style.height = main.offsetHeight+"px";
	}

       return;
    }


	function preload_all() {
		preloading("wimg/bg.jpg",
				   "wimg/bg2.jpg",
				   "wimg/bg3.jpg",
				   "wimg/left_shadow.jpg",
				   "wimg/right_shadow.jpg",
				   "wimg/head.jpg",
				   "wimg/left_top.jpg",
				   "wimg/left.jpg",
				   "wimg/cetli.png",
				   "wimg/cetli2.png",
				   "wimg/deszka.png",
				   "wimg/right_top.png",
				   "wimg/right_bottom.png",
				   "wimg/right.png",
				   "wimg/bs.gif",
				   "wimg/submenu.png",
				   "wimg/submenu2.png",
				   "wimg/cat.gif",
				   "wimg/block_top.jpg",
				   "wimg/block_bottom.jpg",
				   "wimg/block_bg.jpg",
				   "wimg/swordi.png",
				   "wimg/right.jpg",
				   "wimg/messages.png",
				   "wimg/msg_bg.jpg",
				   "wimg/msg_top_hider.png");
	}


	function getMouseXY(e) {
		mousex = e.pageX
		mousey = e.pageY
		if (mousex < 0){mousex = 0}
		if (mousey < 0){mousey = 0}
		return true
	}

	function menu_mouse_over(o) {
		o.style.background='url(wimg/cetli2.png)';
	}

	function menu_mouse_out(o) {
		o.style.background='url(wimg/cetli.png)';
	}

	function submenu_mouse_over(o) {
		o.style.background='url(wimg/submenu2.png)';
	}

	function submenu_mouse_out(o) {
		o.style.background='url(wimg/submenu.png)';
	}

    function formpost_linkto(form) {
        $(form).submit();
	}
	

	function linkto(loc) {
        animation_allow_in = 0;
        animation_ready = 1;
		do_if_ready('linkto_now(\''+loc+'\')');
	}

    function do_if_ready(command) {
		if (animation_ready==0) {
			setTimeout("do_if_ready('"+command+"')",50);
		} else {
			setTimeout(command,1);
		}
	}

    function linkto_popup(loc) {
        animation_allow_in = 0;
        animation_ready = 1;
        window.open(loc,'popup','width=700,height=600,toolbar=0,resizable=1,scrollbars=1');
	}

	function forum_category_link(id) {
		linkto(php_self+'?forum&category='+id);
	}

	function forum_topic_link(id) {
		linkto(php_self+'?forum&topic='+id);
	}

	//Ajaxos válaszolgató fügvények
	function user_login() {
		var user_name_box = document.getElementById('user_name');
		var user_password_box = document.getElementById('user_password');
		var user_login_button = document.getElementById('user_login_button');
		if (user_name_box && user_password_box) {			  
			new Ajax.Request('request/login.php', {
	        parameters: "username="+user_name_box.value+"&password="+user_password_box.value,
	        encoding: "ISO-8859-2",
	        onSuccess: function(transport){process_login(transport)},
	        onFailure: function(){alert("Kapcsolat hiba!");}
    		});			
		}
		return false;		
	}
	
	function process_login(transport) { 
		resp = transport.responseText;
			var user_login_button = document.getElementById('user_login_button')			
  			if (resp=='wrong') {
				alert('Hibás bejelentkezo adatok!');
				user_login_button.style.visibility = "visible";
			} else
			if (resp=='notactive1') {
				alert('Még nem aktiváltad a regisztrációd, kövesd az emailben kapott utasításokat! Ha nem találod a küldött emailt, ellenörizd a Spam (Levélszemét) mappádban is, előfordulhat, hogy tévedésből oda került!');
				user_login_button.style.visibility = "visible";
			} else
			if (resp=='notactive2') {
				alert('Még nem aktív a regisztrációd, az email küldésnél problémák léptek fel, kérlek légy türelemmel, amíg kijavítjuk, vagy írj egy emailt nekünk: csapat@kalandor.dhm.ro!');
				user_login_button.style.visibility = "visible";
			} else
			if (resp=='blocked') {
				alert("A regisztrációdat blokkoltuk!\nAz okát elküldtük az email címedre, ha az email címed nem valós, és ezért nem kaptad meg, akkor ezért blokkoltunk! :) Ha nem értesz egyet, vagy kérdésed van, írj nekünk: csapat@kalandoronline.hu");
				user_login_button.style.visibility = "visible";
			} else
			if (resp=='toomany') {
				alert("Túl sokszor rontottad el a jelszód. 5 perc alatt max 5x próbálhatod. Kérlek várj egy kicsit mielőtt újrapróbálod! Ha elfelejtetted a jelszót írj egy emailt a csapat@kalandoronline.hu címre, és megoldjuk személyesen, amíg nincs jelszó visszaállítás lehetőség a honlapon.");
				user_login_button.style.visibility = "visible";
			} else
			if (resp=='ok') linkto(window.location);
			else {
				alert('Ismeretlen hiba! Válasz: '+resp);
			}
		return false;
	}

    function getStyleClass(className) {
	for (var s = 0; s < document.styleSheets.length; s++)
	{
		if(document.styleSheets[s].rules)
		{
			for (var r = 0; r < document.styleSheets[s].rules.length; r++)
			{
				if (document.styleSheets[s].rules[r].selectorText == '.' + className)
				{
					return document.styleSheets[s].rules[r];
				}
			}
		}
		else if(document.styleSheets[s].cssRules)
		{
			for (var r = 0; r < document.styleSheets[s].cssRules.length; r++)
			{
				if (document.styleSheets[s].cssRules[r].selectorText == '.' + className)
					return document.styleSheets[s].cssRules[r];
			}
		}
	}

	return null;
    }
    
function antihtmlspecialchars(ch) {
    ch = ch.replace(/&amp;/g,"&");
    ch = ch.replace(/&nbsp;/g,"");
    ch = ch.replace(/&quot;/g,"\"");
    ch = ch.replace(/&#039;/g,"\'");
    ch = ch.replace(/&lt;/g,"<");
    ch = ch.replace(/&gt;/g,">");
return ch
}

function getXmlElements(xml,tagnames) {
        var elements = new Array();
        for (e=0;e<tagnames.length;e++) {
         try { elements[e] = xml.getElementsByTagName(tagnames[e])[0].firstChild.data; }
         catch(err) {elements[e]='nincs'}
        }
        return elements;
}

function linktowindow(address) {
    popupwindow = window.open('popups.php?'+address,'popupwindow','width=675,height=600,toolbar=0,resizable=0,scrollbars=1');
    popupwindow.focus();
}

function userlink(id,nick,level) {
	var style = "userlink";
	if (level == 0) style = "userlink_visitor";
	if (level == 1) style = "userlink_kalandor";
	if (level > 1 && level < 40) style = "userlink_kiemelt";
	if (level >=40 && level < 90) style = "userlink_gm";
	if (level >=90) style = "userlink_admin";
    return '<a href="javascript:linktowindow(\'userinfo='+id+'\')" class="'+style+'" title="Részletek"><b>'+nick+'</b></a>';
}

function delete_article(id) {
	if (confirm('Biztosan kitörlöd ezt a cikket?')) {
		linkto(php_self+'?send_delete_article=1&article_id='+id);
	}
}
