
//érték ellenőrzése
function ert_ell(_val, _type, _length1, _length2) {
	switch (_type.toLowerCase()) {
		case 'szam':
				x = parseInt(_val, 10);
				if (!isNaN(x)) {
					if (x == _val) return true;
				}
				return false;
			break;
		case 'egyszam':
				zz = _val;
				for (x = 0;x < zz.length;x++) if (!isNaN(parseInt(zz.charAt(x)))) return true;
				return false;
			break;
		case 'egybetu':
				zz = _val;
				for (x = 0;x < zz.length;x++) if (isNaN(parseInt(zz.charAt(x)))) return true;
				return false;
			break;
		case 'minhossz':
				x = "_" + _val;
				if (x.length >= _length1 + 1) return true;
				return false;
			break;
		case 'maxhossz':
				x = '_' + _val;
				if (x.length <= _length1 + 1) return true;
				return false;
			break;
		case 'minmax':
				x = "_" + _val;
				if ((x.length >= _length1 + 1) && (x.length <= _length2 + 1)) return true;
				return false;
			break;
		case 'emailcim':
				var kukac = _val.indexOf('@');
				if (kukac < 1) return false;
				if (_val.length < kukac+3) return false;
				var vege = _val.substr(kukac+1);
				var vanbenne = false;
				if (kukac+1 == _val.length) return false;
				for (i=kukac+1;i<_val.length;i++)
					if (_val.charAt(i) == '.')
						vanbenne = i;
				if (!vanbenne) return false;
				if (_val.length-vanbenne < 3) return false;
				return true;
			break;
	}
}

function radio_ell(radio) {
	var checked = false;
	for (i=0;i<radio.length;i++)
		if (radio[i].checked)
			checked = true;
	return checked;
}

function ell(miben, szoveg) {
	if (miben.value == '') {
		//window.scrollBy(0,-10);
		uzenet(szoveg, miben);
		//miben.focus();
		return false;
	}
	return true;
}

function ell2(bool, miben, szoveg, scroll) {
	if (ell2.arguments[3] == undefined)
		scroll = false;
	if (bool == false) {
		if (scroll) {
			if (typeof(miben) == 'string' && miben.charAt(0) == '#')
				window.location = miben;
			else
				miben.scrollIntoView();
		}
		uzenet(szoveg, miben);
		return false;
	}
	return true;
}

function uzenet(str, obj) {
	mutat(true, str, obj);
}

function mutat(bool, uzenet, hova) {
	var layer = document.getElementById('uzenet').style;
	l = (screen.width/2)-(302/2);
	t = (screen.height/2)-(300/2)+document.documentElement.scrollTop;
	layer.left = l+'px';
	layer.top = t+'px';

	if (bool) {
		var td = document.getElementById('hibauzenet');
		td.innerHTML = uzenet;
		document.hova = hova;
	}
	layer.display = (bool) ? '' : 'none';
	elrejt(l, t, 302, 120, 'SELECT');
	if (!bool && document.hova != null) {
		if (typeof(document.hova) == 'string' && document.hova.charAt(0) == '#')
			window.location = document.hova;
		else
			document.hova.focus();
	}
}

function csakszam(_e) {
	var _key = (document.all) ? window.event.keyCode : 0;

	if (((_key > 47) && (_key < 58)) ||
		 ((_key > 95) && (_key < 106)) ||
		 (_key == 8) || (_key == 9) ||
		 (_key == 37) || (_key == 39) ||
		 (_key == 17) || (_key == 16) ||
		 (_key == 46) || (_key == 13) ||
		 (_key == 109) || (_key == 107)
		)
		return true;

	window.event.returnValue = false;
	return false;
}

function kugras(form,hol,hanykarakter,hova) {
	var _key = (document.all) ? window.event.keyCode : 0;

	if ((_key == 8) || (_key == 9) ||
		 (_key == 37) || (_key == 39) ||
		 (_key == 17) || (_key == 16) ||
		 (_key == 46) || (_key == 13))
		return true;
	if (form && hanykarakter && hova) {
		var df = document.forms[form];
		if (df[hol].value.length == hanykarakter)
			df[hova].focus();
	}
	return true;
}

function onlynum(_e) {
	var _key = (document.all) ? window.event.keyCode : 0;

	if (((_key > 47) && (_key < 58)) ||
		 ((_key > 95) && (_key < 106)) ||
		 (_key == 8) || (_key == 9) ||
		 (_key == 37) || (_key == 39) ||
		 (_key == 17) || (_key == 16) ||
		 (_key == 46) || (_key == 13))
		return true;

	window.event.returnValue = false;
	return false;
}

function elrejt(x, y, w, h, tipus) {
	var selx,sely,selw,selh,i;
	if (elrejt.arguments[4] == undefined)
		tipus = 'SELECT';
	var sel=document.body.getElementsByTagName(tipus);
	for(i=0;i<sel.length;i++){
		selx=0;
		sely=0;
		var selp;
		if (sel[i].offsetParent) {
			selp=sel[i];
			while (selp.offsetParent) {
				selp=selp.offsetParent;
				selx+=selp.offsetLeft;
				sely+=selp.offsetTop;
			}
		}
		selx+=sel[i].offsetLeft;
		sely+=sel[i].offsetTop;
		selw=sel[i].offsetWidth;
		selh=sel[i].offsetHeight;
		if (selx+selw>x && selx<x+w && sely+selh>y && sely<y+h) {
			if (sel[i].style.visibility != 'hidden')
				sel[i].style.visibility='hidden';
			else
				sel[i].style.visibility='';
		}
	}
}


function csakszam(_e) {
	var _key = (document.all) ? window.event.keyCode : 0;

	if (((_key > 47) && (_key < 58)) ||
		 ((_key > 95) && (_key < 106)) ||
		 (_key == 8) || (_key == 9) ||
		 (_key == 37) || (_key == 39) ||
		 (_key == 17) || (_key == 16) ||
		 (_key == 46) || (_key == 13) ||
		 (_key == 109) || (_key == 107)
		)
		return true;

	if (document.all)
		window.event.returnValue = false;
	return false;
}


