String.prototype.reverse = function() {
	return this.split('').reverse().join('');
}

function sleep(ms) {
	var date    = new Date();
	var curDate = null;
	do curDate  = new Date();
	while(curDate-date<ms);
}

function slide(id) {
	if ($('#'+id).is(':hidden')) $('#'+id).slideDown('slow');
	else $('#'+id).slideUp('slow');
}

function bgblink(id, t) {
	if (t<4) {
		if (t%2==0) {
			document.getElementById(id).style.backgroundColor = '#1B6B80';
			time = 80;
		}
		else {
			document.getElementById(id).style.background = 'none';
			time = 50;
		}
		t++;
		setTimeout("bgblink('"+id+"', "+t+")", time);
	}
}

function highlight(id) {
	if ($('#'+id).is(':hidden')) $('#'+id).slideDown('slow');
	else bgblink(id, 0);
}

function numberFormat(val) {
	separator = ' ';
	thousands = 0;
	result	  = '';
	for(i=val.length-1; i>=0; i--) {
		if (thousands==3) {
			thousands = 0;
			result += separator;
		}
		result += val[i];
		thousands++;
	}
	return result.reverse();
}

function getIFramDoc(iframe) {
    if (iframe.contentDocument) // DOM spec       
        return iframe.contentDocument;
    else if (iframe.contentWindow && iframe.contentWindow.document)
        return iframe.contentWindow.document;
}

function copyToClipboard(textToCopy) {

    // Get the hidden iframe
	var clipFrame = document.getElementById("clipboardFrame");

    // First-time execution?
	if (!clipFrame) {
 
		// Create the hidden iframe
		clipFrame = document.createElement("iframe");
		clipFrame.id = "clipboardFrame";
		clipFrame.style.display = "none";
		document.body.appendChild(clipFrame);
        
        // Insert an input box and switch it to design mode
		var clipDoc = getIFramDoc(clipFrame);
       
       // IE doesn't allow immediate access to the clipboard body, so have to defer the operation
       // after this thread of execution finishes.
        if (!clipDoc.body) {
            setTimeout(function() {
        		clipDoc.body.innerHTML = "<textarea id='clipContainer'/>";
                // IE doesn't need design mode on to expose execCommand... it does not
                // handle DHTML very well either so just keep away from design mode alltogether!
        		copyToClipboard(textToCopy);
            },0);
            return;
        } 
        
		clipDoc.body.innerHTML = "<textarea id='clipContainer'/>";
		clipDoc.designMode = "On";
		clipDoc.body.contentEditable = true;
			
	}
    
    var clipDoc = getIFramDoc(clipFrame);

	// Get the clipboard container (input box) and set its contents
	var container = clipDoc.getElementById("clipContainer");
	container.value = textToCopy;

    // Show the clipboard iframe
	clipFrame.style.display = "";
    
	// Focus/Select the container containing the text to copy
	container.focus();
	container.select();

    // Hide the frame - use user won't see it at all
	clipFrame.style.display = "none";

	// Copy it - only works if have priviledges. Webkit doesn't complain.
    // IE does prompts the user, and always returns true even if the user denies access
	clipDoc.execCommand("copy", false, "");

	alert("Vágólapra másolva! Beillesztés: CTRL+V vagy jobb gomb -> Beillesztés");

}

function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}

function linkAlahuz(a, b, c) { /* ahol nincs kiszedve ez a függvény a régi tartalomból, ott ne jelezzen hibát */ }
/*
function fixselects_IE6() {
	if(document.all){//only ie 6
		if(window.XMLHttpRequest)return false;
			var selects=document.getElementsByTagName('select');
			for(var i=0;i<selects.length;i++){
				var dmr;
				var smallWidth=selects[i].clientWidth;
				selects[i].style.visibility="hidden";		
				selects[i].style.width="auto";
				var bigWidth=selects[i].clientWidth;
				selects[i].style.width=smallWidth;
				selects[i].style.visibility='visible';		
				if(selects[i].style.display==null){selects[i].style.display='static';}
				var defaultpos=selects[i].style.position;		
				if(selects[i].style.marginRight==null){dmr=0;}else{dmr=selects[i].style.marginRight;}
				
				if(bigWidth>smallWidth){	
				var theOptions=selects[i].getElementsByTagName('option');		
					selects[i].onmouseover=function(){this.style.width=bigWidth;this.style.marginRight="-"+(bigWidth-smallWidth);
													if(this.style.position!="absolute"){this.style.position="relative";}}
					selects[i].onmouseout=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;}
					selects[i].onclick=function(){this.onmouseout=function(){}}			
					selects[i].onblur=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;this.onmouseout=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;}}
					selects[i].onchange=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;	this.onmouseout=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;}}
				}}
	}
}

setTimeout('fixselects_IE6()', 500);
*/