$(function() {
    $('.table .ajax-delete').live('click', function() {
        if ( confirm('Biztos, hogy törlöd?') ) {
            var that = $(this);

            $.getJSON($(this).attr('href'), null, function(ret) {
                if ( !ret.ok ) {
                    dialog(ret.mess);

                } else {
                    that.parents('tr').remove();
                }
            });
        }

        return(false);
    });

    $('.table tr').live('click', function() {

	var a = $('a', $(this)).eq(0);

        if ( !$(this).parent().parent().hasClass('tablednd') && a.attr('href') != undefined && !a.hasClass('delete') ) {
	    window.location = a.attr('href');
	}

    }).live('mouseover', function() 
    {
	$(this).addClass('selected');
    }).live('mouseout', function() 
    {
	$(this).removeClass('selected');    
    });
});

function urlencode (str) {
    str = (str + '').toString();

    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}


