$().ready(function() {
   utils.jqueryAddons();
   utils.initStorage();
   utils.ie6FooterRightView();
   utils.jqueryValidateAddon();
   
   //Глобально
   $('ul.tabs').tabs();
   $('#holidays').find('script').remove();
   $('div.seo').seo();
   $('#submenu').submenu();
   $('#affiliatest-widget').addressBlock();
   $('div#content.addressPage').addressPage();
   $('.smp-saxo-data').saxoRates();
   $('select.select-url').selectUrl();
   $('#new_client_select').click(function ()
   {
     var formUrl = this.href;
     $('#new-client-select-type-form').creditRequestForm({
       title: 'Стань клиентом: шаг 1',
       form_url: formUrl,
       width: 300,
       height: 133,
       on_open: function (slf)
       {
         slf.$form.find('input[name=req_type]').attr('checked',false);
       },
       on_init: function (slf)
       {
         slf.$form.find('input[name=req_type]').click(function (eObject)
         {
           slf.goToOtherCreditRequestForm('#new-client-form' + ((eObject.target.value == 'company') ? '-company' : ''), {
             title: 'Стань клиентом: шаг 2',
             form_url: (eObject.target.value == 'person') ? '/new_client' : '/new_client/company',
             validationKey: (eObject.target.value == 'person') ? 'new_client' : 'new_client_company',
             width: 800,
             height: (eObject.target.value == 'person') ? 1300 : 900,
             self_validation: true,
             on_init: function(slf)
             {
               $('#new-client-form' + ((eObject.target.value == 'person') ? '' : '-company')).newClientForm({
                 thisCRForm:slf
               });
               slf.resizeForContent();
             }
           });
         });
       }
     });
     return false;
   });
   
   widgetManager.initWidgets();

   // сортировка в каталогах
   $('#catalog-table table').tablesorter( {cssSort: 'jsort'} );

   // фильтрация в каталогах депозитов
   $('#combined-deposits, #deposits-rub, #deposits-dol, #deposits-eur, #deposits-all').catalogDeposit();

   //$('div.seo').seo();
   $('#deposit-calculator').depositCalculator();

   
   $('#content.cell').cellPage();
   
   $('#content form.cellRequest').cellRequestForm();
   
   $('#content form#business_credit_request').businessCreditForm();
   
   $('#content form#factoring_request').factoringForm();

   $('.deposit-request-form').depositRequestForm();

   $('#smp-fin-market').finmarket();

   //$(document).pngFix({ blankgif : '/img/blank.gif'});
   
   //$.feedbackForm.init();
   //$('#decor a').click(function(){$.feedbackForm.show();});
   
   
   if ($.browser.opera)
   {
      var $div = $('<div style="visibility:hidden; width: 1px; height: 1px"></div>');
      $("#content_wrap").append($div);
      $div.remove();
   }
   
   (typeof DD_belatedPNG != 'undefined') && DD_belatedPNG.fix('.png');
});

var globalCache = {};

var ajaxPost = $.post;
$.post = function(url, params)
{
   if (!jQuery.isFunction( params ))
   {
      params = params || {};
      for (var i in params)
         typeof params[i] === 'boolean' && (params[i] = Number(params[i]));
   }
   return ajaxPost.apply(this, arguments);
};

function popwin(url, sizes)
{
  var newwindowWidth  = (sizes && sizes[0]) ? sizes[0] : 500;
  var newwindowHeight = (sizes && sizes[1]) ? sizes[1] : 240;
  var newwindow=window.open(url,'name','height=' + newwindowHeight + ',width=' + newwindowWidth);
  if (window.focus) {newwindow.focus();}
}

