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