function wk_ujraszamol(netto, brutto, afa) {

	var wk_pont = document.getElementById('wk_pont_text').value;
	var wk_pont_max = Number(document.getElementById('wk_pont_max').innerHTML);
	
	if (wk_pont > wk_pont_max)
	{
		document.getElementById('wk_pont').value = wk_pont = wk_pont_max;
		document.getElementById('wk_pont_text').value = wk_pont_max;
	} else {
		document.getElementById('wk_pont').value = wk_pont;
	}

	wk_brutto = Number(brutto) - Number(wk_pont);
	document.getElementById('wk_brutto_text').innerHTML = moneyFormat(wk_brutto.toString());
	wk_netto = Math.ceil(wk_brutto/afa);
	document.getElementById('wk_netto_text').innerHTML = moneyFormat(wk_netto.toString());
	
	//alert(document.getElementById('wk_pont').value);
	//alert(wk_netto.toString());
	//alert(wk_brutto.toString());
}

function moneyFormat(str)
{
	str += '';
	x = str.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + '.' + '$2');
	}
	return x1 + x2;
}


function onlyNumeric(mit)
{
//	mit.value = mit.value.replace(',', ".");
	var re = /[^0123456789]*/g;
	mit.value = mit.value.replace(re,""); 

}

function clearsearch() {
	if (document.getElementById('q').value.substring(0,5) == 'keres') document.getElementById('q').value = '';
}
function clearsearch2() {
	if (document.getElementById('q2').value.substring(0,5) == 'keres') document.getElementById('q2').value = '';
}
function zoom(pic) {
		 window.open('zoom.php?photo='+pic, 'ZOOM', 'scrollbars=no,status=no,location=no,toolbar=no,resizable=no,width=200,height=200');
}
function zoom4(mit,xx,yy) {
    window.open(mit, 'ZOOM4', 'scrollbars=yes,status=yes,location=no,toolbar=yes,resizable=yes,width='+xx+',height='+yy);
}

function setRowBg(sor, newclass) {
    if (newclass == '' || typeof(sor.style) == 'undefined') {
        return false;
    }
    
	if (typeof(document.getElementsByTagName) != 'undefined') {
        var cella = sor.getElementsByTagName('td');
    } else if (typeof(sor.cells) != 'undefined') {
        var cella = sor.cells;
    } else {
        return false;
    }

    var cellak  = cella.length;
    for (var c = 0; c < cellak; c++) {
        cella[c].className = newclass;
        //cella[c].style.cursor = 'pointer';
    }

    return true;
}