$(document).ready(function() {
    (function($) {
        $.fn.extend({
            sui_video: function() {
                this.each(function() {
                    var t = $(this);
                    t.sui_hover().sui_press()
                    .click(function() {
                        var z = $("#sui_video_template").clone();
                        z.removeAttr("id");
                        z.find(".sui_video_header_title").html(t.attr("alt"));
                        z.show().sui_moveable({ handle_selector: ".sui_video_header" }).find(".sui_video_header_close").click(function() { z.sui_moveable("remove"); sui.shader.remove_and_hide(".sui_video") });
                        z.removeAttr("id").sui_shader_load({ offset_x: "center", offset_y: "center" });
                    });
                });
                return $(this);
            }
        });
    })(jQuery);
    $(".sui_video_thumbnail").sui_video();

    var r = /#play_video/.exec(window.location.hash);
    if (r && r.length == 2) {
        $(".sui_video_thumbnail[href]").each(function() {
            var t = $(this);
            t.triggerHandler("click");
            return false;
            /*
            var z = /#.*vid:(.+);/.exec(t.attr("href"));
            if (z && z.length == 2 && z[1] == r[1]) {
            t.triggerHandler("click");
            return false;
            }
            return true;
            */
        });
    }

});
