Signin  Pricing  Examples  Support

Libraries > shopware-responsive.min.js

shopware-responsive.min.js - Search Live Website Code
It's like doing CTRL+F on millions of websites' source code



NerdyData is a search engine for source code. Search the source code of 200 million websites.


JAVASCRIPT FILE http://game-legends.com/templates/_theme-game-legends/frontend/_resources/js/shopware-responsive.min.js

Function Explorer






















Libraries on game-legends.com


ArboroGoogleAnalytics.js

cookie-bar.js

jquery.swag_live_shopping.js

bootstrap.min.js

jquery.1.9.min.js

jquery-ui-1.10.3.custom.min.js

respond.min.js

scripts.js

shopware-responsive.min.js



Explore More


translate.js

prototype.js

validation.js

window.js

shopware-responsive.min.js
				
/** HERE ARE THE IMPORTANT COPYRIGHTS! **/

/*
 * flexmenu plugin v1.1
 * http://iarouse.com/
 *
 * License info: http://codecanyon.net/licenses
 * http://codecanyon.net/item/flexmenu-responsive-offcanvastoggle-navigation/5550510
 */
/*
 * rwdImageMaps jQuery plugin v1.5
 *
 * Allows image maps to be used in a responsive design by recalculating the area coordinates to match the actual image size on load and window.resize
 *
 * Copyright (c) 2013 Matt Stow
 * https://github.com/stowball/jQuery-rwdImageMaps
 * http://mattstow.com
 * Licensed under the MIT license
 */
/*
 * jQuery FlexSlider v2.2.0
 * Copyright 2012 WooThemes
 * Contributing Author: Tyler Smith
 */
/**
 * Compare Plugin
 * for Shopware
 *
 * Shopware AG (c) 2010
 */


/** HERE COMES THE MAGIC **/
;
(function ($) {
    $.format = function (str) {
        for (var i = 1; i < arguments.length; i++) {
            str = str.replace('%' + (i - 1), arguments[i]);
        }
        return str;
    };

    $(document).ready(function () {

        $(document).on('change', '#country', function () {
            var $this = $(this), selected = $this.find(':selected'), val = selected.val();
            // Reset all visible selection boxes if the value is empty (e.g. Please select...)
            $('.country-area-state-selection select').attr('disabled', 'disabled');
            $('.country-area-state-selection select').parents('div.selection').addClass('hidden');

            var id = $.format('#country_%0_states', ~~(1 * val));
            $('.register .shipping_address select' + id).removeAttr('disabled').parents('div.selection').removeClass('hidden');
            $('select' + id).removeAttr('disabled').parents('div.selection').removeClass('hidden');
        });

        $(document).on('change', '#country2', function () {
            var $this = $(this), selected = $this.find(':selected'), val = selected.val();

            // Reset all visible selection boxes if the value is empty (e.g. Please select...)
            $('.country-area-state-selection2 select').attr('disabled', 'disabled');
            $('.country-area-state-selection2 select').parents('div.selection').addClass('hidden');


            var id = $.format('#country_%0_states', ~~(1 * val));
            $('select' + id).removeAttr('disabled').parents('div.selection').removeClass('hidden');
        });

    });
})(jQuery);

;
(function () {
    (function (e, t) {
        "use strict";
        return e.fn.flexMenu = function (n) {
            return this.each(function () {
                var r, i, s, o, u, a, f, l, c, h, p, d, v, navout;
                navout = false;
                d = e.extend({breakpoint: 768, responsivePattern: "toggle", animationSpeed: 250}, n);
                u = e(this);
                o = u.find("li");
                f = e(t);
                v = void 0;
                r = e("body");
                u.addClass("flexmenu");
                i = e(".fm-button");
                l = function () {
                    var t;
                    u.find("li").each(function () {
                        var t;
                        t = e(this);
                        if (t.has("ul").length)return t.addClass("with-ul").find("ul").hide()
                    });
                    t = u.find(".with-ul");
                    t.append('<span class="navicon"></span>');
                    if (d.responsivePattern === "toggle")return u.addClass("fm-toggle");
                    if (d.responsivePattern === "off-canvas") {
                        u.addClass("fm-offcanvas");
                        return r.wrapInner('<div class="fm-inner" />').wrapInner('<div class="fm-outer" />')
                    }
                };
                l();
                a = e(".flexmenu .navicon");
                s = e(".fm-inner");
                c = !1;
                i.on("click", function () {
                    u = e(".flexmenu.fm-sm");
                    if (u.hasClass("fm-toggle"))return u.slideToggle(d.animationSpeed);
                    if (u.hasClass("fm-offcanvas")) {
                        if (c) {
                            s.animate({left: 0}, {duration: d.animationSpeed});
                            u.animate({left: "-70%"}, {duration: d.animationSpeed});
                            return c = !1
                        }
                        s.animate({left: "70%"}, {duration: d.animationSpeed});
                        u.animate({left: 0}, {duration: d.animationSpeed});
                        return c = !0
                    }
                });
                h = function () {
                    u.find("> li > ul").slideUp(200);
                    if (d.responsivePattern === "off-canvas" && e(".flexmenu.fm-sm").length)return function () {
                        u = e(".flexmenu.fm-sm");
                        s.animate({left: 0}, {duration: d.animationSpeed});
                        u.animate({left: "-70%"}, {duration: d.animationSpeed});
                        return c = !1
                    }()
                };
                p = function () {
                    var t;
                    t = f.width();
                    if (t <= d.breakpoint) {
                        if (e(".fm-lg").length) {
                            h();
                            u.hasClass("fm-toggle") && u.hide()
                        }
                        u.removeClass("fm-lg").addClass("fm-sm");
                        i.show();
                        //o.off("mouseenter mouseleave");
                        o.off("mouseleave");
                        a.off("click");
                        return a.on("click", function (t) {
                            var n, r;
                            t.stopPropagation();
                            r = e(this);
                            n = r.parent(".with-ul").children("ul");
                            return n.stop(!0, !0).slideToggle({duration: d.animationSpeed})
                        })
                    }
                    h();
                    u.removeClass("fm-sm").addClass("fm-lg");
                    i.hide();
                    u.hasClass("fm-toggle") && u.slideDown();
                    //o.off("mouseenter mouseleave");
                    o.off("mouseleave");
                    a.off("click");
                    return o.on("mouseenter click",function (ev) {
                        if (!e(this).hasClass("with-ul")) {
                            navout = true;
                        }
                        if (!navout) {
                            if (e(this).hasClass("with-ul")) {
                                ev.preventDefault();
                                ev.stopPropagation();
                            }
                        }
                        return e(this).children("ul").stop(!0, !0).slideDown(d.animationSpeed, function () {
                            setTimeout(function () {
                                navout = true;
                            }, 200);
                        })
                    }).on("mouseleave", function () {
                        if(e(this).parent().parent().hasClass('menu') == false) {
                            return;
                        }
                        navout = false;
                        return e(this).children("ul").stop(!0, !0);//.slideUp(d.animationSpeed, function () {
                        //})
                    })
                };
                p();
                return f.resize(function () {
                    if (isLoaded != "y") return;
                    clearTimeout(v);
                    return v = setTimeout(p, 200)
                })
            })
        }
    })(jQuery, window)
}).call(this);

/*
 * rwdImageMaps jQuery plugin v1.5
 *
 * Allows image maps to be used in a responsive design by recalculating the area coordinates to match the actual image size on load and window.resize
 *
 * Copyright (c) 2013 Matt Stow
 * https://github.com/stowball/jQuery-rwdImageMaps
 * http://mattstow.com
 * Licensed under the MIT license
 */
;
(function (a) {
    a.fn.rwdImageMaps = function () {
        var c = this;
        var b = function () {
            c.each(function () {
                if (typeof(a(this).attr("usemap")) == "undefined") {
                    return
                }
                var e = this, d = a(e);
                a("<img />").load(function () {
                    var g = "width", m = "height", n = d.attr(g), j = d.attr(m);
                    if (!n || !j) {
                        var o = new Image();
                        o.src = d.attr("src");
                        if (!n) {
                            n = o.width
                        }
                        if (!j) {
                            j = o.height
                        }
                    }
                    var f = d.width() / 100, k = d.height() / 100, i = d.attr("usemap").replace("#", ""), l = "coords";
                    a('map[name="' + i + '"]').find("area").each(function () {
                        var r = a(this);
                        if (!r.data(l)) {
                            r.data(l, r.attr(l))
                        }
                        var q = r.data(l).split(","), p = new Array(q.length);
                        for (var h = 0; h < p.length; ++h) {
                            if (h % 2 === 0) {
                                p[h] = parseInt(((q[h] / n) * 100) * f)
                            } else {
                                p[h] = parseInt(((q[h] / j) * 100) * k)
                            }
                        }
                        r.attr(l, p.toString())
                    })
                }).attr("src", d.attr("src"))
            })
        };
        a(window).resize(b).trigger("resize");
        return this
    }
})(jQuery);


/*
 * jQuery FlexSlider v2.2.0
 * Copyright 2012 WooThemes
 * Contributing Author: Tyler Smith
 */
;
(function ($) {

    //FlexSlider: Object Instance
    $.flexslider = function (el, options) {
        var slider = $(el);

        // making variables public
        slider.vars = $.extend({}, $.flexslider.defaults, options);

        var namespace = slider.vars.namespace,
            msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture,
            touch = (( "ontouchstart" in window ) || msGesture || window.DocumentTouch && document instanceof DocumentTouch) && slider.vars.touch,
        // depricating this idea, as devices are being released with both of these events
        //eventType = (touch) ? "touchend" : "click",
            eventType = "click touchend MSPointerUp",
            watchedEvent = "",
            watchedEventClearTimer,
            vertical = slider.vars.direction === "vertical",
            reverse = slider.vars.reverse,
            carousel = (slider.vars.itemWidth > 0),
            fade = slider.vars.animation === "fade",
            asNav = slider.vars.asNavFor !== "",
            methods = {},
            focused = true;

        // Store a reference to the slider object
        $.data(el, "flexslider", slider);

        // Private slider methods
        methods = {
            init: function () {
                slider.animating = false;
                // Get current slide and make sure it is a number
                slider.currentSlide = parseInt(( slider.vars.startAt ? slider.vars.startAt : 0));
                if (isNaN(slider.currentSlide)) slider.currentSlide = 0;
                slider.animatingTo = slider.currentSlide;
                slider.atEnd = (slider.currentSlide === 0 || slider.currentSlide === slider.last);
                slider.containerSelector = slider.vars.selector.substr(0, slider.vars.selector.search(' '));
                slider.slides = $(slider.vars.selector, slider);
                slider.container = $(slider.containerSelector, slider);
                slider.count = slider.slides.length;
                // SYNC:
                slider.syncExists = $(slider.vars.sync).length > 0;
                // SLIDE:
                if (slider.vars.animation === "slide") slider.vars.animation = "swing";
                slider.prop = (vertical) ? "top" : "marginLeft";
                slider.args = {};
                // SLIDESHOW:
                slider.manualPause = false;
                slider.stopped = false;
                //PAUSE WHEN INVISIBLE
                slider.started = false;
                slider.startTimeout = null;
                // TOUCH/USECSS:
                slider.transitions = !slider.vars.video && !fade && slider.vars.useCSS && (function () {
                    var obj = document.createElement('div'),
                        props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
                    for (var i in props) {
                        if (obj.style[ props[i] ] !== undefined) {
                            slider.pfx = props[i].replace('Perspective', '').toLowerCase();
                            slider.prop = "-" + slider.pfx + "-transform";
                            return true;
                        }
                    }
                    return false;
                }());
                // CONTROLSCONTAINER:
                if (slider.vars.controlsContainer !== "") slider.controlsContainer = $(slider.vars.controlsContainer).length > 0 && $(slider.vars.controlsContainer);
                // MANUAL:
                if (slider.vars.manualControls !== "") slider.manualControls = $(slider.vars.manualControls).length > 0 && $(slider.vars.manualControls);

                // RANDOMIZE:
                if (slider.vars.randomize) {
                    slider.slides.sort(function () {
                        return (Math.round(Math.random()) - 0.5);
                    });
                    slider.container.empty().append(slider.slides);
                }

                slider.doMath();

                // INIT
                slider.setup("init");

                // CONTROLNAV:
                if (slider.vars.controlNav) methods.controlNav.setup();

                // DIRECTIONNAV:
                if (slider.vars.directionNav) methods.directionNav.setup();

                // KEYBOARD:
                if (slider.vars.keyboard && ($(slider.containerSelector).length === 1 || slider.vars.multipleKeyboard)) {
                    $(document).bind('keyup', function (event) {
                        var keycode = event.keyCode;
                        if (!slider.animating && (keycode === 39 || keycode === 37)) {
                            var target = (keycode === 39) ? slider.getTarget('next') :
                                (keycode === 37) ? slider.getTarget('prev') : false;
                            slider.flexAnimate(target, slider.vars.pauseOnAction);
                        }
                    });
                }
                // MOUSEWHEEL:
                if (slider.vars.mousewheel) {
                    slider.bind('mousewheel', function (event, delta, deltaX, deltaY) {
                        event.preventDefault();
                        var target = (delta < 0) ? slider.getTarget('next') : slider.getTarget('prev');
                        slider.flexAnimate(target, slider.vars.pauseOnAction);
                    });
                }

                // PAUSEPLAY
                if (slider.vars.pausePlay) methods.pausePlay.setup();

                //PAUSE WHEN INVISIBLE
                if (slider.vars.slideshow && slider.vars.pauseInvisible) methods.pauseInvisible.init();

                // SLIDSESHOW
                if (slider.vars.slideshow) {
                    if (slider.vars.pauseOnHover) {
                        slider.hover(function () {
                            if (!slider.manualPlay && !slider.manualPause) slider.pause();
                        }, function () {
                            if (!slider.manualPause && !slider.manualPlay && !slider.stopped) slider.play();
                        });
                    }
                    // initialize animation
                    //If we're visible, or we don't use PageVisibility API
                    if (!slider.vars.pauseInvisible || !methods.pauseInvisible.isHidden()) {
                        (slider.vars.initDelay > 0) ? slider.startTimeout = setTimeout(slider.play, slider.vars.initDelay) : slider.play();
                    }
                }

                // ASNAV:
                if (asNav) methods.asNav.setup();

                // TOUCH
                if (touch && slider.vars.touch) methods.touch();

                // FADE&&SMOOTHHEIGHT || SLIDE:
                if (!fade || (fade && slider.vars.smoothHeight)) $(window).bind("resize orientationchange focus", methods.resize);

                slider.find("img").attr("draggable", "false");

                // API: start() Callback
                setTimeout(function () {
                    slider.vars.start(slider);
                }, 200);
            },
            asNav: {
                setup: function () {
                    slider.asNav = true;
                    slider.animatingTo = Math.floor(slider.currentSlide / slider.move);
                    slider.currentItem = slider.currentSlide;
                    slider.slides.removeClass(namespace + "active-slide").eq(slider.currentItem).addClass(namespace + "active-slide");
                    if (!msGesture) {
                        slider.slides.click(function (e) {
                            e.preventDefault();
                            var $slide = $(this),
                                target = $slide.index();
                            var posFromLeft = $slide.offset().left - $(slider).scrollLeft(); // Find position of slide relative to left of slider container
                            if (posFromLeft <= 0 && $slide.hasClass(namespace + 'active-slide')) {
                                slider.flexAnimate(slider.getTarget("prev"), true);
                            } else if (!$(slider.vars.asNavFor).data('flexslider').animating && !$slide.hasClass(namespace + "active-slide")) {
                                slider.direction = (slider.currentItem < target) ? "next" : "prev";
                                slider.flexAnimate(target, slider.vars.pauseOnAction, false, true, true);
                            }
                        });
                    } else {
                        el._slider = slider;
                        slider.slides.each(function () {
                            var that = this;
                            that._gesture = new MSGesture();
                            that._gesture.target = that;
                            that.addEventListener("MSPointerDown", function (e) {
                                e.preventDefault();
                                if (e.currentTarget._gesture)
                                    e.currentTarget._gesture.addPointer(e.pointerId);
                            }, false);
                            that.addEventListener("MSGestureTap", function (e) {
                                e.preventDefault();
                                var $slide = $(this),
                                    target = $slide.index();
                                if (!$(slider.vars.asNavFor).data('flexslider').animating && !$slide.hasClass('active')) {
                                    slider.direction = (slider.currentItem < target) ? "next" : "prev";
                                    slider.flexAnimate(target, slider.vars.pauseOnAction, false, true, true);
                                }
                            });
                        });
                    }
                }
            },
            controlNav: {
                setup: function () {
                    if (!slider.manualControls) {
                        methods.controlNav.setupPaging();
                    } else { // MANUALCONTROLS:
                        methods.controlNav.setupManual();
                    }
                },
                setupPaging: function () {
                    var type = (slider.vars.controlNav === "thumbnails") ? 'control-thumbs' : 'control-paging',
                        j = 1,
                        item,
                        slide;

                    slider.controlNavScaffold = $('<ol class="' + namespace + 'control-nav ' + namespace + type + '"></ol>');
                    if (slider.pagingCount > 1) {
                        for (var i = 0; i < slider.pagingCount; i++) {
                            slide = slider.slides.eq(i);
                            item = (slider.vars.controlNav === "thumbnails") ? '<img src="' + slide.attr('data-thumb') + '"/>' : '<a>' + j + '</a>';
                            if ('thumbnails' === slider.vars.controlNav && true === slider.vars.thumbCaptions) {
                                var captn = slide.attr('data-thumbcaption');
                                if ('' != captn && undefined != captn) item += '<span class="' + namespace + 'caption">' + captn + '</span>';
                            }
                            slider.controlNavScaffold.append('<li>' + item + '</li>');
                            j++;
                        }
                    }

                    // CONTROLSCONTAINER:
                    (slider.controlsContainer) ? $(slider.controlsContainer).append(slider.controlNavScaffold) : slider.append(slider.controlNavScaffold);
                    methods.controlNav.set();

                    methods.controlNav.active();

                    slider.controlNavScaffold.delegate('a, img', eventType, function (event) {
                        event.preventDefault();

                        if (watchedEvent === "" || watchedEvent === event.type) {
                            var $this = $(this),
                                target = slider.controlNav.index($this);

                            if (!$this.hasClass(namespace + 'active')) {
                                slider.direction = (target > slider.currentSlide) ? "next" : "prev";
                                slider.flexAnimate(target, slider.vars.pauseOnAction);
                            }
                        }

                        // setup flags to prevent event duplication
                        if (watchedEvent === "") {
                            watchedEvent = event.type;
                        }
                        methods.setToClearWatchedEvent();

                    });

                    $('.flex-control-nav').wrap('<div class="navBackground"></div>');

                },
                setupManual: function () {
                    slider.controlNav = slider.manualControls;
                    methods.controlNav.active();

                    slider.controlNav.bind(eventType, function (event) {
                        event.preventDefault();

                        if (watchedEvent === "" || watchedEvent === event.type) {
                            var $this = $(this),
                                target = slider.controlNav.index($this);

                            if (!$this.hasClass(namespace + 'active')) {
                                (target > slider.currentSlide) ? slider.direction = "next" : slider.direction = "prev";
                                slider.flexAnimate(target, slider.vars.pauseOnAction);
                            }
                        }

                        // setup flags to prevent event duplication
                        if (watchedEvent === "") {
                            watchedEvent = event.type;
                        }
                        methods.setToClearWatchedEvent();
                    });
                },
                set: function () {
                    var selector = (slider.vars.controlNav === "thumbnails") ? 'img' : 'a';
                    slider.controlNav = $('.' + namespace + 'control-nav li ' + selector, (slider.controlsContainer) ? slider.controlsContainer : slider);
                },
                active: function () {
                    slider.controlNav.removeClass(namespace + "active").eq(slider.animatingTo).addClass(namespace + "active");
                },
                update: function (action, pos) {
                    if (slider.pagingCount > 1 && action === "add") {
                        slider.controlNavScaffold.append($('<li><a>' + slider.count + '</a></li>'));
                    } else if (slider.pagingCount === 1) {
                        slider.controlNavScaffold.find('li').remove();
                    } else {
                        slider.controlNav.eq(pos).closest('li').remove();
                    }
                    methods.controlNav.set();
                    (slider.pagingCount > 1 && slider.pagingCount !== slider.controlNav.length) ? slider.update(pos, action) : methods.controlNav.active();
                }
            },
            directionNav: {
                setup: function () {
                    var directionNavScaffold = $('<ul class="' + namespace + 'direction-nav"><li><a class="' + namespace + 'prev" href="#">' + slider.vars.prevText + '</a></li><li><a class="' + namespace + 'next" href="#">' + slider.vars.nextText + '</a></li></ul>');

                    // CONTROLSCONTAINER:
                    if (slider.controlsContainer) {
                        $(slider.controlsContainer).append(directionNavScaffold);
                        slider.directionNav = $('.' + namespace + 'direction-nav li a', slider.controlsContainer);
                    } else {
                        slider.append(directionNavScaffold);
                        slider.directionNav = $('.' + namespace + 'direction-nav li a', slider);
                    }

                    methods.directionNav.update();

                    slider.directionNav.bind(eventType, function (event) {
                        event.preventDefault();
                        var target;

                        if (watchedEvent === "" || watchedEvent === event.type) {
                            target = ($(this).hasClass(namespace + 'next')) ? slider.getTarget('next') : slider.getTarget('prev');
                            slider.flexAnimate(target, slider.vars.pauseOnAction);
                        }

                        // setup flags to prevent event duplication
                        if (watchedEvent === "") {
                            watchedEvent = event.type;
                        }
                        methods.setToClearWatchedEvent();
                    });
                },
                update: function () {
                    var disabledClass = namespace + 'disabled';
                    if (slider.pagingCount === 1) {
                        slider.directionNav.addClass(disabledClass).attr('tabindex', '-1');
                    } else if (!slider.vars.animationLoop) {
                        if (slider.animatingTo === 0) {
                            slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "prev").addClass(disabledClass).attr('tabindex', '-1');
                        } else if (slider.animatingTo === slider.last) {
                            slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "next").addClass(disabledClass).attr('tabindex', '-1');
                        } else {
                            slider.directionNav.removeClass(disabledClass).removeAttr('tabindex');
                        }
                    } else {
                        slider.directionNav.removeClass(disabledClass).removeAttr('tabindex');
                    }
                }
            },
            pausePlay: {
                setup: function () {
                    var pausePlayScaffold = $('<div class="' + namespace + 'pauseplay"><a></a></div>');

                    // CONTROLSCONTAINER:
                    if (slider.controlsContainer) {
                        slider.controlsContainer.append(pausePlayScaffold);
                        slider.pausePlay = $('.' + namespace + 'pauseplay a', slider.controlsContainer);
                    } else {
                        slider.append(pausePlayScaffold);
                        slider.pausePlay = $('.' + namespace + 'pauseplay a', slider);
                    }

                    methods.pausePlay.update((slider.vars.slideshow) ? namespace + 'pause' : namespace + 'play');

                    slider.pausePlay.bind(eventType, function (event) {
                        event.preventDefault();

                        if (watchedEvent === "" || watchedEvent === event.type) {
                            if ($(this).hasClass(namespace + 'pause')) {
                                slider.manualPause = true;
                                slider.manualPlay = false;
                                slider.pause();
                            } else {
                                slider.manualPause = false;
                                slider.manualPlay = true;
                                slider.play();
                            }
                        }

                        // setup flags to prevent event duplication
                        if (watchedEvent === "") {
                            watchedEvent = event.type;
                        }
                        methods.setToClearWatchedEvent();
                    });
                },
                update: function (state) {
                    (state === "play") ? slider.pausePlay.removeClass(namespace + 'pause').addClass(namespace + 'play').html(slider.vars.playText) : slider.pausePlay.removeClass(namespace + 'play').addClass(namespace + 'pause').html(slider.vars.pauseText);
                }
            },
            touch: function () {
                var startX,
                    startY,
                    offset,
                    cwidth,
                    dx,
                    startT,
                    scrolling = false,
                    localX = 0,
                    localY = 0,
                    accDx = 0;

                if (!msGesture) {
                    function onTouchStart(e) {
                        if (slider.animating) {
                            e.preventDefault();
                        } else if (( window.navigator.msPointerEnabled ) || e.touches.length === 1) {
                            slider.pause();
                            // CAROUSEL:
                            cwidth = (vertical) ? slider.h : slider.w;
                            startT = Number(new Date());
                            // CAROUSEL:

                            // Local vars for X and Y points.
                            localX = e.touches[0].pageX;
                            localY = e.touches[0].pageY;

                            offset = (carousel && reverse && slider.animatingTo === slider.last) ? 0 :
                                (carousel && reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
                                    (carousel && slider.currentSlide === slider.last) ? slider.limit :
                                        (carousel) ? ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.currentSlide :
                                            (reverse) ? (slider.last - slider.currentSlide + slider.cloneOffset) * cwidth : (slider.currentSlide + slider.cloneOffset) * cwidth;
                            startX = (vertical) ? localY : localX;
                            startY = (vertical) ? localX : localY;

                            el.addEventListener('touchmove', onTouchMove, false);
                            el.addEventListener('touchend', onTouchEnd, false);
                        }
                    }

                    el.addEventListener('touchstart', onTouchStart, false);

                    function onTouchMove(e) {
                        // Local vars for X and Y points.

                        localX = e.touches[0].pageX;
                        localY = e.touches[0].pageY;

                        dx = (vertical) ? startX - localY : startX - localX;
                        scrolling = (vertical) ? (Math.abs(dx) < Math.abs(localX - startY)) : (Math.abs(dx) < Math.abs(localY - startY));

                        var fxms = 500;

                        if (!scrolling || Number(new Date()) - startT > fxms) {
                            e.preventDefault();
                            if (!fade && slider.transitions) {
                                if (!slider.vars.animationLoop) {
                                    dx = dx / ((slider.currentSlide === 0 && dx < 0 || slider.currentSlide === slider.last && dx > 0) ? (Math.abs(dx) / cwidth + 2) : 1);
                                }
                                slider.setProps(offset + dx, "setTouch");
                            }
                        }
                        else {
                            el.removeEventListener('touchmove', onTouchMove, false);
                        }
                    }

                    function onTouchEnd(e) {
                        // finish the touch by undoing the touch session
                        el.removeEventListener('touchmove', onTouchMove, false);

                        if (slider.animatingTo === slider.currentSlide && !scrolling && !(dx === null)) {
                            var updateDx = (reverse) ? -dx : dx,
                                target = (updateDx > 0) ? slider.getTarget('next') : slider.getTarget('prev');

                            if (slider.canAdvance(target) && (Number(new Date()) - startT < 550 && Math.abs(updateDx) > 50 || Math.abs(updateDx) > cwidth / 2)) {
                                slider.flexAnimate(target, slider.vars.pauseOnAction);
                            } else {
                                if (!fade) slider.flexAnimate(slider.currentSlide, slider.vars.pauseOnAction, true);
                            }
                        }
                        el.removeEventListener('touchend', onTouchEnd, false);

                        startX = null;
                        startY = null;
                        dx = null;
                        offset = null;
                    }
                } else {
                    el.style.msTouchAction = "none";
                    el._gesture = new MSGesture();
                    el._gesture.target = el;
                    el.addEventListener("MSPointerDown", onMSPointerDown, false);
                    el._slider = slider;
                    el.addEventListener("MSGestureChange", onMSGestureChange, false);
                    el.addEventListener("MSGestureEnd", onMSGestureEnd, false);

                    function onMSPointerDown(e) {
                        e.stopPropagation();
                        if (slider.animating) {
                            e.preventDefault();
                        } else {
                            slider.pause();
                            el._gesture.addPointer(e.pointerId);
                            accDx = 0;
                            cwidth = (vertical) ? slider.h : slider.w;
                            startT = Number(new Date());
                            // CAROUSEL:

                            offset = (carousel && reverse && slider.animatingTo === slider.last) ? 0 :
                                (carousel && reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
                                    (carousel && slider.currentSlide === slider.last) ? slider.limit :
                                        (carousel) ? ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.currentSlide :
                                            (reverse) ? (slider.last - slider.currentSlide + slider.cloneOffset) * cwidth : (slider.currentSlide + slider.cloneOffset) * cwidth;
                        }
                    }

                    function onMSGestureChange(e) {
                        e.stopPropagation();
                        var slider = e.target._slider;
                        if (!slider) {
                            return;
                        }
                        var transX = -e.translationX,
                            transY = -e.translationY;

                        //Accumulate translations.
                        accDx = accDx + ((vertical) ? transY : transX);
                        dx = accDx;
                        scrolling = (vertical) ? (Math.abs(accDx) < Math.abs(-transX)) : (Math.abs(accDx) < Math.abs(-transY));

                        if (e.detail === e.MSGESTURE_FLAG_INERTIA) {
                            setImmediate(function () {
                                el._gesture.stop();
                            });

                            return;
                        }

                        if (!scrolling || Number(new Date()) - startT > 500) {
                            e.preventDefault();
                            if (!fade && slider.transitions) {
                                if (!slider.vars.animationLoop) {
                                    dx = accDx / ((slider.currentSlide === 0 && accDx < 0 || slider.currentSlide === slider.last && accDx > 0) ? (Math.abs(accDx) / cwidth + 2) : 1);
                                }
                                slider.setProps(offset + dx, "setTouch");
                            }
                        }
                    }

                    function onMSGestureEnd(e) {
                        e.stopPropagation();
                        var slider = e.target._slider;
                        if (!slider) {
                            return;
                        }
                        if (slider.animatingTo === slider.currentSlide && !scrolling && !(dx === null)) {
                            var updateDx = (reverse) ? -dx : dx,
                                target = (updateDx > 0) ? slider.getTarget('next') : slider.getTarget('prev');

                            if (slider.canAdvance(target) && (Number(new Date()) - startT < 550 && Math.abs(updateDx) > 50 || Math.abs(updateDx) > cwidth / 2)) {
                                slider.flexAnimate(target, slider.vars.pauseOnAction);
                            } else {
                                if (!fade) slider.flexAnimate(slider.currentSlide, slider.vars.pauseOnAction, true);
                            }
                        }

                        startX = null;
                        startY = null;
                        dx = null;
                        offset = null;
                        accDx = 0;
                    }
                }
            },
            resize: function () {
                if (!slider.animating && slider.is(':visible')) {
                    if (!carousel) slider.doMath();

                    if (fade) {
                        // SMOOTH HEIGHT:
                        methods.smoothHeight();
                    } else if (carousel) { //CAROUSEL:
                        slider.slides.width(slider.computedW);
                        slider.update(slider.pagingCount);
                        slider.setProps();
                    }
                    else if (vertical) { //VERTICAL:
                        slider.viewport.height(slider.h);
                        slider.setProps(slider.h, "setTotal");
                    } else {
                        // SMOOTH HEIGHT:
                        if (slider.vars.smoothHeight) methods.smoothHeight();
                        slider.newSlides.width(slider.computedW);
                        slider.setProps(slider.computedW, "setTotal");
                    }
                }
            },
            smoothHeight: function (dur) {
                if (!vertical || fade) {
                    var $obj = (fade) ? slider : slider.viewport;
                    (dur) ? $obj.animate({"height": slider.slides.eq(slider.animatingTo).height()}, dur) : $obj.height(slider.slides.eq(slider.animatingTo).height());
                }
            },
            sync: function (action) {
                var $obj = $(slider.vars.sync).data("flexslider"),
                    target = slider.animatingTo;

                switch (action) {
                    case "animate":
                        $obj.flexAnimate(target, slider.vars.pauseOnAction, false, true);
                        break;
                    case "play":
                        if (!$obj.playing && !$obj.asNav) {
                            $obj.play();
                        }
                        break;
                    case "pause":
                        $obj.pause();
                        break;
                }
            },
            pauseInvisible: {
                visProp: null,
                init: function () {
                    var prefixes = ['webkit', 'moz', 'ms', 'o'];

                    if ('hidden' in document) return 'hidden';
                    for (var i = 0; i < prefixes.length; i++) {
                        if ((prefixes[i] + 'Hidden') in document)
                            methods.pauseInvisible.visProp = prefixes[i] + 'Hidden';
                    }
                    if (methods.pauseInvisible.visProp) {
                        var evtname = methods.pauseInvisible.visProp.replace(/[H|h]idden/, '') + 'visibilitychange';
                        document.addEventListener(evtname, function () {
                            if (methods.pauseInvisible.isHidden()) {
                                if (slider.startTimeout) clearTimeout(slider.startTimeout); //If clock is ticking, stop timer and prevent from starting while invisible
                                else slider.pause(); //Or just pause
                            }
                            else {
                                if (slider.started) slider.play(); //Initiated before, just play
                                else (slider.vars.initDelay > 0) ? setTimeout(slider.play, slider.vars.initDelay) : slider.play(); //Didn't init before: simply init or wait for it
                            }
                        });
                    }
                },
                isHidden: function () {
                    return document[methods.pauseInvisible.visProp] || false;
                }
            },
            setToClearWatchedEvent: function () {
                clearTimeout(watchedEventClearTimer);
                watchedEventClearTimer = setTimeout(function () {
                    watchedEvent = "";
                }, 3000);
            }
        }

        // public methods
        slider.flexAnimate = function (target, pause, override, withSync, fromNav) {
            if (!slider.vars.animationLoop && target !== slider.currentSlide) {
                slider.direction = (target > slider.currentSlide) ? "next" : "prev";
            }

            if (asNav && slider.pagingCount === 1) slider.direction = (slider.currentItem < target) ? "next" : "prev";

            if (!slider.animating && (slider.canAdvance(target, fromNav) || override) && slider.is(":visible")) {
                if (asNav && withSync) {
                    var master = $(slider.vars.asNavFor).data('flexslider');
                    slider.atEnd = target === 0 || target === slider.count - 1;
                    master.flexAnimate(target, true, false, true, fromNav);
                    slider.direction = (slider.currentItem < target) ? "next" : "prev";
                    master.direction = slider.direction;

                    if (Math.ceil((target + 1) / slider.visible) - 1 !== slider.currentSlide && target !== 0) {
                        slider.currentItem = target;
                        slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
                        target = Math.floor(target / slider.visible);
                    } else {
                        slider.currentItem = target;
                        slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
                        return false;
                    }
                }

                slider.animating = true;
                slider.animatingTo = target;

                // SLIDESHOW:
                if (pause) slider.pause();

                // API: before() animation Callback
                slider.vars.before(slider);

                // SYNC:
                if (slider.syncExists && !fromNav) methods.sync("animate");

                // CONTROLNAV
                if (slider.vars.controlNav) methods.controlNav.active();

                // !CAROUSEL:
                // CANDIDATE: slide active class (for add/remove slide)
                if (!carousel) slider.slides.removeClass(namespace + 'active-slide').eq(target).addClass(namespace + 'active-slide');

                // INFINITE LOOP:
                // CANDIDATE: atEnd
                slider.atEnd = target === 0 || target === slider.last;

                // DIRECTIONNAV:
                if (slider.vars.directionNav) methods.directionNav.update();

                if (target === slider.last) {
                    // API: end() of cycle Callback
                    slider.vars.end(slider);
                    // SLIDESHOW && !INFINITE LOOP:
                    if (!slider.vars.animationLoop) slider.pause();
                }

                // SLIDE:
                if (!fade) {
                    var dimension = (vertical) ? slider.slides.filter(':first').height() : slider.computedW,
                        margin, slideString, calcNext;

                    // INFINITE LOOP / REVERSE:
                    if (carousel) {
                        //margin = (slider.vars.itemWidth > slider.w) ? slider.vars.itemMargin * 2 : slider.vars.itemMargin;
                        margin = slider.vars.itemMargin;
                        calcNext = ((slider.itemW + margin) * slider.move) * slider.animatingTo;
                        slideString = (calcNext > slider.limit && slider.visible !== 1) ? slider.limit : calcNext;
                    } else if (slider.currentSlide === 0 && target === slider.count - 1 && slider.vars.animationLoop && slider.direction !== "next") {
                        slideString = (reverse) ? (slider.count + slider.cloneOffset) * dimension : 0;
                    } else if (slider.currentSlide === slider.last && target === 0 && slider.vars.animationLoop && slider.direction !== "prev") {
                        slideString = (reverse) ? 0 : (slider.count + 1) * dimension;
                    } else {
                        slideString = (reverse) ? ((slider.count - 1) - target + slider.cloneOffset) * dimension : (target + slider.cloneOffset) * dimension;
                    }
                    slider.setProps(slideString, "", slider.vars.animationSpeed);
                    if (slider.transitions) {
                        if (!slider.vars.animationLoop || !slider.atEnd) {
                            slider.animating = false;
                            slider.currentSlide = slider.animatingTo;
                        }
                        slider.container.unbind("webkitTransitionEnd transitionend");
                        slider.container.bind("webkitTransitionEnd transitionend", function () {
                            slider.wrapup(dimension);
                        });
                    } else {
                        slider.container.animate(slider.args, slider.vars.animationSpeed, slider.vars.easing, function () {
                            slider.wrapup(dimension);
                        });
                    }
                } else { // FADE:
                    if (!touch) {
                        //slider.slides.eq(slider.currentSlide).fadeOut(slider.vars.animationSpeed, slider.vars.easing);
                        //slider.slides.eq(target).fadeIn(slider.vars.animationSpeed, slider.vars.easing, slider.wrapup);

                        slider.slides.eq(slider.currentSlide).css({"zIndex": 1}).animate({"opacity": 0}, slider.vars.animationSpeed, slider.vars.easing);
                        slider.slides.eq(target).css({"zIndex": 2}).animate({"opacity": 1}, slider.vars.animationSpeed, slider.vars.easing, slider.wrapup);

                    } else {
                        slider.slides.eq(slider.currentSlide).css({ "opacity": 0, "zIndex": 1 });
                        slider.slides.eq(target).css({ "opacity": 1, "zIndex": 2 });
                        slider.wrapup(dimension);
                    }
                }
                // SMOOTH HEIGHT:
                if (slider.vars.smoothHeight) methods.smoothHeight(slider.vars.animationSpeed);
            }
        }
        slider.wrapup = function (dimension) {
            // SLIDE:
            if (!fade && !carousel) {
                if (slider.currentSlide === 0 && slider.animatingTo === slider.last && slider.vars.animationLoop) {
                    slider.setProps(dimension, "jumpEnd");
                } else if (slider.currentSlide === slider.last && slider.animatingTo === 0 && slider.vars.animationLoop) {
                    slider.setProps(dimension, "jumpStart");
                }
            }
            slider.animating = false;
            slider.currentSlide = slider.animatingTo;
            // API: after() animation Callback
            slider.vars.after(slider);
        }

        // SLIDESHOW:
        slider.animateSlides = function () {
            if (!slider.animating && focused) slider.flexAnimate(slider.getTarget("next"));
        }
        // SLIDESHOW:
        slider.pause = function () {
            clearInterval(slider.animatedSlides);
            slider.animatedSlides = null;
            slider.playing = false;
            // PAUSEPLAY:
            if (slider.vars.pausePlay) methods.pausePlay.update("play");
            // SYNC:
            if (slider.syncExists) methods.sync("pause");
        }
        // SLIDESHOW:
        slider.play = function () {
            if (slider.playing) clearInterval(slider.animatedSlides);
            slider.animatedSlides = slider.animatedSlides || setInterval(slider.animateSlides, slider.vars.slideshowSpeed);
            slider.started = slider.playing = true;
            // PAUSEPLAY:
            if (slider.vars.pausePlay) methods.pausePlay.update("pause");
            // SYNC:
            if (slider.syncExists) methods.sync("play");
        }
        // STOP:
        slider.stop = function () {
            slider.pause();
            slider.stopped = true;
        }
        slider.canAdvance = function (target, fromNav) {
            // ASNAV:
            var last = (asNav) ? slider.pagingCount - 1 : slider.last;
            return (fromNav) ? true :
                (asNav && slider.currentItem === slider.count - 1 && target === 0 && slider.direction === "prev") ? true :
                    (asNav && slider.currentItem === 0 && target === slider.pagingCount - 1 && slider.direction !== "next") ? false :
                        (target === slider.currentSlide && !asNav) ? false :
                            (slider.vars.animationLoop) ? true :
                                (slider.atEnd && slider.currentSlide === 0 && target === last && slider.direction !== "next") ? false :
                                    (slider.atEnd && slider.currentSlide === last && target === 0 && slider.direction === "next") ? false :
                                        true;
        }
        slider.getTarget = function (dir) {
            slider.direction = dir;
            if (dir === "next") {
                return (slider.currentSlide === slider.last) ? 0 : slider.currentSlide + 1;
            } else {
                return (slider.currentSlide === 0) ? slider.last : slider.currentSlide - 1;
            }
        }

        // SLIDE:
        slider.setProps = function (pos, special, dur) {
            var target = (function () {
                var posCheck = (pos) ? pos : ((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo,
                    posCalc = (function () {
                        if (carousel) {
                            return (special === "setTouch") ? pos :
                                (reverse && slider.animatingTo === slider.last) ? 0 :
                                    (reverse) ? slider.limit - (((slider.itemW + slider.vars.itemMargin) * slider.move) * slider.animatingTo) :
                                        (slider.animatingTo === slider.last) ? slider.limit : posCheck;
                        } else {
                            switch (special) {
                                case "setTotal":
                                    return (reverse) ? ((slider.count - 1) - slider.currentSlide + slider.cloneOffset) * pos : (slider.currentSlide + slider.cloneOffset) * pos;
                                case "setTouch":
                                    return (reverse) ? pos : pos;
                                case "jumpEnd":
                                    return (reverse) ? pos : slider.count * pos;
                                case "jumpStart":
                                    return (reverse) ? slider.count * pos : pos;
                                default:
                                    return pos;
                            }
                        }
                    }());

                return (posCalc * -1) + "px";
            }());

            if (slider.transitions) {
                target = (vertical) ? "translate3d(0," + target + ",0)" : "translate3d(" + target + ",0,0)";
                dur = (dur !== undefined) ? (dur / 1000) + "s" : "0s";
                slider.container.css("-" + slider.pfx + "-transition-duration", dur);
            }

            slider.args[slider.prop] = target;
            if (slider.transitions || dur === undefined) slider.container.css(slider.args);
        }

        slider.setup = function (type) {
            // SLIDE:
            if (!fade) {
                var sliderOffset, arr;

                if (type === "init") {
                    slider.viewport = $('<div class="' + namespace + 'viewport"></div>').css({"overflow": "hidden", "position": "relative"}).appendTo(slider).append(slider.container);
                    // INFINITE LOOP:
                    slider.cloneCount = 0;
                    slider.cloneOffset = 0;
                    // REVERSE:
                    if (reverse) {
                        arr = $.makeArray(slider.slides).reverse();
                        slider.slides = $(arr);
                        slider.container.empty().append(slider.slides);
                    }
                }
                // INFINITE LOOP && !CAROUSEL:
                if (slider.vars.animationLoop && !carousel) {
                    slider.cloneCount = 2;
                    slider.cloneOffset = 1;
                    // clear out old clones
                    if (type !== "init") slider.container.find('.clone').remove();
                    slider.container.append(slider.slides.first().clone().addClass('clone').attr('aria-hidden', 'true')).prepend(slider.slides.last().clone().addClass('clone').attr('aria-hidden', 'true'));
                }
                slider.newSlides = $(slider.vars.selector, slider);

                sliderOffset = (reverse) ? slider.count - 1 - slider.currentSlide + slider.cloneOffset : slider.currentSlide + slider.cloneOffset;
                // VERTICAL:
                if (vertical && !carousel) {
                    slider.container.height((slider.count + slider.cloneCount) * 200 + "%").css("position", "absolute").width("100%");
                    setTimeout(function () {
                        slider.newSlides.css({"display": "block"});
                        slider.doMath();
                        slider.viewport.height(slider.h);
                        slider.setProps(sliderOffset * slider.h, "init");
                    }, (type === "init") ? 100 : 0);
                } else {
                    slider.container.width((slider.count + slider.cloneCount) * 200 + "%");
                    slider.setProps(sliderOffset * slider.computedW, "init");
                    setTimeout(function () {
                        slider.doMath();
                        slider.newSlides.css({"width": slider.computedW, "float": "left", "display": "block"});
                        // SMOOTH HEIGHT:
                        if (slider.vars.smoothHeight) methods.smoothHeight();
                    }, (type === "init") ? 100 : 0);
                }
            } else { // FADE:
                slider.slides.css({"width": "100%", "float": "left", "marginRight": "-100%", "position": "relative"});
                if (type === "init") {
                    if (!touch) {
                        //slider.slides.eq(slider.currentSlide).fadeIn(slider.vars.animationSpeed, slider.vars.easing);
                        slider.slides.css({ "opacity": 0, "display": "block", "zIndex": 1 }).eq(slider.currentSlide).css({"zIndex": 2}).animate({"opacity": 1}, slider.vars.animationSpeed, slider.vars.easing);
                    } else {
                        slider.slides.css({ "opacity": 0, "display": "block", "webkitTransition": "opacity " + slider.vars.animationSpeed / 1000 + "s ease", "zIndex": 1 }).eq(slider.currentSlide).css({ "opacity": 1, "zIndex": 2});
                    }
                }
                // SMOOTH HEIGHT:
                if (slider.vars.smoothHeight) methods.smoothHeight();
            }
            // !CAROUSEL:
            // CANDIDATE: active slide
            if (!carousel) slider.slides.removeClass(namespace + "active-slide").eq(slider.currentSlide).addClass(namespace + "active-slide");
        }


        slider.doMath = function () {
            var slide = slider.slides.first(),
                slideMargin = slider.vars.itemMargin,
                minItems = slider.vars.minItems,
                maxItems = slider.vars.maxItems;

            slider.w = (slider.viewport === undefined) ? slider.width() : slider.viewport.width();
            slider.h = slide.height();
            slider.boxPadding = slide.outerWidth() - slide.width();

            // CAROUSEL:
            if (carousel) {
                slider.itemT = slider.vars.itemWidth + slideMargin;
                slider.minW = (minItems) ? minItems * slider.itemT : slider.w;
                slider.maxW = (maxItems) ? (maxItems * slider.itemT) - slideMargin : slider.w;
                slider.itemW = (slider.minW > slider.w) ? (slider.w - (slideMargin * (minItems - 1))) / minItems :
                    (slider.maxW < slider.w) ? (slider.w - (slideMargin * (maxItems - 1))) / maxItems :
                        (slider.vars.itemWidth > slider.w) ? slider.w : slider.vars.itemWidth;

                slider.visible = Math.floor(slider.w / (slider.itemW));
                slider.move = (slider.vars.move > 0 && slider.vars.move < slider.visible ) ? slider.vars.move : slider.visible;
                slider.pagingCount = Math.ceil(((slider.count - slider.visible) / slider.move) + 1);
                slider.last = slider.pagingCount - 1;
                slider.limit = (slider.pagingCount === 1) ? 0 :
                    (slider.vars.itemWidth > slider.w) ? (slider.itemW * (slider.count - 1)) + (slideMargin * (slider.count - 1)) : ((slider.itemW + slideMargin) * slider.count) - slider.w - slideMargin;
            } else {
                slider.itemW = slider.w;
                slider.pagingCount = slider.count;
                slider.last = slider.count - 1;
            }
            slider.computedW = slider.itemW - slider.boxPadding;
        }


        slider.update = function (pos, action) {
            slider.doMath();

            // update currentSlide and slider.animatingTo if necessary
            if (!carousel) {
                if (pos < slider.currentSlide) {
                    slider.currentSlide += 1;
                } else if (pos <= slider.currentSlide && pos !== 0) {
                    slider.currentSlide -= 1;
                }
                slider.animatingTo = slider.currentSlide;
            }

            // update controlNav
            if (slider.vars.controlNav && !slider.manualControls) {
                if ((action === "add" && !carousel) || slider.pagingCount > slider.controlNav.length) {
                    methods.controlNav.update("add");
                } else if ((action === "remove" && !carousel) || slider.pagingCount < slider.controlNav.length) {
                    if (carousel && slider.currentSlide > slider.last) {
                        slider.currentSlide -= 1;
                        slider.animatingTo -= 1;
                    }
                    methods.controlNav.update("remove", slider.last);
                }
            }
            // update directionNav
            if (slider.vars.directionNav) methods.directionNav.update();

        }

        slider.addSlide = function (obj, pos) {
            var $obj = $(obj);

            slider.count += 1;
            slider.last = slider.count - 1;

            // append new slide
            if (vertical && reverse) {
                (pos !== undefined) ? slider.slides.eq(slider.count - pos).after($obj) : slider.container.prepend($obj);
            } else {
                (pos !== undefined) ? slider.slides.eq(pos).before($obj) : slider.container.append($obj);
            }

            // update currentSlide, animatingTo, controlNav, and directionNav
            slider.update(pos, "add");

            // update slider.slides
            slider.slides = $(slider.vars.selector + ':not(.clone)', slider);
            // re-setup the slider to accomdate new slide
            slider.setup();

            //FlexSlider: added() Callback
            slider.vars.added(slider);
        }
        slider.removeSlide = function (obj) {
            var pos = (isNaN(obj)) ? slider.slides.index($(obj)) : obj;

            // update count
            slider.count -= 1;
            slider.last = slider.count - 1;

            // remove slide
            if (isNaN(obj)) {
                $(obj, slider.slides).remove();
            } else {
                (vertical && reverse) ? slider.slides.eq(slider.last).remove() : slider.slides.eq(obj).remove();
            }

            // update currentSlide, animatingTo, controlNav, and directionNav
            slider.doMath();
            slider.update(pos, "remove");

            // update slider.slides
            slider.slides = $(slider.vars.selector + ':not(.clone)', slider);
            // re-setup the slider to accomdate new slide
            slider.setup();

            // FlexSlider: removed() Callback
            slider.vars.removed(slider);
        }

        //FlexSlider: Initialize
        methods.init();
    }

    // Ensure the slider isn't focussed if the window loses focus.
    $(window).blur(function (e) {
        focused = false;
    }).focus(function (e) {
        focused = true;
    });

    //FlexSlider: Default Settings
    $.flexslider.defaults = {
        namespace: "flex-",             //{NEW} String: Prefix string attached to the class of every element generated by the plugin
        selector: ".slides > li",       //{NEW} Selector: Must match a simple pattern. '{container} > {slide}' -- Ignore pattern at your own peril
        animation: "fade",              //String: Select your animation type, "fade" or "slide"
        easing: "swing",                //{NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported!
        direction: "horizontal",        //String: Select the sliding direction, "horizontal" or "vertical"
        reverse: false,                 //{NEW} Boolean: Reverse the animation direction
        animationLoop: true,            //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
        smoothHeight: false,            //{NEW} Boolean: Allow height of the slider to animate smoothly in horizontal mode
        startAt: 0,                     //Integer: The slide that the slider should start on. Array notation (0 = first slide)
        slideshow: true,                //Boolean: Animate slider automatically
        slideshowSpeed: 7000,           //Integer: Set the speed of the slideshow cycling, in milliseconds
        animationSpeed: 600,            //Integer: Set the speed of animations, in milliseconds
        initDelay: 0,                   //{NEW} Integer: Set an initialization delay, in milliseconds
        randomize: false,               //Boolean: Randomize slide order
        thumbCaptions: false,           //Boolean: Whether or not to put captions on thumbnails when using the "thumbnails" controlNav.

        // Usability features
        pauseOnAction: true,            //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
        pauseOnHover: false,            //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
        pauseInvisible: true,   		//{NEW} Boolean: Pause the slideshow when tab is invisible, resume when visible. Provides better UX, lower CPU usage.
        useCSS: true,                   //{NEW} Boolean: Slider will use CSS3 transitions if available
        touch: true,                    //{NEW} Boolean: Allow touch swipe navigation of the slider on touch-enabled devices
        video: false,                   //{NEW} Boolean: If using video in the slider, will prevent CSS3 3D Transforms to avoid graphical glitches

        // Primary Controls
        controlNav: true,               //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
        directionNav: true,             //Boolean: Create navigation for previous/next navigation? (true/false)
        prevText: "Previous",           //String: Set the text for the "previous" directionNav item
        nextText: "Next",               //String: Set the text for the "next" directionNav item

        // Secondary Navigation
        keyboard: true,                 //Boolean: Allow slider navigating via keyboard left/right keys
        multipleKeyboard: false,        //{NEW} Boolean: Allow keyboard navigation to affect multiple sliders. Default behavior cuts out keyboard navigation with more than one slider present.
        mousewheel: false,              //{UPDATED} Boolean: Requires jquery.mousewheel.js (https://github.com/brandonaaron/jquery-mousewheel) - Allows slider navigating via mousewheel
        pausePlay: false,               //Boolean: Create pause/play dynamic element
        pauseText: "Pause",             //String: Set the text for the "pause" pausePlay item
        playText: "Play",               //String: Set the text for the "play" pausePlay item

        // Special properties
        controlsContainer: "",          //{UPDATED} jQuery Object/Selector: Declare which container the navigation elements should be appended too. Default container is the FlexSlider element. Example use would be $(".flexslider-container"). Property is ignored if given element is not found.
        manualControls: "",             //{UPDATED} jQuery Object/Selector: Declare custom control navigation. Examples would be $(".flex-control-nav li") or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
        sync: "",                       //{NEW} Selector: Mirror the actions performed on this slider with another slider. Use with care.
        asNavFor: "",                   //{NEW} Selector: Internal property exposed for turning the slider into a thumbnail navigation for another slider

        // Carousel Options
        itemWidth: 0,                   //{NEW} Integer: Box-model width of individual carousel items, including horizontal borders and padding.
        itemMargin: 0,                  //{NEW} Integer: Margin between carousel items.
        minItems: 1,                    //{NEW} Integer: Minimum number of carousel items that should be visible. Items will resize fluidly when below this.
        maxItems: 0,                    //{NEW} Integer: Maxmimum number of carousel items that should be visible. Items will resize fluidly when above this limit.
        move: 0,                        //{NEW} Integer: Number of carousel items that should move on animation. If 0, slider will move all visible items.
        allowOneSlide: true,           //{NEW} Boolean: Whether or not to allow a slider comprised of a single slide

        // Callback API
        start: function () {
        },            //Callback: function(slider) - Fires when the slider loads the first slide
        before: function () {
        },           //Callback: function(slider) - Fires asynchronously with each slider animation
        after: function () {
        },            //Callback: function(slider) - Fires after each slider animation completes
        end: function () {
        },              //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
        added: function () {
        },            //{NEW} Callback: function(slider) - Fires after a slide is added
        removed: function () {
        }           //{NEW} Callback: function(slider) - Fires after a slide is removed
    }


    //FlexSlider: Plugin Function
    $.fn.flexslider = function (options) {
        if (options === undefined) options = {};

        if (typeof options === "object") {
            return this.each(function () {
                var $this = $(this),
                    selector = (options.selector) ? options.selector : ".slides > li",
                    $slides = $this.find(selector);

                if (( $slides.length === 1 && options.allowOneSlide === true ) || $slides.length === 0) {
                    $slides.fadeIn(400);
                    if (options.start) options.start($this);
                } else if ($this.data('flexslider') === undefined) {
                    new $.flexslider(this, options);
                }
            });
        } else {
            // Helper strings to quickly perform functions on the slider
            var $slider = $(this).data('flexslider');
            switch (options) {
                case "play":
                    $slider.play();
                    break;
                case "pause":
                    $slider.pause();
                    break;
                case "stop":
                    $slider.stop();
                    break;
                case "next":
                    $slider.flexAnimate($slider.getTarget("next"), true);
                    break;
                case "prev":
                case "previous":
                    $slider.flexAnimate($slider.getTarget("prev"), true);
                    break;
                default:
                    if (typeof options === "number") $slider.flexAnimate(options, true);
            }
        }
    }
})(jQuery);


/**
 * Bootstrap custom Javascript
 */


// Hide fields if private
$(document).ready(function () {
    $(document).on('change', 'textarea[name=sComment]', function () {
        $('.comment-textarea').val($(this).val());
    });

    $(document).on('change', 'select.auto_submit', function () {
        this.form.submit();
    });
    $(document).on('click', 'input.auto_submit:radio, a.auto_submit, input.auto_submit:checkbox',function () {
        this.form.submit();
    });
    $(document).on('blur', 'input.auto_submit:text', function () {
        this.form.submit();
    });

    if ($("#register_personal_customer_type").val() !== "private") {
        $('#register-business').addClass('in');
    }

    $(document).on('change', "#register_personal_customer_type", function () {
        if ($("#register_personal_customer_type").val() === "private") {
            $('#register-business').collapse("hide");
        }
        else {
            $('#register-business').collapse("show");
        }
    });

    if ($('#register_billing_shippingAddress').length > 0 && !$('#register_billing_shippingAddress').is(':checked')) {
        $('#shippingAddress').removeClass("in")
    }

});

$(function () {
    jQuery.migrateTrace = false;


    $(document).on('click', '*[data-podiv]', function () {
        var e = $(this);
        e.unbind('click');
        e.popover({ content: $(e.data('podiv')).html(), trigger: 'click', html: true, animation: false }).popover('show');
        $.compare.resetup();
    });
});

/**
 * Compare Plugin
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
(function ($) {

    //Extends jQuery's namespace
    $.compare = {};

    //Default options
    $.compare.options = {
        viewportAjax: '',
        compareContainer: '#compare_bigbox',
        compareOverlay: '#lbOverlay',
        resultsContainer: '#compareContainerResults',
        ajaxContainer: '#compareContainerAjax',
        compareHighlight: '#compareHighlight',
        highlightSpeed: 1750,
        highlightColor: '#dd4800',
        dataType: 'jsonp',
        requestType: 'post',
        animationSpeed: 400,
        topLink: '#top',
        maxCount: 6,
        compareCount: 0
    };

    //Sets user settings
    $.compare.setup = function (params) {
        if (params) {
            $.each(params, function (i, param) {
                $.compare.options[i] = param;
            });
        }

        if (compareMaxCount) {
            $.compare.options.maxCount = parseInt(compareMaxCount, 10);
        }
        if (compareCount) {
            $.compare.options.compareCount = parseInt(compareCount, 10);
        }

        //binding events
        $(document).on('click', '.compare_delete_all', function (event) {
            $.compare.deleteComparisons(this.href);
            event.preventDefault();
        });
        $(document).on('click', '.compare_add_article', function (event) {
            $.compare.addCompare(this.href);
            event.preventDefault();
        });
        $(document).on('click', '.compare_get_overlay', function (event) {
            $.compare.startComparison(this.href);
            event.preventDefault();
        });
        $(document).on('click', '.compare_delete_article', function (event) {
            $.compare.deleteCompare(this.href);
            event.preventDefault();
        });
    };

    //Sets user settings
    $.compare.resetup = function (params) {
        if (params) {
            $.each(params, function (i, param) {
                $.compare.options[i] = param;
            });
        }

        if (compareMaxCount) {
            $.compare.options.maxCount = parseInt(compareMaxCount, 10);
        }
        if (compareCount) {
            $.compare.options.compareCount = parseInt(compareCount, 10);
        }

        //binding events
        $('.compare_delete_all').on('click', function (event) {
            $.compare.deleteComparisons(this.href);
            event.preventDefault();
        });
        $('.compare_get_overlay').on('click', function (event) {
            $.compare.startComparison(this.href);
            event.preventDefault();
        });
        $('.compare_delete_article').on('click', function (event) {
            $.compare.deleteCompare(this.href);
            event.preventDefault();
        });
    };

    //Displays the compare container
    $.compare.showCompare = function () {
//        $($.compare.options.compareHighlight).addClass('active');
//        $($.compare.options.resultsContainer).show();
    };

    //Hides the compare container
    $.compare.hideCompare = function () {
//        $($.compare.options.compareHighlight).removeClass('active');
//        $($.compare.options.resultsContainer).hide();
    };

    //Hides the compare window
    $.compare.hideCompareList = function () {
        $($.compare.options.compareContainer).animate({
            'top': -($($.compare.options.compareContainer).height() + 100) + 'px'
        });
        $($.compare.options.compareOverlay).fadeOut();
    };

    //Requests the compare informations
    $.compare.startComparison = function (url) {
        $.ajax({
            'dataType': $.compare.options.dataType,
            'type': $.compare.options.requestType,
            'url': url,
            'success': function (result) {
                $('#myModal').html(result);
                $('#myModal').modal();
            }
        });
    };

    //Adds an article with it's article id
    //to the current compare list
    $.compare.addCompare = function (url) {
        $.ajax({
            'dataType': $.compare.options.dataType,
            'type': $.compare.options.requestType,
            'url': url,
            'success': function (result) {
                if (result.indexOf('class="modal-close"') !== -1) {
                    $('#myModal').html(result);
                    $('#myModal').modal();
                    return;
                }

                $($.compare.options.ajaxContainer).html(result);
                $('*[data-podiv]').on('click', function () {
                    var e = $(this);
                    e.unbind('click');
                    e.popover({ content: $(e.data('podiv')).html(), trigger: 'click', html: true, animation: false }).popover('show');
                    $.compare.resetup();
                });
                window.location = $.compare.options.topLink;
            }
        });
    };

    //Deletes an article with it's article id
    //from the current compare list
    $.compare.deleteCompare = function (url) {
        $.ajax({
            'dataType': $.compare.options.dataType,
            'type': $.compare.options.requestType,
            'url': url,
            'beforeSend': function () {
//                $.compare.options.compareCount = $.compare.options.compareCount - 1;
//                compareCount = $.compare.options.compareCount - 1;
            },
            'success': function (result) {
                $($.compare.options.ajaxContainer).html(result);
                $(document).on('click', '*[data-podiv]', function () {
                    var e = $(this);
                    e.unbind('click');
                    e.popover({ content: $(e.data('podiv')).html(), trigger: 'click', html: true, animation: false }).popover('show');
                    $.compare.resetup();
                });
            }
        });
    };

    //Deletes the current compare list
    $.compare.deleteComparisons = function (url) {
        $.ajax({
            'dataType': $.compare.options.dataType,
            'type': $.compare.options.requestType,
            'url': url,
            'crossDomain': true,
            'beforeSend': function () {
                $.compare.options.compareCount = 0;
                compareCount = $.compare.options.compareCount;
            },
            'success': function () {
                $($.compare.options.ajaxContainer).empty();
                $(document).on('click', '*[data-podiv]', function () {
                    var e = $(this);
                    e.unbind('click');
                    e.popover({ content: $(e.data('podiv')).html(), trigger: 'click', html: true, animation: false }).popover('show');
                    $.compare.resetup();
                });
            }
        });
    };
})(jQuery);


/*
 Funktion öffnet aus dem Select heraus Links, so wie sie im Backend einstellbar sind.
 */
function openlocation(link, linktarget) {
    if (linktarget == "_self" || linktarget == "" || linktarget == "_top" || linktarget == "_parent") {
        location.href = link;
    }
    else {
        // Target unterscheidet sich und daher in neuem Fenster öffnen
        window.open(link);
    }
}

jQuery.fn.quickEach = function (f) {//compact
    var t = $([0]), i = -1, l = this.length, e;
    while (
        ++i < l
            && (e = t[0] = this[i])
            && f.call(t, i, e) !== false
        );
    return this;
};


function fast_shrink() {
    $('.adjustHeightSingle[data-height="1"]').quickEach(function () {
        me = this;
        (me).find('.item-wrapper,.image-wrapper,.title-wrapper,.desc-wrapper,.pseudo-wrapper,.price-wrapper,.unit-wrapper,.button-wrapper').quickEach(function () {
            v = this;
            (v).height("auto");
        });
    });

    $('.adjustHeight[data-height="1"]').quickEach(function () {
        me = this;
        $('.adjustHeight[data-height="1"]' + '[data-group="' + (me).data("group") + '"]').quickEach(function () {
            me2 = this;
            (me2).find('.item-wrapper,.image-wrapper,.title-wrapper,.desc-wrapper,.pseudo-wrapper,.price-wrapper,.unit-wrapper,.button-wrapper').quickEach(function () {
                v = this;
                (v).height("auto");
            });
        });
    });
}


function fast_thumbnailHeight() {
    $('.adjustHeight[data-height="1"]').quickEach(function () {
        gvalue = this;
        var itemHeight = 0;
        var imgHeight = 0;
        var titleHeight = 0;
        var descHeight = 0;
        var pseudoHeight = 0;
        var priceHeight = 0;
        var unitHeight = 0;
        var buttonHeight = 0;
        $('.adjustHeight[data-height="1"]' + '[data-group="' + (gvalue).data("group") + '"]').quickEach(function () {
            value = this;
            var image_wrapper = (value).find('.image-wrapper')
            image_wrapper.quickEach(function () {
                v = this;
                if (imgHeight < (v).height()) {
                    imgHeight = (v).height();
                }
            });
            image_wrapper.quickEach(function () {
                v = this;
                if (imgHeight != 0) {
                    (v).height(imgHeight);
                }
            });
            var title_wrapper = (value).find('.title-wrapper');
            title_wrapper.quickEach(function () {
                v = this;
                if (titleHeight < (v).height())
                    titleHeight = (v).height();
            });
            title_wrapper.quickEach(function () {
                v = this;
                if (titleHeight != 0)
                    (v).height(titleHeight);
            });
            var desc_wrapper = (value).find('.desc-wrapper');
            desc_wrapper.quickEach(function () {
                v = this;
                if (descHeight < (v).height())
                    descHeight = (v).height();
            });
            desc_wrapper.quickEach(function () {
                v = this;
                if (descHeight != 0)
                    (v).height(descHeight);
            });
            var pseudo_wrapper = (value).find('.pseudo-wrapper');
            pseudo_wrapper.quickEach(function () {
                v = this;
                if (pseudoHeight < (v).height())
                    pseudoHeight = (v).height();
            });
            pseudo_wrapper.quickEach(function () {
                v = this;
                if (pseudoHeight != 0)
                    (v).height(pseudoHeight);
            });
            var price_wrapper = (value).find('.price-wrapper');
            price_wrapper.quickEach(function () {
                v = this;
                if (priceHeight < (v).height())
                    priceHeight = (v).height();
            });
            price_wrapper.quickEach(function () {
                v = this;
                if (priceHeight != 0)
                    (v).height(priceHeight);
            });
            var unit_wrapper = (value).find('.unit-wrapper');
            unit_wrapper.quickEach(function () {
                v = this;
                if (unitHeight < (v).height())
                    unitHeight = (v).height();
            });
            unit_wrapper.quickEach(function () {
                v = this;
                if (unitHeight != 0)
                    (v).height(unitHeight);
            });
            var button_wrapper = (value).find('.button-wrapper');
            button_wrapper.quickEach(function () {
                v = this;
                if (buttonHeight < (v).height())
                    buttonHeight = (v).height();
            });
            button_wrapper.quickEach(function () {
                v = this;
                if (buttonHeight != 0)
                    (v).height(buttonHeight);
            });
            var item_wrapper = (value).find('.item-wrapper');
            item_wrapper.quickEach(function () {
                v = this;
                if (itemHeight < (v).height())
                    itemHeight = (v).height();
            });
            item_wrapper.quickEach(function () {
                v = this;
                if (itemHeight != 0)
                    (v).height(itemHeight);
            });
        });
    });
}

var s_itemHeight = 0;
var s_imgHeight = 0;
var s_titleHeight = 0;
var s_descHeight = 0;
var s_pseudoHeight = 0;
var s_priceHeight = 0;
var s_unitHeight = 0;
var s_buttonHeight = 0;


function fast_single_thumbnailHeight() {
    $('.adjustHeightSingle[data-height="1"]').quickEach(function () {
        value = this;
        var image_wrapper = (value).find('.image-wrapper');
        image_wrapper.quickEach(function () {
            v = this;
            if (s_imgHeight < (v).height())
                s_imgHeight = (v).height();
        });
        image_wrapper.quickEach(function () {
            v = this;
            if (s_imgHeight != 0)
                (v).height(s_imgHeight);
        });
        var title_wrapper = (value).find('.title-wrapper');
        title_wrapper.quickEach(function () {
            v = this;
            if (s_titleHeight < (v).height())
                s_titleHeight = (v).height();
        });
        title_wrapper.quickEach(function () {
            v = this;
            if (s_titleHeight != 0)
                (v).height(s_titleHeight);
        });
        var desc_wrapper = (value).find('.desc-wrapper');
        desc_wrapper.quickEach(function () {
            v = this;
            if (s_descHeight < (v).height())
                s_descHeight = (v).height();
        });
        desc_wrapper.quickEach(function () {
            v = this;
            if (s_descHeight != 0)
                (v).height(s_descHeight);
        });
        var pseudo_wrapper = (value).find('.pseudo-wrapper');
        pseudo_wrapper.quickEach(function () {
            v = this;
            if (s_pseudoHeight < (v).height())
                s_pseudoHeight = (v).height();
        });
        pseudo_wrapper.quickEach(function () {
            v = this;
            if (s_pseudoHeight != 0)
                (v).height(s_pseudoHeight);
        });
        var price_wrapper = (value).find('.price-wrapper');
        price_wrapper.quickEach(function () {
            v = this;
            if (s_priceHeight < (v).height())
                s_priceHeight = (v).height();
        });
        price_wrapper.quickEach(function () {
            v = this;
            if (s_priceHeight != 0)
                (v).height(s_priceHeight);
        });
        var unit_wrapper = (value).find('.unit-wrapper');
        unit_wrapper.quickEach(function () {
            v = this;
            if (s_unitHeight < (v).height())
                s_unitHeight = (v).height();
        });
        unit_wrapper.quickEach(function () {
            v = this;
            if (s_unitHeight != 0)
                (v).height(s_unitHeight);
        });
        var button_wrapper = (value).find('.button-wrapper');
        button_wrapper.quickEach(function () {
            v = this;
            if (s_buttonHeight < (v).height())
                s_buttonHeight = (v).height();
        });
        button_wrapper.quickEach(function () {
            v = this;
            if (s_buttonHeight != 0)
                (v).height(s_buttonHeight);
        });
        var item_wrapper = (value).find('.item-wrapper');
        item_wrapper.quickEach(function () {
            v = this;
            if (s_itemHeight < (v).height())
                s_itemHeight = (v).height();
        });
        item_wrapper.quickEach(function () {
            v = this;
            if (s_itemHeight != 0)
                (v).height(s_itemHeight);
        });
    });
}


function thumbnailHeight() {
    $('.adjustHeight[data-height="1"]').each(function (index, gvalue) {
        var itemHeight = 0;
        var imgHeight = 0;
        var titleHeight = 0;
        var descHeight = 0;
        var pseudoHeight = 0;
        var priceHeight = 0;
        var unitHeight = 0;
        var buttonHeight = 0;
        $('.adjustHeight[data-height="1"]' + '[data-group="' + $(gvalue).data("group") + '"]').each(function (index, value) {
            var image_wrapper = $(value).find('.image-wrapper')
            image_wrapper.each(function (i, v) {
                if (imgHeight < $(v).height()) {
                    imgHeight = $(v).height();
                }
            });
            image_wrapper.each(function (i, v) {
                if (imgHeight != 0) {
                    $(v).height(imgHeight);
                }
            });

            var title_wrapper = $(value).find('.title-wrapper');
            title_wrapper.each(function (i, v) {
                if (titleHeight < $(v).height())
                    titleHeight = $(v).height();
            });
            title_wrapper.each(function (i, v) {
                if (titleHeight != 0)
                    $(v).height(titleHeight);
            });
            var desc_wrapper = $(value).find('.desc-wrapper');
            desc_wrapper.each(function (i, v) {
                if (descHeight < $(v).height())
                    descHeight = $(v).height();
            });
            desc_wrapper.each(function (i, v) {
                if (descHeight != 0)
                    $(v).height(descHeight);
            });
            var pseudo_wrapper = $(value).find('.pseudo-wrapper');
            pseudo_wrapper.each(function (i, v) {
                if (pseudoHeight < $(v).height())
                    pseudoHeight = $(v).height();
            });
            pseudo_wrapper.each(function (i, v) {
                if (pseudoHeight != 0)
                    $(v).height(pseudoHeight);
            });
            var price_wrapper = $(value).find('.price-wrapper');
            price_wrapper.each(function (i, v) {
                if (priceHeight < $(v).height())
                    priceHeight = $(v).height();
            });
            price_wrapper.each(function (i, v) {
                if (priceHeight != 0)
                    $(v).height(priceHeight);
            });
            var unit_wrapper = $(value).find('.unit-wrapper');
            unit_wrapper.each(function (i, v) {
                if (unitHeight < $(v).height())
                    unitHeight = $(v).height();
            });
            unit_wrapper.each(function (i, v) {
                if (unitHeight != 0)
                    $(v).height(unitHeight);
            });
            var button_wrapper = $(value).find('.button-wrapper');
            button_wrapper.each(function (i, v) {
                if (buttonHeight < $(v).height())
                    buttonHeight = $(v).height();
            });
            button_wrapper.each(function (i, v) {
                if (buttonHeight != 0)
                    $(v).height(buttonHeight);
            });
            var item_wrapper = $(value).find('.item-wrapper');
            item_wrapper.each(function (i, v) {
                if (itemHeight < $(v).height())
                    itemHeight = $(v).height();
            });
            item_wrapper.each(function (i, v) {
                if (itemHeight != 0)
                    $(v).height(itemHeight);
            });
        });
    });
}

var s_itemHeight = 0;
var s_imgHeight = 0;
var s_titleHeight = 0;
var s_descHeight = 0;
var s_pseudoHeight = 0;
var s_priceHeight = 0;
var s_unitHeight = 0;
var s_buttonHeight = 0;


function single_thumbnailHeight() {
    $('.adjustHeightSingle[data-height="1"]').each(function (index, value) {
        var image_wrapper = $(value).find('.image-wrapper');
        image_wrapper.each(function (i, v) {
            if (s_imgHeight < $(v).height())
                s_imgHeight = $(v).height();
        });
        image_wrapper.each(function (i, v) {
            if (s_imgHeight != 0)
                $(v).height(s_imgHeight);
        });
        var title_wrapper = $(value).find('.title-wrapper');
        title_wrapper.each(function (i, v) {
            if (s_titleHeight < $(v).height())
                s_titleHeight = $(v).height();
        });
        title_wrapper.each(function (i, v) {
            if (s_titleHeight != 0)
                $(v).height(s_titleHeight);
        });
        var desc_wrapper = $(value).find('.desc-wrapper');
        desc_wrapper.each(function (i, v) {
            if (s_descHeight < $(v).height())
                s_descHeight = $(v).height();
        });
        desc_wrapper.each(function (i, v) {
            if (s_descHeight != 0)
                $(v).height(s_descHeight);
        });
        var pseudo_wrapper = $(value).find('.pseudo-wrapper');
        pseudo_wrapper.each(function (i, v) {
            if (s_pseudoHeight < $(v).height())
                s_pseudoHeight = $(v).height();
        });
        pseudo_wrapper.each(function (i, v) {
            if (s_pseudoHeight != 0)
                $(v).height(s_pseudoHeight);
        });
        var price_wrapper = $(value).find('.price-wrapper');
        price_wrapper.each(function (i, v) {
            if (s_priceHeight < $(v).height())
                s_priceHeight = $(v).height();
        });
        price_wrapper.each(function (i, v) {
            if (s_priceHeight != 0)
                $(v).height(s_priceHeight);
        });
        var unit_wrapper = $(value).find('.unit-wrapper');
        unit_wrapper.each(function (i, v) {
            if (s_unitHeight < $(v).height())
                s_unitHeight = $(v).height();
        });
        unit_wrapper.each(function (i, v) {
            if (s_unitHeight != 0)
                $(v).height(s_unitHeight);
        });
        var button_wrapper = $(value).find('.button-wrapper');
        button_wrapper.each(function (i, v) {
            if (s_buttonHeight < $(v).height())
                s_buttonHeight = $(v).height();
        });
        button_wrapper.each(function (i, v) {
            if (s_buttonHeight != 0)
                $(v).height(s_buttonHeight);
        });
        var item_wrapper = $(value).find('.item-wrapper');
        item_wrapper.each(function (i, v) {
            if (s_itemHeight < $(v).height())
                s_itemHeight = $(v).height();
        });
        item_wrapper.each(function (i, v) {
            if (s_itemHeight != 0)
                $(v).height(s_itemHeight);
        });
    });
}


/* Aus Kompatibilitätsgründen zu anderen Module hier noch render erlauben */
var isLoaded = "n";
function render() {
    if (isLoaded == "y") {
        autosize();
    }
}

function autosize() {
    fast_shrink()
    fast_thumbnailHeight();
    fast_single_thumbnailHeight();
}


$(document).ready(function () {
    $("select.auto").change(function () {
        if ($(this).val() != 'skipSubmit')
            $(this).closest('form').submit();
    });


    $('#ajaxSearchInput').autocomplete({
        'minLength': 2,
        'source': function () {
        }
    });

    $(document).on("autocompletesearch", '#ajaxSearchInput', function (event, ui) {
        if (event.key == "Down" || event.key == "Up") return;
        var url = jQuery.controller.ajax_search;
        var safeurl = url.replace("http:", "");
        safeurl = safeurl.replace("https:", "");
        $.ajax({
            url: safeurl,
            type: "GET",
            data: {callback: 'openAjaxSearchResults', sSearch: $('#ajaxSearchInput').val()},
            dataType: "script"
        });
    });
});

function openAjaxSearchResults(html) {
    html = $(html);
    title = html.find('.popover-title').html();
    html.find('.popover-title').remove();
    content = html.find('.content').html();

    $('.appendAjaxSearchResults').popover('destroy');

    $('.appendAjaxSearchResults').popover({
        html: true,
        placement: 'bottom',
        title: title,
        content: content
    });

    $('.appendAjaxSearchResults').popover('show');


    function moveHorizont(direction) {
        newsel = (selectedAjax);

        if (direction == 'select') {
            if (typeof $('#ajaxresult' + newsel).attr('href') !== 'undefined') {
                location.href = $('#ajaxresult' + newsel).attr('href');
            }
        }

        $('#ajaxresult' + selectedAjax).removeClass('active');
        if (direction == 'down') {
            newsel = (selectedAjax + 1);
        }
        if (direction == 'up') {
            newsel = (selectedAjax - 1);
            if (newsel < 1) {
                newsel = 1;
            }
        }

        selectedAjax = newsel;
        $('#ajaxresult' + newsel).addClass('active');
    }

    var selectedAjax;
    $(window).keydown(function (e) {
        if ($(document).find('.popover-title').is(":visible")) {
            if ($('.popover-content').find('a.active').length < 1) {
                $('#ajaxresult1').addClass('active');
                selectedAjax = 1;
            } else {
                switch (e.which) {
                    case 38: // up
                        moveHorizont('up');
                        break;
                    case 40: // down
                        moveHorizont('down');
                        break;
                    case 13: // enter
                        e.preventDefault();
                        moveHorizont('select');
                        break;
                    case 27: // esc
                        e.preventDefault();
                        $('.appendAjaxSearchResults').popover('hide');
                        break;

                    default:
                        return; // exit this handler for other keys
                }
                e.preventDefault();
            }
        }
    });

}

function ajaxAddArticle(e) {
    var url = jQuery.controller.checkout;
    var safeurl = url.replace("http:", "");
    safeurl = safeurl.replace("https:", "");

    $.ajax({url: safeurl + "/addArticle", type: "GET", data: {callback: "openAddArticleModal", earning_points_per_unit: $(e).data("earning_points_per_unit"), buy_for: $('input[name=buy_for]:checked').val(), points_per_unit: $(e).data("points_per_unit"), sActionIdentifier: $(e).data("sactionoidentifier"), sAdd: $(e).data("sadd"), sAddAccessories: $(e).data("saddaccessories"), sQuantity: $("#sQuantity").val()}, dataType: "script"})
}


function carty(what) {
    var e = $(what);
    e.unbind("click");
    var t = $("#carty").html();

    $("#carty").html(e.data("poloadingtext"));

    var url = e.data("poload");
    var safeurl = url.replace("http:", "");
    safeurl = safeurl.replace("https:", "");

    $.get(safeurl, function (n) {
        $("#carty").html(t);
        e.popover({content: n, trigger: "click", html: !0, placement: "bottom", content: getcarty}).popover("show").addClass("popover-left");
    });
}

function getcarty() {
    var t = $("#carty").html();
    var weite = $("#carty").outerWidth(true);
    $("#carty").css("width", weite + 'px');
    $("#carty").html($('#carty').data("poloadingtext"));
    $("#carty").css("width", weite + 'px');
    $("#carty").addClass('ajax-cart-fix');

    var url = jQuery.controller.ajax_cart;
    var safeurl = url.replace("http:", "");
    safeurl = safeurl.replace("https:", "");

    var content = $.ajax({
        url: safeurl + '/ajax_cart',
        type: "GET",
        dataType: "html",
        async: false,
        success: function () {
            // just get the response
        },
        error: function () {
            // nothing
        }
    }).responseText;

    $("#carty").css("width", 'auto');
    $("#carty").removeClass('ajax-cart-fix');
    $("#carty").html(t);

    return content;
}

var cartyoldstyle = "0";
$(function () {
//    $("*[data-poload]").bind("click", function() {
////        carty(this);
//        $(this).popover({content: n, trigger: "click", html: !0, placement: "bottom", content : getcarty}).popover("show").addClass("popover-left")
//    });

    $(document).popover({
        selector: '#carty',
        placement: 'bottom',
        content: getcarty,
        html: true,
        trigger: 'click'
    });
    $(document).on('shown.bs.popover', '#carty', function(){
        $('.popover').css({right: '1px', left: 'auto'});
    });

    $(document).on('shown.bs.popover', '#carty', function () {
        if (cartyoldstyle != "0") {

            $('.popover').removeAttr("style");
            $('.popover').attr("style", cartyoldstyle);
        }
        $('.popover').addClass("popover-left");
    });

    $(document).on('hidden.bs.popover', '#carty', function () {
        cartyoldstyle = ($('.popover').attr("style"));
        $('.popover').remove();
    });
});


function openAddArticleModal(html) {
    $('#myModal').html(html);
    $('#myModal').modal();
    $(document).on('shown.bs.modal', '#myModal', function () {
        $('#ajaxCrossSellerCarousel').flexslider({
            animation: "slide",
            animationLoop: true,
            slideshow: false,
            pauseOnHover: true,
            controlNav: false,
            itemWidth: 200,
            minItems: 1,
            maxItems: 4,
            start: function () {
                render();
            }
        });
    });
    $(document).on('hidden.bs.modal', '#myModal', function () {
        // Beim Schließen des Add-Basket nach oben scrollen und die Seite neu laden, damit der WK-Button oben richtig angezeigt wird.
        $("html, body").animate({ scrollTop: 0 }, "fast");
        window.location.href = window.location.href;
    });
}

$(function () {
    $(document).on('click', '.modal_image', function (e) {
        e.preventDefault();

        var url = $(this).attr('href');
        var title = $(this).data('title');
        var $modal = $('#myModal');
        var $window = $(window);

        $modal.html('<div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title">' + title + '</h4></div><div class="modal-body"><a href="" data-dismiss="modal"><img src="' + url + '" class="img-responsive img-center"></a></div></div></div>');

        var $image = $('.modal-dialog img');
        var imageWidth = $image[0].naturalWidth;
        var imageHeight = $image[0].naturalHeight;

        var width = $window.width() * 0.88;
        var height = $window.height() * 0.88;
        var imageRatio = (imageWidth / imageHeight);

        if(imageRatio < 1) {
            newHeight = height;
            percentage = ((newHeight * 100) / imageHeight) / 100;
            newWidth = (imageWidth * percentage);

            if(newWidth > width) {
                newWidth = width;
                percentage = ((newWidth * 100) / imageWidth) / 100;
                newHeight = (imageHeight * percentage);
            }

            $modal.find('.modal-dialog').width(newWidth).height(newHeight);
        } else {
            newWidth = width;
            percentage = ((newWidth * 100) / imageWidth) / 100;
            newHeight = (imageHeight * percentage);

            if(newHeight > height) {
                newHeight = height;
                percentage = ((newHeight * 100) / imageHeight) / 100;
                newWidth = (imageWidth * percentage);
            }

            $modal.find('.modal-dialog').width(newWidth).height(newHeight);
        }

        $modal = $('#myModal');
        $modal.modal();
    });
});

$(function () {
    $(document).on("click", '.showtabcomments', function () {
        return $('#tabcomments').tab('show');
    });

    $(document).on("click", "*[data-location]", function () {
        url = $(this).data("location");
        location.href = url;
    });

    $(document).on("click", "*[data-sAdd]", function () {
        ajaxAddArticle(this);
        return false;
    });

    $(document).on("click", '.change-currency', function () {
        $('#currency_shop').val($(this).data("currency"));
        $('#currency').submit();
        return false;
    });

    $(document).on("click", '.change-language', function () {
        $('#language_shop').val($(this).data("language"));
        $('#language').submit();
        return false;
    });

    $(document).on("click", ".modal_open a, a.modal_open, *[data-modal-height]", function (e) {
        e.preventDefault();
        var orig_href = $(this).attr("href");
        var t = orig_href;
        if ($(this).data("href") != "" && typeof $(this).data("href") !== 'undefined') t = $(this).data("href");

        if (location.protocol === 'https:') {
            t = t.replace('http:', 'https:');
        }
        else {
            t = t.replace('https:', 'http:');
        }

        if (!t.indexOf("#") == 0) {
            $.ajax(t, {
                type: "GET",
                cache: false,
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
                },
                success: function (e, status, xhr) {
                    if (e.length > 80) {
                        $("#myModal").html('<div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title">' + $(e).find(".modal-helper-title").html() + '</h4></div><div class="modal-body">' + $(e).find(".modal-helper-body").html() + '</div></div></div>');
                        $("#myModal").modal();
                        $(document).on("shown.bs.modal", "#myModal", function () {
                            $("#ajaxCrossSellerCarousel").flexslider({animation: "slide", animationLoop: !1, itemWidth: 118, minItems: 3, maxItems: 4, start: function () {
                                render()
                            }});
                        });
                    }
                    else {
                        window.location.href = orig_href;
                    }
                },

                xhrFields: {
                    withCredentials: true
                },
                crossDomain: true
            });
        }
    });
});

$.fn.tabs = function () {
}
$.fn.ajaxSlider = function () {
}


;
(function ($) {
    $.fn.equalize = function (options) {
        var $containers = this, // this is the jQuery object
            children = true,
            reset = false,
            equalize,
            type;

        // when options are an object
        if ($.isPlainObject(options)) {
            equalize = options.equalize || 'height';
            children = options.children || false;
            reset = options.reset || false;
        } else { // otherwise, a string was passed in or default to height
            equalize = options || 'height';
        }

        if (!$.isFunction($.fn[equalize])) {
            return false;
        }
        // determine if the height or width is being equalized
        type = (equalize.indexOf('eight') > 0) ? 'height' : 'width';

        return $containers.each(function () {
            // when children exist, equalize the passed in child elements, otherwise equalize the children
            var $children = (children) ? $(this).find(children) : $(this).children(),
                max = 0; // reset for each container

            $children.each(function () {
                var $element = $(this),
                    value;
                if (reset) {
                    $element.css(type, '');
                } // remove existing height/width dimension
                value = $element[equalize](); // call height(), outerHeight(), etc.
                if (value > max) {
                    max = value;
                } // update max
            });

            $children.css(type, max + 'px'); // add CSS to children
        });
    };

}(jQuery));


$(window).load(function () {
    $(document).on('shown.bs.tab', 'a[data-toggle="tab"]', function (e) {
        render();
    });
//    render();

    /* Scroll Up Button */
    $(window).scroll(function () {
        if ($(this).scrollTop() > 100) {
            $('.scroll-up').fadeIn();
        } else {
            $('.scroll-up').fadeOut();
        }
    });

    $('.scroll-up').click(function () {
        $("html, body").animate({ scrollTop: 0 }, 600);
        return false;
    });

    $(document).on('click', '.navbar a.dropdown-toggle', function (e) {
        if ($(e.currentTarget).parent().hasClass("open")) {
            href = $(e.currentTarget).parent().find('a:first-of-type').attr("href");
            if (href != "" && typeof href !== 'undefined') {
                e.stopPropagation();
                location.href = href;
            }
        }
    });

    // Resize-Funktion, so dass der Browser nicht zu sehr belastet wird. Nur alle 100 ms
    function resizedw() {
        autosize();
    }

    var doit;
    $(window).resize(function () {
        clearTimeout(doit);
        doit = setTimeout(resizedw, 250);
    });

    $('img[usemap]').rwdImageMaps();

    $(window).trigger('resize');

    // Flexslider-Init
//    setTimeout(function () {
//        $(window).trigger('resize');
//        isLoaded = "y";
//    }, 600);
    setTimeout(function () {
        $(window).trigger('resize');
        setTimeout(function () {
            isLoaded = "y";
        }, 300);
    }, 1600);
});


(function ($) {
//Check if the article are set up for
//email notification and checks if
//a notification was sent
    $.checkNotification = function (ordernumber) {
        if (typeof (variantOrdernumberArray) === 'undefined') {
            return;
        }
        var isSet = false;
        try {
            for (var i = 0; i < variantOrdernumberArray.length; ++i) {
                if (variantOrdernumberArray[i] === ordernumber) {
                    isSet = true;
                    try {
                        $('#articleNotificationWasSend').show();
                    } catch (e) {
                    }
                    try {
                        $('#sendArticleNotification').hide();
                    } catch (e) {
                    }
                }
            }
        } catch (err) {
        }
    };

//Changes the displayed informations on the
//article detail site and changes the active
//images which is used by variant articles
    $.changeDetails = function (ordernumber) {
        if (ordernumber) {
            ordernumber = ordernumber.replace(/\./g, '\\.');
        }
        if (typeof ($.checkNotification) === 'function') {
            if (!ordernumber) {
                $.checkNotification($.ordernumber);
            } else {
                $.checkNotification(ordernumber);
            }
        }
        try {
            if (!ordernumber || $('#instock_' + ordernumber).val() > 0) {
                $('#article_notification').hide();
                $('#detailCartButton').show();
                $('#detailBuyInfoNotAvailable').hide();
            } else {
                $('#article_notification').show();
                var hideBasket = $('#notifyHideBasket').val();
                hideBasket = ~~hideBasket;

                if (hideBasket) {
                    $('#detailCartButton').hide();
                }
                if ($('#detailBuyInfoNotAvailable').length) {
                    $('#detailCartButton').hide();
                    $('#detailBuyInfoNotAvailable').show();
                }
            }
        } catch (e) {
        }

        if (!ordernumber) {
            // Hide Pseudoprice
            $('.PseudoPrice').hide();

            // Hide all other thumbnails
            if (isVariant) {
                var thumbs = $('.thumb_box').children('a:[id]');
                thumbs.each(function (i, el) {
                    if ($(el).attr('id') !== 'thumb' + $.ordernumber) {
                        $(el).hide();
                    }
                });
            }
            // Hide delivery info
            $('.delivery_container').hide();
            // Hide basket
            $('#basketButton').css('opacity', '0.4');
        } else {

            // Show Pseudo price
            $('#' + ordernumber).find('.PseudoPrice').show();

            // Show delivery info
            $('.delivery_container').show();

            // Change informations
            $('#article_details').html($('#' + ordernumber).html());

            //Set basket button to active
            $('#basketButton').css('opacity', '1.0');

            // Change main image
            $('a#zoom1 img').attr('src', $('#img' + ordernumber).find('img').attr('src'));

            if (ordernumber !== $.ordernumber) {

                // ZoomViewer active...
                var useZoom = parseInt(useZoom, 10);
                if (useZoom) {
                    var img_link = $('a#zoom1 img');

                    // Refresh src attribute
                    if (img_link.attr('src')) {
                        $('a#zoom1 img').attr('src', $('#img' + ordernumber).find('img').attr('src'));
                    }
                    // Refresh img title
                    if (img_link.attr('title')) {
                        img_link.attr('title', $('#img' + ordernumber).children('a').attr('title'));
                    }

                    // If image found and the neccessary attributes are set
                    // fire the click event to change the image over the
                    // CloudZoom plugin
                    if (img_link.attr('src') && img_link.attr('title')) {
                        $('#img' + ordernumber).find('a').trigger('click');
                    }
                } else {
                    // Change lightbox link
                    $('a#zoom1').attr('href', $('#img' + ordernumber).children('a').attr('href'));
                }

                // Change active thumbnail image
                $('#thumb' + $.ordernumber).hide();
                $('#thumb' + ordernumber).show();


                // Set the new ordernumber in the global scope
                $.ordernumber = ordernumber;
                try {
                    $('#variantOrdernumber').val(ordernumber);
                } catch (err) {

                }
            }
        }
        // Try to active liveshopping
        try {
            $('#article_details').liveshopping();
        } catch (err) {
        }
    };
})(jQuery);



A B C D E F G H I J K L M N O P Q R S T U V W X Y Z