function myAjax(destanation, element)
{
    if (typeof SpawEngine == 'undefined')
    {
        
    } 
    else
    {
        SpawEngine.updateFields();    
    }
    
    $.php(destanation, $(element).serialize());
    return false;
}

function activeConfirmDelete()
{
   jQuery.each($('a:regex(href,delete)'), function(i, val) 
   {
        var href = $(this).attr('href');
        
        $(this).click(function()
        {
            if (confirm("Вы действительно хотите удалить?"))
            {
                window.location = href;
            }
        });
        
        $(this).attr('href','javascript:void(0)');              
   });                
}

function search(destanation, element)
{
    $.post('/admin/users/searchresult/', $(element).serialize() , function(data)
    {
        $("#search_result").html(data);
    });
        
    return false;
}

function massChecker(complexName, element)
{
    $('[name="'+ complexName +'\[\]"]').attr('checked', $(element).attr('checker') );
}

/* ПрогрессБар */
function progress(element,percent)
{
    $('#' + element).progressBar(percent,{width:311,height:11,boxImage: '/design/modules/jqueryprogressbar/images/progressbar2.gif',barImage: '/design/modules/jqueryprogressbar/images/progressbar.png'});        
}

/* Обновить каптчу */
function MyUpdateCaptcha()
{
     $.getJSON
     (
         '/index/captcha', {}, function(json)
         {
             $('#captchaPlace').html( json.html )
             $('#captcha_id').val(json.id);
             $('#captcha').val('');
         }
     );
}

 function setMode(value)
 {            
    $.post('/index/mode/value/' + value, {}, function()
    {
        switch(value)
        {
            case 'news':
                window.location = '/';
            break;
            
            case 'bleat':
                window.location = '/bleat/index/';
            break;                    
            
            case 'films':
                window.location = '/films/index/';
            break;
        }
    });
 }

function preLoading()
{
    $('input').attr('disabled',true);
    var w = $(document).width();
    var h = $(document).height();
    $('#loading').css('left',w/2-100+"px").css('top',h/2-25+"px").show();
}

function postLoading()
{
    $('input').attr('disabled',false);
    $('#loading').hide();        
    $('.myDisabled').attr('disabled',true);        
}
