function ar(meret,termek)
{
	oid = "meret=" + meret;
	id = "ardiv";
	
	getData({modul: 'termek', func: 'ar_ajax', id_params: termek, get_params: oid, target_id: id, response_format: 'HTML', target_overwrite: 'true'});
}

 function digitsOnly(obj){
obj.value=obj.value.replace(/[^\d]/g,'');
obj.value=obj.value.replace(/^0/g,'');
//if (obj.value=='') obj.value='1';
}

function extra_n(e)
{
	$('extra_name').innerHTML = e.value;
}

function swap(from,to,baseuri)
{
	//alert(baseuri);
	from_file = $(from).src;
	from_type = from_file.replace(/\/[^\/]*\.[^\/]*$/g,'');
	from_type = from_type.replace(/[^\/]*\//g,'');
	from_type = from_type.replace(/_.*/,'');
	from_file = from_file.replace(/[^\/]*\//g,'');
	
	
	to_file = $(to).src;
	to_type = to_file.replace(/\/[^\/]*\.[^\/]*$/g,'');
	to_type = to_type.replace(/[^\/]*\//g,'');
	to_file = to_file.replace(/[^\/]*\//g,'');

	//alert(from_type);
	$(from).src = baseuri+to_type+"_ikon/"+to_file;
	$(to).src = baseuri+from_type+"/"+from_file;
	
	$('big_link').href = baseuri+from_type+"_nagy/"+from_file;
	
	if (from_type=='normal' || from_type == 'hatul')
	{
		$('fordit').style.display = 'block';
	}
	else
	{
		$('fordit').style.display = 'none';
	}
}

function set_ar(meret)
{
	uj_ar = $('ar_'+meret.value).value;
	$('ar').innerHTML = uj_ar;
	set_extra_ar($('extra'));
	//alert(uj_ar);
}

function set_extra_ar(extra)
{
	most = $('ar').innerHTML;
	extra_ar = $('ar_extra').value == '' ? 0 : $('ar_extra').value;
	//uj = parseInt(most) + parseInt(extra_ar);
	if (extra.checked)
	{
	$('ar').innerHTML = parseInt(most) + parseInt(extra_ar);
	}
	else
	{
		
	$('ar').innerHTML = $('ar_'+$('_meret').value).value;
	}
}

function front_back(normal,hatul,normal_nagy,hatul_nagy)
{
	from_file = $('big').src;
	from_type = from_file.replace(/\/[^\/]*\.[^\/]*$/g,'');
	from_type = from_type.replace(/[^\/]*\//g,'');
	from_type = from_type.replace(/_.*/,'');
	//from_file = from_file.replace(/[^\/]*\//g,'');
	
	//to_type = from_type=='normal' ? 'hatul' : 'normal';
	
	$('big').src = from_type=='normal' ? hatul : normal;
	$('big_link').href = from_type=='normal' ? hatul_nagy : normal_nagy;
}

function del_kosar(id)
{
	_id = "kosar_div";
	
	getData({modul: 'kosar', func: 'del_ajax', id_params: id, target_id: _id, response_format: 'HTML', target_overwrite: 'true'});
}

function set_statusz(id)
{
	$('set_'+id).style.display = 'block';
	$('statusz_'+id).style.display = 'none';
	
}

function set_stat(_this,id)
{
   	oid = "statusz=" + _this.value;
	_target_id = "ajax_re_"+id;
	$(_target_id).innerHTML = 'friss&iacute;t&eacute;s..';
	
	getData({modul: 'kosar', func: 'set_statusz', id_params: id, get_params: oid, target_id: _target_id, response_format: 'HTML', target_overwrite: 'true'});

}

function checkall(_this)
{
	var form = document.forms['table_form'];
	for (i=0; i<form.length; i++)
	form[i].checked = _this.checked;
}

function check_true(id)
{
	if (!document.getElementById(id).checked) document.getElementById(id).checked = true;
}

function check_false(id)
{
	if (document.getElementById(id).checked) document.getElementById(id).checked = false;
}

function filter(attr,max)
{
	filter_ = document.getElementById(attr).value;
	if (filter_ == "") { none();}
		var form = document.forms['table_form'];

	for (i=1000; i<max+1; i++)
	{
		//alert(i);
		id = attr+"_"+i;
		if (document.getElementById(id))
		{
			if(document.getElementById(id).innerHTML.match(filter_))
			{ check_true('ch['+i+']');}
			else
			{ check_false('ch['+i+']');}
		}
	}
}

function none()
{
	var form = document.forms['table_form'];

	for (i=0; i<form.length; i++)
	form[i].checked = false;
}


function inactive(attr)
{
	
	document.getElementById(attr).className = "_inactive";
}

function active(attr,max)
{
	if (document.getElementById(attr).value != "") filter(attr,max);
	document.getElementById(attr).className = "_active";
}

function showfilter()
{
	document.getElementById('filter').style.display = document.getElementById('filter').style.display == "none" ? "block" : "none";

}

function reset(attr)
{
	document.getElementById(attr).value = "";
}

function copy_address()
{
	$('szallitasi_irsz').value = $('szamlazasi_irsz').value; 
	$('szallitasi_cim').value = $('szamlazasi_cim').value; 
	$('szallitasi_varos').value = $('szamlazasi_varos').value; 
}

function anyag()
{
	//$('anyag').style.display = $('anyag').style.display == 'block' ? 'none' : 'block';
	new Effect.toggle($('anyag'),'appear');
}
