ÿþf u n c t i o n   G e t H t m l P o l l ( u r l ,   d i v )   {  
 v a r   h e i g h t d i v = $ ( d i v ) . h e i g h t ( ) ;  
         $ ( d i v ) . h t m l ( " < d i v   s t y l e = '   h e i g h t :   " + h e i g h t d i v + " p x ;   f l o a t : l e f t ;   w i d t h :   1 0 0 % ; ' > < c e n t e r > < i m g   s r c = ' / W e b / i m a g e s / l o a d i n g 7 . g i f '   a l t = ' l o a d i n g . . . '   / > < / c e n t e r > < / d i v > " )  
          
 / /         $ ( d i v ) . h t m l ( ' < c e n t e r > . . . a n g   t £i   d ï  l i Çu   t ë  H Ç  t h Ñn g . . . < / c e n t e r > ' )  
         $ . g e t ( e n c o d e U R I ( u r l ) , f u n c t i o n ( d a t a ) {  
                 / / g e t   r e s p o n s e   t e x t   o n l y  
                 v a r   s   =   d a t a . i n d e x O f ( ' < r e s p o n s e T e x t > ' )  
                 v a r   t   =   d a t a . i n d e x O f ( ' < / r e s p o n s e T e x t > ' )  
                 v a r   r e s p o n s e   =   d a t a . s u b s t r i n g ( s   +   1 6 ,   t )                  
                
                 $ ( d i v ) . f a d e O u t ( ' f a s t ' )  
                 $ ( d i v ) . h t m l ( r e s p o n s e )  
                 $ ( d i v ) . f a d e I n ( ' f a s t ' )  
         } )  
 }  
 f u n c t i o n   f o r m _ c r e a t e p o l l ( )  
 {  
         v a r   w i n _ w = w i n d o w . i n n e r W i d t h   ?   w i n d o w . i n n e r W i d t h   :   d o c u m e n t . b o d y . o f f s e t W i d t h ;  
         v a r   l e f t W p x = ( w i n _ w - 6 0 0 ) / 2 + ' p x '  
         $ . b l o c k U I ( { m e s s a g e :   $ ( ' # u c _ c r e a t e p o l l ' ) ,   c s s :   {   b a c k g r o u n d C o l o r :   ' g r a y ' , l e f t : l e f t W p x   } } ) ;  
 }  
 f u n c t i o n   c r e a t e _ p o l l ( q u e s t i o n i d , b l o c k m o d e i d , a c t i v e i d )  
 {  
         v a r   q u e s t i o n = $ ( " # " + q u e s t i o n i d ) . v a l ( )  
         v a r   b l o c k m o d e = ' '  
         v a r   a c t i v e = 0 ;  
         $ ( " # " + b l o c k m o d e i d + "   i n p u t [ t y p e = ' r a d i o ' ]   " ) . e a c h ( f u n c t i o n   ( ) {  
                  
                 i f ( $ ( t h i s ) . a t t r ( ' c h e c k e d ' ) = = t r u e )  
                 {  
                         b l o c k m o d e = $ ( t h i s ) . a t t r ( ' v a l u e ' )  
                 }  
         } )  
         i f ( $ ( " # " + a c t i v e i d ) . a t t r ( ' c h e c k e d ' ) = = t r u e )  
         {  
                 a c t i v e   =   1  
         }  
         / /   g e t   c h o i c e s  
         v a r   l s t _ c h o i c e s = ' '  
         $ ( " # f o r m _ f i e l d C h o i c e   i n p u t [ t y p e = ' t e x t ' ] " ) . e a c h ( f u n c t i o n   ( ) {  
                 l s t _ c h o i c e s + = e n c o d e U R I C o m p o n e n t ( $ ( t h i s ) . v a l ( ) ) + " ; "  
         } )  
         / / e n d  
         v a r   u r l = " / M o d u l e s / P o l l / C P / A j a x C p / A j a x C P . a s p x ? c t r l = . . / U s e r C o n t r o l l s / C r e a t e P o l l & q = " + e n c o d e U R I C o m p o n e n t ( q u e s t i o n ) + " & b m = " + b l o c k m o d e + " & a c t = " + a c t i v e + " & l s t = " + l s t _ c h o i c e s        
         G e t H t m l P o l l ( u r l , " # u c _ c r e a t e p o l l " )  
         v a r   u r l = " / M o d u l e s / P o l l / C P / A j a x C p / A j a x C P . a s p x ? c t r l = . . / U s e r C o n t r o l l s / P _ L i s t A l l "  
         G e t H t m l P o l l ( u r l , " # u c _ p l i s t a l l " )                                  
 }  
 f u n c t i o n   R e m o v e F i e l d ( f i e l d i d )  
 {  
         $ ( " # " + f i e l d i d ) . r e m o v e ( )  
         s h o w F i e l d I n d e x s ( )  
 }  
 f u n c t i o n     s h o w F i e l d I n d e x s ( )  
 {  
       v a r   i   =   0 ;  
         $ ( " # f o r m _ f i e l d C h o i c e   s p a n " ) . e a c h ( f u n c t i o n   ( ) {  
                 i + + ;  
                 $ ( t h i s ) . h t m l ( " L ña   c h Ín   "   +   i + " : " )   ;  
         } ) ;  
          
 }  
 f u n c t i o n   a d d F i e l d ( )  
 {  
         v a r   i = 0  
         v a r   j = 5 0 0 0  
         $ ( " # f o r m _ f i e l d C h o i c e   s p a n " ) . e a c h ( f u n c t i o n   ( ) {  
                 i + + ;  
                 j + + ;  
                 } ) ;  
         i = i + 1  
         $ ( " # f o r m _ f i e l d C h o i c e " ) . a p p e n d ( " < d i v   c l a s s = ' i t e m _ p o l l '   i d = ' f i e l d " + j + " '   > < s p a n   c l a s s = ' n a m e ' > L ña   c h Ín   " + i + " :   < / s p a n > < d i v   c l a s s = ' v a l u e ' > < i n p u t   i d = ' c h o i c e " + j + " '   t y p e = ' t e x t '   s t y l e = '   w i d t h : 2 2 0 p x ; '   / > < a   h r e f = ' j a v a s c r i p t : ; '   o n c l i c k = \ " R e m o v e F i e l d ( ' f i e l d " + j + " ' )   > L o ¡i   b Ï< / a > < / d i v > < / d i v > < p   c l a s s = ' c l e a r ' > < / p > " ) ;  
 }  
 f u n c t i o n   a d d F i e l d I n U p d a t e F o r m ( )  
 {  
         v a r   j = 0 ;  
         $ ( " # l o a d d i n g _ o l d c h o i c e s   i n p u t [ t y p e = ' t e x t ' ] " ) . e a c h ( f u n c t i o n   ( ) {  
                 j + + ;  
                 } ) ;  
         v a r   i = 1 ;  
         $ ( " # f o r m _ n e w i t e m   s p a n " ) . e a c h ( f u n c t i o n   ( ) {  
                 i + + ;  
                 } ) ;  
         v a r   t o t a l n e w = 0 ;  
         t o t a l n e w = j +   i  
         $ ( " # f o r m _ n e w i t e m " ) . a p p e n d ( " < d i v   c l a s s = ' i t e m _ p o l l '   i d = ' f i e l d " + t o t a l n e w + " '   > < s p a n   c l a s s = ' n a m e ' > L ña   c h Ín   " + t o t a l n e w + " :   < / s p a n > < d i v   c l a s s = ' v a l u e ' > < i n p u t   i d = ' c h o i c e " + t o t a l n e w + " '   t y p e = ' t e x t '   s t y l e = '   w i d t h : 2 2 0 p x ; '   / > < a   h r e f = ' j a v a s c r i p t : ; '   o n c l i c k = \ " R e m o v e F i e l d I n U p d a t e F o r m ( ' f i e l d " + t o t a l n e w + " ' )   > L o ¡i   b Ï< / a > < / d i v > < / d i v > < p   c l a s s = ' c l e a r ' > < / p > " ) ;  
 }  
 f u n c t i o n   R e m o v e F i e l d I n U p d a t e F o r m ( f i e l d i d )  
 {  
           $ ( " # " + f i e l d i d ) . r e m o v e ( )  
                 s h o w F i e l d I n d e x s I n U p d a t e F o r m ( )  
 }  
 f u n c t i o n   s h o w F i e l d I n d e x s I n U p d a t e F o r m ( )  
 {  
           v a r   j = 0 ;  
         $ ( " # l o a d d i n g _ o l d c h o i c e s   i n p u t [ t y p e = ' t e x t ' ] " ) . e a c h ( f u n c t i o n   ( ) {  
                 j + + ;  
                 } ) ;  
         v a r   i   =   j ;  
         $ ( " # f o r m _ n e w i t e m   s p a n " ) . e a c h ( f u n c t i o n   ( ) {  
                 i + + ;  
                 $ ( t h i s ) . h t m l ( " L ña   c h Ín   "   +   i + " : " )   ;  
         } ) ;  
 }  
 f u n c t i o n   D e l e t e P o l l ( q u e s t i o n , p o l l i d )  
 {  
     v a r   i n p u t _ b o x =   c o n f i r m ( ' B ¡n   c ó   m u Ñn   x ó a   B ì n h   c h Ín :   ' + d e c o d e U R I C o m p o n e n t ( q u e s t i o n ) ) ;  
       i f ( i n p u t _ b o x = = t r u e )  
       {  
                 v a r   u r l = " / M o d u l e s / P o l l / C P / A j a x C p / A j a x C P . a s p x ? c t r l = . . / U s e r C o n t r o l l s / P _ L i s t A l l & a c t i o n = d e l & p o l l i d = " + p o l l i d  
                 G e t H t m l ( u r l , " # u c _ p l i s t a l l " )      
       }  
       e l s e  
       {  
                 a l e r t ( ' B ¡n   ã   h çy   t á c   v å  X ó a ! ' )  
       }  
 }  
 f u n c t i o n   v o t i n g ( p o l l i d , b l o c k m o d e i d )  
 {  
         v a r   i d v a l u e = $ ( " # " + p o l l i d ) . v a l ( )  
         v a r   c h o i c e d s e l e c t e d = ' '  
         $ ( " # u c _ p o l l b o x   i n p u t [ t y p e = ' r a d i o ' ]   " ) . e a c h ( f u n c t i o n ( ) {  
                   i f ( $ ( t h i s ) . a t t r ( ' c h e c k e d ' ) = = t r u e )  
                 {  
                         c h o i c e d s e l e c t e d = $ ( t h i s ) . a t t r ( ' i d ' )  
                 }  
         } )  
         i f ( c h o i c e d s e l e c t e d ! = ' ' )  
         {  
                 v a r   u r l = " / W e b / A j a x W e b . a s p x ? c t r l = / M o d u l e s / P o l l / W e b / P o l l _ b o x & a c t i o n = v o t i n g & p o l l i d = " + i d v a l u e + ' & c h o i c e i d = ' + c h o i c e d s e l e c t e d + ' & b m = ' + b l o c k m o d e i d  
                 G e t H t m l P o l l ( u r l , " # u c _ p o l l b o x " )          
         }  
         e l s e  
                 a l e r t ( ' H ã y   c h Ín   ý   k i ¿n   c ça   b ¡n ! ' )  
 }  
   f u n c t i o n   a n i m a t e R e s u l t s ( ) 
         { 
         $ ( " # u c _ p o l l b o x   i m g " ) . e a c h ( f u n c t i o n ( ) 
         { 
                 v a r   p e r c e n t a g e   =   $ ( t h i s ) . a t t r ( " v a l " ) ; 
                 $ ( t h i s ) . c s s ( { w i d t h :   " 0 % " } ) . a n i m a t e ( { w i d t h :   p e r c e n t a g e } ,   ' s l o w ' ) ;    
         } ) ;  
 }  
 f u n c t i o n   f o r m _ u p d a t e p o l l ( p i d )  
 {  
               v a r   w i n _ w = w i n d o w . i n n e r W i d t h   ?   w i n d o w . i n n e r W i d t h   :   d o c u m e n t . b o d y . o f f s e t W i d t h ;  
         v a r   l e f t W p x = ( w i n _ w - 6 0 0 ) / 2 + ' p x '  
         v a r   u r l = " / M o d u l e s / P o l l / C P / A j a x C p / A j a x C P . a s p x ? c t r l = . . / U s e r C o n t r o l l s / U p d a t e P o l l & p o l l i d = " + p i d  
         G e t H t m l ( u r l , " # u c _ u p d a t e p o l l " )    
         $ . b l o c k U I ( { m e s s a g e :   $ ( ' # u c _ u p d a t e p o l l ' )     ,   c s s :   {   b a c k g r o u n d C o l o r :   ' g r a y ' ,   l e f t : l e f t W p x   } } ) ;  
 }  
 f u n c t i o n   u p d a t e _ p o l l ( p i d , q i d , b m i d , a c t i d )  
 {  
         v a r   q u e s t i o n = $ ( " # " + q i d ) . v a l ( )  
         v a r   b l o c k m o d e = ' '  
         v a r   a c t i v e = 0 ;  
         $ ( " # " + b m i d + "   i n p u t [ t y p e = ' r a d i o ' ]   " ) . e a c h ( f u n c t i o n   ( ) {  
                  
                 i f ( $ ( t h i s ) . a t t r ( ' c h e c k e d ' ) = = t r u e )  
                 {  
                         b l o c k m o d e = $ ( t h i s ) . a t t r ( ' v a l u e ' )  
                 }  
         } )  
         i f ( $ ( " # " + a c t i d ) . a t t r ( ' c h e c k e d ' ) = = t r u e )  
         {  
                 a c t i v e   =   1  
         }  
         / /   g e t   c h o i c e s  
         v a r   l s t _ o l d c h o i c e s = ' '  
         $ ( " # l o a d d i n g _ o l d c h o i c e s   i n p u t [ t y p e = ' t e x t ' ] " ) . e a c h ( f u n c t i o n   ( ) {  
                 v a r   i d _ c h o i c e b a s e = $ ( t h i s ) . a t t r ( ' i d v a l u e ' )  
                 v a r   i d i d i d = $ ( t h i s ) . a t t r ( ' i d ' )  
                 i f ( i d _ c h o i c e b a s e . i n d e x O f ( ' _ p ' ) > - 1 )  
                 {  
                         v a r   c h o i c e _ i d = i d _ c h o i c e b a s e . s u b s t r i n g ( 0 , i d _ c h o i c e b a s e . i n d e x O f ( ' _ p ' ) )  
                         v a r   c h o i c e _ v a l u e = $ ( ' # ' + i d i d i d ) . v a l ( )  
                         l s t _ o l d c h o i c e s   + = c h o i c e _ i d + ' , ' + e n c o d e U R I C o m p o n e n t ( c h o i c e _ v a l u e ) + ' ; '  
                 }  
         } )  
          
         v a r   l s t _ n e w c h o i c e s = ' '  
         $ ( " # f o r m _ n e w i t e m   i n p u t [ t y p e = ' t e x t ' ] " ) . e a c h ( f u n c t i o n   ( ) {  
                 l s t _ n e w c h o i c e s + = e n c o d e U R I C o m p o n e n t ( $ ( t h i s ) . v a l ( ) ) + " ; "  
         } )  
         / / e n d  
         v a r   u r l = " / M o d u l e s / P o l l / C P / A j a x C p / A j a x C P . a s p x ? c t r l = . . / U s e r C o n t r o l l s / U p d a t e P o l l & p o l l i d = " + p i d + " & q = " + e n c o d e U R I C o m p o n e n t ( q u e s t i o n ) + " & b m = " + b l o c k m o d e + " & a c t = " + a c t i v e + " & l s t _ o l d = " + l s t _ o l d c h o i c e s + " & l s t _ n e w = "       + l s t _ n e w c h o i c e s  
         G e t H t m l P o l l ( u r l , " # u c _ u p d a t e p o l l " )  
         v a r   u r l = " / M o d u l e s / P o l l / C P / A j a x C p / A j a x C P . a s p x ? c t r l = . . / U s e r C o n t r o l l s / P _ L i s t A l l "  
         G e t H t m l P o l l ( u r l , " # u c _ p l i s t a l l " )    
 }  
 f u n c t i o n   d e l e t e _ c h o i c e ( c h o i c e i d , c h o i c e n a m e , p o l l i d )  
 {  
           v a r   i n p u t _ b o x =   c o n f i r m ( " B ¡n   c ó   m u Ñn   x ó a   L ña   c h Ín :   " + d e c o d e U R I C o m p o n e n t ( c h o i c e n a m e ) ) ;  
       i f ( i n p u t _ b o x = = t r u e )  
       {  
                 v a r   u r l = ' / M o d u l e s / P o l l / C P / A j a x C p / A j a x C P . a s p x ? c t r l = . . / U s e r C o n t r o l l s / L o a d _ O l d C h o i c e s & a c t = d e l & c i d = ' + c h o i c e i d + ' & p o l l i d = ' + p o l l i d  
                 G e t H t m l ( u r l ,   " # l o a d d i n g _ o l d c h o i c e s " )          
                 v a r   u r l = " / M o d u l e s / P o l l / C P / A j a x C p / A j a x C P . a s p x ? c t r l = . . / U s e r C o n t r o l l s / P _ L i s t A l l "  
                 G e t H t m l P o l l ( u r l , " # u c _ p l i s t a l l " )    
       }  
       e l s e  
       {  
                 a l e r t ( ' B ¡n   ã   h çy   t á c   v å  X ó a ! ' )  
       }  
 } 
