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(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('_reloadselect.php', d, true, 'html', target_id, "$( target ).val("+ def +")");
}

function reloadCaptcha(id)
{
	document.getElementById('captcha_'+id).src = 'img/captcha.php?id='+id+'&'+Math.random();
}

function blankTarget()
{
    if(!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for(var i=0; i<anchors.length; i++)
    {
        var anchor = anchors[i];
        anchor.tabindex = i;
        if(anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
        {
            anchor.target = "_blank";
        }
    }
}

function kuss(z)
{
    var d = '';
    d += 'zene=' + z;

    ajax('_zene.php', d, true);
}

$(document).ready(function() {
	blankTarget();
});
