﻿(function ($) {
    var methods = {
        init: function (method) {
            method = $.extend({
                width: 200, // Gesamtbreite des geklicketen Bildes
                height: 200 // Gesamthöhe des geklicketen Bildes
            }, method);

            var Load = new Object();
            Load.Next = new Object();
            Load.Prev = new Object();

            Load.Prev.run = function (me) {
                var this_number = parseInt($("._zoomed_img").attr("id").substr(5, me.length));
                var next_value = parseInt(this_number) - 1;
                var next_id_kl = "#i_kl_" + next_value;
                var next_id_gr = "i_gr_" + next_value;

                if (next_value >= 0) {
                    var next_img = new Image();
                    next_img.src = $(next_id_kl).attr("src").replace(/thumb_/, "").replace(/thumb/, "full");

                    if (next_img.width > 0) {
                        var next_height = next_img.height;
                        var next_width = next_img.width;

                        var left_position = (parseInt($(window).width() / 2) - (parseInt(next_width) + dim_add + 70) / 2);
                        var alt_text = $(next_id_kl).attr("alt");

                        if ($.browsercheck()) {
                            $("._zoomed_img").fadeOut("slow", function () {
                                $("#jq_zoomin_pic").animate({
                                    "height": next_height + dim_add + 70 + "px",
                                    "width": next_width + dim_add_width + 70 + "px",
                                    "left": left_position + "px"
                                }, 1000, function () {
                                    $("#jq_zoomin_pic_inner").animate({
                                        "height": next_height + dim_add + "px"
                                    });

                                    $(".img_container").css({ "height": next_height + "px" });

                                    $("#jq_alt_text").html(alt_text);
                                    $("#jq_pic_nr").html(next_value + 1);
                                    $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src)
                                    $("._zoomed_img").fadeIn("slow");
                                });
                            });
                        }
                        else {
                            $("._zoomed_img").fadeOut("slow", function () {
                                $("#jq_zoomin_pic").css({
                                    "height": next_height + dim_add + 70 + "px",
                                    "width": next_width + dim_add_width + 70 + "px",
                                    "left": left_position + "px"
                                });
                                $("#jq_zoomin_pic_inner").css({
                                    "height": next_height + dim_add + "px"
                                });

                                $(".img_container").css({ "height": next_height + "px" });

                                $("#jq_alt_text").html(alt_text);
                                $("#jq_pic_nr").html(next_value + 1);
                                $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src)
                                $("._zoomed_img").fadeIn("slow");
                            });
                        }
                    }
                    else {
                        $(next_img).load(function () {
                            img_dims = { width: next_img.width, height: next_img.height };

                            var next_height = img_dims.height;
                            var next_width = img_dims.width;

                            var left_position = (parseInt($(window).width() / 2) - (parseInt(next_width) + dim_add + 70) / 2);
                            var alt_text = $(next_id_kl).attr("alt");

                            if ($.browsercheck()) {
                                $("._zoomed_img").fadeOut("slow", function () {
                                    $("#jq_zoomin_pic").animate({
                                        "height": next_height + dim_add + 70 + "px",
                                        "width": next_width + dim_add_width + 70 + "px",
                                        "left": left_position + "px"
                                    }, 1000, function () {
                                        $("#jq_zoomin_pic_inner").animate({
                                            "height": next_height + dim_add + "px"
                                        });

                                        $(".img_container").css({ "height": next_height + "px" });

                                        $("#jq_alt_text").html(alt_text);
                                        $("#jq_pic_nr").html(next_value + 1);
                                        $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src)
                                        $("._zoomed_img").fadeIn("slow");
                                    });
                                });
                            }
                            else {
                                $("._zoomed_img").fadeOut("slow", function () {
                                    $("#jq_zoomin_pic").css({
                                        "height": next_height + dim_add + 70 + "px",
                                        "width": next_width + dim_add_width + 70 + "px",
                                        "left": left_position + "px"
                                    });
                                    $("#jq_zoomin_pic_inner").css({
                                        "height": next_height + dim_add + "px"
                                    });

                                    $(".img_container").css({ "height": next_height + "px" });

                                    $("#jq_alt_text").html(alt_text);
                                    $("#jq_pic_nr").html(next_value + 1);
                                    $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src)
                                    $("._zoomed_img").fadeIn("slow");
                                });
                            }
                        });
                    }
                }
                else {
                    next_value = $("._element_zoompic").length - 1;
                    var next_img = new Image();
                    next_img.src = $("#i_kl_" + next_value).attr("src").replace(/thumb_/, "").replace(/thumb/, "full");

                    var name_attr = $("#i_kl_" + next_value).attr("name").split("x");

                    if (next_img.width > 0) {
                        var next_height = next_img.height;
                        var next_width = next_img.width;

                        var left_position = (parseInt($(window).width() / 2) - (parseInt(next_width) + dim_add + 70) / 2);
                        var alt_text = $(next_id_kl).attr("alt");

                        if ($.browsercheck()) {
                            $("._zoomed_img").fadeOut("slow", function () {
                                $("#jq_zoomin_pic").animate({
                                    "height": next_height + dim_add + 70 + "px",
                                    "width": next_width + dim_add_width + 70 + "px",
                                    "left": left_position + "px"
                                }, 1000, function () {
                                    $("#jq_zoomin_pic_inner").animate({
                                        "height": next_height + dim_add + "px"
                                    });

                                    $(".img_container").css({ "height": next_height + "px" });

                                    $("#jq_alt_text").html(alt_text);
                                    $("#jq_pic_nr").html(next_value + 1);
                                    $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src)
                                    $("._zoomed_img").fadeIn("slow");
                                });
                            });
                        }
                        else {
                            $("._zoomed_img").fadeOut("slow", function () {
                                $("#jq_zoomin_pic").css({
                                    "height": next_height + dim_add + 70 + "px",
                                    "width": next_width + dim_add_width + 70 + "px",
                                    "left": left_position + "px"
                                });
                                $("#jq_zoomin_pic_inner").css({
                                    "height": next_height + dim_add + "px"
                                });

                                $(".img_container").css({ "height": next_height + "px" });

                                $("#jq_alt_text").html(alt_text);
                                $("#jq_pic_nr").html(next_value + 1);
                                $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src)
                                $("._zoomed_img").fadeIn("slow");
                            });
                        }
                    }
                    else {
                        $(next_img).load(function () {
                            img_dims = { width: next_img.width, height: next_img.height };

                            var next_height = img_dims.height;
                            var next_width = img_dims.width;

                            var left_position = (parseInt($(window).width() / 2) - (parseInt(next_width) + dim_add + 70) / 2);
                            var alt_text = $("#i_kl_" + next_value).attr("alt");

                            if ($.browsercheck()) {
                                $("._zoomed_img").fadeOut("slow", function () {
                                    $("#jq_zoomin_pic").animate({
                                        "width": next_width + dim_add_width + 70 + "px",
                                        "height": next_height + dim_add + 70 + "px",
                                        "left": left_position + "px"
                                    }, 1000, function () {
                                        $("#jq_zoomin_pic_inner").animate({
                                            "height": next_height + dim_add + "px"
                                        });

                                        $(".img_container").css({ "height": next_height + "px" });

                                        $("#jq_alt_text").html(alt_text);
                                        $("#jq_pic_nr").html($("._element_zoompic").length);
                                        $("._zoomed_img").attr("id", "i_gr_" + next_value).attr("src", next_img.src)
                                        $("._zoomed_img").fadeIn("slow");
                                    });
                                });
                            }
                            else {
                                $("._zoomed_img").fadeOut("slow", function () {
                                    $("#jq_zoomin_pic").css({
                                        "width": next_width + dim_add_width + 70 + "px",
                                        "height": next_height + dim_add + 70 + "px",
                                        "left": left_position + "px"
                                    });
                                    $("#jq_zoomin_pic_inner").css({
                                        "height": next_height + dim_add + "px"
                                    });

                                    $(".img_container").css({ "height": next_height + "px" });

                                    $("#jq_alt_text").html(alt_text);
                                    $("#jq_pic_nr").html($("._element_zoompic").length);
                                    $("._zoomed_img").attr("id", "i_gr_" + next_value).attr("src", next_img.src)
                                    $("._zoomed_img").fadeIn("slow");
                                });
                            }
                        });
                    }
                }
            }

            Load.Next.run = function (me) {
                var this_number = parseInt($("._zoomed_img").attr("id").substr(5, me.length));
                var next_value = parseInt(this_number) + 1
                var next_id_kl = "#i_kl_" + next_value;
                var next_id_gr = "i_gr_" + next_value;

                if (next_value < $("._element_zoompic").length) {
                    var next_img = new Image();
                    next_img.src = $(next_id_kl).attr("src").replace(/thumb_/, "").replace(/thumb/, "full");

                    if (next_img.width > 0) {
                        var next_height = next_img.height;
                        var next_width = next_img.width;

                        var left_position = (parseInt($(window).width() / 2) - (parseInt(next_width) + dim_add + 70) / 2);
                        var alt_text = $(next_id_kl).attr("alt");

                        if ($.browsercheck()) {
                            $("._zoomed_img").fadeOut("slow", function () {
                                $("#jq_zoomin_pic").animate({
                                    "height": next_height + dim_add + 70 + "px",
                                    "width": next_width + dim_add_width + 70 + "px",
                                    "left": left_position + "px"
                                }, 1000, function () {
                                    $("#jq_zoomin_pic_inner").animate({
                                        "height": next_height + dim_add + "px"
                                    });

                                    $(".img_container").css({ "height": next_height + "px" });

                                    $("#jq_alt_text").html(alt_text);
                                    $("#jq_pic_nr").html(next_value + 1);
                                    $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src).fadeIn("slow");
                                });
                            });
                        }
                        else {
                            $("._zoomed_img").fadeOut("slow", function () {                                
                                $("#jq_zoomin_pic").css({
                                    "height": next_height + dim_add + 70 + "px",
                                    "width": next_width + dim_add_width + 70 + "px",
                                    "left": left_position + "px"
                                });
                                $("#jq_zoomin_pic_inner").css({
                                    "height": next_height + dim_add + "px"
                                });

                                $(".img_container").css({ "height": next_height + "px" });

                                $("#jq_alt_text").html(alt_text);
                                $("#jq_pic_nr").html(next_value + 1);
                                $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src).fadeIn("slow");
                            });
                        }
                    }
                    else {
                        $(next_img).load(function () {
                            img_dims = { width: next_img.width, height: next_img.height };

                            var next_height = img_dims.height;
                            var next_width = img_dims.width;

                            var left_position = (parseInt($(window).width() / 2) - (parseInt(next_width) + dim_add + 70) / 2);
                            var alt_text = $(next_id_kl).attr("alt");

                            if ($.browsercheck()) {
                                $("._zoomed_img").fadeOut("slow", function () {
                                    $("#jq_zoomin_pic").animate({
                                        "height": next_height + dim_add + 70 + "px",
                                        "width": next_width + dim_add_width + 70 + "px",
                                        "left": left_position + "px"
                                    }, 1000, function () {
                                        $("#jq_zoomin_pic_inner").animate({
                                            "height": next_height + dim_add + "px"
                                        });

                                        $(".img_container").css({ "height": next_height + "px" });

                                        $("#jq_alt_text").html(alt_text);
                                        $("#jq_pic_nr").html(1);
                                        $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src).fadeIn("slow");
                                    });
                                });
                            }
                            else {
                                $("._zoomed_img").fadeOut("slow", function () {                                    
                                    $("#jq_zoomin_pic").css({
                                        "height": next_height + dim_add + 70 + "px",
                                        "width": next_width + dim_add_width + 70 + "px",
                                        "left": left_position + "px"
                                    });
                                    $("#jq_zoomin_pic_inner").css({
                                        "height": next_height + dim_add + "px"
                                    });

                                    $(".img_container").css({ "height": next_height + "px" });

                                    $("#jq_alt_text").html(alt_text);
                                    $("#jq_pic_nr").html(1);
                                    $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src).fadeIn("slow");
                                });
                            }
                        });
                    }
                }
                else {
                    var next_img = new Image();
                    next_img.src = $("#i_kl_0").attr("src").replace(/thumb_/, "").replace(/thumb/, "full");

                    if (next_img.width > 0) {
                        var next_height = next_img.height;
                        var next_width = next_img.width;

                        var left_position = (parseInt($(window).width() / 2) - (parseInt(next_width) + dim_add + 70) / 2);
                        var alt_text = $(next_id_kl).attr("alt");

                        if ($.browsercheck()) {
                            $("._zoomed_img").fadeOut("slow", function () {
                                $("#jq_zoomin_pic").animate({
                                    "height": next_height + dim_add + 70 + "px",
                                    "width": next_width + dim_add_width + 70 + "px",
                                    "left": left_position + "px"
                                }, 1000, function () {
                                    $("#jq_zoomin_pic_inner").animate({
                                        "height": next_height + dim_add + "px"
                                    });

                                    $(".img_container").css({ "height": next_height + "px" });

                                    $("#jq_alt_text").html(alt_text);
                                    $("#jq_pic_nr").html(1);
                                    $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src).fadeIn("slow");
                                });
                            });
                        }
                        else {
                            $("._zoomed_img").fadeOut("slow", function () {
                                // alert("1")
                                $("#jq_zoomin_pic").css({
                                    "height": next_height + dim_add + 70 + "px",
                                    "width": next_width + dim_add_width + 70 + "px",
                                    "left": left_position + "px"
                                });
                                $("#jq_zoomin_pic_inner").css({
                                    "height": next_height + dim_add + "px"
                                });

                                $(".img_container").css({ "height": next_height + "px" });

                                $("#jq_alt_text").html(alt_text);
                                $("#jq_pic_nr").html(1);
                                $("._zoomed_img").attr("id", next_id_gr).attr("src", next_img.src).fadeIn("slow");
                            });
                        }
                    }
                    else {
                        $(next_img).load(function () {							
                            img_dims = { width: next_img.width, height: next_img.height };

                            var next_height = img_dims.height;
                            var next_width = img_dims.width;

                            var left_position = (parseInt($(window).width() / 2) - (parseInt(next_width) + dim_add + 70) / 2);
                            var alt_text = $("#i_kl_0").attr("alt");

                            if ($.browsercheck()) {
                                $("._zoomed_img").fadeOut("slow", function () {
                                    $("#jq_zoomin_pic").animate({
                                        "height": next_height + dim_add + 70 + "px",
                                        "width": next_width + dim_add_width + 70 + "px",
                                        "left": left_position + "px"
                                    }, 1000, function () {
                                        $("#jq_zoomin_pic_inner").animate({
                                            "height": next_height + dim_add + "px"
                                        });

                                        $(".img_container").css({ "height": next_height + "px" });

                                        $("#jq_alt_text").html(alt_text);
                                        $("#jq_pic_nr").html(1);
                                        $("._zoomed_img").attr("id", "i_gr_0").attr("src", next_img.src).fadeIn("slow");
                                    });
                                });
                            }
                            else {
                                $("._zoomed_img").fadeOut("slow", function () {                                    
                                    $("#jq_zoomin_pic").css({
                                        "height": next_height + dim_add + 70 + "px",
                                        "width": next_width + dim_add_width + 70 + "px",
                                        "left": left_position + "px"
                                    });
                                    $("#jq_zoomin_pic_inner").css({
                                        "height": next_height + dim_add + "px"
                                    });

                                    $(".img_container").css({ "height": next_height + "px" });

                                    $("#jq_alt_text").html(alt_text);
                                    $("#jq_pic_nr").html(1);
                                    $("._zoomed_img").attr("id", "i_gr_0").attr("src", next_img.src).fadeIn("slow");
                                });
                            }
                        });
                    }
                }
                return false;
            }

            //#############################################
            // Basis, Ändern des Elements von <img /> 
            // auf div mit Hintergrund
            //#############################################

            var this_class = $(this).attr("class");
            $("#node-text").find("." + this_class).each(function (index) {
                $(this).addClass("ui-corner-all _element_zoompic cur_pointer ie-corner").attr("id", "i_kl_" + index).css({ "border": "1px solid #b35b33" });
                var img_full = new Image();
                img_full.src = $(this).attr("src").replace(/thumb_/, "").replace(/thumb/, "full");
            });

            //#############################################
            // Click-Events
            //#############################################

            $("._element_zoompic").live("click", function () {
				var img_full = "";
				
                var img_full = new Image();
                img_full.src = $(this).attr("src").replace(/thumb_/, "").replace(/thumb/, "full");
                var this_int = parseInt($(this).attr("id").substr(5, $(this).attr("id").length));
                var this_alt = $(this).attr("alt");

                if (img_full.width > 0 && !$.browsercheck()) {					
                    var this_height = img_full.height;
                    var this_width = img_full.width;

                    if (!$.browsercheck()) {
                        dim_add = 10;
                        top_pos = 15;
                        dim_add_width = 20;

                        close_button_top = 5;
                        close_bottom_right = 10;
                    }
                    else {
                        dim_add = 20;
                        top_pos = 15;
                        dim_add_width = 10;

                        close_button_top = 5;
                        close_bottom_right = 10;
                    }

                    $("._destroy_me").remove();
                    var this_Overlay = "<div style='display:none;' id='jq_zoomin_overlay' class='_destroy_me _close'></div>";

                    //Overlay
                    if ($("#jq_zoomin_overlay").length == 0) {
                        $("body").prepend(this_Overlay);
                    }

                    //Image-Content-body
                    if ($("#jq_zoomin_pic").length == 0) {
                        $("body").prepend("<div align='center' class='_destroy_me' id='jq_zoomin_pic' style='display:none;'></div>");
                    }

                    if ($("#jq_zoomin_pic_inner").length == 0) {
                        $("#jq_zoomin_pic").html("<div align='center' class='ui-corner-all ie-corner _destroy_me ui-widget-content' id='jq_zoomin_pic_inner'></div>");
                    }

                    //Close-Button
                    if ($("#jq_close").length == 0) {
                        $("#jq_zoomin_pic_inner").prepend("<a class='_close _destroy_me _button' id='jq_close' style='position:absolute; top:" + close_button_top + "px; right:" + close_bottom_right + "px; z-index:902; cursor:pointer;'><img src='IMG/close_zoompic.png' /></a>");
                    }

                    //Das Bild!
                    if ($("._zoomed_img").length == 0) {
                        $("#jq_zoomin_pic_inner").prepend("<div class='_destroy_me_first img_container _destroy_me' style='position:relative; z-index:903; height:" + this_height + "px; background:url(IMG/loading_content.gif) no-repeat center center;'><img id='i_gr_" + this_int + "' src='" + img_full.src + "' class='ui-corner-all ie-corner _close _destroy_me _zoomed_img' style='border:2px solid #FBF0B7; cursor:pointer; display:none; position:relative; z-index:903;' /></div>");
                    }

                    $("#jq_zoomin_overlay").css({
                        "background": "#080808 url('../style/images/ui-bg_flat_0_080808_40x100.png') no-repeat 50% 50%",
                        "opacity": .6,
                        "filter": "Alpha(opacity=60)",
                        "zoom": 1,
                        "z-index": 900,
                        "height": "100%",
                        "width": "100%",
                        "position": "absolute",
                        "top": "0px",
                        "left": "0px"
                    });

                    var left_position = (parseInt($(window).width() / 2) - (parseInt(this_width) + dim_add + 70) / 2);
                    $("#jq_zoomin_pic_inner").css({
                        "padding": "0",
                        "padding-bottom": "40px",
                        "padding-top": "10px",
                        "margin-left": "20px",
                        "margin-right": "20px",
                        "margin-top": "20px",
                        //"height": "auto", //parseInt(this_height) + dim_add + "px", // + dim_add + "px",
                        //"width": "auto", //parseInt(this_width) + dim_add_width + "px",
                        "left": left_position + "px",
                        "border": "1px solid #FBF0B7",
                        "zoom": 1,
                        "z-index": 902,
                        "opacity": 1,
                        "filter": "Alpha(opacity=100)"
                    })

                    $("#jq_zoomin_pic").css({
                        "padding": "0em",
                        "padding-bottom": "2em",
                        "padding-top": "2px",
                        "padding-left": "7px",
                        "padding-right": "7px",
                        "height": parseInt(this_height) + dim_add + 70 + "px", // + dim_add + "px",
                        "width": parseInt(this_width) + dim_add_width + 70 + "px",
                        "left": left_position + "px",
                        "top": "0px",
                        "bottom": "3%",
                        "margin": "auto auto",
                        // "border": "1px solid blue",
                        "zoom": 1,
                        "z-index": 901,
                        "position": "absolute"
                        //"filter": "Alpha(opacity=100)"
                    }).fadeIn("slow");


                    if ($("._element_zoompic").length >= 2) {
                        var this_number = this_int + 1;
                        if ($("._arrow").length == 0) {
                            if ($("#jq_next").length == 0) {
                                $("#jq_zoomin_pic_inner").prepend("<a class='_arrow_next _arrow _destroy_me _button' id='jq_next' style='position:absolute; top:40%; right:10px; z-index:902; cursor:pointer;'><img src='IMG/zoompic_next.png' alt='weiter' /></a>");
                            }

                            if ($("#jq_prev").length == 0) {
                                $("#jq_zoomin_pic_inner").prepend("<a class='_arrow_prev _arrow _destroy_me _button' id='jq_prev' style='position:absolute; top:40%; left:10px; z-index:902; cursor:pointer;'><img src='IMG/zoompic_prev.png' alt='zur&uml;//ck' /></a>");
                            }

                        }

                        var item_nummer = "<br /><font class='_arrow _pages _destroy_me' style='color:#FBF0B7; float:left;'><span id='jq_pic_nr'>" + this_number + "</span> / " + $("._element_zoompic").length + "</font>";
                    }
                    else {
                        var item_nummer = "";
                    }

                    $("#jq_zoomin_pic_inner").append("<div class='_destroy_me _arrow' style='padding-left:20px; height:20px; position:relative; bottom:5px;'><br /><br /><span class='_close _destroy_me' id='jq_alt_text' style='float:left;'>" + this_alt + "</span>" +
                                            item_nummer +
                                            "</div>");

                    $("#jq_zoomin_overlay").fadeIn("slow", function () {
                        $("#jq_zoomin_pic").fadeIn("slow", function () {
                            $("._zoomed_img").fadeIn("slow");
                            $("._arrow").fadeIn("slow");
                        });
                    });

                    $("._arrow_next").bind("click", function () {
                        var me = $("._zoomed_img").attr("id");
                        Load.Next.run(me)
                    });

                    $("._arrow_prev").bind("click", function () {
                        var me = $("._zoomed_img").attr("id");
                        Load.Prev.run(me)
                    });
                }
                else {                    				                                        
                    $(img_full).load(function () {							                        
                        img_dims = { width: img_full.width, height: img_full.height };
                        var this_height = img_dims.height;
                        var this_width = img_dims.width;

                        if (!$.browsercheck()) {
                            dim_add = 10;
                            top_pos = 15;
                            dim_add_width = 20;

                            close_button_top = 5;
                            close_bottom_right = 10;
                        }
                        else {
                            dim_add = 20;
                            top_pos = 15;
                            dim_add_width = 10;

                            close_button_top = 5;
                            close_bottom_right = 10;
                        }

                        $("._destroy_me").remove();
                        var this_Overlay = "<div style='display:none;' id='jq_zoomin_overlay' class='_destroy_me _close'></div>";

                        //Overlay
                        if ($("#jq_zoomin_overlay").length == 0) {
                            $("body").prepend(this_Overlay);
                        }

                        //Image-Content-body
                        if ($("#jq_zoomin_pic").length == 0) {
                            $("body").prepend("<div align='center' class='_destroy_me' id='jq_zoomin_pic' style='display:none;'></div>");
                        }

                        if ($("#jq_zoomin_pic_inner").length == 0) {
                            $("#jq_zoomin_pic").html("<div align='center' class='ui-corner-all ie-corner _destroy_me ui-widget-content' id='jq_zoomin_pic_inner'></div>");
                        }

                        //Close-Button
                        if ($("#jq_close").length == 0) {
                            $("#jq_zoomin_pic_inner").prepend("<a class='_close _destroy_me _button' id='jq_close' style='position:absolute; top:" + close_button_top + "px; right:" + close_bottom_right + "px; z-index:902; cursor:pointer;'><img src='IMG/close_zoompic.png' /></a>");
                        }

                        //Das Bild!
                        if ($("._zoomed_img").length == 0) {
                            $("#jq_zoomin_pic_inner").prepend("<div class='_destroy_me_first img_container _destroy_me' style='position:relative; z-index:903; height:" + this_height + "px; background:url(IMG/loading_content.gif) no-repeat center center;'><img id='i_gr_" + this_int + "' src='" + img_full.src + "' class='ui-corner-all ie-corner _close _destroy_me _zoomed_img' style='border:2px solid #FBF0B7; cursor:pointer; display:none; position:relative; z-index:903;' /></div>");
                        }

                        $("#jq_zoomin_overlay").css({
                            "background": "#080808 url('../style/images/ui-bg_flat_0_080808_40x100.png') no-repeat 50% 50%",
                            "opacity": .6,
                            "filter": "Alpha(opacity=60)",
                            "zoom": 1,
                            "z-index": 900,
                            "height": "100%",
                            "width": "100%",
                            "position": "absolute",
                            "top": "0px",
                            "left": "0px"
                        });

                        var left_position = (parseInt($(window).width() / 2) - (parseInt(this_width) + dim_add + 70) / 2);
                        $("#jq_zoomin_pic_inner").css({
                            "padding": "0",
                            "padding-bottom": "40px",
                            "padding-top": "10px",
                            "margin-left": "20px",
                            "margin-right": "20px",
                            "margin-top": "20px",
                            //"height": "auto", //parseInt(this_height) + dim_add + "px", // + dim_add + "px",
                            //"width": "auto", //parseInt(this_width) + dim_add_width + "px",
                            "left": left_position + "px",
                            "border": "1px solid #FBF0B7",
                            "zoom": 1,
                            "z-index": 902,
                            "opacity": 1,
                            "filter": "Alpha(opacity=100)"
                        })

                        $("#jq_zoomin_pic").css({
                            "padding": "0em",
                            "padding-bottom": "2em",
                            "padding-top": "2px",
                            "padding-left": "7px",
                            "padding-right": "7px",
                            "height": parseInt(this_height) + dim_add + 70 + "px", // + dim_add + "px",
                            "width": parseInt(this_width) + dim_add_width + 70 + "px",
                            "left": left_position + "px",
                            "top": "0px",
                            "bottom": "3%",
                            "margin": "auto auto",
                            // "border": "1px solid blue",
                            "zoom": 1,
                            "z-index": 901,
                            "position": "absolute"
                            //"filter": "Alpha(opacity=100)"
                        }).fadeIn("slow");


                        if ($("._element_zoompic").length >= 2) {
                            var this_number = this_int + 1;
                            if ($("._arrow").length == 0) {
                                if ($("#jq_next").length == 0) {
                                    $("#jq_zoomin_pic_inner").prepend("<a class='_arrow_next _arrow _destroy_me _button' id='jq_next' style='position:absolute; top:40%; right:10px; z-index:902; cursor:pointer;'><img src='IMG/zoompic_next.png' alt='weiter' /></a>");
                                }

                                if ($("#jq_prev").length == 0) {
                                    $("#jq_zoomin_pic_inner").prepend("<a class='_arrow_prev _arrow _destroy_me _button' id='jq_prev' style='position:absolute; top:40%; left:10px; z-index:902; cursor:pointer;'><img src='IMG/zoompic_prev.png' alt='zur&uml;//ck' /></a>");
                                }

                            }

                            var item_nummer = "<br /><font class='_arrow _pages _destroy_me' style='color:#FBF0B7; float:left;'><span id='jq_pic_nr'>" + this_number + "</span> / " + $("._element_zoompic").length + "</font>";
                        }
                        else {
                            var item_nummer = "";
                        }

                        $("#jq_zoomin_pic_inner").append("<div class='_destroy_me _arrow' style='padding-left:20px; height:20px; position:relative; bottom:5px;'><br /><br /><span class='_close _destroy_me' id='jq_alt_text' style='float:left;'>" + this_alt + "</span>" +
                                            item_nummer +
                                            "</div>");

                        $("#jq_zoomin_overlay").fadeIn("slow", function () {
                            $("#jq_zoomin_pic").fadeIn("slow", function () {
                                $("._zoomed_img").fadeIn("slow");
                                $("._arrow").fadeIn("slow");
                            });
                        });

                        $("._arrow_next").bind("click", function () {
                            var me = $("._zoomed_img").attr("id");
                            Load.Next.run(me)
                        });

                        $("._arrow_prev").bind("click", function () {
                            var me = $("._zoomed_img").attr("id");
                            Load.Prev.run(me)
                        });
                    });
                }
            });

            $("._close").live("click", function () {
                $("._arrow").fadeOut("slow");
                $("._destroy_me_first").css("background", "");
                $("._zoomed_img").fadeOut("slow", function () {
                    $("#jq_zoomin_pic").fadeOut("slow");
                    $("#jq_zoomin_overlay").fadeOut("slow", function () {
                        $("._destroy_me").remove();
                    });

                    $("._arrow_prev").unbind("click");
                    $("._arrow_next").unbind("click");
                });
            });

            //#############################################
            // MouseEnter / Out-Events
            //#############################################

            $("._arrow_next").live("mouseenter", function () {
                $(this).children().attr("src", "IMG/mo_zoompic_next.png");
            });
            $("._arrow_next").live("mouseout", function () {
                $(this).children().attr("src", "IMG/zoompic_next.png");
            });

            $("._arrow_prev").live("mouseenter", function () {
                $(this).children().attr("src", "IMG/mo_zoompic_prev.png");
            });
            $("._arrow_prev").live("mouseout", function () {
                $(this).children().attr("src", "IMG/zoompic_prev.png");
            });

            $("._close").live("mouseenter", function () {
                $(this).children().attr("src", "IMG/mo_close_zoompic.png");
            });
            $("._close").live("mouseout", function () {
                $(this).children().attr("src", "IMG/close_zoompic.png");
            });
        }
    };

    $.fn.zoompics = function (method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error(alert('Method ' + method + ' does not exist on jQuery.zoompic'));
        }
    }
})(jQuery);



