        $.easing.elasout = function(x, t, b, c, d) {
            var s=1.70158;var p=0;var a=c;
            if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
            if (a < Math.abs(c)) { a=c; var s=p/4; }
            else var s = p/(2*Math.PI) * Math.asin (c/a);
            return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
        };



        function draw( counter, cont_id)
        {
        	if( $('#' + cont_id).length > 0 )
        	{

        		if(counter==0)
        			$('#' + cont_id).css('background-position', '0 0');
        		else
        			$('#' + cont_id).css('background-position', '0 -'+71*counter+'px');


        			//console.log(counter);

        		counter++; if(counter>=12)counter=0;

        		setTimeout( function(){ return draw(counter, cont_id); }, 80);
        	}
        }

    	ShowLocalWaitWindow = function ()
    	{

            if( $('#wait_ajax_executed').length > 0 )
            {
                $('#wait_ajax_executed').remove();
            }

            var obWaitMessage = document.body.appendChild(document.createElement('DIV'));

    		$(obWaitMessage).attr('id','wait_ajax_executed')/*.addClass('waitwindowlocal')*/.attr('style', 'background-image: url(/bitrix/templates/.default/images/progress3.png); background-repeat: no-repeat; background-position: 0 0; height: 71px; width: 71px; z-index:10000;').css('position','fixed').css({
    			/*top: container_offset.top - ($(obContainerNode).outerHeight(true) + $('body').scrollTop())/2 ,
    			left: container_offset.left + $(obContainerNode).outerWidth(true)/2*/
    			top: parseInt( $(window).height()/2 - 30),
    			left: parseInt( $(window).width()/2 )

    		});

    		draw(0, $(obWaitMessage).attr('id') );

    	}

        HideLocalWaitWindow = function ()
    	{
            if( $('#wait_ajax_executed').length > 0 )
            {
                $('#wait_ajax_executed').remove();
            }
    	}



    if (window.jsAjaxUtil)
    {
    	// переопределим метод jsAjaxUtil.ShowLocalWaitWindow()
    	jsAjaxUtil.ShowLocalWaitWindow = function (TID, cont, bShadow)
    	{
    	    $('#fancybox-tmp, #fancybox-loading, #fancybox-overlay, #fancybox-wrap').hide();

    		if( typeof cont == 'string' || typeof cont == 'object' && cont.constructor == String )
    			var obContainerNode = document.getElementById(cont);
    		else
    			var obContainerNode = cont;



    			var container_offset = $(obContainerNode).offset();
    			//console.log( 'container_offset.left ' + container_offset.left + '  container_offset.top ' + container_offset.top);
    			//console.log( '$(obContainerNode).outerHeight() ' + $(obContainerNode).outerHeight() + '  $(obContainerNode).outerWidth() ' + $(obContainerNode).outerWidth() );



    		var obWaitMessage = document.body.appendChild(document.createElement('DIV'));

    		$(obWaitMessage).attr('id','wait_' +  obContainerNode.id + '_' + TID)/*.addClass('waitwindowlocal')*/.attr('style', 'background-image: url(/bitrix/templates/shop/images/loader/progress3.png); background-repeat: no-repeat; background-position: 0 0; height: 71px; width: 71px;').css('position','fixed').css({
    			/*top: container_offset.top - ($(obContainerNode).outerHeight(true) + $('body').scrollTop())/2 ,
    			left: container_offset.left + $(obContainerNode).outerWidth(true)/2*/


    			top: parseInt( $(window).height()/2 - 30),
    			left: parseInt( $(window).width()/2 ),
                zIndex: 1000
    		});

    		draw(0, $(obWaitMessage).attr('id') );

    	}


        jsAjaxUtil.ScrollToNode = function(node)
        {

                if (typeof node == 'string' || typeof node == 'object' && node.constructor == String)
                var obNode = document.getElementById(node);
                else
                var obNode = node;

                //$.scrollTo( obNode, 1200, { /*onAfter:function(){ $.fancybox.center(); },*/ easing:'elasout' }  );//called after the first axis scrolled
                $.scrollTo( obNode, 800/*, { onAfter:function(){ $.fancybox.center(); }, easing:'elasout' } */ );//called after the first axis scrolled

        } 

}


