jQuery(document).ready( function() {
	var fake		= jQuery( 'div#en_images img' );

	if ( fake && fake.attr( 'mg:xml' ) ) {
		var container	= fake.parent();
		jQuery.ajax( {
			type:		'GET',
			dataType:	'xml',
			url:		fake.attr( 'mg:xml' ),
			success:	function( xml ) {
				var loader		= new Loader( {
					onComplete:	function( images ) {
						for( var i=0; i<images.length; i++ ) {
							fake.parent().append( images[ i ] );
						}
						new Patchwork(
							container,
							images,
							{
								onBeforeItemBound:	function( e ) {
									e.target.css( { display: 'none' } );
								},
								onAfterItemBound:	function( e ) {
			//						e.target.css( { width: e.target.width() } ).slideDown();
									e.target.fadeIn();
								},
								onBindStart:		function( e ) {
			//						e.target.container.css( { display: 'none' } );
								},
								onBindComplete:		function( e ) {
									jQuery( 'ul.system_links', e.target.container ).css( { zIndex: this.size() + 1 } );
			//						e.target.container.fadeIn();
								}
							}
						).bind();
					}
				} );

				jQuery(xml).find('picture').each( function( i ) {
					loader.add( jQuery(this).attr( 'src' ) );
				} );

				loader.start();
			}
		} );
	}
} );