ÿþ/ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 P o w e r e d   a n d   d e s i g n e d     b y   B l u e C o . i r   |   B l u e S o f t C o . i r   |   W a n a l y s t . n e t   |   A14'/-Ì/1Ì. 'Ì1'F. i r  
 A14'/  -Ì/1Ì 
 ¯1HG  F1E  'A2'1Ì  "(Ì 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * / 
 ( f u n c t i o n ( $ )   { 
 	 v a r   m o d a l d i a l o g   =   {   } ; 
 
 	 / /   C r e a t e s   a n d   s h o w s   t h e   m o d a l   d i a l o g 
 	 f u n c t i o n   s h o w D i a l o g   ( m s g ,   o p t i o n s )   { 
 	 	 / /   M a k e   s u r e   t h e   d i a l o g   t y p e   i s   v a l i d .   I f   n o t   a s s i g n   t h e   d e f a u l t   o n e   ( t h e   f i r s t ) 
 	 	 i f ( ! $ . i n A r r a y ( o p t i o n s . t y p e ,   m o d a l d i a l o g . D i a l o g T y p e s ) )   { 
 	 	 	 o p t i o n s . t y p e   =   m o d a l d i a l o g . D i a l o g T y p e s [ 0 ] ; 
 	 	 } ; 
 
 	 	 / /   M e r g e   d e f a u l t   t i t l e   ( p e r   t y p e ) ,   d e f a u l t   s e t t i n g s ,   a n d   u s e r   d e f i n e d   s e t t i n g s 
 	 	 v a r   s e t t i n g s   =   $ . e x t e n d ( {   t i t l e :   m o d a l d i a l o g . D i a l o g T i t l e s [ o p t i o n s . t y p e ]   } ,   m o d a l d i a l o g . d e f a u l t s ,   o p t i o n s ) ; 
 
 	 	 / /   I f   t h e r e ' s   n o   t i m e o u t ,   m a k e   s u r e   t h e   c l o s e   b u t t o n   i s   s h o w   ( o r   t h e   d i a l o g   c a n ' t   c l o s e ) 
 	 	 s e t t i n g s . t i m e o u t   =   ( t y p e o f ( s e t t i n g s . t i m e o u t )   = =   " u n d e f i n e d " )   ?   0   :   s e t t i n g s . t i m e o u t ; 
 	 	 s e t t i n g s . s h o w C l o s e   =   ( ( t y p e o f ( s e t t i n g s . s h o w C l o s e )   = =   " u n d e f i n e d " )   |   ! s e t t i n g s . t i m e o u t )   ?   t r u e   :   ! ! s e t t i n g s . s h o w C l o s e ; 
 
 	 	 / /   C h e c k   i f   t h e   d i a l o g   e l e m e n t s   e x i s t   a n d   c r e a t e   t h e m   i f   n o t 
 	 	 i f   ( ! d o c u m e n t . g e t E l e m e n t B y I d ( ' d i a l o g ' ) )   { 
 	 	 	 d i a l o g   =   d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) ; 
 	 	 	 d i a l o g . i d   =   ' d i a l o g ' ; 
 	 	 	 $ ( d i a l o g ) . h t m l ( 
 	 	 	 	 " < d i v   i d = ' d i a l o g - h e a d e r ' > "   + 
 	 	 	 	 	 " < d i v   i d = ' d i a l o g - t i t l e ' > < / d i v > "   + 
 	 	 	 	 	 " < d i v   i d = ' d i a l o g - c l o s e ' > < / d i v > "   + 
 	 	 	 	 " < / d i v > "   + 
 	 	 	 	 " < d i v   i d = ' d i a l o g - c o n t e n t ' > "   + 
 	 	 	 	 	 " < d i v   i d = ' d i a l o g - c o n t e n t - i n n e r '   / > "   + 
 	 	 	 	 	 " < d i v   i d = ' d i a l o g - b u t t o n - c o n t a i n e r ' > "   + 
 	 	 	 	 	 	 " < i n p u t   t y p e = ' b u t t o n '   i d = ' d i a l o g - b u t t o n '   v a l u e = ' C l o s e ' > "   + 
 	 	 	 	 	 " < / d i v > "   + 
 	 	 	 	 " < / d i v > " 
 	 	 	 	 ) ; 
 	 	 	 
 	 	 	 d i a l o g m a s k   =   d o c u m e n t . c r e a t e E l e m e n t ( ' d i v ' ) ; 
 	 	 	 d i a l o g m a s k . i d   =   ' d i a l o g - m a s k ' ; 
 	 	 	 
 	 	 	 $ ( d i a l o g m a s k ) . h i d e ( ) ; 
 	 	 	 $ ( d i a l o g ) . h i d e ( ) ; 
 	 	 	 
 	 	 	 d o c u m e n t . b o d y . a p p e n d C h i l d ( d i a l o g m a s k ) ; 
 	 	 	 d o c u m e n t . b o d y . a p p e n d C h i l d ( d i a l o g ) ; 
 
 	 	 	 / /   S e t   t h e   c l i c k   e v e n t   f o r   t h e   " x "   a n d   " C l o s e "   b u t t o n s 	 	 	 
 	 	 	 $ ( " # d i a l o g - c l o s e " ) . c l i c k ( m o d a l d i a l o g . h i d e ) ; 
 	 	 	 $ ( " # d i a l o g - b u t t o n " ) . c l i c k ( m o d a l d i a l o g . h i d e ) ; 
 	 	 } 
 
 	 	 v a r   d l   =   $ ( ' # d i a l o g ' ) ; 
 	 	 v a r   d l h   =   $ ( ' # d i a l o g - h e a d e r ' ) ; 
 	 	 v a r   d l c   =   $ ( ' # d i a l o g - c o n t e n t ' ) ; 
 	 	 v a r   d l b   =   $ ( ' # d i a l o g - b u t t o n ' ) ; 
 
 	 	 $ ( ' # d i a l o g - t i t l e ' ) . h t m l ( s e t t i n g s . t i t l e ) ; 
 	 	 $ ( ' # d i a l o g - c o n t e n t - i n n e r ' ) . h t m l ( m s g ) ; 
 
 	 	 / /   C e n t e r   t h e   d i a l o g   i n   t h e   w i n d o w   b u t   m a k e   s u r e   i t ' s   a t   l e a s t   2 5   p i x e l s   f r o m   t h e   t o p 
 	 	 / /   W i t h o u t   t h a t   c h e c k ,   d i a l o g s   t h a t   a r e   t a l l e r   t h a n   t h e   v i s i b l e   w i n d o w   r i s k 
 	 	 / /   h a v i n g   t h e   c l o s e   b u t t o n s   o f f - s c r e e n ,   r e n d e r i n g   t h e   d i a l o g   u n c l o s a b l e   
 	 	 d l . c s s ( ' w i d t h ' ,   s e t t i n g s . w i d t h ) ; 
 	 	 v a r   d i a l o g T o p   =   M a t h . a b s ( $ ( w i n d o w ) . h e i g h t ( )   -   d l . h e i g h t ( ) )   /   2 ; 
 	 	 d l . c s s ( ' l e f t ' ,   ( $ ( w i n d o w ) . w i d t h ( )   -   d l . w i d t h ( ) )   /   2 ) ; 
 	 	 d l . c s s ( ' t o p ' ,   ( d i a l o g T o p   > =   2 5 )   ?   d i a l o g T o p   :   2 5 ) ; 
 
 	 	 / /   C l e a r   t h e   d i a l o g - t y p e   c l a s s e s   a n d   a d d   t h e   c u r r e n t   d i a l o g - t y p e   c l a s s 	 	 
 	 	 $ . e a c h ( m o d a l d i a l o g . D i a l o g T y p e s ,   f u n c t i o n   ( )   {   d l h . r e m o v e C l a s s ( t h i s   +   " h e a d e r " )   } ) ; 
 	 	 d l h . a d d C l a s s ( s e t t i n g s . t y p e   +   " h e a d e r " ) 
 	 	 $ . e a c h ( m o d a l d i a l o g . D i a l o g T y p e s ,   f u n c t i o n   ( )   {   d l c . r e m o v e C l a s s ( t h i s )   } ) ; 
 	 	 d l c . a d d C l a s s ( s e t t i n g s . t y p e ) ; 
 	 	 $ . e a c h ( m o d a l d i a l o g . D i a l o g T y p e s ,   f u n c t i o n   ( )   {   d l b . r e m o v e C l a s s ( t h i s   +   " b u t t o n " )   } ) ; 
 	 	 d l b . a d d C l a s s ( s e t t i n g s . t y p e   +   " b u t t o n " ) 
 
 	 	 i f   ( ! s e t t i n g s . s h o w C l o s e )   { 
 	 	 	 $ ( ' # d i a l o g - c l o s e ' ) . h i d e ( ) ; 
 	 	 	 $ ( ' # d i a l o g - b u t t o n - c o n t a i n e r ' ) . h i d e ( ) ; 
 	 	 }   e l s e   { 
 	 	 	 $ ( ' # d i a l o g - c l o s e ' ) . s h o w ( ) ; 
 	 	 	 $ ( ' # d i a l o g - b u t t o n - c o n t a i n e r ' ) . s h o w ( ) ; 
 	 	 } 
 
 	 	 i f   ( s e t t i n g s . t i m e o u t )   { 
 	 	 	 w i n d o w . s e t T i m e o u t ( " $ ( ' # d i a l o g ' ) . f a d e O u t ( ' s l o w ' ,   0 ) ;   $ ( ' # d i a l o g - m a s k ' ) . f a d e O u t ( ' n o r m a l ' ,   0 ) ; " ,   ( s e t t i n g s . t i m e o u t   *   1 0 0 0 ) ) ; 
 	 	 } 
 	 	 
 	 	 d l . f a d e I n ( " s l o w " ) ; 
 	 	 $ ( ' # d i a l o g - m a s k ' ) . f a d e I n ( " n o r m a l " ) ; 
 	 } ; 
 
 	 m o d a l d i a l o g . e r r o r   =   f u n c t i o n   $ $ m o d a l d i a l o g $ e r r o r   ( m s g ,   o p t i o n s )   { 
 	 	 i f   ( t y p e o f ( o p t i o n s )   = =   " u n d e f i n e d " )   { 
 	 	 	 o p t i o n s   =   {   } ; 
 	 	 } 
 	 	 o p t i o n s [ ' t y p e ' ]   =   " e r r o r " ; 
 	 	 r e t u r n ( s h o w D i a l o g ( m s g ,   o p t i o n s ) ) ; 
 	 } 
 	 m o d a l d i a l o g . w a r n i n g   =   f u n c t i o n   $ $ m o d a l d i a l o g $ e r r o r   ( m s g ,   o p t i o n s )   { 
 	 	 i f   ( t y p e o f ( o p t i o n s )   = =   " u n d e f i n e d " )   { 
 	 	 	 o p t i o n s   =   {   } ; 
 	 	 } 
 	 	 o p t i o n s [ ' t y p e ' ]   =   " w a r n i n g " ; 
 	 	 r e t u r n ( s h o w D i a l o g ( m s g ,   o p t i o n s ) ) ; 
 	 } 
 	 m o d a l d i a l o g . s u c c e s s   =   f u n c t i o n   $ $ m o d a l d i a l o g $ e r r o r   ( m s g ,   o p t i o n s )   { 
 	 	 i f   ( t y p e o f ( o p t i o n s )   = =   " u n d e f i n e d " )   { 
 	 	 	 o p t i o n s   =   {   } ; 
 	 	 } 
 	 	 o p t i o n s [ ' t y p e ' ]   =   " s u c c e s s " ; 
 	 	 r e t u r n ( s h o w D i a l o g ( m s g ,   o p t i o n s ) ) ; 
 	 } 
 	 m o d a l d i a l o g . p r o m p t   =   f u n c t i o n   $ $ m o d a l d i a l o g $ e r r o r   ( m s g ,   o p t i o n s )   { 
 	 	 i f   ( t y p e o f ( o p t i o n s )   = =   " u n d e f i n e d " )   { 
 	 	 	 o p t i o n s   =   {   } ; 
 	 	 } 
 	 	 o p t i o n s [ ' t y p e ' ]   =   " p r o m p t " ; 
 	 	 r e t u r n ( s h o w D i a l o g ( m s g ,   o p t i o n s ) ) ; 
 	 } 
 
 	 m o d a l d i a l o g . h i d e   =   f u n c t i o n   $ $ m o d a l d i a l o g $ h i d e   ( )   { 
 	 	 $ ( ' # d i a l o g ' ) . f a d e O u t ( " s l o w " ,   f u n c t i o n   ( )   {   $ ( t h i s ) . h i d e ( 0 ) ;   } ) ; 
 	 	 $ ( ' # d i a l o g - m a s k ' ) . f a d e O u t ( " n o r m a l " ,   f u n c t i o n   ( )   {   $ ( t h i s ) . h i d e ( 0 ) ;   } ) ; 
 	 } ; 
 
 	 m o d a l d i a l o g . D i a l o g T y p e s   =   n e w   A r r a y ( " e r r o r " ,   " w a r n i n g " ,   " s u c c e s s " ,   " p r o m p t " ) ; 
 	 m o d a l d i a l o g . D i a l o g T i t l e s   =   { 
 	 	 " e r r o r " :   " ! !   E r r o r   ! ! " 
 	 	 ,   " w a r n i n g " :   " W a r n i n g ! " 
 	 	 ,   " s u c c e s s " :   " S u c c e s s " 
 	 	 ,   " p r o m p t " :   " P l e a s e   C h o o s e " 
 	 } ; 
 
 	 m o d a l d i a l o g . d e f a u l t s   =   { 
 	 	 t i m e o u t :   0 
 	 	 ,   s h o w C l o s e :   t r u e 
 	 	 ,   w i d t h :   5 2 5 
 	 } ; 
 
 	 $ . e x t e n d ( {   m o d a l d i a l o g :   m o d a l d i a l o g   } ) ; 
 } ) ( j Q u e r y ) ;  
  
  
  
 / * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
 P o w e r e d   a n d   d e s i g n e d     b y   B l u e C o . i r   |   B l u e S o f t C o . i r   |   W a n a l y s t . n e t   |   A14'/-Ì/1Ì. 'Ì1'F. i r  
 A14'/  -Ì/1Ì 
 ¯1HG  F1E  'A2'1Ì  "(Ì 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * / 
  
                 
