(
    function($) {
        $(window).load(function(e) {
            $(document).ready(function() {
                var thumb_row = -1, thumb_col = -1;
                $.each($(".cookie-gallery-thumbs img"), function(idx, el) {
                                                            if (  idx % 4 === 0 ) {

                                                                thumb_row +=  1;
                                                                thumb_col  = -1;

                                                            }

                                                            thumb_col += 1;

                                                            var left  =  8 + ( 8 + 150 ) * thumb_col,
                                                                top   =  8 + ( 8 + 150 ) * thumb_row,
                                                                mi_func = ( function(l, t) {
                                                                                return function(e) {
                                                                                        var left_pos = ( l - 25 ) + "px",
                                                                                            top_pos  = ( t - 25 ) + "px";

                                                                                       /* $(el).removeClass("cookie-gallery-thumb-shadow");
                                                                                        $(el).css({ zIndex : "900" });
                                                                                        $(el).stop().animate( {
                                                                                                                left   : left_pos,
                                                                                                                width  : "200px",
                                                                                                                top    : top_pos,
                                                                                                                height : "200px" 
                                                                                                            },
                                                                                                            "fast", function() {
                                                                                                                        $(el).addClass("cookie-gallery-thumb-shadow");
                                                                                                                    });
																						*/
																						$(el).css({ zIndex : "900" });
																						$(el).stop().animate( { opacity : 0 },
																												"fast",
																						                        function() {
																													$(el).animate( {
																																			opacity : 1,
																																			left    : left_pos,
																																			width   : "200px",
																																			top     : top_pos,
																																			height  : "200px" 
																																		},
																																		"fast"
																																	);
																															});

                                                                                    };

                                                                            }(left, top)
                                                                        ),
                                                                mo_func = ( function(l, t) {
                                                                                return function(e) {
                                                                                        var left_pos = l + "px",
                                                                                            top_pos  = t + "px";

                                                                                       /* $(el).removeClass("cookie-gallery-thumb-shadow");
                                                                                        $(el).stop().animate( {
                                                                                                                left  : left_pos,
                                                                                                                width : "150px",
                                                                                                                top   : top_pos,
                                                                                                                height : "150px"
                                                                                                            },
                                                                                                            "fast", function() {
                                                                                                                        $(el).addClass("cookie-gallery-thumb-shadow");
                                                                                                                        $(el).css( { zIndex : '0' } );
                                                                                                                    });
																						*/
																						
																						$(el).stop().animate( {
																												opacity : 0,
                                                                                                                left    : left_pos,
                                                                                                                width   : "150px",
                                                                                                                top     : top_pos,
                                                                                                                height  : "150px"
                                                                                                            },
                                                                                                            "fast",
																											function() {
      																											$(el).animate( { opacity : 1 }, "fast");
																												$(el).css( { zIndex : '0' } );
                                                                                                            }
																										);

                                                                                    };

                                                                            }(left, top)
                                                                        );

                                                            $(el).css( { position : "absolute",
                                                                         left : left + "px",
                                                                         top  : top + "px",
                                                                       });

                                                            //$(el).addClass("cookie-gallery-thumb-shadow");

                                                            $(el).mouseover(mi_func);
                                                            $(el).mouseout(mo_func);

                                                        });

                                    $(".cookie-gallery-thumbs-curtain").hide(800);



            });
        });
    }(jQuery)
);
