ÿþ/ /   w F o r m s   -   a   j a v a s c r i p t   e x t e n s i o n   t o   w e b   f o r m s .  
 / /   v 0 . 9 9 . 1   -   M a y   2 6   2 0 0 5  
 / /   C o p y r i g h t   ( c )   2 0 0 5   C Ùd r i c   S a v a r e s e   < p r o @ 4 2 1 3 m i l e s . c o m >  
 / /   T h i s   s o f t w a r e   i s   l i c e n s e d   u n d e r   t h e   C C - G N U   L G P L   < h t t p : / / c r e a t i v e c o m m o n s . o r g / l i c e n s e s / L G P L / 2 . 1 / >  
 / /   O t h e r   C o n t r i b u t o r s :   M i c h a e l   D u f f   ( f u l l m o o n d e s i g n s . n e t )  
  
 / /   C h a n g e   L o g :   s e e   h t t p : / / f o r m a s s e m b l y . c o m / b l o g / w f o r m s - a - j a v a s c r i p t - e x t e n s i o n - t o - w e b - f o r m s /  
  
 / /   K n o w n   P r o b l e m s :  
 / /   	 	 S a f a r i   1 . x :     	 V a l i d a t i o n   D i s a b l e d .   N o   w a y   o f   k n o w i n g   i f   a   f i e l d   i s   v i s i b l e   o r   n o t   ( c f .   c h e c k V i s i b i l i t y ( ) )  
 / /   	 	 I E   5 . 2   M a c :   	 V a l i d a t i o n   D i s a b l e d .   c u r r e n t S t y l e . d i s p l a y   r e t u r n s   a n   e m p t y   s t r i n g   i n   c h e c k V i s i b i l i t y ( )   c a u s i n g   n o n - v i s i b l e   f i e l d s   t o   g e t   v a l i d a t e d .    
 / / 	 	 	 	 	 	 B u g g y   R e n d e r i n g   o f   t h e   R e p e a t   b e h a v i o r    
 / / 	 	 	 	 	 	 C o u n t e r   F i e l d   o f   R e p e a t   B e h a v i o r   n o t   s u b m i t t e d   ( p r o b a b l y   s e t t i n g   t h e   n a m e   a t t r i b u t e   d i d n ' t   w o r k )  
 / /   	 	 I E   5 . 0   P C : 	 	 R e p e a t   b e h a v i o r   d o e s n ' t   w o r k .   A l l   f i e l d   a r e   c r e a t e d   a s   T E X T   i n p u t   ?   T o   b e   c h e c k e d   a g a i n .  
  
  
 f u n c t i o n   w F O R M S ( )   {   / /   w F O R M S   C l a s s   C o n s t r u c t o r  
  
 	 v a r   w u   =   n e w   w U T I L I T Y ( ) ;  
 	 v a r   s e l f   =   t h i s ;  
  
 	 / /   C S S   c l a s s   n a m e   d e f i n i t i o n s .    
 	 t h i s . c l a s s N a m e P r e f i x _ s w i t c h 	 	 	 =   " s w i t c h " ;  
 	 t h i s . c l a s s N a m e _ s w i t c h I s O n   	 	 	 =   " s w t c h I s O n " ;   / /   u s e d   t o   k e e p   t r a c k   o f   t h e   s w i t c h   s t a t e   o n   b u t t o n s   a n d   l i n k s   ( w h e r e   t h e   c h e c k e d   a t t r i b u t e   i s   n o t   a v a i l a b l e )   ( a d d e d   i n   v 0 . 9 7 )  
 	 t h i s . c l a s s N a m e P r e f i x _ o f f S t a t e 	 	 =   " o f f s t a t e " ;  
 	 t h i s . c l a s s N a m e P r e f i x _ o n S t a t e 	 	 =   " o n s t a t e " ;  
 	 t h i s . c l a s s N a m e _ r e p e a t   	 	 	 	 =   " r e p e a t " ;  
 	 t h i s . c l a s s N a m e _ d e l e t e   	 	 	 	 =   " r e m o v e a b l e " ;  
 	 t h i s . c l a s s N a m e _ r e q u i r e d   	 	 	 =   " r e q u i r e d " ;  
 	 t h i s . c l a s s N a m e _ v a l i d a t i o n E r r o r _ m s g   	 =   " e r r M s g " ; 	 	    
 	 t h i s . c l a s s N a m e _ v a l i d a t i o n E r r o r _ f l d 	 =   " e r r F l d " ;      
 	 t h i s . c l a s s N a m e P r e f i x _ v a l i d a t i o n   	 =   " v a l i d a t e " ;  
 	 t h i s . c l a s s N a m e _ d u p l i c a t e L i n k   	 	 =   " d u p l i c a t e L i n k " ;  
 	 t h i s . c l a s s N a m e _ r e m o v e L i n k   	 	 	 =   " r e m o v e L i n k " ;  
 	 t h i s . c l a s s N a m e _ a c t i v e F i e l d H i n t   	 	 =   " f i e l d - h i n t " ;  
 	 t h i s . c l a s s N a m e _ i n a c t i v e F i e l d H i n t   	 =   " f i e l d - h i n t - i n a c t i v e " ;  
 	 t h i s . c l a s s N a m e _ p a g i n g 	 	 	 	 =   " w f P a g e " ;  
 	 t h i s . c l a s s N a m e _ p a g i n g C u r r e n t 	 	 =   " w f C u r r e n t P a g e " ;  
 	 t h i s . c l a s s N a m e _ p a g i n g B u t t o n s 	 	 =   " w f P a g e B u t t o n " ;  
 	 t h i s . c l a s s N a m e _ h i d e S u b m i t 	 	 	 =   " w f H i d e S u b m i t " ;  
 	 / /   i d   a t t r i b u t e   s u f f i x e s  
 	 t h i s . i d S u f f i x _ f i e l d H i n t   	 	 	 =   " - H " ;  
 	 t h i s . i d S u f f i x _ f i e l d L a b e l 	 	 	 =   " - L " ;  
 	 t h i s . i d S u f f i x _ f i e l d E r r o r 	 	 	 =   " - E " ;  
 	 t h i s . i d S u f f i x _ r e p e a t C o u n t e r 	 	 	 =   " - R C " ;  
 	 t h i s . i d S u f f i x _ d u p l i c a t e L i n k 	 	 	 =   " - w f D L " ; 	 	 / /   n o t   f u l l y   i m p l e m e n t e d   y e t  
 	 t h i s . i d P r e f i x _ p a g e I n d e x 	 	 	 	 =   " w f P g I n d e x - " ;  
  
 	 / /   B e h a v i o r   c o n f i g u r a t i o n   o p t i o n s  
 	 t h i s . p r e s e r v e R a d i o N a m e 	 	 	 	 =   t r u e ;   	 	 / /   i f   t r u e ,   R e p e a t   b e h a v i o r   w i l l   p r e s e r v e   n a m e   a t t r i b u t e s   f o r   r a d i o   i n p u t .    
 	 t h i s . s w i t c h S c o p e R o o t T a g 	 	 	 	 =   " F O R M " ; 	 	 / /   l i m i t   t h e   s c o p e   o f   t h e   s w i t c h   b e h a v i o r .   Y o u   m a y   u s e   ' B O D Y ' .  
 	  
 	 / /   F o r m   v a l i d a t i o n   f u n c t i o n   n a m e .   M a y   b e   o v e r i d d e n   i f   y o u   n e e d   t o   r u n   y o u r   o w n   v a l i d a t i o n   r o u t i n e   ( b u t   m a k e   s u r e   t o   r u n   f o r m V a l i d a t i o n ( )   i n   i t ) .  
 	 t h i s . f u n c t i o n N a m e _ f o r m V a l i d a t i o n   =   " t h i s . f o r m V a l i d a t i o n " ;  
 	 t h i s . s h o w A l e r t O n E r r o r   =   t r u e ;   / /   s e t   t o   f a l s e   t o   n o t   s h o w   t h e   a l e r t   w h e n   a   v a l i d a t i o n   e r r o r   o c c u r s .  
 	 t h i s . p r e v e n t S u b m i s s i o n O n E n t e r   =   f a l s e ;   / /   p r e v e n t   s u b m i s s i o n   w h e n   p r e s s i n g   t h e   ' e n t e r '   k e y .   S e t   t o   t r u e   i f   p a g i n a t i o n   b e h a v i o r   i s   u s e d .  
 	  
 	 / /   E r r o r   m e s s a g e s .   T h i s   a r r a y   m a y   b e   o v e r w r i t t e n   i n   a   s e p a r a t e   j s   f i l e   f o r   l o c a l i z a t i o n   o r   c u s t o m i z a t i o n   p u r p o s e .  
 	 t h i s . a r r E r r o r M s g   =   n e w   A r r a y ( ) ;    
 	 t h i s . a r r E r r o r M s g [ 0 ]   =   " E s t a   c a s i l l a   e s   o b l i g a t o r i a .   " ;   / /   r e q u i r e d  
 	 t h i s . a r r E r r o r M s g [ 1 ]   =   " E l   t e x t o   d e b e   e s t a r   c o m p u e s t o   s o l a m e n t e   d e   c a r a c t e r e s   a l f a b é t i c o s   ( a - z ,   A - Z ) .   " ;   	 / /   v a l i d a t e _ a l p h a  
 	 t h i s . a r r E r r o r M s g [ 2 ]   =   " D i r e c c i ó n   d e   c o r r e o   e l e c t r ó n i c o   n o   v a l i d a . " ; 	 	 	 	 	 	 	 	 	 / /   v a l i d a t e _ e m a i l  
 	 t h i s . a r r E r r o r M s g [ 3 ]   =   " I n t r o d u z c a   u n   n ú m e r o   e n t e r o   p o r   f a v o r   . " ; 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 / /   v a l i d a t e _ i n t e g e r  
 	 t h i s . a r r E r r o r M s g [ 4 ]   =   " I n t r o d u z c a   u n   n ú m e r o   p o r   f a v o r   ( e j .   1 . 9 ) . " ;  
 	 t h i s . a r r E r r o r M s g [ 5 ]   =   " C o n t r a s e ñ a   r i e s g o s a .   L a   c o n t r a s e ñ a   d e b e   t e n e r   e n t r e   4   y   1 2   c a r a c t e r e s ,   n u m é r i c o s   y   a l f a b é t i c o s ,   m a y ú s c u l a s   y   m i n ú s c u l a s . " ;  
 	 t h i s . a r r E r r o r M s g [ 6 ]   =   " P o r   f a v o r   u s e   c a r a c t e r e s   n u m é r i c o s   y   a l f a b é t i c o s   n a d a   m a s   ( a - z ,   0 - 9 ) . " ;  
 	 t h i s . a r r E r r o r M s g [ 7 ]   =   " E s t a   f e c h a   n o   e s   v a l i d a . " ;  
 	 t h i s . a r r E r r o r M s g [ 8 ]   =   " % %   e r r o r ( e s )   d e t e c t a d o ( s ) .   S u   f o r m u l a r i o   n o   f u e   r e g i s t r a d o .   P o r   f a v o r   c h e q u e   l a   i n f o r m a c i ó n   q u e   h a   s u m i n i s t r a d o . " ;   / /   % %   w i l l   b e   r e p l a c e d   b y   t h e   a c t u a l   n u m b e r   o f   e r r o r s .  
 	  
 	 / /   O t h e r   M e s s a g e s  
 	 t h i s . a r r M s g   =   n e w   A r r a y ( ) ;  
 	 t h i s . a r r M s g [ 0 ]   =   " A d d   a   r o w " ;   	 / /   r e p e a t   l i n k  
 	 t h i s . a r r M s g [ 1 ]   =   " R e p e a t s   t h e   p r e c e d i n g   f i e l d   o r   f i e l d   g r o u p . "   / /   t i t l e   a t t r i b u t e   o n   t h e   r e p e a t   l i n k    
 	 t h i s . a r r M s g [ 2 ]   =   " R e m o v e " ;   	 	 / /   r e m o v e   l i n k  
 	 t h i s . a r r M s g [ 3 ]   =   " R e m o v e s   t h e   p r e c e d i n g   f i e l d   o r   f i e l d   g r o u p . "   / /   t i t l e   a t t r i b u t e   o n   t h e   r e m o v e   l i n k  
 	 t h i s . a r r M s g [ 4 ]   =   " N e x t   P a g e " ;  
 	 t h i s . a r r M s g [ 5 ]   =   " P r e v i o u s   P a g e " ; 	  
 	 t h i s . u t i l i t i e s   =   w u ; 	  
 	  
  
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
 	 / /   S w i t c h   B e h a v i o r   M e t h o d s  
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
  
 	 / /   P r i v i l e g e d   I n s t a n c e   M e t h o d s  
 	 / / - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 t h i s . r e f r e s h A l l S t a t e s   =   f u n c t i o n ( f I d )   {  
 	 	 v a r   f = d o c u m e n t . g e t E l e m e n t B y I d ( f I d ) ;  
 	 	 i f ( ! f )   r e t u r n ;  
 	 	 / /   l o o p   t h r o u g h   t h e   f i e l d s  
 	 	 v a r   x   =   w u . g e t E l e m e n t s ( f ) ;  
 	 	 f o r   ( v a r   i = 0 ; i < x . l e n g t h ; i + + )   {  
 	 	 	 / /   a d d   s w i t c h / s t a t e   b e h a v i o r  
 	 	 	 i f   ( x [ i ] . t a g N a m e . t o U p p e r C a s e ( )   = =   " S E L E C T "   & &   w u . i s E v e n t H a n d l e d ( x [ i ] , ' c h a n g e ' )   )   { 	 	 	 	  
 	 	 	 	 t h i s . r e f r e s h S t a t e ( n u l l , x [ i ] ) ;  
 	 	 	 }  
 	 	 	 i f   ( x [ i ] . c l a s s N a m e   & &   x [ i ] . c l a s s N a m e . i n d e x O f ( t h i s . c l a s s N a m e P r e f i x _ s w i t c h )   ! =   - 1 )   { 	 	 	  
 	 	 	 	 s w i t c h ( x [ i ] . t a g N a m e . t o U p p e r C a s e ( ) )   {  
 	 	 	 	 	 c a s e   " O P T I O N " :  
 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 d e f a u l t :  
 	 	 	 	 	 	 t h i s . r e f r e s h S t a t e ( n u l l , x [ i ] ) ;  
 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 }  
 	 	 	 }  
 	 	 }  
 	 }  
 	  
 	 t h i s . r e f r e s h S t a t e   =   f u n c t i o n ( e )   {  
 	 	 i f ( ! e   & &   a r g u m e n t s . l e n g t h = = 2 )  
 	 	 	 v a r   s r c E   =   a r g u m e n t s [ 1 ] ;  
 	 	 e l s e  
 	 	 	 v a r   s r c E   =   w u . g e t S r c E l e m e n t ( e ) ;  
 	 	  
 	 	 s w i t c h ( s r c E . t a g N a m e . t o U p p e r C a s e ( ) )   {  
 	 	 	 c a s e   " S E L E C T " :  
 	 	 	 	  
 	 	 	 	 v a r   s e l e c t e d S t a t e C l a s s = " " ;  
 	 	 	 	 v a r   l o c a l S c o p e   =   s w i t c h S c o p e ( s r c E ) ;  
 	 	 	 	 f o r ( v a r   i = 0 ; i < s r c E . o p t i o n s . l e n g t h ; i + + )   {  
 	 	 	 	 	 i f ( s r c E . o p t i o n s [ i ] . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h )   ! =   - 1   )   {  
 	 	 	 	 	 	 v a r   s   =   s r c E . o p t i o n s [ i ] . c l a s s N a m e ;  
 	 	 	 	 	 	 s   =   s . s u b s t r ( s . i n d e x O f ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h ) ) . s p l i t ( "   " ) [ 0 ] . s u b s t r ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h . l e n g t h ) ;  
 	 	 	 	 	 	 v a r   o f f S t a t e C l a s s   =   s e l f . c l a s s N a m e P r e f i x _ o f f S t a t e   +   s ;  
 	 	 	 	 	 	 v a r   o n S t a t e C l a s s   =   s e l f . c l a s s N a m e P r e f i x _ o n S t a t e   +   s ; 	 	 	 	  
 	 	 	 	 	 	 i f ( i = = s r c E . s e l e c t e d I n d e x )   { 	 	 	 	 	  
 	 	 	 	 	 	 	 s w i t c h S t a t e ( l o c a l S c o p e ,   o f f S t a t e C l a s s ,   o n S t a t e C l a s s ) ;  
 	 	 	 	 	 	 	 s e l e c t e d S t a t e C l a s s   =   o n S t a t e C l a s s ;   / /   p r e v e n t s   f u r t h e r   s w i t c h i n g   o f f    
 	 	 	 	 	 	 }  
 	 	 	 	 	 	 e l s e   i f ( o n S t a t e C l a s s   ! =   s e l e c t e d S t a t e C l a s s )   {  
 	 	 	 	 	 	 	 s w i t c h S t a t e ( l o c a l S c o p e ,   o n S t a t e C l a s s ,   o f f S t a t e C l a s s ) ;  
 	 	 	 	 	 	 }  
 	 	 	 	 	 } 	 	 	  
 	 	 	 	 }  
 	 	 	 	 b r e a k ;  
 	 	 	 c a s e   " I N P U T " : 	  
 	 	 	 	 i f ( s r c E . t y p e . t o L o w e r C a s e ( )   = =   ' r a d i o ' )   {  
 	 	 	 	 	 / /   G o   t h r o u g h   t h e   r a d i o   g r o u p .  
 	 	 	 	 	 f o r ( v a r   i = 0 ; i   < s r c E . f o r m [ s r c E . n a m e ] . l e n g t h ; i + + )   {    
 	 	 	 	 	 	 v a r   r   =   s r c E . f o r m [ s r c E . n a m e ] [ i ] ;  
 	 	 	 	 	 	 i f ( r . c l a s s N a m e   & &   r . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h ) ! = - 1 )   {  
 	 	 	 	 	 	 	 v a r   s   =   r . c l a s s N a m e ;  
 	 	 	 	 	 	 	 s   =   s . s u b s t r ( s . i n d e x O f ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h ) ) . s p l i t ( "   " ) [ 0 ] . s u b s t r ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h . l e n g t h ) ;  
 	 	 	 	 	 	 	 v a r   o f f S t a t e C l a s s   =   s e l f . c l a s s N a m e P r e f i x _ o f f S t a t e   +   s ;  
 	 	 	 	 	 	 	 v a r   o n S t a t e C l a s s   =   s e l f . c l a s s N a m e P r e f i x _ o n S t a t e   +   s ; 	  
  
 	 	 	 	 	 	 	 i f ( r . c h e c k e d )    
 	 	 	 	 	 	 	 	 s w i t c h S t a t e ( s w i t c h S c o p e ( r ) ,   o f f S t a t e C l a s s ,   o n S t a t e C l a s s ) ;  
 	 	 	 	 	 	 	 e l s e   { 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 s w i t c h S t a t e ( s w i t c h S c o p e ( r ) ,   o n S t a t e C l a s s ,   o f f S t a t e C l a s s ) ;    
 	 	 	 	 	 	 	 } 	 	 	 	 	 	  
 	 	 	 	 	 	 }  
 	 	 	 	 	 }  
 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 v a r   s   =   s r c E . c l a s s N a m e ;  
 	 	 	 	 	 s   =   s . s u b s t r ( s . i n d e x O f ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h ) ) . s p l i t ( "   " ) [ 0 ] . s u b s t r ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h . l e n g t h ) ;  
 	 	 	 	 	 v a r   o f f S t a t e C l a s s   =   s e l f . c l a s s N a m e P r e f i x _ o f f S t a t e   +   s ;  
 	 	 	 	 	 v a r   o n S t a t e C l a s s   =   s e l f . c l a s s N a m e P r e f i x _ o n S t a t e   +   s ; 	  
  
 	 	 	 	 	 i f ( s r c E . c h e c k e d   | |    
 	 	 	 	 	     ( s r c E . t y p e . t o L o w e r C a s e ( )   = =   ' b u t t o n '   & &   s r c E   ! =   a r g u m e n t s [ 1 ]   & &   s r c E . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ s w i t c h I s O n )   = =   - 1   ) )   {   / /   & &   ! s r c E . d e f a u l t C h e c k e d  
 	 	 	 	 	 	 s w i t c h S t a t e ( s w i t c h S c o p e ( s r c E ) ,   o f f S t a t e C l a s s ,   o n S t a t e C l a s s ) ;  
 	 	 	 	 	 	 i f ( s r c E . t y p e . t o L o w e r C a s e ( )   = =   ' b u t t o n ' )   {  
 	 	 	 	 	 	 	 s r c E . c l a s s N a m e   + =   "   "   +   s e l f . c l a s s N a m e _ s w i t c h I s O n ;  
 	 	 	 	 	 	 }  
 	 	 	 	 	 }  
 	 	 	 	 	 e l s e   { 	 	 	 	 	 	 	  
 	 	 	 	 	 	 s w i t c h S t a t e ( s w i t c h S c o p e ( s r c E ) ,   o n S t a t e C l a s s ,   o f f S t a t e C l a s s ) ;    
 	 	 	 	 	 	 i f ( s r c E . t y p e . t o L o w e r C a s e ( )   = =   ' b u t t o n '   & &   s r c E   ! =   a r g u m e n t s [ 1 ] )   {  
 	 	 	 	 	 	 	 s r c E . c l a s s N a m e   =   s r c E . c l a s s N a m e . r e p l a c e ( s e l f . c l a s s N a m e _ s w i t c h I s O n , " " ) ;  
 	 	 	 	 	 	 }  
 	 	 	 	 	 }  
 	 	 	 	 }  
 	 	 	 	 b r e a k ;  
 	 	 	 d e f a u l t :    
 	 	 	 	 v a r   s   =   s r c E . c l a s s N a m e ;  
 	 	 	 	 s   =   s . s u b s t r ( s . i n d e x O f ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h ) ) . s p l i t ( "   " ) [ 0 ] . s u b s t r ( s e l f . c l a s s N a m e P r e f i x _ s w i t c h . l e n g t h ) ;  
 	 	 	 	 v a r   o f f S t a t e C l a s s   =   s e l f . c l a s s N a m e P r e f i x _ o f f S t a t e   +   s ;  
 	 	 	 	 v a r   o n S t a t e C l a s s   =   s e l f . c l a s s N a m e P r e f i x _ o n S t a t e   +   s ; 	  
 	 	 	 	 i f ( s r c E   ! =   a r g u m e n t s [ 1 ]   & &   s r c E . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ s w i t c h I s O n )   = =   - 1 )   {    
 	 	 	 	 	 s w i t c h S t a t e ( s w i t c h S c o p e ( s r c E ) ,   o f f S t a t e C l a s s ,   o n S t a t e C l a s s ) ;  
 	 	 	 	 	 s r c E . c l a s s N a m e   + =   "   "   +   s e l f . c l a s s N a m e _ s w i t c h I s O n ;  
 	 	 	 	 }  
 	 	 	 	 e l s e   i f ( s r c E   ! =   a r g u m e n t s [ 1 ] )   {  
 	 	 	 	 	 s w i t c h S t a t e ( s w i t c h S c o p e ( s r c E ) ,   o n S t a t e C l a s s ,   o f f S t a t e C l a s s ) ;    
 	 	 	 	 	 s r c E . c l a s s N a m e   =   s r c E . c l a s s N a m e . r e p l a c e ( s e l f . c l a s s N a m e _ s w i t c h I s O n , " " ) ;  
 	 	 	 	 }  
 	 	 	 	 b r e a k ;  
 	 	 } 	  
 	 } 	  
 	  
 	 / /   S w i t c h   B e h a v i o r   P r i v a t e   M e t h o d s  
 	 / /   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
  
 	 / /   T h e   s w i t c h   s c o p e   l i m i t s   t h e   e l e m e n t   t r e e   o n   w h i c h   t h e   s w i t c h   c a n   o p e r a t e .  
 	 / /   B e c a u s e   o f   i n t e r f e r e n c e   i s s u e ,   a   S W I T C H   c o n t a i n e d   i n   a   R E P E A T e d   b l o c k  
 	 / /   s h o u l d   n o t   b e   a l l o w e d   t o   o p e r a t e   o u t s i d e   o f   i t .  
 	 f u n c t i o n   s w i t c h S c o p e ( n )   {  
 	 	 w h i l e ( n )   {  
 	 	 	   i f   ( n . c l a s s N a m e   & &   (   ( '   ' + n . c l a s s N a m e + '   ' ) . i n d e x O f ( '   ' + s e l f . c l a s s N a m e _ r e p e a t + '   ' )   ! =   - 1   | |   ( '   ' + n . c l a s s N a m e + '   ' ) . i n d e x O f ( '   ' + s e l f . c l a s s N a m e _ d e l e t e + '   ' )   ! =   - 1 ) )    
 	 	 	 	 r e t u r n   n ;  
 	 	 	   i f   ( n . t a g N a m e . t o U p p e r C a s e ( )   = =   s e l f . s w i t c h S c o p e R o o t T a g )  
 	 	 	 	 r e t u r n   n ;  
 	 	 	   n   =   n . p a r e n t N o d e ;  
 	 	 }  
 	 	 r e t u r n   n u l l ;   / /   s h o u l d   n o t   h a p p e n .   A   f o r m   s h o u l d   e x i s t s .  
 	 }  
 	  
 	 / /   R e c u r s i v e   l o o p   w i t h i n   t h e   s c o p e   t o   s w i t c h   c l a s s e s  
 	 f u n c t i o n   s w i t c h S t a t e ( n ,   o l d S t a t e C l a s s ,   n e w S t a t e C l a s s )   { 	 	  
 	 	 i f ( n . n o d e T y p e   ! =   1 )   r e t u r n ;  
 	 	 i f ( n . c l a s s N a m e   & &   n . c l a s s N a m e . i n d e x O f ( o l d S t a t e C l a s s )   ! =   - 1 )   {     	 	  
 	 	 	 n . c l a s s N a m e   =   n . c l a s s N a m e . r e p l a c e ( o l d S t a t e C l a s s ,   n e w S t a t e C l a s s ) ;  
 	 	 	 / /   F A T   s u p p o r t  
 	 	 	 / /   n . i d   n o t   s e t .  
 	 	 	 / /   i f ( F a t   & &   n . i d )   F a t . f a d e _ e l e m e n t ( n . i d ,   1 0 ,   6 0 0 ,   " # F F F F C C " ,   " # F F F F F F " ) ; 	  
 	 	 }  
 	 	 f o r   ( v a r   i = 0 ; i < n . c h i l d N o d e s . l e n g t h ; i + + )    
 	 	 	 s w i t c h S t a t e ( n . c h i l d N o d e s [ i ] ,   o l d S t a t e C l a s s ,   n e w S t a t e C l a s s ) ;  
 	 }  
  
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
 	 / /   R e p e a t / R e m o v e   B e h a v i o r   M e t h o d s  
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
  
 	 / /   - - - - - - - - - - - - - - - - - - -  
 	 / /   P r i v i l e d g e d   M e t h o d s  
 	 / /   - - - - - - - - - - - - - - - - - - -  
 	 t h i s . d u p l i c a t e F i e l d G r o u p   =   f u n c t i o n ( e )   {  
 	 	 v a r   s r c E   =   w u . g e t S r c E l e m e n t ( e ) ;  
 	 	 / /   G e t   E l e m e n t   t o   d u p l i c a t e .  
 	 	 v a r   s o u r c e N o d e   =   s r c E . p a r e n t N o d e ;  
 	 	 w h i l e   ( s o u r c e N o d e   & &   ( ! s o u r c e N o d e . c l a s s N a m e   | |   ( '   ' + s o u r c e N o d e . c l a s s N a m e + '   ' ) . i n d e x O f ( '   ' + s e l f . c l a s s N a m e _ r e p e a t + '   ' )   = =   - 1 ) )   {  
 	 	 	 s o u r c e N o d e   =   s o u r c e N o d e . p a r e n t N o d e ;  
 	 	 } 	  
 	 	 i f   ( s o u r c e N o d e   & &   s o u r c e N o d e . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ r e p e a t )   ! =   - 1 )   {  
 	 	 	 / /   E x t r a c t   r o w   c o u n t e r   i n f o r m a t i o n  
 	 	 	 c o u n t e r F i e l d   =   d o c u m e n t . g e t E l e m e n t B y I d ( s o u r c e N o d e . i d   +   s e l f . i d S u f f i x _ r e p e a t C o u n t e r ) ;  
 	 	 	 i f ( ! c o u n t e r F i e l d )   r e t u r n ;   / /   s h o u l d   n o t   h a p p e n .  
 	 	 	 v a r   r o w C o u n t   =   p a r s e I n t ( c o u n t e r F i e l d . v a l u e )   +   1 ;  
 	 	 	 / /   P r e p a r e   i d   s u f f i x  
 	 	 	 v a r   s u f f i x   =   " - "   +   r o w C o u n t . t o S t r i n g ( )  
 	 	 	 / /   d u p l i c a t e   n o d e   t r e e    
 	 	 	 v a r   d u p T r e e   =   r e p l i c a t e T r e e ( s o u r c e N o d e ,   n u l l ,   s u f f i x ) ;     / /     s o u r c e N o d e . c l o n e N o d e ( t r u e ) ;    
 	 	 	 / /   f i n d   i n s e r t   p o i n t   i n   D O M   t r e e   ( a f t e r   e x i s t i n g   r e p e a t e d   e l e m e n t )  
 	 	 	 v a r   i n s e r t N o d e   =   s o u r c e N o d e . n e x t S i b l i n g ;  
 	 	 	 w h i l e ( i n s e r t N o d e   & &   i n s e r t N o d e . c l a s s N a m e   & &   i n s e r t N o d e . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ d e l e t e )   ! =   - 1 )   {  
 	 	 	 	 i n s e r t N o d e   =   i n s e r t N o d e . n e x t S i b l i n g ;  
 	 	 	 }  
 	 	 	 	 	  
 	 	 	 s o u r c e N o d e . p a r e n t N o d e . i n s e r t B e f o r e ( d u p T r e e , i n s e r t N o d e ) ; 	   / /   B u g g y   r e n d e r i n g   i n   I E 5 / M a c  
 	 	 	 / /   i f ( n a v i g a t o r . a p p V e r s i o n . i n d e x O f ( " M S I E " )   ! =   - 1   & &   n a v i g a t o r . a p p V e r s i o n . i n d e x O f ( " W i n d o w s " )   = =   - 1 ) 	 	 	  
 	 	 	 / /  
 	 	 	  
 	 	 	 / /   t h e   c o p y   i s   n o t   d u p l i c a b l e ,   i t ' s   r e m o v e a b l e  
 	 	 	 d u p T r e e . c l a s s N a m e   =   s o u r c e N o d e . c l a s s N a m e . r e p l a c e ( s e l f . c l a s s N a m e _ r e p e a t , s e l f . c l a s s N a m e _ d e l e t e ) ;  
 	 	 	 / /   S a v e   n e w   r o w   c o u n t   	 	 	  
 	 	 	 d o c u m e n t . g e t E l e m e n t B y I d ( s o u r c e N o d e . i d   +   s e l f . i d S u f f i x _ r e p e a t C o u n t e r ) . v a l u e   =   r o w C o u n t ;  
 	 	 	 / /   r e - a d d   b e h a v i o r s  
 	 	 	 i f ( ! d u p T r e e . i d )   d u p T r e e . i d   =   w u . r a n d o m I d ( )   +   s u f f i x ;     / /     c r e a t e A t t r i b u t e ( )  
 	 	 	 w u . d e b u g ( ' D u p l i c a t e d   t r e e   i d   :   ' + d u p T r e e . i d ) ;  
 	 	 	 s e l f . a d d B e h a v i o r s ( d u p T r e e . i d ) ;  
 	 	 	  
 	 	 	 / /   F A T   s u p p o r t  
 	 	 	 i f ( t y p e o f   F a t   ! =   ' u n d e f i n e d '   & &   F a t   & &   d u p T r e e . i d )   F a t . f a d e _ e l e m e n t ( d u p T r e e . i d ,   1 0 ,   6 0 0 ,   " # F F F F C C " ,   " # F F F F F F " ) ; 	  
  
 	 	 }  
 	 	 r e t u r n   w u . X B r o w s e r P r e v e n t E v e n t D e f a u l t ( e ) ;  
 	 }  
 	 t h i s . r e m o v e F i e l d G r o u p   =   f u n c t i o n ( e )   {  
 	 	 v a r   s r c E   =   w u . g e t S r c E l e m e n t ( e ) ; 	 / /   G e t   E l e m e n t   t o   r e m o v e .  
 	 	 v a r   d e l N o d e   =   s r c E . p a r e n t N o d e ;  
  
 	 	 w h i l e   ( d e l N o d e   & &   ( '   ' + d e l N o d e . c l a s s N a m e + '   ' ) . i n d e x O f ( '   ' + s e l f . c l a s s N a m e _ d e l e t e + '   ' )   = =   - 1 )   {  
 	 	 	 d e l N o d e   =   d e l N o d e . p a r e n t N o d e ;  
 	 	 }  
 	 	 d e l N o d e . p a r e n t N o d e . r e m o v e C h i l d ( d e l N o d e ) ;  
 	 	 r e t u r n   w u . X B r o w s e r P r e v e n t E v e n t D e f a u l t ( e ) ;  
 	 }  
  
 	 / /   R e p e a t   B e h a v i o r   P r i v a t e   M e t h o d s  
 	 / /   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 f u n c t i o n   r e m o v e R e p e a t C o u n t S u f f i x ( s t r )   {  
 	 	 r e t u r n   s t r . r e p l a c e ( / - \ d $ / , ' ' ) ;  
 	 }  
 	  
 	 f u n c t i o n   r e p l i c a t e T r e e ( s r c N o d e , d u p P a r e n t N o d e ,   i d S u f f i x )   {  
 	 	 s w i t c h ( s r c N o d e . n o d e T y p e )   {  
 	 	 	 c a s e   1 : 	 / /   E L E M E N T - N O D E  
 	 	 	 	 i f ( s r c N o d e . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ d u p l i c a t e L i n k )   ! =   - 1   | |  
 	 	 	 	 	 s r c N o d e . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ r e m o v e L i n k )   ! =   - 1     )   	 	 	 	 	 	 	  
 	 	 	 	 	 r e t u r n   n u l l ;   / /   E x c l u d e   t h e   ' d u p l i c a t e / r e m o v e '   l i n k s  
 	 	 	 	 i f ( s r c N o d e . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ d e l e t e )   ! =   - 1 )   {   	 	 	 	 	 	 	  
 	 	 	 	 	 r e t u r n   n u l l ;   / /   E x c l u d e   d u p l i c a t e d   e l e m e n t s   o f   a   n e s t e d   r e p e a t   g r o u p  
 	 	 	 	 } 	 	 	 	    
 	 	 	 	 i f ( s r c N o d e . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ r e p e a t )   ! =   - 1   & &   d u p P a r e n t N o d e ! = n u l l )   {    
 	 	 	 	 	 / /   M a t c h   n e s t e d   r e p e a t   g r o u p   o n l y  
 	 	 	 	 	 i d S u f f i x   =   i d S u f f i x . r e p l a c e ( ' - ' , ' _ _ ' ) ;  
 	 	 	 	 }  
 	 	 	 	        
 	 	 	 	 i f ( d o c u m e n t . a l l   & &   ! w i n d o w . o p e r a )   {    
 	 	 	 	 	 / /   I E   S p e c i f i c   :   s e e   h t t p : / / m s d n . m i c r o s o f t . c o m / w o r k s h o p / a u t h o r / d h t m l / r e f e r e n c e / p r o p e r t i e s / n a m e _ 2 . a s p  
 	 	 	 	 	 v a r   t a g H t m l   =   s r c N o d e . t a g N a m e ;  
 	 	 	 	 	  
 	 	 	 	 	 i f ( s r c N o d e . n a m e )   	 	 	 	 	  
 	 	 	 	 	 	 i f   ( s r c N o d e . t a g N a m e . t o U p p e r C a s e ( ) = = " I N P U T "   & &   s r c N o d e . t y p e . t o L o w e r C a s e ( ) = = " r a d i o "   & &   s e l f . p r e s e r v e R a d i o N a m e )  
 	 	 	 	 	 	 	 t a g H t m l   + =   "   N A M E = ' "   +   s r c N o d e . n a m e   +   " '   " ;  
 	 	 	 	 	 	 e l s e  
 	 	 	 	 	 	 	 t a g H t m l   + =   "   N A M E = ' "   +   r e m o v e R e p e a t C o u n t S u f f i x ( s r c N o d e . n a m e )   +   i d S u f f i x   +   " '   " ;  
 	 	 	 	 	 i f ( s r c N o d e . t y p e )   {  
 	 	 	 	 	 	 t a g H t m l   + =   "   T Y P E = ' "   +   s r c N o d e . t y p e   +   " '   " ;  
 	 	 	 	 	 }  
 	 	 	 	 	 i f ( s r c N o d e . s e l e c t e d )    
 	 	 	 	 	 	 t a g H t m l   + =   "   S E L E C T E D = ' S E L E C T E D '   " ;  
 	 	 	 	 	 i f ( s r c N o d e . c h e c k e d )  
 	 	 	 	 	 	 t a g H t m l   + =   "   C H E C K E D = ' C H E C K E D '   " ;  
  
 	 	 	 	 	 i f ( n a v i g a t o r . a p p V e r s i o n . i n d e x O f ( " M S I E " )   ! =   - 1   & &   n a v i g a t o r . a p p V e r s i o n . i n d e x O f ( " W i n d o w s " )   = =   - 1 )   / /   I E 5   M a c  
 	 	 	 	 	 	 v a r   n e w N o d e   =   d o c u m e n t . c r e a t e E l e m e n t ( t a g H t m l ) ;  
 	 	 	 	 	 e l s e  
 	 	 	 	 	 	 v a r   n e w N o d e   =   d o c u m e n t . c r e a t e E l e m e n t ( " < "   +   t a g H t m l   +   " > < / " +   s r c N o d e . t a g N a m e   +   " > " ) ;    
 	 	 	 	 	 t r y   {   n e w N o d e . t y p e   =   s r c N o d e . t y p e ;   }   c a t c h ( e )   { } ;   / /   n a i l   i t   d o w n   f o r   I E 5   ? ,   b r e a k s   i n   I E 6  
   	 	 	 	 	  
 	 	 	 	 }  
 	 	 	 	 e l s e  
 	 	 	 	 	 v a r   n e w N o d e   =   d o c u m e n t . c r e a t e E l e m e n t ( s r c N o d e . t a g N a m e ) ;    
 	  
 	 	 	 	 / /   g e t   a t t r i b u t e s 	 	 	 	 	 	 	 	 	 	  
 	 	 	 	 f o r ( v a r   i = 0 ;   i <   s r c N o d e . a t t r i b u t e s . l e n g t h ;   i + + )   {  
 	  
 	 	 	 	 	 i f ( 	 s r c N o d e . a t t r i b u t e s [ i ] . s p e c i f i e d   | |   / /   i n   I E ,   t h e   a t t r i b u t e s   a r r a y   c o n t a i n s   a l l   a t t r i b u t e s   i n   t h e   D T D  
 	 	 	 	 	 	 s r c N o d e . a t t r i b u t e s [ i ] . n o d e N a m e . t o L o w e r C a s e ( )   = =   ' v a l u e '   )   {   / /   a t t r . s p e c i f i e d   b u g g y   i n   I E ?      
 	  
 	 	 	 	 	 	 i f ( 	 s r c N o d e . a t t r i b u t e s [ i ] . n o d e N a m e . t o L o w e r C a s e ( )   = =   " i d "   | |    
 	 	 	 	 	 	 	 s r c N o d e . a t t r i b u t e s [ i ] . n o d e N a m e . t o L o w e r C a s e ( )   = =   " n a m e "   | |  
 	 	 	 	 	 	 	 s r c N o d e . a t t r i b u t e s [ i ] . n o d e N a m e . t o L o w e r C a s e ( )   = =   " f o r " )   {  
 	 	 	 	 	 	 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 i f ( s r c N o d e . a t t r i b u t e s [ i ] . n o d e V a l u e . i n d e x O f ( s e l f . i d S u f f i x _ f i e l d H i n t )   ! =   - 1 )     {  
 	 	 	 	 	 	 	 	 / / l e a v e   t h e   f i e l d   h i n t   s u f f i x   a t   t h e   e n d   o f   t h e   i d .  
 	 	 	 	 	 	 	 	 v a r   v a l u e   =   s r c N o d e . a t t r i b u t e s [ i ] . n o d e V a l u e ;  
 	 	 	 	 	 	 	 	 v a l u e =   r e m o v e R e p e a t C o u n t S u f f i x ( v a l u e . s u b s t r ( 0 , v a l u e . i n d e x O f ( s e l f . i d S u f f i x _ f i e l d H i n t ) ) )   +   i d S u f f i x   +   s e l f . i d S u f f i x _ f i e l d H i n t ;  
 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 e l s e   {  
 	 	 	 	 	 	 	 	 i f   ( s r c N o d e . t a g N a m e . t o U p p e r C a s e ( ) = = " I N P U T "   & &   s r c N o d e . g e t A t t r i b u t e ( ' t y p e ' , f a l s e ) . t o L o w e r C a s e ( ) = = " r a d i o "   & &  
 	 	 	 	 	 	 	 	 	 s r c N o d e . a t t r i b u t e s [ i ] . n o d e N a m e . t o L o w e r C a s e ( )   = =   " n a m e "   & &   s e l f . p r e s e r v e R a d i o N a m e )   {  
 	 	 	 	 	 	 	 	 	 v a r   v a l u e   =   s r c N o d e . a t t r i b u t e s [ i ] . n o d e V a l u e ; 	 	 	 	 	 	  
 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 	 e l s e   {  
 	 	 	 	 	 	 	 	 	 / /   v a r   v a l u e   =   r e m o v e R e p e a t C o u n t S u f f i x ( s r c N o d e . a t t r i b u t e s [ i ] . n o d e V a l u e )   +   i d S u f f i x ;  
 	 	 	 	 	 	 	 	 	 v a r   v a l u e   =   s r c N o d e . a t t r i b u t e s [ i ] . n o d e V a l u e   +   i d S u f f i x ;  
 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 	 	 / /   D o   n o t   c o p y   t h e   v a l u e   a t t r i b u t e   f o r   t e x t / p a s s w o r d / f i l e   i n p u t  
 	 	 	 	 	 	 	 i f ( s r c N o d e . a t t r i b u t e s [ i ] . n o d e N a m e . t o L o w e r C a s e ( )   = =   " v a l u e "   & &  
 	 	 	 	 	 	 	   	 s r c N o d e . t a g N a m e . t o U p p e r C a s e ( ) = = ' I N P U T '   & &      
 	 	 	 	 	 	 	 	     ( s r c N o d e . t y p e . t o L o w e r C a s e ( )   = =   ' t e x t '   | |   s r c N o d e . t y p e . t o L o w e r C a s e ( )   = =   ' p a s s w o r d '   | |   s r c N o d e . t y p e . t o L o w e r C a s e ( )   = =   ' f i l e ' ) )    
 	 	 	 	 	 	 	 	 v a r   v a l u e = ' ' ;        
 	 	 	 	 	 	 	 e l s e  
 	 	 	 	 	 	 	 	 v a r   v a l u e   =   s r c N o d e . a t t r i b u t e s [ i ] . n o d e V a l u e ;  
 	 	 	 	 	 	 }  
 	 	 	 	 	 	 s w i t c h ( s r c N o d e . a t t r i b u t e s [ i ] . n o d e N a m e . t o L o w e r C a s e ( ) )   {  
 	 	 	 	 	 	 	 c a s e   " c l a s s " :  
 	 	 	 	 	 	 	 	 n e w N o d e . c l a s s N a m e   =   v a l u e ;    
 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 c a s e   " s t y l e " :   / /   i n l i n e   s t y l e   a t t r i b u t e   ( f i x   f o r   I E )  
 	 	 	 	 	 	 	 	 i f ( s r c N o d e . s t y l e   & &   s r c N o d e . s t y l e . c s s T e x t )   n e w N o d e . s t y l e . c s s T e x t   =   s r c N o d e . s t y l e . c s s T e x t ;    
 	 	 	 	 	 	 	 	 b r e a k ; 	 	 	 	 	 	 	 	  
 	 	 	 	 	 	 	 d e f a u l t :  
 	 	 	 	 	 	 	 	 n e w N o d e . s e t A t t r i b u t e ( s r c N o d e . a t t r i b u t e s [ i ] . n a m e ,   v a l u e ,   0 ) ; / / s e t A t t r i b u t e ( n e w N o d e ,   s r c N o d e . a t t r i b u t e s [ i ] . n a m e ,   v a l u e ) ;  
 	 	 	 	 	 	 }  
 	 	 	 	 	 }  
 	 	 	 	 } 	 	 	 	  
 	 	 	 	 b r e a k ;  
 	 	 	 c a s e   3 :   / /   T E X T - N O D E   ( d o   n o t   c o p y   v a l u e   o f   t e x t a r e a s )  
 	 	 	 	 i f ( s r c N o d e . p a r e n t N o d e . t a g N a m e . t o U p p e r C a s e ( )   ! =   ' T E X T A R E A ' )  
 	 	 	 	 	 v a r   n e w N o d e   =   d o c u m e n t . c r e a t e T e x t N o d e ( s r c N o d e . d a t a ) ;    
 	 	 	 	 b r e a k ;  
 	 	 }  
 	 	 i f ( d u p P a r e n t N o d e   & &   n e w N o d e )   d u p P a r e n t N o d e . a p p e n d C h i l d ( n e w N o d e ) ;  
 	 	 f o r ( v a r   i = 0 ;   i < s r c N o d e . c h i l d N o d e s . l e n g t h ; i + + )   {  
 	 	 	 r e p l i c a t e T r e e ( s r c N o d e . c h i l d N o d e s [ i ] , n e w N o d e , i d S u f f i x ) ;  
 	 	 }  
 	 	 r e t u r n   n e w N o d e ;  
 	 }  
 	 	  
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
 	 / /   F i e l d   H i n t   B e h a v i o r   M e t h o d s  
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
  
 	 t h i s . a c t i v a t e F i e l d H i n t   =   f u n c t i o n ( e )   {  
 	 	 v a r   s r c E   =   w u . g e t S r c E l e m e n t ( e ) ;  
 	 	 v a r   f h   =   d o c u m e n t . g e t E l e m e n t B y I d ( s r c E . i d   +     s e l f . i d S u f f i x _ f i e l d H i n t ) ;  
 	 	 i f ( ! f h   & &   s r c E . t a g N a m e . t o U p p e r C a s e ( ) = = ' I N P U T '   & &   s r c E . t y p e . t o L o w e r C a s e ( )   = =   ' r a d i o ' )   {  
 	 	 	 f h   =   d o c u m e n t . g e t E l e m e n t B y I d ( s r c E . n a m e   +   s e l f . i d S u f f i x _ f i e l d H i n t ) ;  
 	 	 } 	 	  
 	 	 i f ( f h )   f h . c l a s s N a m e   =   f h . c l a s s N a m e . r e p l a c e ( s e l f . c l a s s N a m e _ i n a c t i v e F i e l d H i n t ,   s e l f . c l a s s N a m e _ a c t i v e F i e l d H i n t ) ;  
 	 }  
 	 t h i s . d e s a c t i v a t e F i e l d H i n t   =   f u n c t i o n ( e )   {  
 	 	 v a r   s r c E   =   w u . g e t S r c E l e m e n t ( e ) ;  
 	 	 v a r   f h   =   d o c u m e n t . g e t E l e m e n t B y I d ( s r c E . i d   +     s e l f . i d S u f f i x _ f i e l d H i n t ) ;  
 	 	 i f ( ! f h   & &   s r c E . t a g N a m e . t o U p p e r C a s e ( ) = = ' I N P U T '   & &   s r c E . t y p e . t o L o w e r C a s e ( )   = =   ' r a d i o ' )   {  
 	 	 	 f h   =   d o c u m e n t . g e t E l e m e n t B y I d ( s r c E . n a m e   +   s e l f . i d S u f f i x _ f i e l d H i n t ) ;  
 	 	 } 	 	  
 	 	 i f ( f h )   f h . c l a s s N a m e   =   f h . c l a s s N a m e . r e p l a c e ( s e l f . c l a s s N a m e _ a c t i v e F i e l d H i n t , s e l f . c l a s s N a m e _ i n a c t i v e F i e l d H i n t ) ;  
 	 }  
 	  
 	  
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
 	 / /   M u l t i - p a g e   F o r m s   M a n a g e m e n t  
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
 	 t h i s . p a g i n g N e x t =   f u n c t i o n ( e )   {  
 	 	 v a r   s r c E   =   w u . g e t S r c E l e m e n t ( e ) ;  
 	 	 v a r   c u r P a g e D i v   =   s r c E . p a r e n t N o d e ;  
 	 	 v a r   p a g e I n d e x   =   p a r s e I n t ( c u r P a g e D i v . i d . r e p l a c e ( / [ \ D ] * / , " " ) )   +   1 ;  
 	 	 v a r   p a g e D i v   =   d o c u m e n t . g e t E l e m e n t B y I d ( s e l f . i d P r e f i x _ p a g e I n d e x + p a g e I n d e x . t o S t r i n g ( ) ) ;  
 	 	 i f ( p a g e D i v )   {  
 	 	 	 i f ( e v a l ( s e l f . f u n c t i o n N a m e _ f o r m V a l i d a t i o n . r e p l a c e ( " t h i s " , " s e l f " ) ) ( e ) )   {  
 	 	 	 	 c u r P a g e D i v . c l a s s N a m e   =   c u r P a g e D i v . c l a s s N a m e . r e p l a c e ( s e l f . c l a s s N a m e _ p a g i n g C u r r e n t , " " ) ;  
 	 	 	 	 p a g e D i v . c l a s s N a m e   + =   '   '   +   s e l f . c l a s s N a m e _ p a g i n g C u r r e n t ;  
 	 	 	 	 / /   s h o w   s u b m i t   b u t t o n   i f   t h e   l a s t   p a g e   o f   t h e   f o r m   i s   r e a c h e d  
 	 	 	 	 p a g e I n d e x + + ;  
 	 	 	 	 v a r   a n o t h e r p a g e   =   d o c u m e n t . g e t E l e m e n t B y I d ( s e l f . i d P r e f i x _ p a g e I n d e x + p a g e I n d e x . t o S t r i n g ( ) ) ; 	 	 	  
 	 	 	 	 i f ( ! a n o t h e r p a g e )   { 	 	 	 	  
 	 	 	 	 	 v a r   s u b m i t B u t t o n   =   d o c u m e n t . g e t E l e m e n t B y I d ( " s u b m i t - " + s r c E . f o r m . i d ) ;  
 	 	 	 	 	 i f ( s u b m i t B u t t o n )   s u b m i t B u t t o n . c l a s s N a m e   =   s u b m i t B u t t o n . c l a s s N a m e . r e p l a c e ( s e l f . c l a s s N a m e _ h i d e S u b m i t , " " ) ;  
 	 	 	 	 } 	 	 	 	  
 	 	 	 }  
 	 	 }  
 	 }  
  
 	 t h i s . p a g i n g P r e v i o u s   =   f u n c t i o n ( e )   {  
 	 	 v a r   s r c E   =   w u . g e t S r c E l e m e n t ( e ) ;  
 	 	 v a r   c u r P a g e D i v   =   s r c E . p a r e n t N o d e ;  
 	 	 v a r   p a g e I n d e x   =   p a r s e I n t ( c u r P a g e D i v . i d . r e p l a c e ( / [ \ D ] * / , " " ) )   -   1 ;  
 	 	 v a r   p a g e D i v   =   d o c u m e n t . g e t E l e m e n t B y I d ( s e l f . i d P r e f i x _ p a g e I n d e x + p a g e I n d e x . t o S t r i n g ( ) ) ;  
 	 	 i f ( p a g e D i v )   {  
 	 	 	 c u r P a g e D i v . c l a s s N a m e   =   c u r P a g e D i v . c l a s s N a m e . r e p l a c e ( s e l f . c l a s s N a m e _ p a g i n g C u r r e n t , " " ) ;  
 	 	 	 p a g e D i v . c l a s s N a m e   + =   '   '   +   s e l f . c l a s s N a m e _ p a g i n g C u r r e n t ;  
 	 	 	 / /   h i d e   s u b m i t   b u t t o n   i f   n e c e s s a r y  
 	 	 	 v a r   s u b m i t B u t t o n   =   d o c u m e n t . g e t E l e m e n t B y I d ( " s u b m i t - " + s r c E . f o r m . i d ) ;  
 	 	 	 i f ( s u b m i t B u t t o n   & &   s u b m i t B u t t o n . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ h i d e S u b m i t ) = = - 1 )   s u b m i t B u t t o n . c l a s s N a m e   + =   '   '   +   s e l f . c l a s s N a m e _ h i d e S u b m i t ;  
 	 	 }  
 	 }  
 	  
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
 	 / /   F O R M   V A L I D A T I O N    
 	 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
 	 t h i s . f o r m V a l i d a t i o n   =   f u n c t i o n ( e )   { 	 	  
  
 	 	 v a r   s r c E   =   w u . g e t S r c E l e m e n t ( e ) ;  
 	 	  
 	 	 i f ( s e l f . p r e v e n t S u b m i s s i o n O n E n t e r )   {    
 	 	 	 / /   p r e v e n t   f o r m   s u b m i s s i o n   i f   ' e n t e r '   k e y   i s   p r e s s e d  
 	 	 	 / /   ( d o e s n ' t   w o r k   i n   O p e r a .   F u r t h e r   t e s t s   n e e d e d   i n   I E   a n d   S a f a r i )  
 	 	 	 i f ( ! e )   e   =   w i n d o w . e v e n t ; 	 	 	  
 	 	 	 i f ( s r c E . t y p e   & &   s r c E . t y p e . t o L o w e r C a s e ( ) = = ' t e x t ' )  
 	 	 	 	 r e t u r n   w u . X B r o w s e r P r e v e n t E v e n t D e f a u l t ( e ) ;   / /   w o r k s   w /   F i r e f o x .  
 	 	 }  
 	 	  
 	 	 w h i l e   ( s r c E   & &   s r c E . t a g N a m e . t o U p p e r C a s e ( )   ! =   ' F O R M ' )   {  
 	 	 	 s r c E   =   s r c E . p a r e n t N o d e ;  
 	 	 } 	 	 	 	  
 	 	 v a r   x   =   w u . g e t E l e m e n t s ( s r c E ) ;   / / s r c E . e l e m e n t s ;      
 	 	 v a r   n b T o t a l E r r o r s   =   0 ;  
 	 	 v a r   i s V i s i b l e   =   f a l s e ;  
 	 	  
 	 	 f o r   ( v a r   i = 0 ; i < x . l e n g t h ; i + + )   {  
 	 	 	 v a r   n b E r r o r s   =   0 ; 	 	 	  
 	 	 	  
 	 	 	 i f   ( ( '   ' + x [ i ] . c l a s s N a m e + '   ' ) . i n d e x O f ( '   ' + s e l f . c l a s s N a m e _ r e q u i r e d + '   ' )   ! =   - 1 )   { 	 	 	 	  
 	 	 	 	 i f ( w u . c h e c k V i s i b i l i t y ( x [ i ] ) )   {  
 	 	 	 	 	 i s V i s i b l e   =   t r u e ;  
 	 	 	 	 	 v a r   v   =   t r u e ;   / /   i s   V a l i d 	 	 	 	  
 	 	 	 	 	 s w i t c h ( x [ i ] . t a g N a m e . t o U p p e r C a s e ( ) )   {  
 	 	 	 	 	 	 c a s e   " I N P U T " :  
 	 	 	 	 	 	 	 s w i t c h ( x [ i ] . g e t A t t r i b u t e ( " t y p e " ) . t o U p p e r C a s e ( ) )   {  
 	 	 	 	 	 	 	 	 c a s e   " C H E C K B O X " :  
 	 	 	 	 	 	 	 	 	 v   =   x [ i ] . c h e c k e d ;    
 	 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 	 c a s e   " R A D I O " :  
 	 	 	 	 	 	 	 	 	 v   =   x [ i ] . c h e c k e d ;    
 	 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 	 d e f a u l t :  
 	 	 	 	 	 	 	 	 	 v   =   ! s e l f . i s E m p t y ( x [ i ] . v a l u e ) ;  
 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 c a s e   " S E L E C T " :  
 	 	 	 	 	 	 	 v   =   ! s e l f . i s E m p t y ( x [ i ] . o p t i o n s [ x [ i ] . s e l e c t e d I n d e x ] . v a l u e ) ;  
 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 c a s e   " T E X T A R E A " :  
 	 	 	 	 	 	 	 v   =   ! s e l f . i s E m p t y ( x [ i ] . v a l u e ) ;  
 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 c a s e   " F I E L D S E T " :  
 	 	 	 	 	 	 	 v   =   c h e c k O n e R e q u i r e d ( x [ i ] ) ;  
 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 c a s e   " D I V " :  
 	 	 	 	 	 	 	 v   =   c h e c k O n e R e q u i r e d ( x [ i ] ) ;  
 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 c a s e   " S P A N " :  
 	 	 	 	 	 	 	 v   =   c h e c k O n e R e q u i r e d ( x [ i ] ) ;  
 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 }   / /   e n d   s w i t c h  
 	 	 	 	 	 i f ( ! v )   {  
 	 	 	 	 	 	 / /   f l a g   e r r o r  
 	 	 	 	 	 	 s e l f . s h o w E r r o r ( x [ i ] , s e l f . a r r E r r o r M s g [ 0 ] ) ;  
 	 	 	 	 	 	 n b E r r o r s + + ;  
 	 	 	 	 	 }     e l s e   {   / /   r e m o v e   r e q u i r e d   e r r o r   f l a g   i f   a n y .  
 	 	 	 	 	 	 v a r   r E r r C l a s s   =   n e w   R e g E x p ( s e l f . c l a s s N a m e _ v a l i d a t i o n E r r o r _ f l d , " g i " ) ;  
 	 	 	 	 	 	 x [ i ] . c l a s s N a m e   =   x [ i ] . c l a s s N a m e . r e p l a c e ( r E r r C l a s s , " " ) ;  
 	 	 	 	 	 	 v a r   f e   =   d o c u m e n t . g e t E l e m e n t B y I d ( x [ i ] . i d   +     s e l f . i d S u f f i x _ f i e l d E r r o r ) ;  
 	 	 	 	 	 	 i f ( f e )   f e . p a r e n t N o d e . r e m o v e C h i l d ( f e ) ;  
 	 	 	 	 	 }    
 	 	 	 	 }   e l s e   {   / /   n o t   v i s i b l e  
 	 	 	 	 }  
 	 	 	 }   / /   e n d   t e s t = r e q u i r e d  
  
 	 	 	 / /   i n p u t   v a l i d a t i o n  
 	 	 	 i f   ( x [ i ] . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e P r e f i x _ v a l i d a t i o n )   ! =   - 1 )   {  
 	 	 	 	 i f ( ! i s V i s i b l e )   i s V i s i b l e   =   w u . c h e c k V i s i b i l i t y ( x [ i ] ) ;  
 	 	 	 	 i f ( i s V i s i b l e )   {  
 	 	 	 	 	 v a r   a r r C l a s s e s   =   x [ i ] . c l a s s N a m e . s p l i t ( "   " ) ;  
 	 	 	 	 	 f o r   ( j = 0 ; j < a r r C l a s s e s . l e n g t h ; j + + )   {  
 	 	 	 	 	 	 s w i t c h ( a r r C l a s s e s [ j ] )   {  
 	 	 	 	 	 	 	 c a s e   " v a l i d a t e - a l p h a " :  
 	 	 	 	 	 	 	 	 i f ( ! s e l f . i s A l p h a ( x [ i ] . v a l u e ) )   {  
 	 	 	 	 	 	 	 	 	 s e l f . s h o w E r r o r ( x [ i ] , s e l f . a r r E r r o r M s g [ 1 ] ) ;  
 	 	 	 	 	 	 	 	 	 n b E r r o r s + + ;  
 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 c a s e   " v a l i d a t e - a l p h a n u m " :  
 	 	 	 	 	 	 	 	 i f ( ! s e l f . i s A l p h a N u m ( x [ i ] . v a l u e ) )   {  
 	 	 	 	 	 	 	 	 	 s e l f . s h o w E r r o r ( x [ i ] , s e l f . a r r E r r o r M s g [ 6 ] ) ;  
 	 	 	 	 	 	 	 	 	 n b E r r o r s + + ;  
 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 c a s e   " v a l i d a t e - d a t e " :  
 	 	 	 	 	 	 	 	 i f ( ! s e l f . i s D a t e ( x [ i ] . v a l u e ) )   {  
 	 	 	 	 	 	 	 	 	 s e l f . s h o w E r r o r ( x [ i ] , s e l f . a r r E r r o r M s g [ 7 ] ) ;  
 	 	 	 	 	 	 	 	 	 n b E r r o r s + + ;  
 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 c a s e   " v a l i d a t e - t i m e " :  
 	 	 	 	 	 	 	 	 / *   N O T   I M P L E M E N T E D   * /  
 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 c a s e   " v a l i d a t e - e m a i l " :  
 	 	 	 	 	 	 	 	 i f ( ! s e l f . i s E m a i l ( x [ i ] . v a l u e ) )   {  
 	 	 	 	 	 	 	 	 	 s e l f . s h o w E r r o r ( x [ i ] , s e l f . a r r E r r o r M s g [ 2 ] ) ;  
 	 	 	 	 	 	 	 	 	 n b E r r o r s + + ;  
 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 c a s e   " v a l i d a t e - i n t e g e r " :  
 	 	 	 	 	 	 	 	 i f ( ! s e l f . i s I n t e g e r ( x [ i ] . v a l u e ) )   {  
 	 	 	 	 	 	 	 	 	 s e l f . s h o w E r r o r ( x [ i ] , s e l f . a r r E r r o r M s g [ 3 ] ) ;  
 	 	 	 	 	 	 	 	 	 n b E r r o r s + + ;  
 	 	 	 	 	 	 	 	 } 	 	 	 	 	  
 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 c a s e   " v a l i d a t e - f l o a t " :  
 	 	 	 	 	 	 	 	 i f ( ! s e l f . i s F l o a t ( x [ i ] . v a l u e ) )   {  
 	 	 	 	 	 	 	 	 	 s e l f . s h o w E r r o r ( x [ i ] , s e l f . a r r E r r o r M s g [ 4 ] ) ;  
 	 	 	 	 	 	 	 	 	 n b E r r o r s + + ;  
 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 	 c a s e   " v a l i d a t e - s t r o n g p a s s w o r d " :   / /   N O T   I M P L E M E N T E D  
 	 	 	 	 	 	 	 	 i f ( ! s e l f . i s P a s s w o r d ( x [ i ] . v a l u e ) )   {  
 	 	 	 	 	 	 	 	 	 s e l f . s h o w E r r o r ( x [ i ] , s e l f . a r r E r r o r M s g [ 5 ] ) ;  
 	 	 	 	 	 	 	 	 	 n b E r r o r s + + ;  
 	 	 	 	 	 	 	 	 }  
 	 	 	 	 	 	 	 	 b r e a k ;  
 	 	 	 	 	 	 }   / /   e n d   s w i t c h  
 	 	 	 	 	 }   / /   e n d   f o r  
 	 	 	 	 }     e l s e   {   / /   n o t   v i s i b l e  
 	 	 	 	 }  
 	 	 	 }   / /   e n d   v a l i d a t i o n   c h e c k  
 	 	 	 	  
 	 	 	 i f ( n b E r r o r s > 0 )   {  
 	 	 	 	 n b T o t a l E r r o r s + =   n b E r r o r s ;  
 	 	 	 }   e l s e   {  
 	 	 	 	 v a r   r E r r C l a s s   =   n e w   R e g E x p ( s e l f . c l a s s N a m e _ v a l i d a t i o n E r r o r _ f l d , " g i " ) ;  
 	 	 	 	 x [ i ] . c l a s s N a m e   =   x [ i ] . c l a s s N a m e . r e p l a c e ( r E r r C l a s s , " " ) ;  
 	 	 	 	 v a r   f e   =   d o c u m e n t . g e t E l e m e n t B y I d ( x [ i ] . i d   +     s e l f . i d S u f f i x _ f i e l d E r r o r ) ;  
 	 	 	 	 i f ( f e )   f e . p a r e n t N o d e . r e m o v e C h i l d ( f e ) ;  
 	 	 	 }    
 	 	 }  
 	 	 i f   ( n b T o t a l E r r o r s   >   0 )   {  
 	 	 	 i f ( s e l f . s h o w A l e r t O n E r r o r ) {     s e l f . s h o w A l e r t ( n b T o t a l E r r o r s ) ;   }  
 	 	 	 r e t u r n   w u . X B r o w s e r P r e v e n t E v e n t D e f a u l t ( e ) ;  
 	 	 }  
 	 	 r e t u r n   t r u e ;  
 	 }  
 	 t h i s . i s E m p t y   =   f u n c t i o n ( s )   {  
 	 	 v a r   r e g e x p W h i t e s p a c e   =   / ^ \ s + $ / ;  
 	 	 r e t u r n     ( ( s   = =   n u l l )   | |   ( s . l e n g t h   = =   0 )   | |   r e g e x p W h i t e s p a c e . t e s t ( s ) ) ;  
 	 }  
 	 t h i s . i s A l p h a   =   f u n c t i o n ( s )   {  
 	 	 v a r   r e g e x p A l p h a b e t i c   =   / ^ [ a - z A - Z ] + $ / ;   / /   A d d   '   a n d   -   ?  
 	 	 r e t u r n   s e l f . i s E m p t y ( s )   | |   r e g e x p A l p h a b e t i c . t e s t ( s ) ;  
 	 }  
 	 t h i s . i s A l p h a N u m   =   f u n c t i o n ( s )   {  
 	 	 v a r   i l l e g a l C h a r s   =   / \ W / ;  
 	 	 r e t u r n   s e l f . i s E m p t y ( s )   | |   ! i l l e g a l C h a r s . t e s t ( s ) ;  
 	 }  
 	 t h i s . i s D a t e   =   f u n c t i o n ( s )   {  
 	 	 v a r   t e s t D a t e   =   n e w   D a t e ( s ) ;  
 	 	 r e t u r n   s e l f . i s E m p t y ( s )   | |   ! i s N a N ( t e s t D a t e ) ;  
 	 }  
 	 t h i s . i s E m a i l   =   f u n c t i o n ( s )   {  
 	 	 v a r   r e g e x p E m a i l   =   / \ w { 1 , } [ @ ] [ \ w \ - ] { 1 , } ( [ . ] ( [ \ w \ - ] { 1 , } ) ) { 1 , 3 } $ / ;  
 	 	 r e t u r n   s e l f . i s E m p t y ( s )   | |   r e g e x p E m a i l . t e s t ( s ) ;  
 	 }  
 	 t h i s . i s I n t e g e r   = f u n c t i o n ( s )   {  
 	 	 v a r   r e g e x p   =   / ^ [ + ] ? \ d + $ / ;  
 	 	 r e t u r n   s e l f . i s E m p t y ( s )   | |   r e g e x p . t e s t ( s ) ;  
 	 }  
 	 t h i s . i s F l o a t   =   f u n c t i o n ( s )   { 	 	  
 	 	 r e t u r n   s e l f . i s E m p t y ( s )   | |   ! i s N a N ( p a r s e F l o a t ( s ) ) ;  
 	 }  
 	 / /   N O T   I M P L E M E N T E D  
 	 t h i s . i s P a s s w o r d   =   f u n c t i o n ( s )   {  
 	 	 / /   M a t c h e s   s t r o n g   p a s s w o r d   :   a t   l e a s t   1   u p p e r   c a s e   l a t t e r ,   o n e   l o w e r   c a s e   l e t t e r .   4   c h a r a c t e r s   m i n i m u m .   1 2   m a x .  
 	 	 / / v a r   r e g e x p   =   / ^ ( ? = . * [ a - z ] ) ( ? = . * [ A - Z ] ) ( ? ! . * \ s ) . { 4 , 1 2 } $ / ;     / /   < =   b r e a k s   i n   I E 5 / M a c  
 	 	 r e t u r n   s e l f . i s E m p t y ( s ) ;  
 	 }  
 	 t h i s . s h o w E r r o r   =   f u n c t i o n   ( n , e r r o r M s g )   { 	 	  
 	 	 i f ( n . c l a s s N a m e . i n d e x O f ( s e l f . c l a s s N a m e _ v a l i d a t i o n E r r o r _ f l d ) ! =   - 1 )   {  
 	 	 	 r e t u r n ;  
 	 	 }  
 	 	 i f   ( ! n . i d )   n . i d   =   w u . r a n d o m I d ( ) ;   / /   w e ' l l   n e e d   a n   i d   h e r e . 	 	  
 	 	 / /   A d d   e r r o r   f l a g   t o   t h e   f i e l d  
 	 	 n . c l a s s N a m e   + =   "   "   +   s e l f . c l a s s N a m e _ v a l i d a t i o n E r r o r _ f l d ;  
 	 	 / /   P r e p a r e   e r r o r   m e s s a g e  
 	 	 v a r   m s g N o d e   =   d o c u m e n t . c r e a t e T e x t N o d e ( "   "   +   e r r o r M s g ) ;  
 	 	 / /   F i n d   e r r o r   m e s s a g e   p l a c e h o l d e r .  
 	 	 v a r   f e   =   d o c u m e n t . g e t E l e m e n t B y I d ( n . i d   +     s e l f . i d S u f f i x _ f i e l d E r r o r ) ;  
 	 	 i f ( ! f e )   {   / /   c r e a t e   p l a c e h o l d e r .  
 	 	 	 f e   =   d o c u m e n t . c r e a t e E l e m e n t ( " d i v " ) ;    
 	 	 	 f e . s e t A t t r i b u t e ( ' i d ' ,   n . i d   +     s e l f . i d S u f f i x _ f i e l d E r r o r ) ; 	 	 	  
 	 	 	 / /   a t t a c h   t h e   e r r o r   m e s s a g e   a f t e r   t h e   f i e l d   l a b e l   i f   p o s s i b l e  
 	 	 	 v a r   f l   =   d o c u m e n t . g e t E l e m e n t B y I d ( n . i d   +     s e l f . i d S u f f i x _ f i e l d L a b e l ) ;  
 	 	 	 i f ( f l )  
 	 	 	 	 f l . p a r e n t N o d e . i n s e r t B e f o r e ( f e , f l . n e x t S i b l i n g ) ;  
 	 	 	 e l s e  
 	 	 	 	 / /   o t h e r w i s e ,   a t t a c h   i t   a f t e r   t h e   f i e l d   t a g .  
 	 	 	 	 n . p a r e n t N o d e . i n s e r t B e f o r e ( f e , n . n e x t S i b l i n g ) ;  
 	 	 }  
 	 	 / /   F i n i s h   t h e   e r r o r   m e s s a g e .  
 	 	 f e . a p p e n d C h i l d ( m s g N o d e ) ;     	  
 	 	 f e . c l a s s N a m e   + =   "   "   +   s e l f . c l a s s N a m e _ v a l i d a t i o n E r r o r _ m s g ;  
 	 }  
 	 t h i s . s h o w A l e r t   =   f u n c t i o n   ( n b T o t a l E r r o r s )   {  
   	       a l e r t ( s e l f . a r r E r r o r M s g [ 8 ] . r e p l a c e ( ' % % ' , n b T o t a l E r r o r s ) ) ;  
 	 }  
 	 / /   V a l i d a t i o n   P r i v a t e   M e t h o d  
 	 / /   - - - - - - - - - - - - - - - - - - - - - - - - -  
 	 f u n c t i o n   c h e c k O n e R e q u i r e d ( n )   { 	  
 	 	 v a r   v = n u l l ;  
 	 	 i f ( n . n o d e T y p e   ! =   1 )   r e t u r n   f a l s e ;  
 	 	 i f ( n . t a g N a m e . t o U p p e r C a s e ( )   = =   " I N P U T " )   {  
 	 	 	 s w i t c h ( n . t y p e . t o L o w e r C a s e ( ) )   {  
 	 	 	 	 c a s e   " c h e c k b o x " :  
 	 	 	 	 	 v   =   n . c h e c k e d ;    
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 c a s e   " r a d i o " :  
 	 	 	 	 	 v   =   n . c h e c k e d ;    
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 d e f a u l t :  
 	 	 	 	 	 v   =   n . g e t A t t r i b u t e ( " v a l u e " ) ;  
 	 	 	 }  
 	 	 }   e l s e   v   =   n . g e t A t t r i b u t e ( " v a l u e " ) ;  
 	 	 i f ( v   & &   ! s e l f . i s E m p t y ( v ) )   {  
 	 	 	 r e t u r n   t r u e ;  
 	 	 }  
 	 	 f o r ( v a r   i = 0 ;   i < n . c h i l d N o d e s . l e n g t h ; i + + )   {  
 	 	 	 i f ( c h e c k O n e R e q u i r e d ( n . c h i l d N o d e s [ i ] ) )   r e t u r n   t r u e ;  
 	 	 }  
 	 	 r e t u r n   f a l s e ;  
 	 }  
  
 }  
  
 / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 / /   W F O R M S   P u b l i c   M e t h o d s  
 / / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 w F O R M S . p r o t o t y p e . o n L o a d H a n d l e r   =   f u n c t i o n ( )   { 	 	  
 	 f o r   ( v a r   i = 0 ; i < d o c u m e n t . f o r m s . l e n g t h ; i + + )   {  
 	 	 i f ( ! d o c u m e n t . f o r m s [ i ] . i d )   d o c u m e n t . f o r m s [ i ] . i d   =   t h i s . u t i l i t i e s . r a n d o m I d ( ) ;  
 	 	 t h i s . a d d B e h a v i o r s ( d o c u m e n t . f o r m s [ i ] . i d ) ;  
 	 }  
 }  
 w F O R M S . p r o t o t y p e . a d d B e h a v i o r s   =   f u n c t i o n   ( f I d )   {  
 	 v a r   f = d o c u m e n t . g e t E l e m e n t B y I d ( f I d ) ;  
 	 i f ( ! f )   r e t u r n ;  
  
 	 v a r   t h i s F o r m ;   	 	 	 	 / /   P o i n t e r   t o   k e e p   t r a c k   o f   t h e   c u r r e n t   f o r m   b e i n g   p r o c e s s e d .  
 	 v a r   w u   =   t h i s . u t i l i t i e s ; 	 / /   U t i l t i y   c l a s s   i n s t a n c e  
 	 w u . r e s e t E v e n t L i s t ( ) ;  
 	  
 	 / /   l o o p   t h r o u g h   t h e   f i e l d s  
 	 v a r   x   =   w u . g e t E l e m e n t s ( f ) ;  
 	  
 	 f o r   ( v a r   i = 0 ; i < x . l e n g t h ; i + + )   {  
  
 	 	 / /   a d d   f o r m   v a l i d a t i o n   b e h a v i o r  
 	 	 i f ( x [ i ] . t a g N a m e . t o U p p e r C a s e ( ) = = " F O R M " )   { 	 	 	  
 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( x [ i ] , ' s u b m i t ' , e v a l ( t h i s . f u n c t i o n N a m e _ f o r m V a l i d a t i o n ) ) ;  
 	 	 	 t h i s F o r m   =   x [ i ] ; 	 / /   P o i n t e r   t o   k e e p   t r a c k   o f   t h e   c u r r e n t   f o r m   b e i n g   p r o c e s s e d .  
 	 	 }  
 	 	 / /   a d d   f i e l d h i n t   b e h a v i o r  
 	 	 v a r   f h   =   d o c u m e n t . g e t E l e m e n t B y I d ( x [ i ] . i d   +   t h i s . i d S u f f i x _ f i e l d H i n t ) ; 	 	 	  
 	 	 i f ( ! f h   & &   x [ i ] . t a g N a m e . t o U p p e r C a s e ( ) = = ' I N P U T '   & &   x [ i ] . t y p e . t o L o w e r C a s e ( )   = =   ' r a d i o ' )   {  
 	 	 	 f h   =   d o c u m e n t . g e t E l e m e n t B y I d ( x [ i ] . n a m e   +   t h i s . i d S u f f i x _ f i e l d H i n t ) ;  
 	 	 } 	 	  
 	 	 i f ( f h )   { 	 	  
 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( x [ i ] , ' f o c u s ' , t h i s . a c t i v a t e F i e l d H i n t ) ;  
 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( x [ i ] , ' b l u r ' , t h i s . d e s a c t i v a t e F i e l d H i n t ) ; 	 	 	  
 	 	 }  
 	 	 / /   a d d   s w i t c h / s t a t e   b e h a v i o r  
 	 	 i f   ( x [ i ] . c l a s s N a m e   & &   x [ i ] . c l a s s N a m e . i n d e x O f ( t h i s . c l a s s N a m e P r e f i x _ s w i t c h )   ! =   - 1 )   {  
 	 	 	  
 	 	 	 s w i t c h ( x [ i ] . t a g N a m e . t o U p p e r C a s e ( ) )   {  
 	 	 	 	 c a s e   " O P T I O N " :  
 	 	 	 	 	 v a r   s e l   =   x [ i ] . p a r e n t N o d e ; 	 / /   G e t   t o   t h e   S E L E C T  
 	 	 	 	 	 i f ( s e l . t a g N a m e . t o U p p e r C a s e ( )   = =   " O P T G R O U P " )   s e l   =   s e l . p a r e n t N o d e ;   / /   t r y   a g a i n .  
 	 	 	 	 	 i f ( ! w u . i s E v e n t H a n d l e d ( s e l , ' c h a n g e ' ) )   {  
 	 	 	 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( s e l , ' c h a n g e ' , t h i s . r e f r e s h S t a t e ) ; 	 	 	 	 	 	  
 	 	 	 	       	 }  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 c a s e   " I N P U T " :  
 	 	 	 	 	 i f ( x [ i ] . t y p e   & &   x [ i ] . t y p e . t o L o w e r C a s e ( )   = =   ' r a d i o ' )   {  
 	 	 	 	 	 	 / /   A d d   t h e   o n c l i c k   e v e n t   o n   r a d i o   i n p u t s   o f   t h e   s a m e   g r o u p  
 	 	 	 	 	 	 i f ( ! t h i s F o r m )   t h i s F o r m   =   x [ i ] . f o r m ; 	  
 	 	 	 	 	 	 f o r   ( v a r   j = 0 ; j < t h i s F o r m [ x [ i ] . n a m e ] . l e n g t h ; j + + )   {  
 	 	 	 	 	 	 	 i f ( t h i s F o r m [ x [ i ] . n a m e ] [ j ] . t y p e   = =   ' r a d i o ' )   / /   p r e v e n t s   c o n f l i c t s   w i t h   e l e m e n t s   w i t h   a n   i d   =   n a m e   o f   r a d i o   g r o u p  
 	 	 	 	 	 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( t h i s F o r m [ x [ i ] . n a m e ] [ j ] , ' c l i c k ' , t h i s . r e f r e s h S t a t e ) ;  
 	 	 	 	 	 	 }  
 	 	 	 	 	 }   e l s e   {  
 	 	 	 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( x [ i ] , ' c l i c k ' , t h i s . r e f r e s h S t a t e ) ;  
 	 	 	 	 	 }  
 	 	 	 	 	 b r e a k ;  
 	 	 	 	 d e f a u l t : 	 	 	 	 	  
 	 	 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( x [ i ] , ' c l i c k ' , t h i s . r e f r e s h S t a t e ) ;  
 	 	 	 	 	 b r e a k ;  
 	 	 	 }  
 	 	 }  
  
 	 	 / /   a d d   p a g i n g   b e h a v i o r  
 	 	 i f   ( x [ i ] . c l a s s N a m e   & &   ( '   ' + x [ i ] . c l a s s N a m e + '   ' ) . i n d e x O f ( '   ' +   t h i s . c l a s s N a m e _ p a g i n g + '   ' )   ! =   - 1 )   {  
 	 	 	 v a r   c u r r e n t P a g e I n d e x   =   p a r s e I n t ( x [ i ] . i d . r e p l a c e ( / [ \ D ] * / , " " ) ) ;  
 	 	 	 i f ( c u r r e n t P a g e I n d e x   >   1 )   {  
 	 	 	 	 / /   a d d   p r e v i o u s   p a g e   b u t t o n 	 	 	  
 	 	 	 	 v a r   a c t i o n N o d e   =   d o c u m e n t . c r e a t e E l e m e n t ( " i n p u t " ) ;    
 	 	 	 	 a c t i o n N o d e . s e t A t t r i b u t e ( ' v a l u e ' , t h i s . a r r M s g [ 5 ] ) ; 	  
 	 	 	 	 a c t i o n N o d e . s e t A t t r i b u t e ( ' t y p e ' , " b u t t o n " ) ; 	  
 	 	 	 	 a c t i o n N o d e . c l a s s N a m e   =   t h i s . c l a s s N a m e _ p a g i n g B u t t o n s ;  
 	 	 	 	 x [ i ] . a p p e n d C h i l d ( a c t i o n N o d e ) ;  
 	 	 	 	 / /   A d d   e v e n t   h a n d l e r 	 	 	  
 	 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( a c t i o n N o d e , ' c l i c k ' , t h i s . p a g i n g P r e v i o u s ) ; 	 	 	  
 	 	 	 }   e l s e   {  
 	 	 	 	 / /   s e t   c u r r e n t   p a g e   c l a s s  
 	 	 	 	 x [ i ] . c l a s s N a m e   + =   '   '   +   t h i s . c l a s s N a m e _ p a g i n g C u r r e n t ;  
 	 	 	 	 / /   h i d e   s u b m i t   b u t t o n   u n t i l   t h e   l a s t   p a g e   o f   t h e   f o r m   i s   r e a c h e d  
 	 	 	 	 i f ( ! t h i s F o r m )   {  
 	 	 	 	 	 t h i s F o r m   =   x [ i ] . p a r e n t N o d e ;  
 	 	 	 	 	 w h i l e ( t h i s F o r m   & &   t h i s F o r m . t a g N a m e . t o U p p e r C a s e ( )   ! =   " F O R M " )  
 	 	 	 	 	 	 t h i s F o r m   =   t h i s F o r m . p a r e n t N o d e ;  
 	 	 	 	 }  
 	 	 	 	 v a r   s u b m i t B u t t o n   =   d o c u m e n t . g e t E l e m e n t B y I d ( " s u b m i t - " + t h i s F o r m . i d ) ;  
 	 	 	 	 i f ( s u b m i t B u t t o n )   s u b m i t B u t t o n . c l a s s N a m e   =   t h i s . c l a s s N a m e _ h i d e S u b m i t ;    
 	 	 	 	 / /   p r e v e n t   s u b m i s s i o n   o f   f o r m   w i t h   e n t e r   k e y .  
 	 	 	 	 t h i s . p r e v e n t S u b m i s s i o n O n E n t e r   =   t r u e ;  
 	 	 	 }  
 	 	 	 i f ( d o c u m e n t . g e t E l e m e n t B y I d ( t h i s . i d P r e f i x _ p a g e I n d e x + ( c u r r e n t P a g e I n d e x + 1 ) . t o S t r i n g ( ) ) )   {  
 	 	 	 	 / /   a d d   n e x t   p a g e   b u t t o n 	 	 	  
 	 	 	 	 v a r   a c t i o n N o d e   =   d o c u m e n t . c r e a t e E l e m e n t ( " i n p u t " ) ;    
 	 	 	 	 a c t i o n N o d e . s e t A t t r i b u t e ( ' v a l u e ' , t h i s . a r r M s g [ 4 ] ) ; 	  
 	 	 	 	 a c t i o n N o d e . s e t A t t r i b u t e ( ' t y p e ' , " b u t t o n " ) ; 	  
 	 	 	 	 a c t i o n N o d e . c l a s s N a m e   =   t h i s . c l a s s N a m e _ p a g i n g B u t t o n s ;  
 	 	 	 	 x [ i ] . a p p e n d C h i l d ( a c t i o n N o d e ) ;  
 	 	 	 	 / /   A d d   e v e n t   h a n d l e r 	 	 	  
 	 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( a c t i o n N o d e , ' c l i c k ' , t h i s . p a g i n g N e x t ) ; 	 	 	  
 	 	 	 }  
 	 	 }  
 	 	  
 	 	 / /   a d d   r e p e a t   b e h a v i o r  
 	 	 i f   ( x [ i ] . c l a s s N a m e   & &   ( '   ' + x [ i ] . c l a s s N a m e + '   ' ) . i n d e x O f ( '   ' + t h i s . c l a s s N a m e _ r e p e a t + '   ' )   ! =   - 1 )   {  
 	 	 	 / /   t h i s   e l e m e n t   t o   b e   d u p l i c a t e d .  
 	 	 	 w u . d e b u g ( ' a d d i n g   r e p e a t   o n   '   +   x [ i ] . i d ) ;  
 	 	 	 v a r   a c t i o n N o d e   =   n u l l ;  
 	 	 	 i f ( x [ i ] . i d )   a c t i o n N o d e   =   d o c u m e n t . g e t E l e m e n t B y I d ( x [ i ] . i d   +   t h i s . i d S u f f i x _ d u p l i c a t e L i n k ) ;  
 	 	 	 i f   ( ! a c t i o n N o d e )   { 	 	 	 	  
 	 	 	 	 / /   a d d   d u p l i c a t e   a c t i o n  
 	 	 	 	 a c t i o n N o d e   =   d o c u m e n t . c r e a t e E l e m e n t ( " a " ) ;    
 	 	 	 	 v a r   t e x t N o d e   =   d o c u m e n t . c r e a t e T e x t N o d e ( t h i s . a r r M s g [ 0 ] ) ;  
 	 	 	 	 a c t i o n N o d e . s e t A t t r i b u t e ( ' h r e f ' , " # " ) ; 	  
 	 	 	 	 a c t i o n N o d e . c l a s s N a m e   =   t h i s . c l a s s N a m e _ d u p l i c a t e L i n k ; 	 	 	  
 	 	 	 	 a c t i o n N o d e . s e t A t t r i b u t e ( ' t i t l e ' ,   t h i s . a r r M s g [ 1 ] ) ; 	  
 	 	 	 	 i f ( x [ i ] . t a g N a m e . t o U p p e r C a s e ( ) = = " T R " )   {  
 	 	 	 	 	 / /   f i n d   t h e   l a s t   T D  
 	 	 	 	 	 v a r   n   =   x [ i ] . l a s t C h i l d ; 	  
 	 	 	 	 	 w h i l e ( n   & &   n . n o d e T y p e   ! =   1 )      
 	 	 	 	 	 	 n   =   n . p r e v i o u s S i b l i n g ;  
 	 	 	 	 	 i f ( n   & &   n . n o d e T y p e   = =   1 )    
 	 	 	 	 	 	 n . a p p e n d C h i l d ( a c t i o n N o d e ) ;  
 	 	 	 	 	 / /   E l s e   C o u l d n ' t   f i n d   t h e   T D .   T a b l e   r o w   m a l f o r m e d   ?  
 	 	 	 	 }   e l s e  
 	 	 	 	 	 x [ i ] . a p p e n d C h i l d ( a c t i o n N o d e ) ;  
 	 	 	 	 a c t i o n N o d e . a p p e n d C h i l d ( t e x t N o d e ) ;    
 	 	 	 }  
 	 	 	 / /   A d d   h i d d e n   c o u n t e r   f i e l d   i f   n e c e s s a r y  
 	 	 	 v a r   c o u n t e r F i e l d   =   d o c u m e n t . g e t E l e m e n t B y I d ( x [ i ] . i d   +   t h i s . i d S u f f i x _ r e p e a t C o u n t e r ) ;  
 	 	 	 i f   ( ! c o u n t e r F i e l d )   {  
 	 	 	 	 i f ( d o c u m e n t . a l l   & &   ! w i n d o w . o p e r a )   {   / /   I E   S p e c i f i c   : - (  
 	 	 	 	 	 / /   s e e   h t t p : / / m s d n . m i c r o s o f t . c o m / w o r k s h o p / a u t h o r / d h t m l / r e f e r e n c e / p r o p e r t i e s / n a m e _ 2 . a s p  
 	 	 	 	 	 v a r   c o u n t e r F i e l d I d   =   x [ i ] . i d   +   t h i s . i d S u f f i x _ r e p e a t C o u n t e r ;  
 	 	 	 	 	 i f ( n a v i g a t o r . a p p V e r s i o n . i n d e x O f ( " M S I E " )   ! =   - 1   & &   n a v i g a t o r . a p p V e r s i o n . i n d e x O f ( " W i n d o w s " )   = =   - 1 )   / /   I E 5   M a c  
 	 	 	 	 	 	 c o u n t e r F i e l d   =   d o c u m e n t . c r e a t e E l e m e n t ( " I N P U T   N A M E = \ " "   +   c o u n t e r F i e l d I d   +   " \ " " ) ;  
 	 	 	 	 	 e l s e  
 	 	 	 	 	 	 c o u n t e r F i e l d   =   d o c u m e n t . c r e a t e E l e m e n t ( " < I N P U T   N A M E = \ " "   +   c o u n t e r F i e l d I d   +   " \ " > < / I N P U T > " ) ;   	 	 	 	 	  
 	 	 	 	 	 c o u n t e r F i e l d . t y p e = ' h i d d e n ' ;  
 	 	 	 	 	 c o u n t e r F i e l d . i d   =   c o u n t e r F i e l d I d ;    
 	 	 	 	 	 c o u n t e r F i e l d . v a l u e   =   " 1 " ;  
 	 	 	 	 }  
 	 	 	 	 e l s e   {  
 	 	 	 	 	 c o u n t e r F i e l d   =   d o c u m e n t . c r e a t e E l e m e n t ( " I N P U T " ) ;    
 	 	 	 	 	 c o u n t e r F i e l d . s e t A t t r i b u t e ( ' t y p e ' , ' h i d d e n ' ) ;   / /   h i d d e n  
 	 	 	 	 	 c o u n t e r F i e l d . s e t A t t r i b u t e ( ' v a l u e ' , ' 1 ' ) ;  
 	 	 	 	 	 c o u n t e r F i e l d . s e t A t t r i b u t e ( ' n a m e ' ,   x [ i ] . i d   +   t h i s . i d S u f f i x _ r e p e a t C o u n t e r ) ;  
 	 	 	 	 	 c o u n t e r F i e l d . s e t A t t r i b u t e ( ' i d ' ,   x [ i ] . i d   +   t h i s . i d S u f f i x _ r e p e a t C o u n t e r ) ;    
 	 	 	 	 }  
 	 	 	 	 i f ( ! t h i s F o r m )   {  
 	 	 	 	 	 t h i s F o r m   =   x [ i ] . p a r e n t N o d e ;  
 	 	 	 	 	 w h i l e ( t h i s F o r m   & &   t h i s F o r m . t a g N a m e . t o U p p e r C a s e ( )   ! =   " F O R M " )  
 	 	 	 	 	 	 t h i s F o r m   =   t h i s F o r m . p a r e n t N o d e ;  
 	 	 	 	 }  
 	 	 	 	 t h i s F o r m . a p p e n d C h i l d ( c o u n t e r F i e l d ) ;  
 	 	 	 }  
 	 	 	 / /   A d d   e v e n t   h a n d l e r 	 	 	  
 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( a c t i o n N o d e , ' c l i c k ' , t h i s . d u p l i c a t e F i e l d G r o u p ) ; 	 	 	  
 	 	 } 	  
 	 	 / /   a d d   r e m o v e   b e h a v i o r  
 	 	 i f   ( x [ i ] . c l a s s N a m e   & &   ( '   ' + x [ i ] . c l a s s N a m e + '   ' ) . i n d e x O f ( '   ' + t h i s . c l a s s N a m e _ d e l e t e + '   ' )   ! =   - 1 )   {  
 	 	 	 w u . d e b u g ( ' a d d i n g   r e m o v e   o n   '   +   x [ i ] . i d ) ;  
 	 	 	 / /   t h i s   e l e m e n t   c a n   b e   r e m o v e d  
 	 	 	 / /   a d d   r e m o v e   a c t i o n  
 	 	 	 v a r   a c t i o n N o d e   =   d o c u m e n t . c r e a t e E l e m e n t ( " a " ) ;    
 	 	 	 v a r   t e x t N o d e   =   d o c u m e n t . c r e a t e T e x t N o d e ( t h i s . a r r M s g [ 2 ] ) ;  
 	 	 	 a c t i o n N o d e . s e t A t t r i b u t e ( ' h r e f ' , " # " ) ; 	  
 	 	 	 a c t i o n N o d e . c l a s s N a m e   =   t h i s . c l a s s N a m e _ r e m o v e L i n k ;  
 	 	 	 a c t i o n N o d e . s e t A t t r i b u t e ( ' t i t l e ' , t h i s . a r r M s g [ 3 ] ) ; 	  
 	 	 	 i f ( x [ i ] . t a g N a m e . t o U p p e r C a s e ( ) = = " T R " )   {  
 	 	 	 	 / /   f i n d   t h e   l a s t   T D  
 	 	 	 	 v a r   n   =   x [ i ] . l a s t C h i l d ; 	  
 	 	 	 	 w h i l e ( n   & &   n . n o d e T y p e   ! =   1 )      
 	 	 	 	 	 n   =   n . p r e v i o u s S i b l i n g ;  
 	 	 	 	 i f ( n   & &   n . n o d e T y p e   = =   1 )    
 	 	 	 	 	 n . a p p e n d C h i l d ( a c t i o n N o d e ) ;  
 	 	 	 	 / /   E l s e   C o u l d n ' t   f i n d   t h e   T D .   T a b l e   r o w   m a l f o r m e d   ?  
 	 	 	 }   e l s e  
 	 	 	 	 x [ i ] . a p p e n d C h i l d ( a c t i o n N o d e ) ;  
 	 	 	 a c t i o n N o d e . a p p e n d C h i l d ( t e x t N o d e ) ;   	 	 	  
 	 	 	 w u . X B r o w s e r A d d H a n d l e r ( a c t i o n N o d e , ' c l i c k ' , t h i s . r e m o v e F i e l d G r o u p ) ; 	 	 	  
 	 	 } 	  
 	   }  
 	   t h i s . r e f r e s h A l l S t a t e s ( f I d ) ;  
 }  
  
  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 / /   U T I L I T Y   C L A S S  
 / /   * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  
 f u n c t i o n   w U T I L I T Y ( )   {  
 	 / /   E v e n t   H a n d l e r   u t i l i t y   l i s t  
 	 t h i s . h a n d l e r L i s t   =   n e w   A r r a y ( ) ;    
 }  
  
 / /   C r o s s - B r o w s e r   e v e n t   h a n d l e r   m a n a g e m e n t .  
 / /   a d a p t e d   f r o m   A n d y   S m i t h ' s   ( h t t p : / / w e b l o g s . a s p . n e t / a s m i t h / a r c h i v e / 2 0 0 3 / 1 0 / 0 6 / 3 0 7 4 4 . a s p x )  
 w U T I L I T Y . p r o t o t y p e . X B r o w s e r A d d H a n d l e r   =   f u n c t i o n   ( t a r g e t , e v e n t N a m e , h a n d l e r N a m e )   {  
 	 i f ( ! t a r g e t )   r e t u r n ;  
 	 i f   ( t a r g e t . a d d E v e n t L i s t e n e r )   {    
 	 	 t a r g e t . a d d E v e n t L i s t e n e r ( e v e n t N a m e ,   f u n c t i o n ( e ) { e v a l ( h a n d l e r N a m e ) ( e ) ; } ,   f a l s e ) ;  
 	 }   e l s e   i f   ( t a r g e t . a t t a c h E v e n t )   {    
 	 	 t a r g e t . a t t a c h E v e n t ( " o n "   +   e v e n t N a m e ,   f u n c t i o n ( e ) { e v a l ( h a n d l e r N a m e ) ( e ) ; } ) ;  
 	 	 }   e l s e   {    
 	 	 / /   T H I S   C O D E   N O T   T E S T E D    
 	 	 v a r   o r i g i n a l H a n d l e r   =   t a r g e t [ " o n "   +   e v e n t N a m e ] ;    
 	 	 i f   ( o r i g i n a l H a n d l e r )   {    
 	 	     t a r g e t [ " o n "   +   e v e n t N a m e ]   =   f u n c t i o n ( e ) { o r i g i n a l H a n d l e r ( e ) ; e v a l ( h a n d l e r N a m e ) ( e ) ; } ;    
 	 	 }   e l s e   {    
 	 	     t a r g e t [ " o n "   +   e v e n t N a m e ]   =   e v a l ( h a n d l e r N a m e ) ;    
 	 	 }    
 	 }    
 	 / /   K e e p   t r a c k   o f   a d d e d   h a n d l e r s .  
 	 v a r   l   =   t h i s . h a n d l e r L i s t . l e n g t h ;  
 	 t h i s . h a n d l e r L i s t [ l ]   =   n e w   A r r a y ( 2 ) ;  
 	 t h i s . h a n d l e r L i s t [ l ] [ 0 ]   =   t a r g e t . i d ;      
 	 t h i s . h a n d l e r L i s t [ l ] [ 1 ]   =   e v e n t N a m e ;     	  
 	 t h i s . d e b u g ( " H a n d l e r   a d d e d   : "   +   t a r g e t . i d   +   '   '   +   e v e n t N a m e ) ;  
 }  
 / /    
 w U T I L I T Y . p r o t o t y p e . i s E v e n t H a n d l e d   =   f u n c t i o n ( n ,   t y p e )   { 	  
 	 f o r ( v a r   i = 0 ;   i   <   t h i s . h a n d l e r L i s t . l e n g t h ;   i + + )   {  
 	 	 i f ( t h i s . h a n d l e r L i s t [ i ] [ 0 ] = = n . i d   & &   t h i s . h a n d l e r L i s t [ i ] [ 1 ] = = t y p e )  
 	 	 	 r e t u r n   t r u e ;  
 	 }  
 	 r e t u r n   f a l s e ;  
 }  
 w U T I L I T Y . p r o t o t y p e . r e s e t E v e n t L i s t   =   f u n c t i o n ( )   {  
 	 t h i s . h a n d l e r L i s t   =   n e w   A r r a y ( ) ;    
 }  
  
 / /   A c t i v a t i n g   a n   A l t e r n a t e   S t y l e s h e e t   ( t h x   t o :   h t t p : / / w w w . h o w t o c r e a t e . c o . u k / t u t o r i a l s / i n d e x . p h p ? t u t = 0 & p a r t = 2 7 )  
 / /   U s e   t h i s   t o   a c t i v a t e   a   C S S   S t y l e s h e e t   t h a t   s h o u l d n ' t   b e   u s e d   i f   j a v a s c r i p t   i s   t u r n e d   o f f .  
 / /   T h e   s t y l e s h e e t   r e l   a t t r i b u t e   s h o u l d   b e   ' a l t e r n a t e   s t y l e s h e e t ' .   T h e   t i t l e   a t t r i b u t e   s h o u l d   b e   s e t .  
 w U T I L I T Y . p r o t o t y p e . a c t i v a t e S t y l e s h e e t   =   f u n c t i o n ( s h e e t r e f )   {  
 	 i f ( d o c u m e n t . g e t E l e m e n t s B y T a g N a m e )   {  
 	 	 v a r   s s = d o c u m e n t . g e t E l e m e n t s B y T a g N a m e ( ' l i n k ' ) ;  
 	 }   e l s e   i f   ( d o c u m e n t . s t y l e S h e e t s )   {  
 	 	 v a r   s s   =   d o c u m e n t . s t y l e S h e e t s ;  
 	 }  
 	 f o r ( v a r   i = 0 ; s s [ i ] ; i + +   )   {  
 	 	 i f ( s s [ i ] . h r e f . i n d e x O f ( s h e e t r e f )   ! =   - 1 )   {  
 	 	 	 s s [ i ] . d i s a b l e d   =   t r u e ;  
 	 	 	 s s [ i ] . d i s a b l e d   =   f a l s e ; 	 	 	  
 	 	 }  
 	 }  
 }  
 / /   G e n e r a t e s   a   r a n d o m   I D  
 w U T I L I T Y . p r o t o t y p e . r a n d o m I d   =   f u n c t i o n   ( )   {  
 	 v a r   r I d   =   " " ;  
 	 f o r   ( v a r   i = 0 ;   i < 6 ; i + + )  
 	 	 r I d   + =   S t r i n g . f r o m C h a r C o d e ( 9 7   +   M a t h . f l o o r ( ( M a t h . r a n d o m ( ) * 2 4 ) ) )  
 	 r e t u r n   r I d ;  
 }  
 / /   r e t u r n s   a l l   c h i l d   e l e m e n t s   o f   a   n o d e .  
 w U T I L I T Y . p r o t o t y p e . g e t E l e m e n t s   =   f u n c t i o n ( n ,   l i s t )   {  
 	 i f ( ! l i s t )   l i s t   =   n e w   A r r a y ( ) ;  
 	 i f ( n . n o d e T y p e = = 1 )   {  
 	 	 l i s t [ l i s t . l e n g t h ] =   n ;  
 	 	 f o r ( v a r   i = 0 ;   i < n . c h i l d N o d e s . l e n g t h ; i + + )    
 	 	 	 t h i s . g e t E l e m e n t s ( n . c h i l d N o d e s [ i ] ,   l i s t ) ;  
 	 	 r e t u r n   l i s t ;  
 	 }  
 }  
 / /   R e t u r n s   t h e   e v e n t ' s   s o u r c e   e l e m e n t    
 w U T I L I T Y . p r o t o t y p e . g e t S r c E l e m e n t   =   f u n c t i o n ( e )   { 	  
 	 i f ( ! e )    
 	 	 e   =   w i n d o w . e v e n t ; 	  
 	 i f ( e . t a r g e t )  
 	 	 v a r   s r c E   =   e . t a r g e t ;  
 	 e l s e  
 	 	 v a r   s r c E   =   e . s r c E l e m e n t ;  
 	 i f ( s r c E . n o d e T y p e   = =   3 )   s r c E   =   s r c E . p a r e n t N o d e ;   / /   s a f a r i   w e i r d n e s s 	 	  
 	 i f ( s r c E . t a g N a m e . t o U p p e r C a s e ( ) = = ' L A B E L ' )   {    
 	 	 / /   w h e n   c l i c k i n g   a   l a b e l ,   f i r e f o x   f i r e s   t h e   i n p u t   o n c l i c k   e v e n t  
 	 	 / /   b u t   t h e   l a b e l   r e m a i n s   t h e   s o u r c e   o f   t h e   e v e n t .   I n   O p e r a   a n d   I E    
 	 	 / /   t h e   s o u r c e   o f   t h e   e v e n t   i s   t h e   i n p u t   e l e m e n t .   W h i c h   i s   t h e    
 	 	 / /   e x p e c t e d   b e h a v i o r ,   I   s u p p o s e . 	 	  
 	 	 i f ( s r c E . g e t A t t r i b u t e ( ' f o r ' ) )   {  
 	 	 	 s r c E   =   d o c u m e n t . g e t E l e m e n t B y I d ( s r c E . g e t A t t r i b u t e ( ' f o r ' ) ) ;  
 	 	 }  
 	 }  
 	 r e t u r n   s r c E ;  
 }  
 / /   C a n c e l   t h e   d e f a u l t   e x e c u t i o n   o f   a n   e v e n t .  
 w U T I L I T Y . p r o t o t y p e . X B r o w s e r P r e v e n t E v e n t D e f a u l t   =   f u n c t i o n ( e )   {  
 	 i f ( ! e )   e   =   w i n d o w . e v e n t ;  
 	 i f   ( e . p r e v e n t D e f a u l t )   e . p r e v e n t D e f a u l t ( ) ;  
 	 e l s e   e . r e t u r n V a l u e   =   f a l s e ;  
 	 r e t u r n   f a l s e ;  
 }  
 w U T I L I T Y . p r o t o t y p e . c h e c k V i s i b i l i t y   =   f u n c t i o n ( n )   {  
 	 / /   c h e c k   i f   a n y   o f   t h e   e l e m e n t ' s   a n c e s t o r s   i s   n o t   v i s i b l e .  
 	 i f ( w i n d o w . g e t C o m p u t e d S t y l e )   {  
 	 	 v a r   i s V i s i b l e   =   w i n d o w . g e t C o m p u t e d S t y l e ( n , " " ) . g e t P r o p e r t y V a l u e ( " d i s p l a y " ) . t o L o w e r C a s e ( ) ! = " n o n e " ;  
 	 	 i s V i s i b l e   =   i s V i s i b l e   & &   w i n d o w . g e t C o m p u t e d S t y l e ( n , " " ) . g e t P r o p e r t y V a l u e ( " v i s i b i l i t y " ) . t o L o w e r C a s e ( ) ! = " h i d d e n " ;  
 	 	 / /   a d d   v i s i b l i t y ! = c o l l a p s e   ?  
 	 }  
 	 e l s e   i f ( n . c u r r e n t S t y l e )   { 	 	  
 	 	 i f ( n . c u r r e n t S t y l e . d i s p l a y = = ' ' )   r e t u r n   f a l s e ;   / /   e f f e c t i v e l y   d i s a b l e   v a l i d a t i o n   o n   I E 5 / M a c .  
 	 	 v a r   i s V i s i b l e   =   n . c u r r e n t S t y l e . d i s p l a y . t o L o w e r C a s e ( )   ! =   " n o n e " ;  
 	 	 i s V i s i b l e   =   i s V i s i b l e   & &   n . c u r r e n t S t y l e . v i s i b i l i t y . t o L o w e r C a s e ( )   ! = " h i d d e n " ;  
 	 }  
 	 e l s e   {  
 	 	 r e t u r n   f a l s e ;   / /   e f f e c t i v e l y   d i s a b l e   v a l i d a t i o n   f o r   S a f a r i  
 	 	 / /   t r y   t o   f o c u s   o r   s e l e c t . . .  
 	 	 / /   T h i s   c o d e   n o t   f i n a l i z e d   ( d o e s n ' t   w o r k   f o r   S a f a r i ) .  
 	 	 t r y   { 	 	 	  
 	 	 	 	 i f ( n . f o c u s )   a l e r t ( n . f o c u s ( ) ) ;  
 	 	 	 	 i f ( n . s e l e c t )   a l e r t ( n . s e l e c t ( ) ) ;  
 	 	 	 }      
 	 	 c a t c h   ( e )   {  
 	 	 	 	 / /   f o c u s   f a i l e d .   E i t h e r   n o t   a   f i e l d ,   o r   n o t   v i s i b l e .  
 	 	 	 	 a l e r t ( " n o t   a   v i s i b l e   f i e l d .   "   +   e ) ;  
 	 	 	 	 r e t u r n   f a l s e ;  
 	 	 	 } 	 	  
 	 	 	 r e t u r n   t r u e ;   / /   f o c u s   o k .   T h e   f i e l d   i s   d e f i n i t i v e l y   v i s i b l e .  
 	 }  
 	 i f ( ! n . p a r e n t N o d e )   {   r e t u r n   f a l s e ;   }   ;   / /   s h o u l d   n o t   h a p p e n ,   u n l e s s   w e   c h e c k i n g   s o m e   r e m o v e d   e l e m e n t s .  
 	 i f   ( n . p a r e n t N o d e . t a g N a m e . t o U p p e r C a s e ( ) = = " B O D Y "   | |   ! i s V i s i b l e )  
 	 	 r e t u r n   i s V i s i b l e ;  
 	 r e t u r n   t h i s . c h e c k V i s i b i l i t y ( n . p a r e n t N o d e ) ;  
 }  
 	  
 w U T I L I T Y . p r o t o t y p e . d e b u g   =   f u n c t i o n ( t e x t )   {    
 	 / / v a r   d e b u g O u t p u t   =   d o c u m e n t . g e t E l e m e n t B y I d ( ' d e b u g O u t p u t ' ) ;      
 	 / / i f ( d e b u g O u t p u t )   d e b u g O u t p u t . i n n e r H T M L   =   d e b u g O u t p u t . i n n e r H T M L + " < b r   / > " + t e x t ;    
 }  
  
 / /   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =  
 / /   L E T ' s   G O  
 v a r   w f   =   n e w   w F O R M S ( ) ;  
 / /   A t t a c h   J S   o n l y   s t y l e s h e e t .  
 w f . u t i l i t i e s . a c t i v a t e S t y l e s h e e t ( ' w f o r m s - j s o n l y . c s s ' ) ;    
 / /   o n L o a d   e v e n t   h a n d l e r  
 w f . u t i l i t i e s . X B r o w s e r A d d H a n d l e r ( w i n d o w , ' l o a d ' , f u n c t i o n ( )   {   w f . o n L o a d H a n d l e r ( ) ; }     ) ; 
