/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function pdrt(pUrl, pData, pDiv, pFunction) {
    pFunction = pFunction || 0;

    $.ajax(
    {
        type: "POST",
        url: pUrl,
        data: pData,
        async: true,
        success: function(msg)
        {
            $("#" + pDiv).html(msg);
            if (pFunction != 0)
            {
                pFunction(msg);
            }
        }
    });
}

// syncron
function spdrt(pUrl, pData, pDiv, pFunction) {
    pFunction = pFunction || 0;

    $.ajax(
    {
        type: "POST",
        url: pUrl,
        data: pData,
        async: false,
        success: function(msg)
        {
            $("#" + pDiv).html(msg);
            if (pFunction != 0)
            {
                pFunction(msg);
            }
        }
    });
}

function gdrt(pUrl, pData, pDiv, pFunction) {
    pFunction = pFunction || 0;

    $.ajax(
    {
        type: "GET",
        url: pUrl,
        data: pData,
        async: true,
        success: function(msg)
        {
            $("#" + pDiv).html(msg);
            if (pFunction != 0)
            {
                pFunction(msg);
            }
        }
    });
}

// Syncron
function sgdrt(pUrl, pData, pDiv, pFunction) {
    pFunction = pFunction || 0;

    $.ajax(
    {
        type: "GET",
        url: pUrl,
        data: pData,
        async: true,
        success: function(msg)
        {
            $("#" + pDiv).html(msg);
            if (pFunction != 0)
            {
                pFunction(msg);
            }
        }
    });
}

function setDialog(id,title,x,y,callback)
{
    // ha van a DOM-ban id néven div akkor arra visszanyitjuk, ha nincs akkor készítünk egyet
    $(id).remove();
    if ( $(id).is('div') == false )
    {
        // levesszuk az # jelet
        id = id.substr(1, id.length-1 );
        $("<div id='"+id+"'></div>").appendTo("body");
        $('#'+id).html("<center><div><br />Loading ...<br /><br /><img src='/pics/jk/ajax-loader1.gif' /></div></center>");
        if ( x == "" ) {
            x = 'auto';
        }
        if ( y == "" ) {
            y = 'auto';
        }
        $('#'+id).dialog(
        {
            modal: true,
            title: title,
            // resizable: "diabled",
            width: x,
            height : y,
            overlay: {
                opacity: 0.45,
                background: '#000000'
            }
        });
    }
    else
    {
        $(id).html("<center><div><br />Kérem várjon ...<br /><img src='/pics/jk/ajax-loader1.gif' /></div></center>");
        $(id).dialog('open');
    }
    callback = callback || 0;
    if ( callback != 0 ) {
        callback.call();
    }
}
