window.addEvent('scroll',function() {
            
            if($type($('basket')) == 'element') {
            
            
              var scrolledDown=$(document.body).getScroll().y.toInt();
              
                if($type( $('header_top')) == 'element')   var headerHeight = $('header_top').getSize().y.toInt()+ $('header').getSize().y.toInt()+10;
                else var headerHeight = $('header').getSize().y.toInt()+10;
                
              var BasketHeight=$('basket').getSize().y.toInt();
              var ContentHeight = $('content').getSize().y.toInt();
                          
               var BasketTop=$('basket').getCoordinates().top.toInt()-(headerHeight+10);           
                          
                            if(scrolledDown > headerHeight){
                             
                                  if(BasketTop > (ContentHeight-BasketHeight)){
                                                                        
                                           $('basket').set('morph', {onComplete: function(){}, duration: 10});
                                           $('basket').morph({top: ContentHeight-BasketHeight-55});
                                           
                                       }else{



                                           $('basket').set('morph', {onComplete: function(){
                                           
                                                BasketTop=$('basket').getCoordinates().top.toInt()-(headerHeight+10);      
                                                                     
                                               if(BasketTop > (ContentHeight-BasketHeight)){
                                                      $('basket').set('morph', {onComplete: function(){}, duration: 200});
                                                      $('basket').morph({top: ContentHeight-BasketHeight-55});
                                                 }
                                                 
                                           
                                           
                                           },duration: 200});
                                           $('basket').morph({top: scrolledDown-headerHeight});
                          
                                       }
                
                             }else {
                                  $('basket').set('morph', {onComplete: function(){}, duration: 200});
                                  $('basket').morph({top: 0});
                             }
                              
                              
            }
});
