/ /   b b C o d e   c o n t r o l   b y  
 / /   s u b B l u e   d e s i g n  
 / /   w w w . s u b B l u e . c o m  
  
 / /   S t a r t u p   v a r i a b l e s  
 v a r   i m a g e T a g   =   f a l s e ;  
 v a r   t h e S e l e c t i o n   =   f a l s e ;  
  
 / /   C h e c k   f o r   B r o w s e r   &   P l a t f o r m   f o r   P C   &   I E   s p e c i f i c   b i t s  
 / /   M o r e   d e t a i l s   f r o m :   h t t p : / / w w w . m o z i l l a . o r g / d o c s / w e b - d e v e l o p e r / s n i f f e r / b r o w s e r _ t y p e . h t m l  
 v a r   c l i e n t P C   =   n a v i g a t o r . u s e r A g e n t . t o L o w e r C a s e ( ) ;   / /   G e t   c l i e n t   i n f o  
 v a r   c l i e n t V e r   =   p a r s e I n t ( n a v i g a t o r . a p p V e r s i o n ) ;   / /   G e t   b r o w s e r   v e r s i o n  
  
 v a r   i s _ i e   =   ( ( c l i e n t P C . i n d e x O f ( " m s i e " )   ! =   - 1 )   & &   ( c l i e n t P C . i n d e x O f ( " o p e r a " )   = =   - 1 ) ) ;  
 v a r   i s _ n a v   =   ( ( c l i e n t P C . i n d e x O f ( ' m o z i l l a ' ) ! = - 1 )   & &   ( c l i e n t P C . i n d e x O f ( ' s p o o f e r ' ) = = - 1 )  
                                 & &   ( c l i e n t P C . i n d e x O f ( ' c o m p a t i b l e ' )   = =   - 1 )   & &   ( c l i e n t P C . i n d e x O f ( ' o p e r a ' ) = = - 1 )  
                                 & &   ( c l i e n t P C . i n d e x O f ( ' w e b t v ' ) = = - 1 )   & &   ( c l i e n t P C . i n d e x O f ( ' h o t j a v a ' ) = = - 1 ) ) ;  
 v a r   i s _ m o z   =   0 ;  
  
 v a r   i s _ w i n   =   ( ( c l i e n t P C . i n d e x O f ( " w i n " ) ! = - 1 )   | |   ( c l i e n t P C . i n d e x O f ( " 1 6 b i t " )   ! =   - 1 ) ) ;  
 v a r   i s _ m a c   =   ( c l i e n t P C . i n d e x O f ( " m a c " ) ! = - 1 ) ;  
  
 / /   H e l p l i n e   m e s s a g e s  
 b _ h e l p   =   " { L _ B B C O D E _ B _ H E L P } " ;  
 i _ h e l p   =   " { L _ B B C O D E _ I _ H E L P } " ;  
 u _ h e l p   =   " { L _ B B C O D E _ U _ H E L P } " ;  
 q _ h e l p   =   " { L _ B B C O D E _ Q _ H E L P } " ;  
 c _ h e l p   =   " { L _ B B C O D E _ C _ H E L P } " ;  
 l _ h e l p   =   " { L _ B B C O D E _ L _ H E L P } " ;  
 o _ h e l p   =   " { L _ B B C O D E _ O _ H E L P } " ;  
 p _ h e l p   =   " { L _ B B C O D E _ P _ H E L P } " ;  
 w _ h e l p   =   " { L _ B B C O D E _ W _ H E L P } " ;  
 a _ h e l p   =   " { L _ B B C O D E _ A _ H E L P } " ;  
 s _ h e l p   =   " { L _ B B C O D E _ S _ H E L P } " ;  
 f _ h e l p   =   " { L _ B B C O D E _ F _ H E L P } " ;  
  
 / /   D e f i n e   t h e   b b C o d e   t a g s  
 b b c o d e   =   n e w   A r r a y ( ) ;  
 b b t a g s   =   n e w   A r r a y ( ' [ b ] ' , ' [ / b ] ' , ' [ i ] ' , ' [ / i ] ' , ' [ u ] ' , ' [ / u ] ' , ' [ q u o t e ] ' , ' [ / q u o t e ] ' , ' [ c o d e ] ' , ' [ / c o d e ] ' , ' [ l i s t ] ' , ' [ / l i s t ] ' , ' [ l i s t = ] ' , ' [ / l i s t ] ' , ' [ i m g ] ' , ' [ / i m g ] ' , ' [ u r l ] ' , ' [ / u r l ] ' ) ;  
 i m a g e T a g   =   f a l s e ;  
  
 / /   S h o w s   t h e   h e l p   m e s s a g e s   i n   t h e   h e l p l i n e   w i n d o w  
 f u n c t i o n   h e l p l i n e ( h e l p )   {  
 	 d o c u m e n t . p o s t . h e l p b o x . v a l u e   =   e v a l ( h e l p   +   " _ h e l p " ) ;  
 }  
  
  
 / /   R e p l a c e m e n t   f o r   a r r a y n a m e . l e n g t h   p r o p e r t y  
 f u n c t i o n   g e t a r r a y s i z e ( t h e a r r a y )   {  
 	 f o r   ( i   =   0 ;   i   <   t h e a r r a y . l e n g t h ;   i + + )   {  
 	 	 i f   ( ( t h e a r r a y [ i ]   = =   " u n d e f i n e d " )   | |   ( t h e a r r a y [ i ]   = =   " " )   | |   ( t h e a r r a y [ i ]   = =   n u l l ) )  
 	 	 	 r e t u r n   i ;  
 	 	 }  
 	 r e t u r n   t h e a r r a y . l e n g t h ;  
 }  
  
 / /   R e p l a c e m e n t   f o r   a r r a y n a m e . p u s h ( v a l u e )   n o t   i m p l e m e n t e d   i n   I E   u n t i l   v e r s i o n   5 . 5  
 / /   A p p e n d s   e l e m e n t   t o   t h e   a r r a y  
 f u n c t i o n   a r r a y p u s h ( t h e a r r a y , v a l u e )   {  
 	 t h e a r r a y [   g e t a r r a y s i z e ( t h e a r r a y )   ]   =   v a l u e ;  
 }  
  
 / /   R e p l a c e m e n t   f o r   a r r a y n a m e . p o p ( )   n o t   i m p l e m e n t e d   i n   I E   u n t i l   v e r s i o n   5 . 5  
 / /   R e m o v e s   a n d   r e t u r n s   t h e   l a s t   e l e m e n t   o f   a n   a r r a y  
 f u n c t i o n   a r r a y p o p ( t h e a r r a y )   {  
 	 t h e a r r a y s i z e   =   g e t a r r a y s i z e ( t h e a r r a y ) ;  
 	 r e t v a l   =   t h e a r r a y [ t h e a r r a y s i z e   -   1 ] ;  
 	 d e l e t e   t h e a r r a y [ t h e a r r a y s i z e   -   1 ] ;  
 	 r e t u r n   r e t v a l ;  
 }  
  
  
 f u n c t i o n   c h e c k F o r m ( )   {  
  
 	 f o r m E r r o r s   =   f a l s e ;          
  
 	 i f   ( d o c u m e n t . p o s t . m e s s a g e . v a l u e . l e n g t h   <   2 )   {  
 	 	 f o r m E r r o r s   =   " { L _ E M P T Y _ M E S S A G E } " ;  
 	 }  
  
 	 i f   ( f o r m E r r o r s )   {  
 	 	 a l e r t ( f o r m E r r o r s ) ;  
 	 	 r e t u r n   f a l s e ;  
 	 }   e l s e   {  
 	 	 b b s t y l e ( - 1 ) ;  
 	 	 / / f o r m O b j . p r e v i e w . d i s a b l e d   =   t r u e ;  
 	 	 / / f o r m O b j . s u b m i t . d i s a b l e d   =   t r u e ;  
 	 	 r e t u r n   t r u e ;  
 	 }  
 }  
  
 f u n c t i o n   e m o t i c o n ( t e x t )   {  
 	 v a r   t x t a r e a   =   d o c u m e n t . p o s t . m e s s a g e ;  
 	 t e x t   =   '   '   +   t e x t   +   '   ' ;  
 	 i f   ( t x t a r e a . c r e a t e T e x t R a n g e   & &   t x t a r e a . c a r e t P o s )   {  
 	 	 v a r   c a r e t P o s   =   t x t a r e a . c a r e t P o s ;  
 	 	 c a r e t P o s . t e x t   =   c a r e t P o s . t e x t . c h a r A t ( c a r e t P o s . t e x t . l e n g t h   -   1 )   = =   '   '   ?   c a r e t P o s . t e x t   +   t e x t   +   '   '   :   c a r e t P o s . t e x t   +   t e x t ;  
 	 	 t x t a r e a . f o c u s ( ) ;  
 	 }   e l s e   {  
 	 	 t x t a r e a . v a l u e     + =   t e x t ;  
 	 	 t x t a r e a . f o c u s ( ) ;  
 	 }  
 }  
  
 f u n c t i o n   b b f o n t s t y l e ( b b o p e n ,   b b c l o s e )   {  
 	 v a r   t x t a r e a   =   d o c u m e n t . p o s t . m e s s a g e ;  
  
 	 i f   ( ( c l i e n t V e r   > =   4 )   & &   i s _ i e   & &   i s _ w i n )   {  
 	 	 t h e S e l e c t i o n   =   d o c u m e n t . s e l e c t i o n . c r e a t e R a n g e ( ) . t e x t ;  
 	 	 i f   ( ! t h e S e l e c t i o n )   {  
 	 	 	 t x t a r e a . v a l u e   + =   b b o p e n   +   b b c l o s e ;  
 	 	 	 t x t a r e a . f o c u s ( ) ;  
 	 	 	 r e t u r n ;  
 	 	 }  
 	 	 d o c u m e n t . s e l e c t i o n . c r e a t e R a n g e ( ) . t e x t   =   b b o p e n   +   t h e S e l e c t i o n   +   b b c l o s e ;  
 	 	 t x t a r e a . f o c u s ( ) ;  
 	 	 r e t u r n ;  
 	 }  
 	 e l s e   i f   ( t x t a r e a . s e l e c t i o n E n d   & &   ( t x t a r e a . s e l e c t i o n E n d   -   t x t a r e a . s e l e c t i o n S t a r t   >   0 ) )  
 	 {  
 	 	 m o z W r a p ( t x t a r e a ,   b b o p e n ,   b b c l o s e ) ;  
 	 	 r e t u r n ;  
 	 }  
 	 e l s e  
 	 {  
 	 	 t x t a r e a . v a l u e   + =   b b o p e n   +   b b c l o s e ;  
 	 	 t x t a r e a . f o c u s ( ) ;  
 	 }  
 	 s t o r e C a r e t ( t x t a r e a ) ;  
 }  
  
  
 f u n c t i o n   b b s t y l e ( b b n u m b e r )   {  
 	 v a r   t x t a r e a   =   d o c u m e n t . p o s t . m e s s a g e ;  
  
 	 t x t a r e a . f o c u s ( ) ;  
 	 d o n o t i n s e r t   =   f a l s e ;  
 	 t h e S e l e c t i o n   =   f a l s e ;  
 	 b b l a s t   =   0 ;  
  
 	 i f   ( b b n u m b e r   = =   - 1 )   {   / /   C l o s e   a l l   o p e n   t a g s   &   d e f a u l t   b u t t o n   n a m e s  
 	 	 w h i l e   ( b b c o d e [ 0 ] )   {  
 	 	 	 b u t n u m b e r   =   a r r a y p o p ( b b c o d e )   -   1 ;  
 	 	 	 t x t a r e a . v a l u e   + =   b b t a g s [ b u t n u m b e r   +   1 ] ;  
 	 	 	 b u t t e x t   =   e v a l ( ' d o c u m e n t . p o s t . a d d b b c o d e '   +   b u t n u m b e r   +   ' . v a l u e ' ) ;  
 	 	 	 e v a l ( ' d o c u m e n t . p o s t . a d d b b c o d e '   +   b u t n u m b e r   +   ' . v a l u e   = " '   +   b u t t e x t . s u b s t r ( 0 , ( b u t t e x t . l e n g t h   -   1 ) )   +   ' " ' ) ;  
 	 	 }  
 	 	 i m a g e T a g   =   f a l s e ;   / /   A l l   t a g s   a r e   c l o s e d   i n c l u d i n g   i m a g e   t a g s   : D  
 	 	 t x t a r e a . f o c u s ( ) ;  
 	 	 r e t u r n ;  
 	 }  
  
 	 i f   ( ( c l i e n t V e r   > =   4 )   & &   i s _ i e   & &   i s _ w i n )  
 	 {  
 	 	 t h e S e l e c t i o n   =   d o c u m e n t . s e l e c t i o n . c r e a t e R a n g e ( ) . t e x t ;   / /   G e t   t e x t   s e l e c t i o n  
 	 	 i f   ( t h e S e l e c t i o n )   {  
 	 	 	 / /   A d d   t a g s   a r o u n d   s e l e c t i o n  
 	 	 	 d o c u m e n t . s e l e c t i o n . c r e a t e R a n g e ( ) . t e x t   =   b b t a g s [ b b n u m b e r ]   +   t h e S e l e c t i o n   +   b b t a g s [ b b n u m b e r + 1 ] ;  
 	 	 	 t x t a r e a . f o c u s ( ) ;  
 	 	 	 t h e S e l e c t i o n   =   ' ' ;  
 	 	 	 r e t u r n ;  
 	 	 }  
 	 }  
 	 e l s e   i f   ( t x t a r e a . s e l e c t i o n E n d   & &   ( t x t a r e a . s e l e c t i o n E n d   -   t x t a r e a . s e l e c t i o n S t a r t   >   0 ) )  
 	 {  
 	 	 m o z W r a p ( t x t a r e a ,   b b t a g s [ b b n u m b e r ] ,   b b t a g s [ b b n u m b e r + 1 ] ) ;  
 	 	 r e t u r n ;  
 	 }  
 	  
 	 / /   F i n d   l a s t   o c c u r a n c e   o f   a n   o p e n   t a g   t h e   s a m e   a s   t h e   o n e   j u s t   c l i c k e d  
 	 f o r   ( i   =   0 ;   i   <   b b c o d e . l e n g t h ;   i + + )   {  
 	 	 i f   ( b b c o d e [ i ]   = =   b b n u m b e r + 1 )   {  
 	 	 	 b b l a s t   =   i ;  
 	 	 	 d o n o t i n s e r t   =   t r u e ;  
 	 	 }  
 	 }  
  
 	 i f   ( d o n o t i n s e r t )   { 	 	 / /   C l o s e   a l l   o p e n   t a g s   u p   t o   t h e   o n e   j u s t   c l i c k e d   &   d e f a u l t   b u t t o n   n a m e s  
 	 	 w h i l e   ( b b c o d e [ b b l a s t ] )   {  
 	 	 	 	 b u t n u m b e r   =   a r r a y p o p ( b b c o d e )   -   1 ;  
 	 	 	 	 t x t a r e a . v a l u e   + =   b b t a g s [ b u t n u m b e r   +   1 ] ;  
 	 	 	 	 b u t t e x t   =   e v a l ( ' d o c u m e n t . p o s t . a d d b b c o d e '   +   b u t n u m b e r   +   ' . v a l u e ' ) ;  
 	 	 	 	 e v a l ( ' d o c u m e n t . p o s t . a d d b b c o d e '   +   b u t n u m b e r   +   ' . v a l u e   = " '   +   b u t t e x t . s u b s t r ( 0 , ( b u t t e x t . l e n g t h   -   1 ) )   +   ' " ' ) ;  
 	 	 	 	 i m a g e T a g   =   f a l s e ;  
 	 	 	 }  
 	 	 	 t x t a r e a . f o c u s ( ) ;  
 	 	 	 r e t u r n ;  
 	 }   e l s e   {   / /   O p e n   t a g s  
 	  
 	 	 i f   ( i m a g e T a g   & &   ( b b n u m b e r   ! =   1 4 ) )   { 	 	 / /   C l o s e   i m a g e   t a g   b e f o r e   a d d i n g   a n o t h e r  
 	 	 	 t x t a r e a . v a l u e   + =   b b t a g s [ 1 5 ] ;  
 	 	 	 l a s t V a l u e   =   a r r a y p o p ( b b c o d e )   -   1 ; 	 / /   R e m o v e   t h e   c l o s e   i m a g e   t a g   f r o m   t h e   l i s t  
 	 	 	 d o c u m e n t . p o s t . a d d b b c o d e 1 4 . v a l u e   =   " I m g " ; 	 / /   R e t u r n   b u t t o n   b a c k   t o   n o r m a l   s t a t e  
 	 	 	 i m a g e T a g   =   f a l s e ;  
 	 	 }  
 	 	  
 	 	 / /   O p e n   t a g  
 	 	 t x t a r e a . v a l u e   + =   b b t a g s [ b b n u m b e r ] ;  
 	 	 i f   ( ( b b n u m b e r   = =   1 4 )   & &   ( i m a g e T a g   = =   f a l s e ) )   i m a g e T a g   =   1 ;   / /   C h e c k   t o   s t o p   a d d i t i o n a l   t a g s   a f t e r   a n   u n c l o s e d   i m a g e   t a g  
 	 	 a r r a y p u s h ( b b c o d e , b b n u m b e r + 1 ) ;  
 	 	 e v a l ( ' d o c u m e n t . p o s t . a d d b b c o d e ' + b b n u m b e r + ' . v a l u e   + =   " * " ' ) ;  
 	 	 t x t a r e a . f o c u s ( ) ;  
 	 	 r e t u r n ;  
 	 }  
 	 s t o r e C a r e t ( t x t a r e a ) ;  
 }  
  
 / /   F r o m   h t t p : / / w w w . m a s s l e s s . o r g / m o z e d i t /  
 f u n c t i o n   m o z W r a p ( t x t a r e a ,   o p e n ,   c l o s e )  
 {  
 	 v a r   s e l L e n g t h   =   t x t a r e a . t e x t L e n g t h ;  
 	 v a r   s e l S t a r t   =   t x t a r e a . s e l e c t i o n S t a r t ;  
 	 v a r   s e l E n d   =   t x t a r e a . s e l e c t i o n E n d ;  
 	 i f   ( s e l E n d   = =   1   | |   s e l E n d   = =   2 )    
 	 	 s e l E n d   =   s e l L e n g t h ;  
  
 	 v a r   s 1   =   ( t x t a r e a . v a l u e ) . s u b s t r i n g ( 0 , s e l S t a r t ) ;  
 	 v a r   s 2   =   ( t x t a r e a . v a l u e ) . s u b s t r i n g ( s e l S t a r t ,   s e l E n d )  
 	 v a r   s 3   =   ( t x t a r e a . v a l u e ) . s u b s t r i n g ( s e l E n d ,   s e l L e n g t h ) ;  
 	 t x t a r e a . v a l u e   =   s 1   +   o p e n   +   s 2   +   c l o s e   +   s 3 ;  
 	 r e t u r n ;  
 }  
  
 / /   I n s e r t   a t   C l a r e t   p o s i t i o n .   C o d e   f r o m  
 / /   h t t p : / / w w w . f a q t s . c o m / k n o w l e d g e _ b a s e / v i e w . p h t m l / a i d / 1 0 5 2 / f i d / 1 3 0  
 f u n c t i o n   s t o r e C a r e t ( t e x t E l )   {  
 	 i f   ( t e x t E l . c r e a t e T e x t R a n g e )   t e x t E l . c a r e t P o s   =   d o c u m e n t . s e l e c t i o n . c r e a t e R a n g e ( ) . d u p l i c a t e ( ) ;  
 }  
 