/**
 *
 *
 */
function getHtmlData( elem, ajaxString, callback, method )
{

    // in most cases it is element ID, in other cases - object of jQuery
    if (typeof elem == 'string')
        elem = '#' + elem; // create selector from ID
    
    var $block = $(elem);

    var blockPos = $block.css('position');
    
	$block.css('position', 'relative'); // set temporarily for displaying "loading icon"
    
    var $loadingDiv = $(
        '<div class="loading_ajax">' +
            '<img style="margin-top: 16px;" alt="Loading..." src="' + loadingImage + '" />' +
        '</div>'
    )
    .appendTo($block);

 	var iLeftOff = $block.width()  / 2 - ($loadingDiv.find('img:first').width()  / 2);
	var iTopOff  = $block.height() / 2 - ($loadingDiv.find('img:first').height() / 2) + 10;
    if (iTopOff<0) iTopOff = 0;

    $loadingDiv.css({
        position: 'absolute',
        left: iLeftOff,
        top:  iTopOff,
        zIndex:100
	});


	var url = baseURL + "ajax.php?ajax=1&module="+moduleIdent+"&tool="+ajaxString+"&sid="+thisSID+"&target=inv_sess";


	if (undefined != method && (method == 'post' || method == 'POST')) {		

		$.post(url, function(data) {

			$block.html(data);

	        $block
			    .css('position', blockPos);
        
	        if (typeof callback == 'function')
			    callback.apply($block);
		});

	} else {
		$block.load(url, function() {
	        $(this)
			    .css('position', blockPos);
        
	        if (typeof callback == 'function')
			    callback.apply(this);
		});

	}
}
