ÿþf u n c t i o n   s e t M a x L e n g t h ( )   {  
         v a r   x   =   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 ( ' t e x t a r e a ' ) ;  
         v a r   c o u n t e r   =   d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) ;  
         c o u n t e r . c l a s s N a m e   =   ' c o u n t e r ' ;  
  
         f o r   ( v a r   i   =   0 ;   i   <   x . l e n g t h ;   i + + )   {  
                 i f   ( x [ i ] . g e t A t t r i b u t e ( ' M a x L e n ' ) )   {  
                         x [ i ] . o n k e y u p   =   x [ i ] . o n c h a n g e   =   c h e c k M a x L e n g t h ;  
                         x [ i ] . o n k e y u p ( ) ;  
                 }  
         }  
 }  
  
 f u n c t i o n   c h e c k M a x L e n g t h ( )   {  
         v a r   m a x L e n g t h   =   t h i s . g e t A t t r i b u t e ( ' M a x L e n ' ) ;  
         v a r   c u r r e n t L e n g t h   =   t h i s . v a l u e . l e n g t h ;  
         i f   ( c u r r e n t L e n g t h   >   m a x L e n g t h )   {  
                 t h i s . v a l u e   =   t h i s . v a l u e . s u b s t r i n g ( 0 ,   m a x L e n g t h )  
         }  
 }  
  
 w i n d o w . o n l o a d   =   f u n c t i o n ( )   {  
         $ ( " i n p u t ,   t e x t a r e a " ) . c h a n g e ( f u n c t i o n ( )   {  
                 t h i s . v a l u e   =   $ . t r i m ( t h i s . v a l u e ) ;  
                 t h i s . v a l u e   =   s t r i p H T M L ( t h i s . v a l u e ) ;  
         } ) ;  
  
         s e t M a x L e n g t h ( ) ;  
 }  
  
 i f   ( p a r e n t . w i n d o w . f r a m e s . l e n g t h   ! =   0 )   {  
         s e l f . p a r e n t . l o c a t i o n   =   ' / ' ;  
         s e l f . p a r e n t . t b _ r e m o v e ( ) ;  
 }  
  
 f u n c t i o n   i s E m a i l A v a i l a b l e ( e m a i l )   {  
         v a r   i s A v l   =   f a l s e ;  
         $ . a j a x ( {  
                 t y p e :   " P O S T " ,  
                 u r l :   " / C a d a s t r o . a s p x / I s E m a i l A v a i l a b l e " ,  
                 d a t a :   " { ' e m a i l ' : ' "   +   e m a i l   +   " ' } " ,  
                 c o n t e n t T y p e :   " a p p l i c a t i o n / j s o n ;   c h a r s e t = u t f - 8 " ,  
                 d a t a T y p e :   " j s o n " ,  
                 a s y n c :   f a l s e ,  
                 s u c c e s s :   f u n c t i o n ( m s g )   {  
                         i s A v l   =   m s g . d ;  
                 }  
         } ) ;  
  
         r e t u r n   i s A v l ;  
 }  
  
 f u n c t i o n   C E P C o m p l e t e ( t x t C e p ,   t x t E n d e r e c o ,   t x t B a i r r o ,   t x t C i d a d e ,   t x t U f ,   t x t N u m e r o )   {  
         $ . g e t S c r i p t ( " h t t p : / / c e p . r e p u b l i c a v i r t u a l . c o m . b r / w e b _ c e p . p h p ? f o r m a t o = j a v a s c r i p t & c e p = "   +   t x t C e p . v a l ( ) ,   f u n c t i o n ( )   {  
                 i f   ( r e s u l t a d o C E P [ " r e s u l t a d o " ]   & &   r e s u l t a d o C E P [ " b a i r r o " ]   ! =   " " )   {  
                         t x t E n d e r e c o . v a l ( u n e s c a p e ( r e s u l t a d o C E P [ " t i p o _ l o g r a d o u r o " ] )   +   "   "   +   u n e s c a p e ( r e s u l t a d o C E P [ " l o g r a d o u r o " ] ) ) ;  
                         t x t B a i r r o . v a l ( u n e s c a p e ( r e s u l t a d o C E P [ " b a i r r o " ] ) ) ;  
                         t x t C i d a d e . v a l ( u n e s c a p e ( r e s u l t a d o C E P [ " c i d a d e " ] ) ) ;  
                         t x t U f . v a l ( u n e s c a p e ( r e s u l t a d o C E P [ " u f " ] ) ) ;  
                         $ ( " # p a n e l E n d e r e c o " ) . s h o w ( ) ;  
                         $ ( " # p a n e l L o a d E n d e r e c o " ) . h i d e ( ) ;  
                         t x t N u m e r o . f o c u s ( ) ;  
                         $ ( ' # d i s p l a y E r r o ' ) . h t m l ( ' ' ) ;  
                 }   e l s e   {  
                         $ ( ' # d i s p l a y E r r o ' ) . h t m l ( " E n d e r e ç o   n ã o   e n c o n t r a d o ,   v e r i f i q u e   s e u   C E P   o u   p r e e n c h a   o s   c a m p o s   a b a i x o . " ) ;  
                         $ ( " # p a n e l E n d e r e c o " ) . s h o w ( ) ;  
                         $ ( " # p a n e l L o a d E n d e r e c o " ) . h i d e ( ) ;  
                 }  
         } ) ;  
 }    
  
  
  
  
 f u n c t i o n   v a l i d a t e L o g i n ( )   {  
         i f   ( ! $ ( ' # t x t E m a i l ' ) . i s V a l i d E m a i l ( )   | |   $ ( ' # t x t P a s s w o r d ' ) . v a l ( )   = =   " " )   {  
                 a l e r t ( " O s   c a m p o s   E - m a i l   e   S e n h a   n ã o   f o r a m   p r e e n c h i d o   c o r r e t a m e n t e . " ) ;  
                 r e t u r n   f a l s e ;  
         }  
         e l s e  
                 r e t u r n   t r u e ;  
 }  
  
  
 f u n c t i o n   u s e r L o g i n ( e m a i l ,   p a s s w o r d )   {  
         i f   ( ! i s V a l i d E m a i l ( e m a i l )   | |   p a s s w o r d   = =   " " )  
                 a l e r t ( " E - m a i l   o u   s e n h a   i n v á l i d a " ) ;  
         e l s e  
                 $ . a j a x ( {  
                         t y p e :   " P O S T " ,  
                         u r l :   " / D e f a u l t . a s p x / U s e r A u t h o r i z e " ,  
                         d a t a :   " { ' e m a i l ' : ' "   +   e m a i l   +   " ' , ' p a s s w o r d ' : ' "   +   p a s s w o r d   +   " ' } " ,  
                         c o n t e n t T y p e :   " a p p l i c a t i o n / j s o n ;   c h a r s e t = u t f - 8 " ,  
                         d a t a T y p e :   " j s o n " ,  
                         a s y n c :   f a l s e ,  
                         s u c c e s s :   f u n c t i o n   ( d a t a )   {  
      
                                 $ ( ' # t x t E m a i l ' ) . v a l ( " " ) ;  
                                 $ ( ' # t x t P a s s ' ) . v a l ( " " ) ;  
  
                                 i f   ( d a t a . d   = =   ' E R R O W A T I N G A C C E P T ' )   {  
                                         a l e r t ( " S e u   c a d a s t r o   p e n d e n t e   d e   l i b e r a ç ã o   p e l o   a d m i n i s t r a d o r . " ) ;  
                                         r e t u r n ;  
                                 }  
  
                                 i f   ( d a t a . d   = =   ' E R R O N O T A C C E P T ' )   {  
                                         a l e r t ( " S e u   c a d a s t r o   f o i   b l o q u e a d o   p e l o   a d m i n i s t r a d o r . " ) ;  
                                         r e t u r n ;  
                                 }  
  
                                 i f   ( d a t a . d   = =   " E R R O L O G I N " )   {  
                                         a l e r t ( " U s u á r i o   o u   s e n h a   i n v á l i d a " ) ;  
                                         r e t u r n ;  
                                 }  
  
                                 l o c a t i o n   =   d a t a . d ;  
                         }  
                 } ) ;  
      
 }  
  
  
 v a r   m a x W i d t h   =   5 0 0 ;  
 v a r   m a x H e i g h t   =   5 0 0 ;  
 v a r   f i l e T y p e s   =   [ " b m p " ,   " g i f " ,   " p n g " ,   " j p g " ,   " j p e g " ,   " t i f " ] ;  
 v a r   g l o b a l P i c ;  
  
 f u n c t i o n   i m g V e r i f y ( )   {  
         _ _ d o P o s t B a c k ( ' l b t n S e n d P h o t o ' ,   ' ' ) ;  
 }  
  
  
 f u n c t i o n   s a v e E r r o ( )   {  
         a l e r t ( ' N ã o   f o i   p o s s í v e l   s a l v a r   o   f o r m u l á r i o . ' ) ;  
 }  
  
  
 f u n c t i o n   O p e n M o d a l P l a y e r s ( m a t e r i a l I d ,   t i p o ,   w ,   h )   {  
         v a r   n e w A   =   d o c u m e n t . c r e a t e E l e m e n t ( " A " ) ;  
         n e w A . r e l   =   " t h i c k b o x " ;  
         n e w A . h r e f   =   " / P l a y e r s . a s p x ? m a t e r i a l I d = "   +   m a t e r i a l I d   +   " & t i p o = "   +   t i p o   +   " & T B _ i f r a m e = t r u e & h e i g h t = "   +   h   +   " & w i d t h = "   +   w ;  
         n e w A . t i t l e   =   " V i s u a l i z a ç ã o " ;  
         t b _ s h o w ( n e w A . t i t l e ,   n e w A . h r e f ,   n e w A . r e l ) ;  
         n e w A   =   n u l l ;  
 }    
  
 
