$().ready(function(){
     $.blockUI.defaults.fadeIn = 100;
     $.blockUI.defaults.fadeOut = 100;
     
     $().ajaxStart(function(){
          $('#loader')
                    .css('top', '50%')
                    .css('left', (parseInt($(window).width()/2)-parseInt($('#loader').width()/2))+'px')
                    .show();
     });
     
     $().ajaxStop(function(){
          $('#loader').hide();
     });
     
     $('a.window').live('click', function(){
          var url = $(this).attr('href');
          url = url.split('.');
          url[url.length-2] += 'min';
          url = url.join('.');
          var width = $(this).attr('rel') != '' ? $(this).attr('rel') : '300px';
          $.ajax({
               url: url,
               method: 'GET',
               dataType: 'html',
               success: function(html) {
                    $('#modal div.content').html(html);
                     $.blockUI({
                         message: $('#modal'),
                         css:{ 
                              //width:auto,
                              width: '300px',
                              border: 'none'
                         
                         }
                     })
                    var blockWidth = parseInt(width) / 2;
                    var windowWidth =  parseInt($(window).width()) / 2;
                    $('div.blockMsg').css('left',(windowWidth-blockWidth)+'px')
               }
          });
          return false;
     });
     
     $('#modal span.close').live('click', function(){
          $.unblockUI();
     });
});