

function nl2br_12(str) {
  if(typeof(str)=="string") return str.replace(/(\r\n)|(\n\r)|\r|\n/g,"<BR>");
  else return str;
}



function checkEmail() {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test($F("usremail"))){
	 $('usremail').style.background = "#FFFFFF";
return (true)
}
     alert("Az email cím formailag nem jó");
     $('usremail').focus();
	 $('usremail').style.background = "#FFECEC";
     return (false);

}


function checkFields() {
var mynum = $("reg_form").random.value;
var valid = "";
		if (mynum == 1 )
			{
					valid="z6GFB7c";
			}
			if (mynum == 2 )
			{
					valid="b7ReV1b";
			}
			if (mynum == 3 )
			{
					valid="r4wqC5z";
			}
			if (mynum == 4 )
			{
					valid="z9eWf4q";
			}
			if (mynum == 5 )
			{
					valid="b4vqn78";
			}
			if (mynum == 6 )
			{
					valid="L8rdqc8";
			}
			if (mynum == 7 )
			{
					valid="w1fdbx6";
			}
			if (mynum == 8 )
			{
					valid="gvy23rd";
			}
			if (mynum == 9 )
			{
					valid="L1ntrs5";
			}
			if (mynum == 10 )
			{
					valid="Le161g8";
			}
			if (mynum == 11 )
			{
					valid="kEx4j32";
			}
			if (mynum == 12 )
			{
					valid="f2G4q42";
			}
			if (mynum == 13 )
			{
					valid="g4B2Vm4";
			}
			if (mynum == 14 )
			{
					valid="g4V7Sje";
			}
			if (mynum == 15 )
			{
					valid="Fg421gd";
			}
			
			if (valid != $("reg_form").validate.value)
			{
				alert("A megadott biztonsági kód nem egyezik!");
				return(false);

				}
			
	alert(" usrname: "+$("reg_form").usrname.value +"\n passw: "+ $F("usrpassw") +"\n # "+ $F("usrpassw_again") +"\n # ");
	
	
	if($F("agree")){
		
		
		if(checkEmail()){
			
	if($("reg_form").usrname.value && $F("usrpassw") && $F("usrpassw_again") && $F("usremail")){
			
			if($F("usrpassw") != $F("usrpassw_again")){
				alert("A két megadott jelszó nem egyezik meg.");
				return(false);
			} else {
				$("reg_form").submit();
			}
			}
	else
	alert("Töltse ki az összes kötelezo mezot!")
	}
	
	
	
	
	}
	else
	alert("Regisztrációját abban az esetben tudjuk elfogadni, ha egyetért a fórum szabályzatával. Kérjük, jelölje be.")
	}
	
function updateImage(newsrc) {
		$("avatar_kep").src="includes/forum2/avatar/"+newsrc;
	}
	
	
function popUp(URL, width, height) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+width+",height="+height+",left = 287,top = 215.5');");
}

var content = "";
var  opened = 0;
function editInPlace(postid) {
	if(opened){
		if(confirm("Biztos nem akarja elmenteni a jelenleg szerkesztett oldal tartalmát?")){
			cancelSettings(opened);
		}
		else
		return;
	}
	opened = postid;
	var container = $(postid);
	content = container.innerHTML;
	container.onclick="";
	container.innerHTML = '<textarea id="szoveg" name="szoveg" cols="25" rows="10">'+content+'</textarea><br><input type="button" onclick="saveSettings(\''+postid+'\')" value="Mentés"><input type="button" onclick="cancelSettings(\''+postid+'\')" value="Mégse">';
}

function saveSettings(postid) {
	opened = "";
	var newcontent = $("szoveg").value;
	var container = $(postid);
	
	container.innerHTML = nl2br_12(newcontent);
	container.onclick = function() {editInPlace(postid)};
	justDoIt("includes/forum2/worker.php", "postid="+postid+"&postcontent="+newcontent);
}

function cancelSettings(postid) {
	opened = "";
	var container = $(postid);
	container.innerHTML = content;
	container.onclick = function() {editInPlace(postid)};
}

function getData(pars) {
	var url = 'includes/forum2/worker.php';
	var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
}

function postData(pars) {
	var url = 'includes/forum2/addNewPost.php';
	var myAjax = new Ajax.Request( url, { method: 'post', parameters: pars, onComplete: showResponse }); 
	//location.href = "javascript:history.go()";
}

function justDoIt(filename, pars) {
	var url = filename;
	var myAjax = new Ajax.Request( url, {method: 'post', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
}

function showLoad () {
	$('load').style.display = 'block';
}

function hideLoad () {
	$('load').style.display = 'none';
}


function showResponse (originalRequest) {
	var newData = originalRequest.responseText;
	$('load').style.display = 'none';
	$('showresponse').innerHTML = newData;
}




