ÿþv a r   p r o d u c t F i l t e r O r i g i n a l T o p   =   0 ;  
  
 j Q u e r y ( d o c u m e n t ) . r e a d y ( f u n c t i o n ( )   {  
         i f   ( j Q u e r y ( ' . p r o d u c t F i l t e r ' ) . l e n g t h   >   0 )   {  
                 v a r   p r o d u c t I d   =   j Q u e r y ( ' . p r o d u c t F i l t e r ' ) . a t t r ( ' d a t a - p r o d u c t i d ' ) ;  
                 j Q u e r y ( ' . p r o d u c t F i l t e r ' ) . h i d e ( ) ;  
                 j Q u e r y . a j a x ( {  
                         u r l :   ' / p r o d u c t s / p r o d u c t s f r o n t e n d / p r o d u c t s f i l t e r a j a x / ? p r o d u c t i d = '   +   p r o d u c t I d ,  
                         s u c c e s s :   f u n c t i o n ( d a t a )   {  
                                 j Q u e r y ( ' # c o n t e n t ' ) . a f t e r ( d a t a ) ;  
                                 s e t u p A j a x F o r m ( j Q u e r y ( ' # s i d e b a r - m e n u ' ) ,   ' / p r o d u c t s / p r o d u c t s f r o n t e n d / p r o d u c t s f i l t e r a j a x r e s u l t / ? p r o d u c t i d = '   +   p r o d u c t I d ) ;  
                                 p r o d u c t F i l t e r O r i g i n a l T o p   =   j Q u e r y ( ' # s i d e b a r - m e n u ' ) . o f f s e t ( ) . t o p ;  
                                 i f   ( j Q u e r y ( ' # b a n n e r ' ) . l e n g t h   > =   1 )   {  
                                         i f   ( j Q u e r y ( ' # b a n n e r   e m b e d ' ) . l e n g t h   = =   0 )   {  
                                                 p r o d u c t F i l t e r O r i g i n a l T o p   + =   ( 2 8 6   /   2 ) ;  
                                         }  
                                 }  
  
                                 l a y o u t P r o d u c t F i l t e r ( ) ;  
  
                                 j Q u e r y ( w i n d o w ) . r e s i z e ( f u n c t i o n ( )   {  
                                         l a y o u t P r o d u c t F i l t e r ( ) ;  
                                 } ) ;  
  
                                 j Q u e r y ( w i n d o w ) . s c r o l l ( f u n c t i o n ( )   {  
                                         l a y o u t P r o d u c t F i l t e r ( ) ;  
                                 } ) ;  
                         }  
                 } ) ;  
         }  
  
         s e t U p D o w n l o a d T o g g l e ( ) ;  
 } ) ;  
  
 f u n c t i o n   l a y o u t P r o d u c t F i l t e r ( )   {  
 	 / / j Q u e r y ( ' # s i d e b a r - m e n u ' ) . c s s ( {   t o p :   j Q u e r y ( w i n d o w ) . s c r o l l T o p ( ) ,   r i g h t :   0 ,   p o s i t i o n :   ' r e l a t i v e ' ,   b a c k g r o u n d C o l o r :   ' # F F F F F F ' ,   z I n d e x :   9 9 9 9   } ) ;  
 	 i f   ( j Q u e r y ( w i n d o w ) . s c r o l l T o p ( )   > =   p r o d u c t F i l t e r O r i g i n a l T o p )  
 	 	 j Q u e r y ( ' # s i d e b a r - m e n u ' ) . o f f s e t ( {   t o p :   j Q u e r y ( w i n d o w ) . s c r o l l T o p ( )   } ) ;  
 	 e l s e  
 	 	 j Q u e r y ( ' # s i d e b a r - m e n u ' ) . o f f s e t ( {   t o p :   p r o d u c t F i l t e r O r i g i n a l T o p   } ) ;  
 }  
  
 f u n c t i o n   s e t u p A j a x F o r m ( e l e m , u r l )   {  
 	 v a r   c u r r e n t F o r m   =   e l e m . f i n d ( ' f o r m ' ) ;  
 	 e l e m . f i n d ( ' s e l e c t ' ) . c h a n g e ( f u n c t i o n ( e )   {  
 	 	 j Q u e r y . a j a x ( {  
 	 	 	 u r l :   u r l ,  
 	 	 	 t y p e :   ' P O S T ' ,  
 	 	 	 d a t a :   c u r r e n t F o r m . s e r i a l i z e ( ) ,  
 	 	 	 s u c c e s s :   f u n c t i o n ( d a t a )   {  
 	 	 	 	 j Q u e r y ( ' # c o n t e n t   f o r m ' ) . r e m o v e ( ) ;  
 	 	 	 	 j Q u e r y ( ' # c o n t e n t   d i v . c l e a r : e q ( 1 ) ' ) . a f t e r ( d a t a ) ;  
 	 	 	 	 j Q u e r y ( w i n d o w ) . s c r o l l T o p ( j Q u e r y ( ' # p r o d u c t L i s t ' ) . o f f s e t ( ) . t o p ) ;  
 	 	 	 	 l a y o u t P r o d u c t F i l t e r ( ) ;  
 	 	 	 }  
 	 	 } ) ;  
 	 } ) ;  
 }  
  
 f u n c t i o n   s e t U p D o w n l o a d T o g g l e ( )   {  
         j Q u e r y ( ' # s e l e c t A l l ' ) . v a l ( " A l l " ) ;  
         j Q u e r y ( ' # s e l e c t A l l ' ) . c l i c k ( f u n c t i o n ( e v e n t )   {  
                 i f   ( j Q u e r y ( ' # s e l e c t A l l ' ) . v a l ( )   = =   " A l l " )   {  
                         t o g g l e C h e c k e d ( ' c h e c k e d ' ) ;  
                         j Q u e r y ( ' # s e l e c t A l l ' ) . v a l ( " N o n e " ) ;  
                 }   e l s e   {  
                         t o g g l e C h e c k e d ( n u l l ) ;  
                         j Q u e r y ( ' # s e l e c t A l l ' ) . v a l ( " A l l " ) ;  
                 }  
                 e v e n t . p r e v e n t D e f a u l t ( ) ;  
         } ) ;  
 }  
  
 f u n c t i o n   t o g g l e C h e c k e d ( s t a t u s )   {  
         j Q u e r y ( " # D o w n l o a d s   : c h e c k b o x " ) . e a c h ( f u n c t i o n ( )   {  
                 j Q u e r y ( t h i s ) . a t t r ( " c h e c k e d " ,   s t a t u s ) ;  
         } )  
 } 
