function ajax(url, data, async, type, target, readyfunction)
{
    if(typeof async == 'undefined')
    {
        async = true;
    }

    if(typeof type == 'undefined')
    {
        type = 'html';
    }

    $.ajax({
		type: "POST",
		url: url,
		data: data,
        dataType: type,
        async: async,
		complete: function(xhr) {
		    if(typeof target == 'undefined' && xhr.responseText != '')
            {
                //alert(xhr.responseText);
            }
            else if(typeof target != 'undefined')
            {
                $( target ).html( xhr.responseText );
                if(typeof readyfunction != 'undefined')
                {
                    eval(readyfunction);
                }
            }
		}
	});
}

function reload(file, val, table, target_id, def)
{
    var fk = $(val).attr('id');
    var selected = $(val).val();

    var d = '';
    d += 'fk=' + fk;
    d += '&selected=' + selected;
    d += '&table=' + table;
    d += '&def=' + def;

    ajax(file, d, true, 'html', target_id, "$( target ).val("+ def +")");
}