/**
 * jQuery Plugins for Shopware 3.5 Storefront
 * http://shopware.de
 *
 *
 * DISCLAIMER
 *
 * Do not edit this file if you wish to upgrade
 * Shopware to newer versions in the future. If
 * you wish to customize Shopware for your needs
 * please refer to http://www.shopware.de/wiki
 * for more informations.
 *
 * @package        default
 * @subpackage    javascript
 * @category    design
 * version        v1.8
 * @author        stp/shopware AG <info@shopware.de>
 * @copyright    Copyright (c) 2010 Shopware AG (http://www.shopware.de)
 *
 * CHANGELOG
 * Version 1.8
 * - added ajax slider component
 * - loading indicator plugin
 *
 * Version 1.7
 * - added OnePage checkout
 * - liveshopping plugin
 * - check notifcation
 * - bundle plugin
 * - refactoring livesearch
 *
 * Version 1.6
 * - added modal window plugin
 * - added ajax basket plugin
 * - onepage checkout
 * - compressed plugins
 *
 * Version 1.5
 * - inital release
 * - changing listing view
 * - replace fancybox with an enhanced version of slimbox
 * - replace jqzoom with an enhanced version of cloudzoom
 * - completely rewritten topseller accordion
 * - added slideable properties filters
 * - serveral improvements
 * - added jquery ui and jquery tabs
 *
 * Version 1.4
 * - bugfix release
 * - added cross-browser support
 *
 * Version 1.3
 * - added utilities, fancybox and jqzoom
 * - fixes serval bugs in the compare plugin
 *
 * Version 1.2
 * - added search and compare
 *
 * Version 1.1
 * - bugfix release
 *
 * Version 1.0
 * - inital release
 */
 
/**
 * Plugin Starter
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
/**
 * Setting up all plugins and 
 * adding new functionality
 * to the shopware Storefront
 */
jQuery(document).ready(function($) {
        
        /*if ($.browser.webkit) {
            //alert("this is webkit!"); //Safari, Chrome, Mac Safari
            $('#mainNavigation a.top').css({
                'font-size'         : '1.3em',
                //'font-size'         : '14px',
                'padding-left'      : '13px',
                'padding-right'     : '13px',
                'font-family'       : 'Arial,"Helvetica Neue",Helvetica,sans-serif,serif'
            });
            $('#mainNavigation li.sub a.sub').css({
                'font-size'         : '11px',
                'font-family'       : 'Arial,"Helvetica Neue",Helvetica,sans-serif,serif',
                'max-width'         : '150px',
                'min-width'         : '120px',
                'z-index'           : '10000'
            });
            $('#content h2.topseller_home').css({
                'font-size'         : '14px !important',
                'font-family'       : 'Arial,"Helvetica Neue",Helvetica,sans-serif,serif',
                'font-weight'       : 'bold !important'
            });
            $('#content #left .viewlast .heading').css({
                'font-size'         : '14px',
                'font-family'       : 'Arial,"Helvetica Neue",Helvetica,sans-serif,serif',
                'font-weight'       : 'bold'
            });
            $('#content #left .newsletter_left .heading').css({
                'font-size'         : '14px',
                'font-family'       : 'Arial,"Helvetica Neue",Helvetica,sans-serif,serif',
                'font-weight'       : 'bold'
            });
            $('#content #left .vorteile .heading').css({
                'font-size'         : '14px',
                'font-family'       : 'Arial,"Helvetica Neue",Helvetica,sans-serif,serif',
                'font-weight'       : 'bold'
            });
            $('#right.register_vorteile .heading').css({
                'font-size'         : '14px',
                'font-family'       : 'Arial,"Helvetica Neue",Helvetica,sans-serif,serif',
                'font-weight'       : 'bold'
            });
            
            
        } 
        if ($.browser.msie) {
            //alert("ich bin ein IE!");
            $('#mainNavigation a.top').css({
                'font-size' : '1.5em',
                'padding' : '0 12.2px'
            });
            $('#mainNavigation li.sub a.sub').css({
                'font-size'         : '11px',
                'font-family'       : 'Arial',
                'max-width'         : '150px',
                'min-width'         : '120px',
                'z-index'           : '10000',
                'letter-spacing'    : 'normal'
            });
                        
        }
        if ($.browser.msie && parseInt($.browser.version) == 7){                                       
            
        } 
        if ($.browser.mozilla) {
            //alert("ich bin ein Mozilla!");
            $('#mainNavigation li.sub a.sub').css({
                'font-family'       : 'Arial',
                'max-width'         : '150px',
                'min-width'         : '120px',
                'z-index'           : '10000',
                'letter-spacing'    : 'normal'
            });            
        }*/
    
        // checkboxes, radiobuttons
        $(function(){
                
            $('input[type=checkbox]').checkBox();
            $('input[type=radio]').checkBox();
            
            $('#toggle-all').click(function(){
                $('#example input[type=checkbox]').checkBox('toggle');
                return false;
            });
            
            $('#check-all').click(function(){
                $('#example input[type=checkbox]').checkBox('changeCheckStatus', true);
                return false;
            });
            $('#uncheck-all').click(function(){
                $('#example input[type=checkbox]').checkBox('changeCheckStatus', false);
                return false;
            });
            $('#check-2').click(function(){
                $('#example input[type=radio]:eq(1)').checkBox('changeCheckStatus', true);
                return false;
            });
            $('#native').click(function(){
                //native methods
                $('#example input[type=radio]:eq(0)').attr({checked: true, disabled: true})
                    //reflect the current state
                    .checkBox('reflectUI');
                return false;
             });
        }); 
        // outline input
        $("#basketButton").focus(function(){this.blur();});
        
        // Tooltip xp24
        $("#artattr .tipp").tooltip({ position: "top right", opacity: 1});        
        
        // Removes hiding class for all script related elements
        $('.hide_script').removeClass('hide_script');
        
        //IE 6 Drop down menu fallback
        if($.browser.msie && parseInt($.browser.version) == 6) {
            $('#mainNavigation li').hover(function(){ $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); });
        }
        
        //Liveshopping 
        $('.liveshopping_container:visible, .liveshopping_detail:visible').liveshopping();
        
        //Bundle
        $('.bundle_container, .relatedbox_container').bundle();
            
        //Checkout
        $('a.checkout, a.login, a.account').checkout({'viewport': $.controller.ajax_login,'register':$.controller.register,'checkout':$.controller.checkout});
                 
        //Supplier filter
        $('.supplier_filter .slideContainer').supplierfilter();
        
        // Cat Text
        $('.slideText').catTextSlide();
        
        //AJAX Warenkorb
        $.basket.options.viewport = $.controller.ajax_cart;$.basket.init();
        
        $('select.auto_submit').bind('change', function() {this.form.submit(); });
        $('input.auto_submit:radio, a.auto_submit, input.auto_submit:checkbox').live('click', function() { this.form.submit(); });
        $('input.auto_submit:text').live('blur', function() { this.form.submit(); });
        
        $('.modal_close').live('click', function() { $.modalClose(); $.ie6fix.selectShow(); });
        
        $('.modal_open a').click(function(event) {
            event.preventDefault();
            $.post(this.href, function(data) {
                $.modal(data, '', {'position':'fixed'}).find('.close').remove();            
            });
        });
        
        //Striping der Tabellen
        $.stripe('zebra');
        
        //Topseller
        if($('.topseller')) $('.accordion').kwicks({min: 52,sticky: true,spacing: 0,isVertical: true,duration: 350});
        
        //Suche
        $('#searchfield').liveSearch({url:$.controller.ajax_search, 'id': 'searchresults', 'searchPosition': 'right'});
        $('#searchfield').focus(function(){
            if ($('#searchfield').val() == "Suche:"){
                $('#searchfield').val("");
            }
            
        });
        //Serverzeit fuer Liveshopping
        $.server.init(timeNow);
        
        //Wechsel bei Variantenartikeln
        if(typeof(isVariant) != 'undefined' && isVariant == true) {
            $.changeDetails(0);
        }    
        
        $('#sAdd.variant').change(function() {
            $.changeDetails($(this).val())
        });$
        
        //Lightbox Warenkorb
        $('a.zoom_picture[rel^=lightbox]').slimbox();
        
        //Ajax basket
        $('div.ajax_basket').click(function() {
            if($('.ajax_basket_result').hasClass('active')) {
                $('.ajax_basket_result').removeClass('active').slideToggle('fast');
            } else {
                $.basket.getBasket();
            }
        });
        
        //Article detail accessory
        var lasthover;
        $('.basketform label').hover(function() {
            var $this = $(this);
            
            var value = $this.prev('input').val();
            
            if(value.length) {
                $('div#DIV'+value).fadeIn('fast');
                lasthover = $('div#DIV'+value);
            }
            
        }, function() {
            lasthover.fadeOut('fast');
            lasthover = '';
        });
        
        //Article detail accessory
        $('.accessory_group input').bind('change', function() {
            var $this = $(this);
            $accessories = $('#sAddAccessories');
            $accessories.val('');
            if($this.is(':checked')) {
                
                $('.accessory_group input:checked').each(function(i, el) {
                    var val = $accessories.val();
                    val += $(el).val() + ';';
                    $accessories.val(val);
                });
            }
        });
                        
        //Lightbox - Blog
        $('.blogbox [rel^=lightbox]').slimbox();
        
        //Lightbox statt ZoomViewer
        if(typeof(useZoom) != 'undefined' && useZoom == '0') {
            $("[rel^='lightbox']").slimbox();
            $('div.thumb_box a').bind('click', function(event) {
                event.preventDefault();
                $('a#zoom1').hide().attr('href', $(this).attr('href')).children().attr('src', $(this).attr('rev'));
                $('a#zoom1').fadeIn('slow');
                return false;
            });
        }
        
        //Change Password Account
        if(!$('.account .error').length) {
            $('.account .password').hide();
            $('.account .email').hide();
        }
        $('.account .change_password').bind('click', function(event) {
            event.preventDefault();
            $('.account .password').slideToggle('fast');
        });
        
        //Change Email Account
        $('.account .change_mail').bind('click', function(event) {
            event.preventDefault();
            $('.account .email').slideToggle('fast');
        });
        
        //Logout Account
        $('.logout').bind('click', function(event) {
            event.preventDefault();
            $.post($.controller.ajax_logout, function(data) {
                var position = 'fixed'
                if($.browser.msie && parseInt($.browser.version) == 6) {position = 'absolute';}
                $.modal(data, '', {'position':position}).find('.close').remove();            
            });
        });
        
        //User account page orders
        $('.orderoverview_active .orderdetails').bind('click', function(e) {
            e.preventDefault();
            if($('#'+$(this).attr('rel')).hasClass('active')) {
                $('#'+$(this).attr('rel')).removeClass('active').hide();
            } else {
                $('#'+$(this).attr('rel')).addClass('active').show();
            }
        });    
            //Register Validation
            $('.register .required:input').validate();
            
            if($("#register_personal_customer_type").val()=="private") {
                $('.register .company_informations').hide();
            }
            
            if($("#register_personal_skipLogin").is(':checked')) {
                $('.register .fade_password, .register p.description, #birthdate').hide();
            }
            
            $("#register_personal_customer_type").change(function() {
                if($(this).val() == 'buisness') {
                    $('.register .company_informations').slideDown();
                } else {
                    $('.register .company_informations').slideUp();
                }
            });
            
            if(!$("#register_billing_shippingAddress").is(':checked')) {
                if(!$('.register').hasClass('change_shipping')) {
                    $('.register .alternative_shipping').hide();
                }
            }
            
            $('#register_billing_shippingAddress').click(function() {
                if(!$(this).is(':checked')) {
                    $('.register .alternative_shipping').slideUp();
                } else {
                    $('.register .alternative_shipping').slideDown();
                }
            });
            
            $('#register_personal_skipLogin').click(function() {
                if($(this).is(':checked')) {
                    $('.register .fade_password, .register p.description, #birthdate').slideUp();
                } else {
                    $('.register .fade_password, .register p.description, #birthdate').slideDown();
                }
            });
        
        // Loading Indicator
        $('form.upprice_config').bind('change', function() {
            $.loadingIndicator.open();
        });
        

});

/**
 * AJAX Slider
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
(function($) {
        
    /**
     * $.fn.ajaxSlider
     *
     * Creates an slider
     *
     * Just call the plugin with the following syntax:
     * $('selector').ajaxSlider('[mode]', { [your_settings] });
     *
     * The called file must have the following structure
     * <div class="slide">
     *     ... [your elements] ...
     * </div>
     *
     * If you're calling this plugin in ajax mode, please
     * consider that this plugin has two kinds of ajax mode.
     *
     * You're getting in the first mode if you're setting
     * the mode to 'ajax' and 'navigation': true. This mode get's
     * all data at the page load and scrolls through the slides.
     * The second modes would be called when you set the mode to
     * 'ajax' and 'navigation': false.  
     *
     * @param:  (string) mode  - mode to use
     * @param:  (obj) settings - user settings
     * @return: (obj) this     - selector which was passed to the plugin
     */
    $.fn.ajaxSlider = function(mode, settings) {
        
        // default plugin config
        var config = {
            
            // Public
            'layout':           'horizontal',
            'width':            763,
            'height':           220,
            'scrollWidth':      711,
            'scrollHeight':     711,
            'scrollSpeed':      400,
            'containerClass':   'ajaxSlider',
            'containerCSS':     {},
            'ajaxMethod':       'POST',
            'loadingText':      'Loading...',
            'loadingContainer': 'loader',
            'title':            '',
            'titleClass':       'headingbox',
            'outer':            true,
            'headline':         false,
            'url':              '',
            'rotate':           false,
            'rotateSpeed':      5000,
            'navigation':       true,
            'navigationClass':  'slide_navigation',
            'showNumbers':      true,
            'numberText':       'Seite %0 von %1',
            'debug':            false,
            
            // Private
            '_this':                 null,
            '_container':            null,
            '_slideContainer':       null,
            '_slideOuterContainer':  null,
            '_slideContainerWidth':  null,
            '_slideContainerHeight': null,
            '_headline':             null,
            '_loader':               null,
            '_leftArrow':            null,
            '_rightArrow':           null,
            '_slidesCount':          null,
            '_slideNavigation':      null,
            '_activeNavigation':     null,
            '_activeSlide':          null,
            '_rotateInterval':       null,
            '_numbers':              null,
            '_mode':                 null
        };
        
        // Override default config with user settings
        if (settings) $.extend(config, settings);
        
        this.each(function() {
            
            if(config.debug == true) {
                console.group('Slider: .' + $(this).attr('class'));
            }
            
            $.ajaxSlider.debugMode('Mode: ' + mode, config);
            
            config._this = $(this);
            config._this.css('width',config.width+'px');
            
            $.ajaxSlider.debugMode('Create Container', config);
            
            // Create slider outer container and replace selector
            config._container = $('<div>', {
                'class': config.containerClass,
                'css':{
                    'width': config.width+'px',
                    'height': config.height+'px',
                    'position': 'relative'
                }
            }).appendTo(config._this);
            
            $.ajaxSlider.debugMode('Container created', config);
            
            // Save slider mode
            config._mode = mode
            
            // Sets additional css styles
            if(!$.isEmptyObject(config.containerCSS)) {
                $.ajaxSlider.debugMode('Set additional styles', config);
                config._container.css(config.containerCSS);
            }
            
            // Add layout class
            config._this.addClass(config.layout+'_slider');
            
            if(config.title != '' && config.headline) {
                $.ajaxSlider.debugMode('Create headline', config);
                // Create headline
                config._headline = $('<h2>', {
                    'class': config.titleClass,
                    'text': config.title
                }).prependTo(config._container);
            }
            
            $.ajaxSlider.debugMode('Create left arrow', config);
            
            // Left arrow
            config._leftArrow = $('<a>', {
                'class': 'leftArrow',
                'text': 'Slide left',
                'title': 'Slide left',
                'href': '#slideLeft'
                }).appendTo(config._container).hide();
            
            $.ajaxSlider.debugMode('Create right arrow', config);
            
            // Right arrow
            config._rightArrow = $('<a>', {
                'class': 'rightArrow',
                'text': 'Slide right',
                'title': 'Slide right',
                'href': '#slideRight'
            }).appendTo(config._container).hide();
            
            
            $.ajaxSlider.debugMode('Select mode', config);
            
            // Mode selection
            switch(mode) {
                case 'ajax':
                    $.ajaxSlider.ajaxMode(config);
                    break;
                case 'locale':
                    $.ajaxSlider.localeMode(config);
                    break;
                default:
                    $.ajaxSlider.debugMode('The passed mode is not supported', config);
                    return false;
            }
            
            if(config.rotate == true) {
                $.ajaxSlider.debugMode('Create rotation', config);
                $.ajaxSlider.rotateSlider(config);
            }
        });
        
        if(config.debug == true) {
            console.groupEnd();
        }
        
        // Return this to support jQuery's chaining
        return this;
    }
        
    $.ajaxSlider = {
        
        /**
         * $.ajaxSlider.createContainers
         *
         * Creates the needed container for the slider
         *
         * @param:  (obj) config - the plugin config
         */
        createContainers: function(config) {
            // Create sliding outer container
            config._slideOuterContainer = $('<div>', {
                'class': 'sliding_outer',
                'css': {
                    'position': 'relative',
                    'overflow': 'hidden'
                }
            }).appendTo(config._container);
            
            // Create actual sliding container
            config._slideContainer = $('<div>', {
                'class': 'sliding_container'
            }).prependTo(config._slideOuterContainer).hide()
        },
        
        /**
         * $.ajaxSlider.getPage
         *
         * Requests the given url
         * and handles all ajax related
         * stuff
         *
         * @param:  (string) slideNumber - Number of the slide to load
         * @param:  (obj) config - the plugin config
         */
        getPage: function(slideNumber, config) {
            $.ajax({
                'url': config.url,
                'method': config.ajaxMethod,
                'data': {'pages': slideNumber},
                'beforeSend': function() {
                    if(config._loader == null) {
                    
                        // Create AJAX Loader
                        config._loader = $('<div>', {
                            'text': config.loadingText,
                            'class': config.loadingContainer
                        }).appendTo(config._container);
                    } else {
                        config._loader.show();
                    }
                    
                    // Find old slide and remove it
                    config._slideContainer.fadeOut().find('.slide').remove();
                },
                'error': function() {
                    // Fadeout loader and hide container on error
                    config._loader.fadeOut('slow');
                    config._container.hide();
                },
                'success': function(result) {
                    if(!result.length) {
                        // If the result is empty, hide container
                        config._loader.fadeOut('slow');
                        config._container.hide();
                        return false;
                    } else {
                        
                        // Calculate where the content should be insert
                        if(slideNumber > config._activeSlide) {
                            $(result).appendTo(config._slideContainer);
                        } else if(slideNumber < config._activeSlide) {
                            $(result).prependTo(config._slideContainer);
                        } else if(slideNumber == config._activeSlide) {
                            config._slideContainer.html(result);
                        }
                        
                        // Remove pages tag
                        var pages = config._slideContainer.find('.pages');
                        config._slidesCount = pages.text();
                        pages.remove();
                        
                        //Handling arrows
                        if(slideNumber == 1) {
                            config._leftArrow.hide();
                            config._rightArrow.show();
                        } else if(slideNumber == config._slidesCount) {
                            config._leftArrow.show();
                            config._rightArrow.hide();
                        } else {
                            config._leftArrow.show();
                            config._rightArrow.show();
                        }
                        
                        if(parseInt(config._slidesCount) == 1) {
                            config._leftArrow.hide();
                            config._rightArrow.hide();
                        }
                        
                        if(parseInt(config._slidesCount) == 0) {
                            config._container.hide();
                            return;
                        }
                        
                        // horizontal slider
                        if(config.layout == 'horizontal') {
                            var height;
                            if(!config.headline) {
                                height = config.height;
                            } else {
                                height = config.height - config._headline.outerHeight();
                            }
                            if(config.outer) {
                                // Position the outer container
                                config._slideOuterContainer.css({
                                    'left': config._leftArrow.width()+'px',
                                    'width': config.width - (config._leftArrow.width() * 2)+'px',
                                    'height': height
                                });
                            } else {
                                // Position the outer container
                                config._slideOuterContainer.css({
                                    'left': 0,
                                    'width': config.width,
                                    'height': height
                                });
                            }
                        // vertical slider
                        } else {
                            
                            if(config.outer) {
                                // Setting offset
                                config._slideOuterContainer.css({
                                    'top': config._leftArrow.outerHeight()+'px',
                                    'height': config.height - config._headline.outerHeight() - (config._rightArrow.outerHeight() * 2)+'px'
                                });
                            } else {
                                config._slideOuterContainer.css({
                                    'left': 0,
                                    'top': config._leftArrow.outerHeight()+'px',
                                    'height': config.height - config._headline.outerHeight()+'px'
                                });
                            }

                        }
                        
                        // Adding numbers
                        if(config.showNumbers == true) {
                            if(config._numbers == null) { 
                                config._numbers = $('<div>', {
                                    'class': 'slide_numbers'
                                }).insertAfter(config._headline);
                            }
                            
                            var text = $.format(config.numberText, slideNumber, config._slidesCount);
                            config._numbers.empty().html(text);
                        }
                        
                        
                        config._activeSlide = slideNumber;
                        
                        config._loader.fadeOut('fast');
                        config._slideContainer.fadeIn('slow');
                        
                        
                        return true;
                    }
                }
            })
        },
        
        /**
         * $.ajaxSlider.ajaxMode
         *
         * Requests the given url
         * and creates the needed container
         *
         * @param:  (obj) config - the plugin config
         */
        ajaxMode: function(config) {
            
            if(config.navigation == false) {
                $.ajaxSlider.createContainers(config);
                config._activeSlide = 1;
                $.ajaxSlider.getPage(config._activeSlide, config);
                
                config._rightArrow.bind('click', function(event) {
                    event.preventDefault();
                    $.ajaxSlider.getPage(config._activeSlide + 1, config);
                    
                    
                });
                config._leftArrow.bind('click', function(event) {
                    event.preventDefault();
                    $.ajaxSlider.getPage(config._activeSlide - 1, config);
                    
                });

                
            } else { 
                
                // Load content with ajax
                if(config.url.length) {
                    $.ajax({
                        'url': config.url,
                        'method': config.ajaxMethod,
                        'beforeSend': function() {
                        
                            // Create AJAX Loader
                            config._loader = $('<div>', {
                                'text': config.loadingText,
                                'class': config.loadingContainer
                            }).appendTo(config._container);
                        },
                        'error': function() {
                            // Fadeout loader and hide container on error
                            config._loader.fadeOut('slow');
                            config._container.hide();
                        },
                        'success': function(result) {
                            
                            // If the result is empty, hide container
                            if(!result.length) {
                                config._loader.fadeOut('slow');
                                config._container.hide();
                                return;
                            }
                            
                            // Hide AJAX loader
                            window.setTimeout(function() {
                                config._loader.fadeOut('slow');
                                config._loader = null;
                                
                                
                                // Create the needed containers
                                $.ajaxSlider.createContainers(config);
                                
                                //Fill the container and fade it in
                                config._slideContainer.html(result).fadeIn();
                                
                                $.ajaxSlider.sliderNavigation(config);
                                
                                // Configure the slider for both types
                                if(config.layout == 'horizontal') {
                                    $.ajaxSlider.horizontalSlider(config);
                                } else {
                                    $.ajaxSlider.verticalSlider(config);
                                }
                                
                            }, 800);        
                        }
                    });
                } else {
                    // Hide container if no url is passed
                    config._container.hide();
                }
            }
        },
        
        /**
         * $.ajaxSlider.localeMode
         *
         * Gets the given slides, creates the needed
         * container and places the slides in it
         * 
         * @param:  (obj) config - the plugin config
         */
        localeMode: function(config) {
            
            // Getting inline slides
            var slides = $(config._this).find('.slide');
            
            // Create sliding outer container
            config._slideOuterContainer = $('<div>', {
                'class': 'sliding_outer',
                'css': {
                    'position': 'relative',
                    'overflow': 'hidden'
                }
            }).appendTo(config._container);
            
            // Create actual sliding container
            config._slideContainer = $('<div>', {
                'class': 'sliding_container',
                'html': slides
            }).prependTo(config._slideOuterContainer).hide().fadeIn();
            
            // Configure the slider for both types
            if(config.layout == 'horizontal') {
                $.ajaxSlider.horizontalSlider(config);
            } else {
                $.ajaxSlider.verticalSlider(config);
            }
            
            // Create slider navigation
            if(config.navigation == true) {
                $.ajaxSlider.sliderNavigation(config);
            }

        },
        
        /**
         * $.ajaxSlider.horizontalSlider
         *
         * Styles and creates all neeeded
         * components for a horizontal slider
         *
         * @param:  (obj) config - the plugin config
         */
        horizontalSlider: function(config) {
            var height;
            if(!config.headline) {
                height = config.height;
            } else {
                height = config.height - config._headline.outerHeight();
            }
            
            if(config.outer) {
                // Position the outer container
                config._slideOuterContainer.css({
                    'left': config._leftArrow.width()+'px',
                    'width': config.width - (config._leftArrow.width() * 2)+'px',
                    'height': height
                });
            } else {
                // Position the outer container
                config._slideOuterContainer.css({
                    'left': 0,
                    'width': config.width,
                    'height': height
                });
            }
            
            if(config.navigation == true || config.navigation == false && config._mode == 'locale') {
                
                // Setting the width of the slide container
                var slides = config._slideContainer.find('.slide');
                config._slideContainerWidth = 0;
                
                $.each(slides,function(i, el) { config._slideContainerWidth += $(el).width();});
                config._slideContainer.width(config._slideContainerWidth)
                
                // Getting the number of slides
                config._slidesCount = slides.length;
                
                // Show right arrow
                if(config._slidesCount > 1) {
                    config._rightArrow.show();
                }
                
                // Right arrow
                config._rightArrow.bind('click', function(event) {
                    $.ajaxSlider.rightArrow(event, config);
                });
                
                // Left arrow
                config._leftArrow.bind('click', function(event) {
                    $.ajaxSlider.leftArrow(event, config);
                });
            }
        },
        
        /**
         * $.ajaxSlider.verticalSlider
         *
         * Styles and creates all neeeded
         * components for a vertical slider
         *
         * @param:  (obj) config - the plugin config
         */
        verticalSlider: function(config) {
        
            // Position arrows
            config._leftArrow.css({
                'top': config._headline.outerHeight()
            });
            config._rightArrow.css({
                'top': config.height-config._rightArrow.outerHeight()
            });
            
            if(config.outer) {
                // Setting offset
                config._slideOuterContainer.css({
                    'top': config._leftArrow.outerHeight()+'px',
                    'height': config.height - config._headline.outerHeight() - (config._rightArrow.outerHeight() * 2)+'px'
                });
            } else {
                config._slideOuterContainer.css({
                    'left': 0,
                    'top': config._leftArrow.outerHeight()+'px',
                    'height': config.height - config._headline.outerHeight()+'px'
                });
            }
            
            if(config.navigation == true) {
                // Setting containerHeight
                var slides = config._slideContainer.find('.slide');
                config._slideContainerHeight = 0;
                
                $.each(slides,function(i, el) {
                    config._slideContainerHeight += $(el).height();
                });
                config._slideContainer.height(config._slideContainerWidth);
                
                // Getting the number of slides
                config._slidesCount = slides.length;
                
                // Binding events
                config._activeSlide = 1;
                
                // Show bottom arrow
                if(config._slidesCount > 1) {
                    config._rightArrow.show();
                }
                
                // Right arrow
                config._rightArrow.bind('click', function(event) {
                    $.ajaxSlider.rightArrow(event, config);
                });
                
                // Left arrow
                config._leftArrow.bind('click', function(event) {
                    $.ajaxSlider.leftArrow(event, config);
                });
            } else {
            
            }
        },
        
        rightArrow: function(event, config) {
            event.preventDefault();
                    
            config._activeSlide++;
            clearInterval(config._rotateInterval);
            $.ajaxSlider.animateContainerTo(config._activeSlide, config);
        },
        
        leftArrow: function(event, config) {
            event.preventDefault();
            config._activeSlide--;
            window.clearInterval(config._rotateInterval);
            $.ajaxSlider.animateContainerTo(config._activeSlide, config);

        },
        
        /**
         * $.ajaxSlider.sliderNavigation
         *
         * Styles and creates all neeeded
         * components for a slider navigation
         *
         * @param:  (obj) config - the plugin config
         */
        sliderNavigation: function(config) {
            
            // Create an navigation controller and append it
            // to our main container
            config._slideNavigation = $('<div>', {
                'class': config.navigationClass
            }).prependTo(config._container);
            
            var i = 1;
            while(i <= config._slidesCount) {
                var a = $('<a>', {
                    'class': 'point',
                    'html': i,
                    'id': 'slideNavigation'+i,
                    'href': '#slide'+i
                }).appendTo(config._slideNavigation);
                i++;
            }
            
            // Set first link as active
            config._activeNavigation = config._slideNavigation.find('a:first').addClass('active');
            var links = config._slideNavigation.find('a');
            
            links.bind('click', function(event) {
                config._activeSlide = parseInt($(this).text());
                window.clearInterval(config._rotateInterval);
                $.ajaxSlider.animateContainerTo(config._activeSlide -1, config);
            })
            
        },
        
        /**
         * $.ajaxSlider.animateContainerTo
         *
         * This function handles the scrolling
         * of the sliding container
         *
         * @param:  (int) slideNumber - Number of the active slide
         * @param:  (obj) config - the plugin config
         */
        animateContainerTo: function(slideNumber, config) {
        
            //slideNumber = slideNumber -1;
            if(config.layout == 'horizontal') {
                
                if(config._slidesCount > 1) {
                    // Animate sliding container
                    config._leftArrow.unbind('click');
                    config._rightArrow.unbind('click');
                    config._slideContainer.animate({
                        'left': -(config.scrollWidth * slideNumber)
                    }, config.scrollSpeed, function() {
                        
                        // Handling arrows
                        if(config._slideContainer.position().left >= 0) {
                            config._leftArrow.hide();
                            config._rightArrow.show();
                        } else if(config._slideContainer.position().left <= -(config.scrollWidth * (config._slidesCount - 1))) {
                            config._leftArrow.show();
                            config._rightArrow.hide();
                        } else {
                            config._leftArrow.show();
                            config._rightArrow.show();
                        }
                        
                        config._leftArrow.bind('click', function(event) {
                            $.ajaxSlider.leftArrow(event, config);
                        });
                        config._rightArrow.bind('click', function(event) {
                            $.ajaxSlider.rightArrow(event, config);
                        });
                    });
                }
            } else {
                if(config._slidesCount > 1) {
                    config._slideContainer.animate({
                            'top': -(config.scrollWidth * slideNumber)
                        }, config.scrollSpeed, function() {
                        
                        if(config._slideContainer.position().top >= 0) {
                            config._leftArrow.hide();
                            config._rightArrow.show();
                        } else if(config._slideContainer.position().top <= -(config.scrollWidth * (config._slidesCount - 1))) {
                            config._leftArrow.show();
                            config._rightArrow.hide();
                        } else {
                            config._leftArrow.show();
                            config._rightArrow.show();
                        }
                    });
                }
            }
            
            // Set navigation point to active
            if(config.navigation == true) {
                
                // Set this navigation point as active
                config._activeNavigation.removeClass('active');
                config._activeNavigation = $('#slideNavigation'+ (slideNumber +1)).addClass('active');
            }
        },
                    
        /**
         * $.ajaxSlider.rotateSlider
         *
         * Rotates the slides automatically after
         * a given given period of time
         *
         * @param:  (obj) config - the plugin config
         */
        rotateSlider: function(config) {
            
            if(config._slidesCount > 1) {
                var i = 1;
                config._rotateInterval = window.setInterval(function() {
                    i++;
                    if(i > config._slidesCount) {
                        i = 1;
                    }
                    config._activeSlide = i;
                    $.ajaxSlider.animateContainerTo(i - 1, config);
                }, config.rotateSpeed);
            }
        },
        debugMode: function(text, config) {
            if(config.debug == true) {
                console.log(text);
            }
        }
    }
})(jQuery);

/**
 * Loading Indicator Plugin
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
(function($) {
    
    $.loadingIndicator = {
        
        config: {
            'overlay': '#lbOverlay',
            'overlayOpacity': 0.6,
            'hideOverlayAfterClose': false,
            'loadingClass': 'loadingIndicator',
            'loadingText': 'Loading...',
            'height': 64,
            'width': 64,
            'animationSpeed': 500,
            'additionalCSS': {},
            'bindEvent': false,
            '_loader': null
        },
        
        open: function(settings) {
            
            // settings
            if (settings) $.extend($.loadingIndicator.config, settings);
        
            // Create loader
            $.loadingIndicator.config._loader = $('<div>', {
                'class': $.loadingIndicator.config.loadingClass,
                'text': $.loadingIndicator.config.loadingText,
                'css': {
                    'position': 'fixed',
                    'top': '50%',
                    'left': '50%',
                    'marginTop':  -($.loadingIndicator.config.height/2) +'px',
                    'marginLeft': -($.loadingIndicator.config.width/2) + 'px',
                    'height': $.loadingIndicator.config.height,
                    'width': $.loadingIndicator.config.width,
                    'zIndex': 99999
                }
            }).hide().appendTo($(document.body));
            
            // Add additionalcss if passed
            if(!$.isEmptyObject($.loadingIndicator.config.additionalCSS)) {
                $.loadingIndicator.config._loader.css($.loadingIndicator.config.additionalCSS);
            }
            
            // Overlay handling
            if($.loadingIndicator.config.hideOverlayAfterClose == true) {
                $($.loadingIndicator.config.overlay).fadeTo($.loadingIndicator.config.animationSpeed, $.loadingIndicator.config.overlayOpacity);
            }
            if($.loadingIndicator.config.bindEvent == true) {
                $($.loadingIndicator.config.overlay).css({'cursor': 'pointer'}).bind('click', function() {
                    $.loadingIndicator.close();
                });
            } else {
                $($.loadingIndicator.config.overlay).css({'cursor': 'default'});
            }
            if($.browser.msie && parseInt($.browser.version) == 6) {
                $.ie6fix.open($.loadingIndicator.config._loader);
            } else {
                $.loadingIndicator.config._loader.fadeIn($.loadingIndicator.config.animationSpeed);
            }
            
        },
        
        close: function() {
            if($.loadingIndicator.config._loader) {
                $($.loadingIndicator.config.overlay).fadeOut($.loadingIndicator.config.animationSpeed);
                if($.browser.msie && parseInt($.browser.version) == 6) {
                    $.ie6fix.close($.loadingIndicator.config._loader);
                } else {
                    $.loadingIndicator.config._loader.animate({
                        'opacity': 0
                    }, $.loadingIndicator.config.animationSpeed, function() {
                        $.loadingIndicator.config._loader.remove();
                    });
                }
            }
        }
    };
    
})(jQuery);

/**
 * Simple Validation
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
(function($) {

    //Default settings
    var config = {
        errorClass: 'instyle_error',
        successClass: 'instyle_success'
    };

    $.fn.validate = function(settings) {
        
        if (settings) $.extend(config, settings);
        
        this.bind('blur', function(event) {
            validate($(this));
            return false;
        });
        
        return this;
    };
    
    validate = function(el) {
        switch(el.attr('id'))
        {
            case 'register_personal_skipLogin':
            case 'register_personal_email':
            case 'register_personal_emailConfirmation':
                var action = 'ajax_validate_email';
                break;
            case 'register_billing_ustid':
                var action = 'ajax_validate_billing';
                break;
            case 'register_personal_password':
            case 'register_personal_passwordConfirmation':
                var action = 'ajax_validate_password';
                break;
        }
        
        if(!el.val()) {
            setError(el);
            return;
        } else if (action) {
            ajaxValidate(el, action);
            return;
        } else {
            setSuccess(el);
            return;
        }
    }
    
    ajaxValidate = function(el, action) {
        var data = 'action='+action+'&'+$('.register form').serialize(); 
        $.ajax({
            'data': data,
            'type': 'post',
            'dataType': 'json',
            'url': $.controller.ajax_validate,
            'success': function (result, data) {
                if(result && result.error_flags) 
                {
                    for (var error_flag in result.error_flags)
                    {  
                        if(result.error_flags[error_flag])
                            setError($('.register .'+error_flag));
                        else
                            setSuccess($('.register .'+error_flag));
                    }
                }
                
                $('#'+action+'_error').remove();
                
                
                if(result && result.error_messages&& result.error_messages.length)
                {                                        
                    var error_css = {
                        'top': el.offset().top-5,
                        'left': el.offset().left+el.outerWidth()+15,
                        'position': 'absolute',
                        'z-index': 100
                    };
                    
                    var error_el = $('<div>').attr('id', action+'_error').addClass('error').prependTo($('body')).css(error_css);
                    
                    for (var error_key in result.error_messages)
                    {
                        var error_message = result.error_messages[error_key];
                        
                        error_el.append(error_message+'<br />');
                    }
                }
            }
        });
    }
    
    //Sets error class
    setError = function(el) {
        if(!$.isEmptyObject(el)) {
            $.each($(el), function(i, e){
                $(e).removeClass(config.successClass).addClass(config.errorClass);
            });
        } else {
            $(el).removeClass(config.successClass).addClass(config.errorClass);
        }
        return el;
    }
    
    //Sets success class
    setSuccess = function(el) {
        if(!$.isEmptyObject(el)) {
            $.each($(el), function(i, e){
                $(e).removeClass(config.errorClass).addClass(config.successClass);
            });
        } else {
            $(el).removeClass(config.errorClass).addClass(config.successClass);
        }
        return el;
    }

})(jQuery);

/**
 * Liveshopping Plugin
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
(function($) {
    
    $.fn.liveshopping = function() {
        
        // getting liveshopping info
        this.each(function() {
            
            // setting target time
            var target = new Date();
            target.setTime($(this).find('input.valid_to_ts').val() * 1000);
            
            // collection article details
            var article = {
                'article': $(this),
                'ordernumber': $(this).find('input.ordernumber').val(),
                'target': target,
                'uniquekey': $(this).find('input.uniquekey').val(),
                'max_quantity_enable': $(this).find('input.max_quantity_enable').val(),
                'max_quantity': $(this).find('input.max_quantity').val(),
                'sells': $(this).find('input.sells').val(),
                'typeID': parseInt($(this).find('input.typeID').val()),
                'price': eval($(this).find('input.price').val()),
                'minPrice': eval($(this).find('input.minPrice').val())
                //'stints': $(this).find('input.stints').val().split(';')
            };
            
            // calling init function
            $.liveshopping.init(article, this);
        });
        
    };
    
    // extends jQuery's namespace
    $.liveshopping = {
    
        // initialize the liveshopping
        init: function(article, obj) {
            
            // article limitation
            var stints = $(obj).find('input.stints');
            if($.isEmptyObject(stints) == true) {
                article.stints = $(stints).val().split(';');
            }
            
            // prepare ordernumber for sizzle
            article.ordernumber = article.ordernumber.replace('\.', '\\.');
            
            // refresh every second
            window.setInterval(function () {
        
                var now = $.server.dateObj;
                
                // check difference
                var diff = $.timestampDiff(article.target.getTime(), now.getTime());
                
                // liveshopping is running 
                if(diff != false) {
                
                    $.liveshopping.refreshDates(article, diff);
                    
                    // if type standard
                    if(article.typeID == 1) {
                        $.liveshopping.refreshBarChart(article,diff);
                        
                        if(article.max_quantity_enable) {
                            $.liveshopping.refreshQuantity(article)
                        }
                        
                    // Minutes decrease
                    } else if(article.typeID == 2) {
                        $.liveshopping.refreshSecondsCounter(article, diff);
                        $.liveshopping.refreshPrices(article, diff);
                        
                    // Minutes increase
                    } else {
                        $.liveshopping.refreshSecondsCounter(article, diff);
                        $.liveshopping.refreshPrices(article, diff);
                    }
                    
                // liveshopping is finished
                } else {
                    //window.location.reload();
                }
            }, 1000);
        },
        
        // changes bar chart labels which
        // are used by the standard type
        refreshDates: function(article, diff) {
            
            var key = article.uniquekey + article.ordernumber;
            
            // days
            $('span.live'+key+'_days').each(function(index, item) {
                $(item).html(diff.d);
            });
            
            // days - double digit
            $('span.live'+key+'_days_doubledigit').each(function(index, item) {
                tmp = diff.d;
                tmp = tmp.toString();
                if(tmp.length == 1) $(item).html('0' + tmp); else    $(item).html(tmp);
            });
            
            // hours
            $('span.live'+key+'_hours').each(function(index, item) {
                $(item).html(diff.h);
            });
            
            // hours - double digit
            $('span.live'+key+'_hours_doubledigit').each(function(index, item) {
                tmp = diff.h;
                tmp = tmp.toString();
                if(tmp.length == 1) $(item).html('0'+tmp); else $(item).html(tmp);
            });
            
            // minutes
            $('span.live'+key+'_min').each(function(index, item) {
                $(item).html(diff.m);
            });
            
            // minutes - double digit
            $('span.live'+key+'_min_doubledigit').each(function(index, item) {
                tmp = diff.m;
                tmp = tmp.toString();
                if(tmp.length == 1) $(item).html('0'+tmp); else $(item).html(tmp);
            });
            
            // seconds
            $('span.live'+key+'_sec').each(function(index, item) {
                $(item).html(diff.s);
            });
            
            // seconds - double digit
            $('span.live'+key+'_sec_doubledigit').each(function(index, item) {
                tmp = diff.s;
                tmp = tmp.toString();
                if(tmp.length == 1) $(item).html('0'+tmp); else $(item).html(tmp);
            });

        },
        
        // refreshs the bar chart which is used in the
        // standard liveshopping type
        refreshBarChart: function(article, diff, config) {
            
            var key = article.uniquekey + article.ordernumber;
            
            // days process bar
            $('div.live'+key+'_days_process').each(function(index, item) {
                var proz = eval(diff.d)*100/31;
                if(proz > 100) proz = 100;
                proz = 100 - proz;
                $(item).css('width', proz+'%');
            });
            
            // hours process bar
            $('div.live'+key+'_hours_process').each(function(index, item) {
                var proz = eval(diff.h)*100/59;
                proz = 100 - proz;
                $(item).css('width', proz + '%');
            });
            
            // minutes bar chart
            $('div.live'+key+'_min_process').each(function(index, item) {
                var proz = eval(diff.m)*100/59;
                proz = 100 - proz;
                $(item).css('width', proz + '%');
            });
            
            // seconds bar chart
            $('div.live'+key+'_sec_process').each(function(index, item) {
                var proz = eval(diff.s)*100/59;
                proz = 100 - proz;
                $(item).css('width', proz + '%');
            });    

        },
        
        // necessary for minutes increase and decrease
        refreshPrices: function(article, diff) {
        
            if (diff.s == 0) {
                
                var key = article.uniquekey + article.ordernumber;
                // calulating new price
                article.article.find('input.price').each(function(index, item) {
                    newPrice = eval($(item).val());
                });
                
                // setting new price
                $('strong.live'+key+'_display_price').each(function(index, item) {
                    newPrice2 = newPrice;
                    if(article.typeID == 3) {
                        newPrice2 = eval(newPrice2) + eval(article.minPrice);
                    } else {
                        newPrice2 = eval(newPrice2) - eval(article.minPrice);
                    }
                    
                    $(item).text($.number_format(newPrice2, 2, ',','.'));
                });
                
                // setting new price into hidden input
                article.article.find('input.price').val(newPrice2);
            }

        },
        
        // needed for max quantity
        refreshQuantity: function(article) {
            $('div.live'+article.uniquekey+article.ordernumber+'_instock_process').each(function(index, item) {
                var proc = eval(article.max_quantity)*100;
                var total = eval(article.max_quantity)+eval(article.sells);
                proc = proc/total;
                proc = 100 - proc;
                $(item).css('width', proc+'%');
            });
        },
        
        // refresh seconds bar
        refreshSecondsCounter: function(article, diff) {
            $('div.live'+article.uniquekey+article.ordernumber+'_secbar_process').each(function(index, item) {
                var proc = eval(diff.s)*100/59;
                $(item).css('width', proc + '%');
            });
        }
    
    };
    
})(jQuery);

/**
 * Livesearch Plugin
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
jQuery.fn.liveSearch = function (conf) {
    var config = jQuery.extend({
        url: '',
        id: 'search_results',
        duration: 400,
        typeDelay: 500,
        loadingClass: 'loading',
        onSlideUp: function () {},
        positionClass: 'active',
        position: -1,
        results: {},
        lastValue: '',
        timer: null,
        searchPosition: 'middle',        // left, middle, right
        searchWidth: 450                // search width
    }, conf);

    var liveSearch    = jQuery('#' + config.id);
    
    // Create live-search if it doesn't exist
    if (!liveSearch.length) {
        liveSearch = jQuery('<div id="' + config.id + '"></div>')
        .appendTo(document.body)
        .hide()
        .slideUp(0);

        // Close live-search when clicking outside it
        jQuery(document.body).click(function(event) {
            var clicked = jQuery(event.target);

            if (!(clicked.is('#' + config.id) || clicked.parents('#' + config.id).length || clicked.is('input'))) {
                liveSearch.slideUp(config.duration, function () {
                    config.onSlideUp();
                });
            }
        });
    }

    return this.each(function () {
        var input = jQuery(this).attr('autocomplete', 'off');
        var liveSearchPaddingBorderHoriz = parseInt(liveSearch.css('paddingLeft'), 10) + parseInt(liveSearch.css('paddingRight'), 10) + parseInt(liveSearch.css('borderLeftWidth'), 10) + parseInt(liveSearch.css('borderRightWidth'), 10);
        
        // Re calculates live search's position
        var repositionLiveSearch = function () {
            
            var tmpOffset    = input.offset();
            
            switch(config.searchPosition) {
                case 'left':
                    leftValue = tmpOffset.left;
                    break;
                case 'middle':
                    leftValue = (tmpOffset.left + input.outerWidth() / 2) - (config.searchWidth / 2);
                    break;
                case 'right':
                    leftValue = (tmpOffset.left + input.outerWidth()) - config.searchWidth + 8;
                    break;
            }
            
            //console.log(leftValue);
            
            var inputDim    = {
                
                //setting static offset
                left:    leftValue,
                top:    tmpOffset.top,
                width:    input.outerWidth(),
                height:    input.outerHeight()
            };

            inputDim.topPos        = inputDim.top + inputDim.height;
            inputDim.totalWidth    = inputDim.width - liveSearchPaddingBorderHoriz;
            
            liveSearch.css({
                position:    'absolute',
                left:        inputDim.left + 'px',
                top:        inputDim.topPos + 'px',
                width:        config.searchWidth + 'px'
            });
        };

        // Shows live-search for this input
        var showLiveSearch = function () {
            // Always reposition the live-search every time it is shown
            // in case user has resized browser-window or zoomed in or whatever
            repositionLiveSearch();

            // We need to bind a resize-event every time live search is shown
            // so it resizes based on the correct input element
            $(window).unbind('resize', repositionLiveSearch);
            $(window).bind('resize', repositionLiveSearch);

            liveSearch.slideDown(config.duration);
        };

        // Hides live-search for this input
        var hideLiveSearch = function () {
            liveSearch.slideUp(config.duration, function () {
                config.onSlideUp();
            });
        };
        
        var doLiveSearch = function () {
            
            if(input.val() == config.lastValue) return;

            input.addClass(config.loadingClass);
        
            // Stop previous ajax-request
            if (config.timer) {
                clearTimeout(config.timer);
            }
            
            // Reset position
            config.position = -1;
            
            config.lastValue = input.val();

            // Start a new ajax-request in X ms
            config.timer = setTimeout(function () {
                
                jQuery.ajax({
                    'url': config.url,
                    'dataType': 'jsonp',
                    'cancelExisting': true,
                    'data': $(input.attr('form')).serialize(),
                    'beforeSend': function() {
                        $('div.inner_searchcontainer .ajax_loader').show();
                    },
                    'success': function (request) {
                       $('div.inner_searchcontainer .ajax_loader').hide();
                       input.removeClass(config.loadingClass);
                       
                        // Show live-search if results and search-term aren't empty
                        if (request.length) {
                            liveSearch.html(request);
                            config.results = jQuery('#'+config.id+ ' li');
                            showLiveSearch();
                        } else {
                            hideLiveSearch();
                        }
                    }
                });
            }, config.typeDelay);
        };

        input
        // On focus, if the live-search is empty, perform an new search
        // If not, just slide it down. Only do this if there's something in the input
        .focus(function () {
            if (this.value !== '') {
                
                // Perform a new search if there are no search results
                if (liveSearch.html() == '') {
                    config.lastValue = '';
                    doLiveSearch();
                }
                // If there are search results show live search
                else {
                    // HACK: In case search field changes width onfocus
                    setTimeout(showLiveSearch, 1);
                }
            }
        })
        // Auto update live-search onkeyup
        .keydown(function (event) {
            
            doLiveSearch();
            
            if (config.results && config.results.length && (event.keyCode==38 || event.keyCode==40))
            {    
                $(config.results[config.position]).removeClass(config.positionClass);
                if(event.keyCode==40) {
                    config.position++;
                    if(config.position==config.results.length) {
                        config.position = -1;
                    }
                } else if(event.keyCode==38) {
                    if(config.position==-1) {
                        config.position = config.results.length;
                    }
                    config.position--;
                }
                if(config.position!=-1)
                {
                    $(config.results[config.position]).addClass(config.positionClass);
                }
            }
            
            if(event.keyCode==13 && config.position!=-1) {
                
                var target = $(config.results[config.position]).find('a').attr('href');
                location.href = target;
                return false;
            }
        });
    });
};

/**
 * Utitilies Plugin
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
 
(function ($) {
    $.ie7fix ={
        _init: function() {
            if($.browser.msie && parseInt($.browser.version) == 7) {
                 $.ie7fix.open(modal, config);
             } else {
                 return false;
             }
        },
        selectHide: function(selector) {
            if(selector) {
                $(selector + ' select, #detail .liveshopping_detail, .accessory_container, #detail .article_details_price2, #detail .article_details_price, #basketButton').css('visibility', 'hidden');
            } else {
                $('select, #detail .article_details_price2, #detail .article_details_price, #basketButton').css('visibility', 'hidden');
            }
        }
    }
     // Methods to fix the select box bug
    // and the missing position fixed
    $.ie6fix ={
        _init: function() {
            if($.browser.msie && parseInt($.browser.version) == 6) {
                 $.ie6fix.open(modal, config);
             } else {
                 return false;
             }
        },
        open: function(obj) {
            // Hide select boxes
            $('select:visible').css('visibility', 'hidden');
            
            // Fix missing 'position: fixed'
            obj.css({
                'position': 'absolute',
                'top': document.body.scrollTop + 100 + 'px'
            }).fadeIn();
            
            $(window).bind('scroll', function(event) {
                obj.css('top', document.body.scrollTop + 100 + 'px');
            });
        },
        close: function(obj) {
            // Show select boxes
            $('select:hidden').css('visibility', 'visible');
            
            obj.fadeOut();
            
            // Fix missing 'position: fixed'
            $(window).unbind('scroll');
        },
        selectHide: function(selector) {
            if(selector) {
                $(selector + ' select, #detail .liveshopping_detail, .accessory_container').css('visibility', 'hidden');
            } else {
                if($.browser.msie && parseInt($.browser.version) == 7) {
                $('select, #detail .article_details_price2, #detail .article_details_price, #basketButton').css('visibility', 'hidden');
                }else{
                $('select, #detail .article_details_price2, #detail .article_details_price').css('visibility', 'hidden');
                }
            }
        },
        selectShow: function() {
            $('select, #detail .liveshopping_detail, .accessory_container, #detail .article_details_price2, #detail .article_details_price, #basketButton').css('visibility', 'visible');
        },
        selectOnlyShow: function() {
            $('select, #detail .article_details_price2, #detail .article_details_price, #basketButton').css('visibility', 'visible')
        }
    }; 

    // Formats a string
    // Syntax: $.format('<div class="%0"'>%1</div>, [value for %0], [value for %1], ...)
    $.format = function(str) {
            for (var i = 1; i < arguments.length; i++) {
                str = str.replace('%' + (i - 1), arguments[i]);
            }
            return str;
        }

    //Extends jQuery's namespace
    $.server = {
        dateObj: {}
    };
    
    //Initialized the server time which
    //is used by the liveshopping module
    $.server.init = function (servertime) {
        $.server.dateObj = new Date();
        $.server.dateObj.setTime(servertime * 1000);
        window.setInterval(function () {
            $.server.increment();
        }, 1000)
    };
    $.server.increment = function () {
        var crntTime = $.server.dateObj.getTime() + 1000;
        $.server.dateObj = new Date(crntTime)
    };
    
    //Formats floats
    $.number_format = function (number, decimals, dec_point, thousands_sep) {
        var n = number,
            prec = decimals;
        var toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return (Math.round(n * k) / k).toString()
        };
        n = !isFinite(+n) ? 0 : +n;prec = !isFinite(+prec) ? 0 : Math.abs(prec);
        var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep;
        var dec = (typeof dec_point === 'undefined') ? '.' : dec_point;
        var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec);
        var abs = toFixedFix(Math.abs(n), prec);
        var _, i;
        if (abs >= 1000) {
            _ = abs.split(/\D/);
            i = _[0].length % 3 || 3;
            _[0] = s.slice(0, i + (n < 0)) + _[0].slice(i).replace(/(\d{3})/g, sep + '$1');
            s = _.join(dec)
        } else {
            s = s.replace('.', dec)
        }
        var decPos = s.indexOf(dec);
        if (prec >= 1 && decPos !== -1 && (s.length - decPos - 1) < prec) {
            s += new Array(prec - (s.length - decPos - 1)).join(0) + '0'
        } else if (prec >= 1 && decPos === -1) {
            s += dec + new Array(prec).join(0) + '0'
        }
        return s
    };
    
    //Stripes tables
    $.stripe = function (id) {
        return;
        var even = false;
        var evenColor = arguments[1] ? arguments[1] : "#fff";
        var oddColor = arguments[2] ? arguments[2] : "#efefef";
        var table = document.getElementById(id);
        if (!table) {
            return
        }
        var tbodies = table.getElementsByTagName("tbody");
        for (var h = 0; h < tbodies.length; h++) {
            var trs = tbodies[h].getElementsByTagName("tr");
            for (var i = 0; i < trs.length; i++) {
                if (!hasClass(trs[i]) && !trs[i].style.backgroundColor) {
                    var tds = trs[i].getElementsByTagName("td");
                    for (var j = 0; j < tds.length; j++) {
                        var mytd = tds[j];
                        if (!hasClass(mytd) && !mytd.style.backgroundColor) {
                            mytd.style.backgroundColor = even ? evenColor : oddColor
                        }
                    }
                }
                even = !even
            }
        }
    };
        
    //Changes the state of the related articles which is
    //used by the bundle module
    $.changeRelatedArticleState = function (ordernumber, active) {
        var tmpContainerName = '#' + ordernumber + '_related_container';
        if (false == active) {
            $(tmpContainerName).hide()
        } else {
            $(tmpContainerName).show()
        }
    };
    
    //Gets the difference between two timestamps
    //which is used by the live shopping module
    $.timestampDiff = function (d1, d2) {
        if (d1 < d2) {
            return false
        }
        var d = Math.floor((d1 - d2) / (24 * 60 * 60 * 1000));
        var h = Math.floor(((d1 - d2) - (d * 24 * 60 * 60 * 1000)) / (60 * 60 * 1000));
        var m = Math.floor(((d1 - d2) - (d * 24 * 60 * 60 * 1000) - (h * 60 * 60 * 1000)) / (60 * 1000));
        var s = Math.floor(((d1 - d2) - (d * 24 * 60 * 60 * 1000) - (h * 60 * 60 * 1000) - (m * 60 * 1000)) / 1000);
        return {
            'd': d,
            'h': h,
            'm': m,
            's': s
        }
    };
    
    //Changes the displayed informations on the
    //article detail site and changes the active
    //images which is used by variant articles
    $.changeDetails = function (ordernumber) {
        if (typeof($.checkNotification) == 'function') {
            if (!ordernumber){
                $.checkNotification($.ordernumber);
            }else {
                $.checkNotification(ordernumber);
            }
        }
        
        if (!ordernumber) {
            // 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 basket
            $('#basketButton').css('opacity', '0.4')
        } else {
            // 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'));
            
            //Wenn eine andere Variante ausgewaehlt ist
            if(ordernumber != $.ordernumber) {
                
                //Wenn ZoomViewer ist aktiv
                useZoom = parseInt(useZoom);
                if(useZoom) {
                    $('a#zoom1 img').attr('src', $('#img' + ordernumber).find('img').attr('src'));
                    $('#img' + ordernumber).find('a').trigger('click');
                } else {
                     //Lightboxlink wechseln
                    $('a#zoom1').attr('href', $('#img' + ordernumber).children('a').attr('href'));
                }
                
                //Thumbnails wechseln
                $('#thumb' + $.ordernumber).hide();
                $('#thumb' + ordernumber).show();
                
                
                //neue Ordernumber in die globale Variable schreiben
                $.ordernumber = ordernumber;
                try {
                    $('#variantOrdernumber').val(ordernumber);
                }catch (err){
                    
                }
                // try to active liveshopping
                try {
                    $('#article_details').liveshopping();
                } catch(err) {}
            }
        }
    };
    
    //Check if the article are set up for
    //email notification and checks if
    //a notification was sent 
    $.checkNotification = function(ordernumber) {
        
        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) {}
                }
            }
            
            var currentInstock = $('#instock_'+ordernumber).val();
                if(currentInstock > 0) {
                    $('#article_notification').hide();
                    try {
                        $('#detailCartButton').show();
                    } catch(e) {}
                } else {
                    $('#article_notification').show();
                    try {
                        $('#detailCartButton').hide();
                    } catch(e) {}
            }
        } catch(err) {}
    }
    
})(jQuery);

/**
 * Bundle Plugin
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
(function($) {
    
    var config = {
        'ordernumber': $.ordernumber
    };
    
    $.bundle = {
        
        changeDetails: function(selector, ordernumber) {
            
            // setting config ordernumber
            if(typeof(ordernumber) != 'undefined') {
                config.ordernumber = ordernumber;
            } else {
                config.ordernumber = $.ordernumber;
            }
            
            var bundles = $(selector).find('.bundle_bundles_details').text();
            var related = $(selector).find('.bundle_related_articles').text();
            var article = $(selector).find('.bundle_article_details').text();
            
            // evil !!! 
            if(bundles.length) {
                eval("bundles = ("+bundles+")");
            }
            if(related.length) {
                eval("related = ("+related+")");
            }
            if(article.length) {
                eval("article = ("+article+")");
            }
            
            // Related articles
            if(typeof(related) == 'object' && parseInt(article.crossbundlelook) == 1) {
                $.bundle.processRelatedArticles(related, article);
            }
            
            // Bundles
            if(typeof(bundles) == 'object') {
                $.bundle.processBundle(bundles, article, selector);
            }
        },
        
        calculatePrice: function(bundle, ordernumber) {
        
            var articlePriceSelector = 'input#price_'+ordernumber;
            
            // Calculate total price
            var price_rab_span = $('#price_rabAbs_'+bundle.id);
            var articlePrice = $(articlePriceSelector).val();
            var bundleArticlesTotalPrice = bundle.sBundleArticlesTotalPrice.display;
            
            if(price_rab_span != null && articlePrice != null && bundleArticlesTotalPrice != null) {
                var rabTotal = eval(articlePrice) + eval(bundleArticlesTotalPrice);
                price_rab_span.text($.number_format(rabTotal, 2, ',', '.'));
            }
            
            // Calculate bundle price
            var price_bundle_span = $('#price_bundle_'+bundle.id);
            if(price_bundle_span != null) {
                
                // Calculate total discount
                if(bundle.rab_type == "abs") {
                    var bundle_price = bundle.sBundlePrices.display;
                    price_bundle_span.text($.number_format(bundle_price, 2, ',', '.'));
                } else {
                    // Calculate percental discount
                    var percentage = bundle.sBundlePrices.percentage;
                    var tmpDiscount = (eval(rabTotal) / 100) * (eval(percentage));
                    var bundle_price = eval(rabTotal)-eval(tmpDiscount);
                    price_bundle_span.text($.number_format(bundle_price, 2, ',', '.'));
                }
            }
            
            // Discount in percentage
            var price_rabPro_span = $('#price_rabPro_'+bundle.id);
            var rabPro = 100-(eval(bundle_price) * 100 / eval(rabTotal));
            
            if(price_rabPro_span != null && rabPro != null) {
                price_rabPro_span.text($.number_format(rabPro, 2));
            }
        },
        
        processBundle: function(bundles, article, selector) {
        
            // Bundle display flag
            // Will be true if at least
            // one bundle article is active
            var showBundleBox = false;
            
            $.each(bundles,function(i, bundle) {
            
                // Mark variant ordernumber as selected article
                $('input[name=sAddBundle]').each(function(i, item) {
                    $(item).val(config.ordernumber);
                });
                    
                $.bundle.calculatePrice(bundle, config.ordernumber.replace('\.', '\\.'));
                
                
                // Instock check for variant articles
                if(!$.isEmptyObject(bundle.sBundleStints)) {
                    
                    $('.bundle').hide();
                    
                    $('#sAdd.variant').change(function() {
                        var ordernumber = $(this).val();
                        var instock = $('#instock_'+ordernumber.replace('\.', '\\.')).val();
                        
                        // refresh price
                        $.bundle.calculatePrice(bundle, ordernumber);
                        
                        if(instock.length) {    
                            
                            if(instock >= 0) {
                                if(showBundleBox) $(selector).show();
                            } else {
                                $('.bundle').hide();
                            }
                        } else {
                        
                            // Show bundle box, if at least one
                            // one bundle artice is active
                            if(showBundleBox) {
                                $('.bundle').show();
                            }
                        }
                        
                    });
                }
                
                // Check if we've article limitations
                if($.isArray(bundle.sBundleStints)) {
                    
                    // Hide bundle box and check for
                    // entitled articles
                    $('#bundle_set_'+bundle.id).hide();
                    
                    // Pass-through ordernumber, which will
                    // be displayed
                    $.each(bundle.sBundleStints, function(j, stints) {
                        var ordernumberToUpper = config.ordernumber.toUpperCase();
                        
                        if(ordernumberToUpper == stints) {
                            showBundleBox = true;
                            
                            // show bundle box
                            $('#bundleset_'+bundle.id).show();
                        }
                    });
                } else {
                    $('.bundle').fadeIn();
                }
            });
            
            // Show bundle box, if at least one
            // one bundle artice is active
            if(showBundleBox) {
                $('.bundle').show();
            }
            
            /*if(!$.isEmptyObject(article.sVariants)) {
                $('.bundle').hide();
            } */
        },
        
        processRelatedArticles: function(related, article) {
        
            // Release related article box
            try {
                $('.relatedbox_container').show();
            } catch(err) {}
            
            // Caching ordernumber and price
            $('#related_main_ordernumber').val(config.ordernumber);
            $('#selected_articel_price').val($('#price_'+config.ordernumber).val());
            $.refreshRelatedArticle();
            
            // Deposit images
            try {
                var tmpBundleImg = $('#related_main_image');
                var tmpSourceImg = $('#img_1_'+config.ordernumber);
                
                if(tmpSourceImg != null) {tmpBundleImg.html(tmpSourceImg.html());}
            } catch(err) {}
        }
        
    };
    
    
    // Main bundle function
    // exam.: $('.bundlebox').bundle();
    $.fn.bundle = function(settings) {
        
        if (settings) $.extend(config, settings);
        
        this.each(function() {
            $.bundle.changeDetails(this);
        });
    };
    
    //Refreshes the relatedArticles which is
    //used by the bundle module
    $.refreshRelatedArticle = function () {
        var relatedOrdernumbers = '';
        var totalPrice = $('#selected_articel_price').val();
        
        $('input[class=relatedOrdernumber]').each(function (i, item) {
            var tmpOrdernumber = $(item).val();
            var tmpContainerName = '#related_'+tmpOrdernumber+'_image';
            var tmpPlusiconName = '#related_'+tmpOrdernumber+'_plus';
            var tmpPriceName = '#' + tmpOrdernumber + '_price';
            var checkbox = $('#' + tmpOrdernumber + '_related_checkbox');
            if (checkbox.is(':checked')) {
                $(tmpContainerName).fadeIn('fast');
                $(tmpPlusiconName).fadeIn('fast');
                if ('' == relatedOrdernumbers) relatedOrdernumbers = tmpOrdernumber;
                else relatedOrdernumbers += ';' + tmpOrdernumber;
                var tmpPrice = $(tmpPriceName).val();
                if (tmpPrice) totalPrice = eval(totalPrice) + eval(tmpPrice)
            } else {
                $(tmpContainerName).fadeOut('fast');
                $(tmpPlusiconName).fadeOut('fast');
            }
        });
        $('#sRelatedOrdernumbers').val(relatedOrdernumbers);
        $('#price_relatedbundle').html($.number_format(totalPrice, 2, ',', '.'));
    };

})(jQuery);

/**
 * 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: 'json',
        requestType: 'post',
        animationSpeed: 400,
        topLink: '#top',
        maxCount: 5,
        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);
        }
        if(compareCount) {
            $.compare.options.compareCount = parseInt(compareCount);
        }
        
        //binding events
        $('.compare_delete_all').live('click', function(event) {
            $.compare.deleteComparisons(this.href);
            event.preventDefault();
        });
        $('.compare_add_article').live('click', function(event) {
            $.compare.addCompare(this.href);
            event.preventDefault();
        });
        $('.compare_get_overlay').live('click', function(event) {
            $.compare.startComparison(this.href);
            event.preventDefault();
        });
        $('.compare_delete_article').live('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,
            'complete': function (result) {
                var width = 160 * $.compare.options.compareCount + 160;
                    var position = 'fixed';
                
                if($.browser.msie && parseInt($.browser.version) == 6) {
                    width += 2;
                    position = 'absolute';
                }
                
                $.modal(result.responseText, '', {
                       'position': position,
                       'width': width+'px',
                       'top': '30px',
                       'textContainer': '<div>',
                       'textClass': 'ajax_compare_container'
               });
            }
        })
    };
    
    //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,
            'complete': function (result) {
                $.compare.options.compareCount = $.compare.options.compareCount + 1;
                if($.compare.options.compareCount > $.compare.options.maxCount) {
                
                    var width = 500;
                    var position = 'fixed';
                    
                    if($.browser.msie && parseInt($.browser.version) == 6) {
                        width += 2;
                        position = 'absolute';
                    }
                    $.modal(result.responseText, '', {
                        'position': position,
                        'width': width+'px',
                        'textContainer': '<div>',
                        'textClass': 'ajax_compare_max_container'
                    });
                    $.compare.options.compareCount = $.compare.options.maxCount;
                    return;
                }
                $($.compare.options.ajaxContainer).html(result.responseText);
                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;
            },
            'complete': function (result) {
                $($.compare.options.ajaxContainer).html(result.responseText);
                
            }
        })
    };
    
    //Deletes the current compare list
    $.compare.deleteComparisons = function (url) {
        $.ajax({
            'dataType': $.compare.options.dataType,
            'type': $.compare.options.requestType,
            'url': url,
            'beforeSend': function() {
                $.compare.options.compareCount = 0;
                compareCount = $.compare.options.compareCount;
            },
            'complete': function () {
                $($.compare.options.ajaxContainer).empty();
            }
        })
    };
})(jQuery);

/**
 * Modal Plugin
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
(function ($) {
    
    //Default settings
    var config = {
        position: 'absolute',
        left: '50%',
        top: '10%',
        width: '560px',
        border: '1px solid #333',
        background: '#fff',
        animationSpeed: 500,
        frameHeight: '500px',
        textClass: '',
        textContainer: '<p>',
        overlay: '#lbOverlay',
        overlayOpacity: '0.6',
        useOverlay: true
    };
    
    //creates an modal window with text and headline
    $.modal = function (text, headline, settings) {
        if (settings) $.extend(config, settings);
        if ($('.modal')) $('.modal').remove();
        var modal = $('<div>', {
            'class': 'modal',
            'css': {
                'width': config.width,
                'left': '50%',
                'border': config.border,
                'background': config.background,
                'display': 'none',
                'margin-left': -(parseInt(config.width) / 2)
            }
        });
        
        if (headline.length) {
            var h2 = $('<h2>', {
                'html': headline
            }).appendTo(modal)
        }
        if (text.length) {
            var container = $(config.textContainer, {
                'html': text
            });
            
            if (config.textClass.length) {
                container.addClass(config.textClass)
            }
            container.appendTo(modal);
        }
        var close = $('<a>', {
            'text': 'Schliessen',
            'class': 'close'
        }).appendTo(modal);
        close.bind('click', function (event) {
            event.preventDefault();
            if (config.useOverlay == true) {
                $.modal.overlay.fadeOut()
            }
            if (config.position == 'absolute') {
                modal.fadeOut(config.animationSpeed)
            } else if (config.position == 'fixed') {
                modal.animate({
                    'top': -(modal.height() + 100) + 'px'
                }, config.animationSpeed)
            }
        });
        modal.appendTo('body');
        if (config.useOverlay == true) {
            $.modal.overlay.fadeIn();
            
            $(config.overlay).bind('click', function (event) {
                $.modalClose();
            })
        }
        if($.browser.msie && parseInt($.browser.version) == 6) {
             $.ie6fix.open(modal, config);
         } else {
            if (config.position == 'absolute') {
                modal.css({
                    'top': config.top,
                    'position': config.position,
                    'bottom': 'auto'
                }).fadeIn(config.animationSpeed);
            } else if (config.position == 'fixed') {
                modal.css({
                    'position': config.position,
                    'top': -(modal.height() + 100) + 'px',
                    'display': 'block'
                }).animate({
                    'top': '40px'
                }, config.animationSpeed)
            }
        }
        
        return modal
    };
    
    //Cloeses the current modal window
    $.modalClose = function () {
        if (config.useOverlay == true) {
            $.modal.overlay.fadeOut()
        }
        
        if($.browser.msie && parseInt($.browser.version) == 6) {
            $.ie6fix.close($('.modal'), config);
        } else {
            if (config.position == 'absolute') {
                $('.modal').fadeOut(config.animationSpeed)
            } else if (config.position == 'fixed') {
                $('.modal').animate({
                    'top': -($('.modal').height() + 100) + 'px'
                }, config.animationSpeed)
            }
        }
    };
    
    //Creates a modal window with an iframe and a headline
    $.modalFrame = function (url, headline, settings) {
        if (settings) $.extend(config, settings);
        config.animationSpeed = parseInt(config.animationSpeed);
        if ($('.modal')) $('.modal').remove();
        var modal = $('<div>', {
            'class': 'modal',
            'css': {
                'width': config.width,
                'left': '50%',
                'border': config.border,
                'padding': config.padding,
                'background': config.background,
                'display': 'none',
                'margin-left': -(parseInt(config.width) / 2)
            }
        });
        if (headline.length) {
            var h2 = $('<h2>', {
                'text': headline
            }).appendTo(modal)
        }
        if (url.length) {
            var div = $('<iframe>', {
                'src': url,
                'css': {
                    'height': config.frameHeight
                }
            }).appendTo(modal)
        }
        var close = $('<a>', {
            'text': 'Schliessen',
            'class': 'close'
        }).appendTo(modal);
        close.bind('click', function (event) {
            event.preventDefault();
            if (config.position == 'absolute') {
                modal.fadeOut(config.animationSpeed)
            } else if (config.position == 'fixed') {
                modal.animate({
                    'top': -(modal.height() + 100) + 'px'
                }, config.animationSpeed)
            }
        });
        modal.appendTo('.container_20');
        if (config.position == 'absolute') {
            modal.css({
                'position': config.position
            }).fadeIn(config.animationSpeed)
        } else if (config.position == 'fixed') {
            modal.css({
                'position': config.position,
                'top': -(modal.height() + 100) + 'px',
                'display': 'block'
            }).animate({
                'top': '0%'
            }, config.animationSpeed)
        }
    };
        
    //Handles the modal overlay
    $.modal.overlay = {
        fadeIn: function () {
            $(config.overlay).css({
                'display': 'block',
                'opacity': '0'
            }).animate({
                'opacity': '0.4'
            }, 500)
        },
        fadeOut: function () {
            $(config.overlay).animate({
                'opacity': '0'
            }, 500).hide()
        }
    }
})(jQuery);


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

    //Default settings
    var config = {
        dataType: 'text',
        container: '.modal',
        headline: '',
        viewport: '',
        register: '',
        checkout: '',
        target: ''
    };
    
    //Extends jQuery's function namespace
    $.fn.checkout = function (settings) {
        if (settings) $.extend(config, settings);
        
        $(config.container + ' form').live('submit', function (event) {
            if(!$(this).hasClass('new_customer_form')) {
                event.preventDefault();
                $.checkout.loginUser(this);
            }
        });
        
        this.live('click', function (event) {
            event.preventDefault();
            $.checkout.checkUser(this.href);
        });
        
        return this
    };
    
    //Extends jQuery's namespace
    $.checkout = {};
    
    //Checks the user
    $.checkout.checkUser = function (target,event) {
        config.target = target;        
        $.ajax({
            'url': config.viewport,
            'dataType': 'jsonp',
            'success': function (result) {
                if (result.length) {
                    var width = 530;
                    var position = 'fixed';
                
                    if($.browser.msie && parseInt($.browser.version) == 6) {
                        var width = 530;
                        var position = 'absolute';
                    }
                
                    $.modal(result, config.headline, {
                        'position': position,
                        'textClass': '',
                        'textContainer': '<div>',
                        'width': width+'px'
                    }).find('.close').remove();
                
                // user is logged in                
                } else {
                    window.location.href = target;
                }
            }
        });
    };
    
    //Checks if the user is logged in
    $.checkout.loginUser = function (form) {
        config.register  = $.controller.register;
        $.ajax({
            'url': config.viewport,
            'dataType': 'jsonp',
            'data': $(form).serialize(),
            'success': function (result) {
                if(result.length) {
                    $(config.container).empty().html(result);
                } else {
                     window.location.href = config.target ? config.target : config.checkout;
                }
            }
        });
    };
})(jQuery);

/**
 * AJAX Basket Plugin
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
(function ($) {
    
    //Extends jQuery's namespace
    $.basket = {};
    
    //Default settings
    $.basket.options = {
        viewport: '',
        basketLoader: '.ajax_basket .ajax_loader',
        basketResult: '.ajax_basket_result',
        basketDisplay: '#shopnavi div.display_basket',
        basketParent: '.ajax_basket_container'
    };
    
    //Initialize the basket module
    //and binds the needed events
    $.basket.init = function () {
        
        var width = 660;
        var position = 'fixed';
        
        if($.browser.msie && parseInt($.browser.version) == 6) {
            var width = width - 10;
            var position = 'absolute';
        }
        
    
        var modalConfig = {
            'position': position,
            'animationSpeed': 200,
            'width': width+'px',
            'textContainer': '<div>',
            'textClass': 'ajax_add_article_container'
        };
        var sliderConfig = {
               'headline': false,
            'navigation': false,
            'scrollSpeed': 800,
            'rotate': false,
            'width':630,
            'height': 210,
            'scrollWidth': 578,
            'containerCSS': {
                'margin': '0 0 15px 15px'
            }
        };
        
        $('a.buynow').live('click', function (event) {
            event.preventDefault();
            $.ajax({
                'dataType': 'jsonp',
                'beforeSend': function() {
                    $.loadingIndicator.open();
                },
                'url': $(this).attr('href'),
                'success': function (result) {
                    $.loadingIndicator.close();
                    $.modal(result, '', modalConfig);
                    $('#lbOverlay').css('opacity', '0').show().fadeTo('fast', '0.3');
                    
                    $('.slider_modal').ajaxSlider('locale', sliderConfig);
                    
                    $('.modal .close').hide();
                    $.basket.refreshDisplay();
                }
            })
        });
        $('.basketform').bind('submit', function (event) {
            event.preventDefault();
            $.ajax({
                'data': $(this).serialize(),
                'dataType': 'jsonp',
                'url': $(this).attr('action'),
                'beforeSend': function() {
                    $.loadingIndicator.open();
                },
                'success': function(result) {
                    
                    $.loadingIndicator.close();
                    $.modal(result, '', modalConfig);
                    $('#lbOverlay').css('opacity', '0').show().fadeTo('fast', '0.3');
                    
                    $('.slider_modal').ajaxSlider('locale', sliderConfig);
                    
                    $('.modal .close').hide();
                    $.basket.refreshDisplay();
                }
            });
        });
    };
    
    //Refreshs the basket display
    $.basket.refreshDisplay = function () {
        $.ajax({
            'dataType': 'jsonp',
            'url': $.basket.options.viewport,
            'data': {
                'sAction': 'ajaxAmount'
            },
            'success': function (result) {
                $($.basket.options.basketDisplay).html(result)
            }
        })
    };
    
    //Requests the basket content
    $.basket.getBasket = function () {
        if(!$($.basket.options.basketResult).length) {
            $('<div>', {
                'class': 'ajax_basket_result'
            }).appendTo(document.body);
        }
        $($.basket.options.basketLoader).show();
        $.ajax({
            'data': {
                'sAction': 'ajaxCart'
            },
            'dataType': 'jsonp',
            'url': $.basket.options.viewport,
            'success': function (result) {
                var offset = $($.basket.options.basketParent).offset();
                $($.basket.options.basketResult).css({
                    'top': offset.top + 22,
                    'left': offset.left -($($.basket.options.basketResult).width() - $($.basket.options.basketParent).width() + 20)
                });
                $($.basket.options.basketLoader).hide();
                if (result.length) {
                    $($.basket.options.basketResult).empty().html(result);
                } else {
                    $($.basket.options.basketResult).empty().html($.basket.options.emptyText);
                }
                $($.basket.options.basketResult).addClass('active').slideDown('fast');
                $(document.body).bind('click', function() {
                    $($.basket.options.basketResult).removeClass('active').slideUp('fast');
                    $(document.body).unbind('click');
                });
            }
        })
    }
})(jQuery);

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

    //Extends jQuery's function namespace
    $.fn.kwicks = function (n) {
        var p = {
            isVertical: true,
            sticky: false,
            defaultKwick: 0,
            event: 'mouseover',
            spacing: 0,
            duration: 500
        };
        var o = $.extend(p, n);
        var q = (o.isVertical ? 'height' : 'width');
        var r = (o.isVertical ? 'top' : 'left');
        return this.each(function () {
            $(this).parent().show();
            container = $(this);
            var k = container.children('li');
            //var l = k.eq(0).css(q).replace(/px/, '');
            var l = 0;
            k.each(function (i) {
                l += Math.floor($(this).css(q).replace(/px/, ''));
            });
            l /= k.size();
            
            if (!o.max) {
                o.max = (l * k.size()) - (o.min * (k.size() - 1))
            } else {
                o.min = ((l * k.size()) - o.max) / (k.size() - 1)
            }
            if (o.isVertical) {
                container.css({
                    width: k.eq(0).css('width'),
                    height: (l * k.size()) + (o.spacing * (k.size() - 1)) + 'px'
                })
            } else {
                container.css({
                    width: (l * k.size()) + (o.spacing * (k.size() - 1)) + 'px',
                    height: k.eq(0).css('height')
                })
            }
            var m = [];
            for (i = 0; i < k.size(); i++) {
                m[i] = [];
                for (j = 1; j < k.size() - 1; j++) {
                    if (i == j) {
                        m[i][j] = o.isVertical ? j * o.min + (j * o.spacing) : j * o.min + (j * o.spacing)
                    } else {
                        m[i][j] = (j <= i ? (j * o.min) : (j - 1) * o.min + o.max) + (j * o.spacing)
                    }
                }
            }
            k.each(function (i) {
                var h = $(this);
                if (i === 0) {
                    h.css(r, '0px')
                } else if (i == k.size() - 1) {
                    h.css(o.isVertical ? 'bottom' : 'right',
                    '0px')
                } else {
                    if (o.sticky) {
                        h.css(r, m[o.defaultKwick][i])
                    } else {
                        h.css(r, (i * l) + (i * o.spacing))
                    }
                }
                if (o.sticky) {
                    if (o.defaultKwick == i) {
                        h.css(q, o.max + 'px');
                        h.addClass('active')
                    } else {
                        h.css(q, o.min + 'px')
                    }
                }
                h.css({
                    margin: 0,
                    position: 'absolute'
                });
                h.bind(o.event, function () {
                    var c = [];
                    var d = [];
                    k.stop().removeClass('active');
                    for (j = 0; j < k.size(); j++) {
                        c[j] = k.eq(j).css(q).replace(/px/, '');
                        d[j] = k.eq(j).css(r).replace(/px/, '')
                    }
                    var e = {};
                    e[q] = o.max;
                    var f = o.max - c[i];
                    var g = c[i] / f;
                    h.addClass('active').animate(e, {
                        step: function (a) {
                            var b = f != 0 ? a / f - g : 1;k.each(function (j) {
                                if (j != i) {
                                    k.eq(j).css(q, c[j] - ((c[j] - o.min) * b) + 'px')
                                }
                                if (j > 0 && j < k.size() - 1) {
                                    k.eq(j).css(r, d[j] - ((d[j] - m[i][j]) * b) + 'px')
                                }
                            })
                        },
                        duration: o.duration,
                        easing: o.easing
                    })
                })
            });
            if (!o.sticky) {
                container.bind("mouseleave", function () {
                    var c = [];
                    var d = [];
                    k.removeClass('active').stop();
                    for (i = 0; i < k.size(); i++) {
                        c[i] = k.eq(i).css(q).replace(/px/, '');
                        d[i] = k.eq(i).css(r).replace(/px/, '')
                    }
                    var e = {};
                    e[q] = l;
                    var f = l - c[0];
                    k.eq(0).animate(e, {
                        step: function (a) {
                            var b = f != 0 ? (a - c[0]) / f : 1;
                            for (i = 1; i < k.size(); i++) {
                                k.eq(i).css(q, c[i] - ((c[i] - l) * b) + 'px');
                                if (i < k.size() - 1) {
                                    k.eq(i).css(r, d[i] - ((d[i] - ((i * l) + (i * o.spacing))) * b) + 'px')
                                }
                            }
                        },
                        duration: o.duration,
                        easing: o.easing
                    })
                })
            }
        })
    }
})(jQuery);

/**
 * Supplier Filter
 * for Shopware
 *
 * Shopware AG (c) 2010
 */
(function($) {

    //Default setttings
    var config = {
        slideContainer: '.supplier_filter .slideContainer',
        plus: '.filter_actions .plus',
        plusText: '+',
        minus:  '.filter_actions .minus',
        minusText: '-',
        expander: '.expandcollapse',
        expandAll: '.supplier_filter div .expandcollapse',
        activeClass: 'active',
        animationSpeed: 'fast'
    };
    
    $.fn.supplierfilter = function(settings) {
        
        //Extends default settings with user settings
        if (settings) $.extend(config, settings);
        
        this.each(function() {
        
            //Hides the container on start up
            ($(this).find('li').hasClass(config.activeClass)) ? $(this).show() : $(this).hide();
            
            //Bind click event on span
            $(this).prev('div').bind('click', function() {
                $(this).toggleClass(config.activeClass).next('.slideContainer').slideToggle(config.animationSpeed);
                ($(this).hasClass(config.activeClass)) ? $(this).children(config.expander).text(config.minusText) : $(this).children(config.expander).text(config.plusText);
            });
        });
        
    return this;
    };

})(jQuery);

/**
 * cat_text Slide
 * xp24 2011
 */
(function($) {
    
    $.fn.catTextSlide = function() {
        this.each(function() {
        
            $(this).hide();
            $(this).children('div').children('p').last().css('margin-bottom','0');

            $(this).prev('p').bind('click', function() {
                $(this).slideUp('fast').next('.slideText').slideDown('fast');
                $(this).children('expandcollapse').css({'display':'none'});
            });
        });
        
    return this;
    };

})(jQuery);

/**
 * jQuery UI 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI
 */
jQuery.ui||function(c){c.ui={version:"1.8.1",plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")=="hidden")return false;
b=b&&b=="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,f,g){return c.ui.isOverAxis(a,d,f)&&c.ui.isOverAxis(b,e,g)},keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,
PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none")},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||
/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==
undefined)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b=="absolute"||b=="relative"||b=="fixed"){b=parseInt(a.css("zIndex"));if(!isNaN(b)&&b!=0)return b}a=a.parent()}}return 0}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b||"area"==b?a.href||!isNaN(d):!isNaN(d))&&
!c(a)["area"==b?"parents":"closest"](":hidden").length},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}})}(jQuery);

/**
 * jQuery UI Widget 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Widget
 */
(function(b){var j=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add(this).each(function(){b(this).triggerHandler("remove")});return j.call(b(this),a,c)})};b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend({},c.options);b[e][a].prototype=
b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.substring(0,1)==="_")return h;e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==undefined){h=i;return false}}):this.each(function(){var g=
b.data(this,a);if(g){d&&g.option(d);g._init()}else b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){this.element=b(c).data(this.widgetName,this);this.options=b.extend(true,{},this.options,b.metadata&&b.metadata.get(c)[this.widgetName],a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();
this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(a,c){var d=a,e=this;if(arguments.length===0)return b.extend({},e.options);if(typeof a==="string"){if(c===undefined)return this.options[a];d={};d[a]=c}b.each(d,function(f,
h){e._setOption(f,h)});return e},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=
b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);

/**
 * jQuery UI Tabs 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Tabs
 *
 * Depends:
 *    jquery.ui.core.js
 *    jquery.ui.widget.js
 */
(function(d){var s=0,u=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading&#8230;</em>",tabTemplate:'<li><a href="#{href}"><span>#{label}</span></a></li>'},_create:function(){this._tabify(true)},_setOption:function(c,e){if(c=="selected")this.options.collapsible&&e==this.options.selected||
this.select(e);else{this.options[c]=e;this._tabify()}},_tabId:function(c){return c.title&&c.title.replace(/\s/g,"_").replace(/[^A-Za-z0-9\-_:\.]/g,"")||this.options.idPrefix+ ++s},_sanitizeSelector:function(c){return c.replace(/:/g,"\\:")},_cookie:function(){var c=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+ ++u);return d.cookie.apply(null,[c].concat(d.makeArray(arguments)))},_ui:function(c,e){return{tab:c,panel:e,index:this.anchors.index(c)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var c=
d(this);c.html(c.data("label.tabs")).removeData("label.tabs")})},_tabify:function(c){function e(g,f){g.css({display:""});!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}this.list=this.element.find("ol,ul").eq(0);this.lis=d("li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);var a=this,b=this.options,h=/^#.+/;this.anchors.each(function(g,f){var j=d(f).attr("href"),l=j.split("#")[0],p;if(l&&(l===location.toString().split("#")[0]||
(p=d("base")[0])&&l===p.href)){j=f.hash;f.href=j}if(h.test(j))a.panels=a.panels.add(a._sanitizeSelector(j));else if(j!="#"){d.data(f,"href.tabs",j);d.data(f,"load.tabs",j.replace(/#.*$/,""));j=a._tabId(f);f.href="#"+j;f=d("#"+j);if(!f.length){f=d(b.panelTemplate).attr("id",j).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else b.disabled.push(g)});if(c){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(b.selected===undefined){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){b.selected=g;return false}});if(typeof b.selected!="number"&&b.cookie)b.selected=parseInt(a._cookie(),10);if(typeof b.selected!="number"&&this.lis.filter(".ui-tabs-selected").length)b.selected=
this.lis.index(this.lis.filter(".ui-tabs-selected"));b.selected=b.selected||(this.lis.length?0:-1)}else if(b.selected===null)b.selected=-1;b.selected=b.selected>=0&&this.anchors[b.selected]||b.selected<0?b.selected:0;b.disabled=d.unique(b.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(b.selected,b.disabled)!=-1&&b.disabled.splice(d.inArray(b.selected,b.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");
if(b.selected>=0&&this.anchors.length){this.panels.eq(b.selected).removeClass("ui-tabs-hide");this.lis.eq(b.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[b.selected],a.panels[b.selected]))});this.load(b.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else b.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"));this.element[b.collapsible?"addClass":
"removeClass"]("ui-tabs-collapsible");b.cookie&&this._cookie(b.selected,b.cookie);c=0;for(var i;i=this.lis[c];c++)d(i)[d.inArray(c,b.disabled)!=-1&&!d(i).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");b.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(b.event!="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+g)};this.lis.bind("mouseover.tabs",
function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(b.fx)if(d.isArray(b.fx)){m=b.fx[0];o=b.fx[1]}else m=o=b.fx;var q=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal",function(){e(f,o);a._trigger("show",
null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},r=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")};this.anchors.bind(b.event+".tabs",
function(){var g=this,f=d(this).closest("li"),j=a.panels.filter(":not(.ui-tabs-hide)"),l=d(a._sanitizeSelector(this.hash));if(f.hasClass("ui-tabs-selected")&&!b.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}b.selected=a.anchors.index(this);a.abort();if(b.collapsible)if(f.hasClass("ui-tabs-selected")){b.selected=-1;b.cookie&&a._cookie(b.selected,b.cookie);a.element.queue("tabs",function(){r(g,
j)}).dequeue("tabs");this.blur();return false}else if(!j.length){b.cookie&&a._cookie(b.selected,b.cookie);a.element.queue("tabs",function(){q(g,l)});a.load(a.anchors.index(this));this.blur();return false}b.cookie&&a._cookie(b.selected,b.cookie);if(l.length){j.length&&a.element.queue("tabs",function(){r(g,j)});a.element.queue("tabs",function(){q(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier.";d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",
function(){return false})},destroy:function(){var c=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e=d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(b,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,
"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});c.cookie&&this._cookie(null,c.cookie);return this},add:function(c,e,a){if(a===undefined)a=this.anchors.length;var b=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,c).replace(/#\{label\}/g,e));c=!c.indexOf("#")?c.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",
true);var i=d("#"+c);i.length||(i=d(h.panelTemplate).attr("id",c).data("destroy.tabs",true));i.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);i.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]);i.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");i.removeClass("ui-tabs-hide");
this.element.queue("tabs",function(){b._trigger("show",null,b._ui(b.anchors[0],b.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(c){var e=this.options,a=this.lis.eq(c).remove(),b=this.panels.eq(c).remove();if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(c+(c+1<this.anchors.length?1:-1));e.disabled=d.map(d.grep(e.disabled,function(h){return h!=c}),function(h){return h>=c?--h:h});this._tabify();this._trigger("remove",
null,this._ui(a.find("a")[0],b[0]));return this},enable:function(c){var e=this.options;if(d.inArray(c,e.disabled)!=-1){this.lis.eq(c).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=c});this._trigger("enable",null,this._ui(this.anchors[c],this.panels[c]));return this}},disable:function(c){var e=this.options;if(c!=e.selected){this.lis.eq(c).addClass("ui-state-disabled");e.disabled.push(c);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[c],this.panels[c]))}return this},
select:function(c){if(typeof c=="string")c=this.anchors.index(this.anchors.filter("[href$="+c+"]"));else if(c===null)c=-1;if(c==-1&&this.options.collapsible)c=this.options.selected;this.anchors.eq(c).trigger(this.options.event+".tabs");return this},load:function(c){var e=this,a=this.options,b=this.anchors.eq(c)[0],h=d.data(b,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(b,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(c).addClass("ui-state-processing");
if(a.spinner){var i=d("span",b);i.data("label.tabs",i.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){d(e._sanitizeSelector(b.hash)).html(k);e._cleanup();a.cache&&d.data(b,"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[c],e.panels[c]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[c],e.panels[c]));try{a.ajaxOptions.error(k,n,c,b)}catch(m){}}}));e.element.dequeue("tabs");return this}},
abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this},url:function(c,e){this.anchors.eq(c).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.1"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(c,e){var a=this,b=this.options,h=a._rotate||(a._rotate=
function(i){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=b.selected;a.select(++k<a.anchors.length?k:0)},c);i&&i.stopPropagation()});e=a._unrotate||(a._unrotate=!e?function(i){i.clientX&&a.rotate(null)}:function(){t=b.selected;h()});if(c){this.element.bind("tabsshow",h);this.anchors.bind(b.event+".tabs",e);h()}else{clearTimeout(a.rotation);this.element.unbind("tabsshow",h);this.anchors.unbind(b.event+".tabs",e);delete this._rotate;delete this._unrotate}return this}})})(jQuery);

/**
 * jQuery UI Effects 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Effects/
 */
jQuery.effects||function(f){function k(c){var a;if(c&&c.constructor==Array&&c.length==3)return c;if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)];if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return[parseInt(a[1],
16),parseInt(a[2],16),parseInt(a[3],16)];if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];if(/rgba\(0, 0, 0, 0\)/.exec(c))return l.transparent;return l[f.trim(c).toLowerCase()]}function q(c,a){var b;do{b=f.curCSS(c,a);if(b!=""&&b!="transparent"||f.nodeName(c,"body"))break;a="backgroundColor"}while(c=c.parentNode);return k(b)}function m(){var c=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,
a={},b,d;if(c&&c.length&&c[0]&&c[c[0]])for(var e=c.length;e--;){b=c[e];if(typeof c[b]=="string"){d=b.replace(/\-(\w)/g,function(g,h){return h.toUpperCase()});a[d]=c[b]}}else for(b in c)if(typeof c[b]==="string")a[b]=c[b];return a}function n(c){var a,b;for(a in c){b=c[a];if(b==null||f.isFunction(b)||a in r||/scrollbar/.test(a)||!/color/i.test(a)&&isNaN(parseFloat(b)))delete c[a]}return c}function s(c,a){var b={_:0},d;for(d in a)if(c[d]!=a[d])b[d]=a[d];return b}function j(c,a,b,d){if(typeof c=="object"){d=
a;b=null;a=c;c=a.effect}if(f.isFunction(a)){d=a;b=null;a={}}if(f.isFunction(b)){d=b;b=null}if(typeof a=="number"||f.fx.speeds[a]){d=b;b=a;a={}}a=a||{};b=b||a.duration;b=f.fx.off?0:typeof b=="number"?b:f.fx.speeds[b]||f.fx.speeds._default;d=d||a.complete;return[c,a,b,d]}f.effects={};f.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","color","outlineColor"],function(c,a){f.fx.step[a]=function(b){if(!b.colorInit){b.start=q(b.elem,a);b.end=k(b.end);b.colorInit=
true}b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2],10),255),0)+")"}});var l={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,
183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,
165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},o=["add","remove","toggle"],r={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};f.effects.animateClass=function(c,a,b,d){if(f.isFunction(b)){d=b;b=null}return this.each(function(){var e=f(this),g=e.attr("style")||" ",h=n(m.call(this)),p,t=e.attr("className");f.each(o,function(u,
i){c[i]&&e[i+"Class"](c[i])});p=n(m.call(this));e.attr("className",t);e.animate(s(h,p),a,b,function(){f.each(o,function(u,i){c[i]&&e[i+"Class"](c[i])});if(typeof e.attr("style")=="object"){e.attr("style").cssText="";e.attr("style").cssText=g}else e.attr("style",g);d&&d.apply(this,arguments)})})};f.fn.extend({_addClass:f.fn.addClass,addClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{add:c},a,b,d]):this._addClass(c)},_removeClass:f.fn.removeClass,removeClass:function(c,a,b,d){return a?
f.effects.animateClass.apply(this,[{remove:c},a,b,d]):this._removeClass(c)},_toggleClass:f.fn.toggleClass,toggleClass:function(c,a,b,d,e){return typeof a=="boolean"||a===undefined?b?f.effects.animateClass.apply(this,[a?{add:c}:{remove:c},b,d,e]):this._toggleClass(c,a):f.effects.animateClass.apply(this,[{toggle:c},a,b,d])},switchClass:function(c,a,b,d,e){return f.effects.animateClass.apply(this,[{add:a,remove:c},b,d,e])}});f.extend(f.effects,{version:"1.8.1",save:function(c,a){for(var b=0;b<a.length;b++)a[b]!==
null&&c.data("ec.storage."+a[b],c[0].style[a[b]])},restore:function(c,a){for(var b=0;b<a.length;b++)a[b]!==null&&c.css(a[b],c.data("ec.storage."+a[b]))},setMode:function(c,a){if(a=="toggle")a=c.is(":hidden")?"show":"hide";return a},getBaseline:function(c,a){var b;switch(c[0]){case "top":b=0;break;case "middle":b=0.5;break;case "bottom":b=1;break;default:b=c[0]/a.height}switch(c[1]){case "left":c=0;break;case "center":c=0.5;break;case "right":c=1;break;default:c=c[1]/a.width}return{x:c,y:b}},createWrapper:function(c){if(c.parent().is(".ui-effects-wrapper"))return c.parent();
var a={width:c.outerWidth(true),height:c.outerHeight(true),"float":c.css("float")},b=f("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});c.wrap(b);b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(d,e){a[e]=c.css(e);if(isNaN(parseInt(a[e],10)))a[e]="auto"});
c.css({position:"relative",top:0,left:0})}return b.css(a).show()},removeWrapper:function(c){if(c.parent().is(".ui-effects-wrapper"))return c.parent().replaceWith(c);return c},setTransition:function(c,a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0)d[g]=unit[0]*b+unit[1]});return d}});f.fn.extend({effect:function(c){var a=j.apply(this,arguments);a={options:a[1],duration:a[2],callback:a[3]};var b=f.effects[c];return b&&!f.fx.off?b.call(this,a):this},_show:f.fn.show,show:function(c){if(!c||
typeof c=="number"||f.fx.speeds[c])return this._show.apply(this,arguments);else{var a=j.apply(this,arguments);a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(!c||typeof c=="number"||f.fx.speeds[c])return this._hide.apply(this,arguments);else{var a=j.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(!c||typeof c=="number"||f.fx.speeds[c]||typeof c=="boolean"||f.isFunction(c))return this.__toggle.apply(this,
arguments);else{var a=j.apply(this,arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%","pt"],function(d,e){if(a.indexOf(e)>0)b=[parseFloat(a),e]});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return-d*(a/=e)*(a-2)+b},easeInOutQuad:function(c,
a,b,d,e){if((a/=e/2)<1)return d/2*a*a+b;return-d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a+b;return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return-d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a+b;return-d/2*((a-=2)*a*a*a-2)+
b},easeInQuint:function(c,a,b,d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a*a+b;return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2,
10*(a/e-1))+b},easeOutExpo:function(c,a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0)return b;if(a==e)return b+d;if((a/=e/2)<1)return d/2*Math.pow(2,10*(a-1))+b;return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return-d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1)return-d/2*(Math.sqrt(1-a*a)-1)+b;return d/2*(Math.sqrt(1-(a-=2)*
a)+1)+b},easeInElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);return-(h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g))+b},easeOutElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);return h*Math.pow(2,-10*a)*Math.sin((a*e-c)*2*Math.PI/g)+d+b},easeInOutElastic:function(c,
a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e/2)==2)return b+d;g||(g=e*0.3*1.5);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);if(a<1)return-0.5*h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)+b;return h*Math.pow(2,-10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)*0.5+d+b},easeInBack:function(c,a,b,d,e,g){if(g==undefined)g=1.70158;return d*(a/=e)*a*((g+1)*a-g)+b},easeOutBack:function(c,a,b,d,e,g){if(g==undefined)g=1.70158;return d*((a=a/e-1)*a*((g+1)*a+g)+1)+b},easeInOutBack:function(c,
a,b,d,e,g){if(g==undefined)g=1.70158;if((a/=e/2)<1)return d/2*a*a*(((g*=1.525)+1)*a-g)+b;return d/2*((a-=2)*a*(((g*=1.525)+1)*a+g)+2)+b},easeInBounce:function(c,a,b,d,e){return d-f.easing.easeOutBounce(c,e-a,0,d,e)+b},easeOutBounce:function(c,a,b,d,e){return(a/=e)<1/2.75?d*7.5625*a*a+b:a<2/2.75?d*(7.5625*(a-=1.5/2.75)*a+0.75)+b:a<2.5/2.75?d*(7.5625*(a-=2.25/2.75)*a+0.9375)+b:d*(7.5625*(a-=2.625/2.75)*a+0.984375)+b},easeInOutBounce:function(c,a,b,d,e){if(a<e/2)return f.easing.easeInBounce(c,a*2,0,
d,e)*0.5+b;return f.easing.easeOutBounce(c,a*2-e,0,d,e)*0.5+d*0.5+b}})}(jQuery);

/*
 * jQuery UI Effects Slide 1.8.1
 *
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://docs.jquery.com/UI/Effects/Slide
 *
 * Depends:
 *    jquery.effects.core.js
 */
(function(c){c.effects.slide=function(d){return this.queue(function(){var a=c(this),h=["position","top","left"],e=c.effects.setMode(a,d.options.mode||"show"),b=d.options.direction||"left";c.effects.save(a,h);a.show();c.effects.createWrapper(a).css({overflow:"hidden"});var f=b=="up"||b=="down"?"top":"left";b=b=="up"||b=="left"?"pos":"neg";var g=d.options.distance||(f=="top"?a.outerHeight({margin:true}):a.outerWidth({margin:true}));if(e=="show")a.css(f,b=="pos"?-g:g);var i={};i[f]=(e=="show"?b=="pos"?
"+=":"-=":b=="pos"?"-=":"+=")+g;a.animate(i,{queue:false,duration:d.duration,easing:d.options.easing,complete:function(){e=="hide"&&a.hide();c.effects.restore(a,h);c.effects.removeWrapper(a);d.callback&&d.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery);

/*
 * jQuery Tools 1.2.5 - The missing UI library for the Web
 * 
 * [tooltip, tooltip.dynamic]
 * 
 * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
 * 
 * http://flowplayer.org/tools/
 * 
 * File generated: Tue Jan 25 15:08:48 GMT 2011
 */
(function(f){function p(a,b,c){var h=c.relative?a.position().top:a.offset().top,d=c.relative?a.position().left:a.offset().left,i=c.position[0];h-=b.outerHeight()-c.offset[0];d+=a.outerWidth()+c.offset[1];if(/iPad/i.test(navigator.userAgent))h-=f(window).scrollTop();var j=b.outerHeight()+a.outerHeight();if(i=="center")h+=j/2;if(i=="bottom")h+=j;i=c.position[1];a=b.outerWidth()+a.outerWidth();if(i=="center")d-=a/2;if(i=="left")d-=a;return{top:h,left:d}}function u(a,b){var c=this,h=a.add(c),d,i=0,j=
0,m=a.attr("title"),q=a.attr("data-tooltip"),r=o[b.effect],l,s=a.is(":input"),v=s&&a.is(":checkbox, :radio, select, :button, :submit"),t=a.attr("type"),k=b.events[t]||b.events[s?v?"widget":"input":"def"];if(!r)throw'Nonexistent effect "'+b.effect+'"';k=k.split(/,\s*/);if(k.length!=2)throw"Tooltip: bad events configuration for "+t;a.bind(k[0],function(e){clearTimeout(i);if(b.predelay)j=setTimeout(function(){c.show(e)},b.predelay);else c.show(e)}).bind(k[1],function(e){clearTimeout(j);if(b.delay)i=
setTimeout(function(){c.hide(e)},b.delay);else c.hide(e)});if(m&&b.cancelDefault){a.removeAttr("title");a.data("title",m)}f.extend(c,{show:function(e){if(!d){if(q)d=f(q);else if(b.tip)d=f(b.tip).eq(0);else if(m)d=f(b.layout).addClass(b.tipClass).appendTo(document.body).hide().append(m);else{d=a.next();d.length||(d=a.parent().next())}if(!d.length)throw"Cannot find tooltip for "+a;}if(c.isShown())return c;d.stop(true,true);var g=p(a,d,b);b.tip&&d.html(a.data("title"));e=e||f.Event();e.type="onBeforeShow";
h.trigger(e,[g]);if(e.isDefaultPrevented())return c;g=p(a,d,b);d.css({position:"absolute",top:g.top,left:g.left});l=true;r[0].call(c,function(){e.type="onShow";l="full";h.trigger(e)});g=b.events.tooltip.split(/,\s*/);if(!d.data("__set")){d.bind(g[0],function(){clearTimeout(i);clearTimeout(j)});g[1]&&!a.is("input:not(:checkbox, :radio), textarea")&&d.bind(g[1],function(n){n.relatedTarget!=a[0]&&a.trigger(k[1].split(" ")[0])});d.data("__set",true)}return c},hide:function(e){if(!d||!c.isShown())return c;
e=e||f.Event();e.type="onBeforeHide";h.trigger(e);if(!e.isDefaultPrevented()){l=false;o[b.effect][1].call(c,function(){e.type="onHide";h.trigger(e)});return c}},isShown:function(e){return e?l=="full":l},getConf:function(){return b},getTip:function(){return d},getTrigger:function(){return a}});f.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(e,g){f.isFunction(b[g])&&f(c).bind(g,b[g]);c[g]=function(n){n&&f(c).bind(g,n);return c}})}f.tools=f.tools||{version:"1.2.5"};f.tools.tooltip=
{conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,position:["top","center"],offset:[0,0],relative:false,cancelDefault:true,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,b,c){o[a]=[b,c]}};var o={toggle:[function(a){var b=this.getConf(),c=this.getTip();b=b.opacity;b<1&&c.css({opacity:b});c.show();a.call()},function(a){this.getTip().hide();
a.call()}],fade:[function(a){var b=this.getConf();this.getTip().fadeTo(b.fadeInSpeed,b.opacity,a)},function(a){this.getTip().fadeOut(this.getConf().fadeOutSpeed,a)}]};f.fn.tooltip=function(a){var b=this.data("tooltip");if(b)return b;a=f.extend(true,{},f.tools.tooltip.conf,a);if(typeof a.position=="string")a.position=a.position.split(/,?\s/);this.each(function(){b=new u(f(this),a);f(this).data("tooltip",b)});return a.api?b:this}})(jQuery);
(function(g){function j(a){var c=g(window),d=c.width()+c.scrollLeft(),h=c.height()+c.scrollTop();return[a.offset().top<=c.scrollTop(),d<=a.offset().left+a.width(),h<=a.offset().top+a.height(),c.scrollLeft()>=a.offset().left]}function k(a){for(var c=a.length;c--;)if(a[c])return false;return true}var i=g.tools.tooltip;i.dynamic={conf:{classNames:"top right bottom left"}};g.fn.dynamic=function(a){if(typeof a=="number")a={speed:a};a=g.extend({},i.dynamic.conf,a);var c=a.classNames.split(/\s/),d;this.each(function(){var h=
g(this).tooltip().onBeforeShow(function(e,f){e=this.getTip();var b=this.getConf();d||(d=[b.position[0],b.position[1],b.offset[0],b.offset[1],g.extend({},b)]);g.extend(b,d[4]);b.position=[d[0],d[1]];b.offset=[d[2],d[3]];e.css({visibility:"hidden",position:"absolute",top:f.top,left:f.left}).show();f=j(e);if(!k(f)){if(f[2]){g.extend(b,a.top);b.position[0]="top";e.addClass(c[0])}if(f[3]){g.extend(b,a.right);b.position[1]="right";e.addClass(c[1])}if(f[0]){g.extend(b,a.bottom);b.position[0]="bottom";e.addClass(c[2])}if(f[1]){g.extend(b,
a.left);b.position[1]="left";e.addClass(c[3])}if(f[0]||f[2])b.offset[0]*=-1;if(f[1]||f[3])b.offset[1]*=-1}e.css({visibility:"visible"}).hide()});h.onBeforeShow(function(){var e=this.getConf();this.getTip();setTimeout(function(){e.position=[d[0],d[1]];e.offset=[d[2],d[3]]},0)});h.onHide(function(){var e=this.getTip();e.removeClass(a.classNames)});ret=h});return a.api?ret:this}})(jQuery);


/*
 * jQuery Cycle Plugin (core engine)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2010 M. Alsup
 * Version: 2.88 (08-JUN-2010)
 * Dual licensed under the MIT and GPL licenses.
 * http://jquery.malsup.com/license.html
 * Requires: jQuery v1.2.6 or later
 */
(function($){var ver="2.88";if($.support==undefined){$.support={opacity:!($.browser.msie)};}function debug(s){if($.fn.cycle.debug){log(s);}}function log(){if(window.console&&window.console.log){window.console.log("[cycle] "+Array.prototype.join.call(arguments," "));}}$.fn.cycle=function(options,arg2){var o={s:this.selector,c:this.context};if(this.length===0&&options!="stop"){if(!$.isReady&&o.s){log("DOM not ready, queuing slideshow");$(function(){$(o.s,o.c).cycle(options,arg2);});return this;}log("terminating; zero elements found by selector"+($.isReady?"":" (DOM not ready)"));return this;}return this.each(function(){var opts=handleArguments(this,options,arg2);if(opts===false){return;}opts.updateActivePagerLink=opts.updateActivePagerLink||$.fn.cycle.updateActivePagerLink;if(this.cycleTimeout){clearTimeout(this.cycleTimeout);}this.cycleTimeout=this.cyclePause=0;var $cont=$(this);var $slides=opts.slideExpr?$(opts.slideExpr,this):$cont.children();var els=$slides.get();if(els.length<2){log("terminating; too few slides: "+els.length);return;}var opts2=buildOptions($cont,$slides,els,opts,o);if(opts2===false){return;}var startTime=opts2.continuous?10:getTimeout(els[opts2.currSlide],els[opts2.nextSlide],opts2,!opts2.rev);if(startTime){startTime+=(opts2.delay||0);if(startTime<10){startTime=10;}debug("first timeout: "+startTime);this.cycleTimeout=setTimeout(function(){go(els,opts2,0,(!opts2.rev&&!opts.backwards));},startTime);}});};function handleArguments(cont,options,arg2){if(cont.cycleStop==undefined){cont.cycleStop=0;}if(options===undefined||options===null){options={};}if(options.constructor==String){switch(options){case"destroy":case"stop":var opts=$(cont).data("cycle.opts");if(!opts){return false;}cont.cycleStop++;if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);}cont.cycleTimeout=0;$(cont).removeData("cycle.opts");if(options=="destroy"){destroy(opts);}return false;case"toggle":cont.cyclePause=(cont.cyclePause===1)?0:1;checkInstantResume(cont.cyclePause,arg2,cont);return false;case"pause":cont.cyclePause=1;return false;case"resume":cont.cyclePause=0;checkInstantResume(false,arg2,cont);return false;case"prev":case"next":var opts=$(cont).data("cycle.opts");if(!opts){log('options not found, "prev/next" ignored');return false;}$.fn.cycle[options](opts);return false;default:options={fx:options};}return options;}else{if(options.constructor==Number){var num=options;options=$(cont).data("cycle.opts");if(!options){log("options not found, can not advance slide");return false;}if(num<0||num>=options.elements.length){log("invalid slide index: "+num);return false;}options.nextSlide=num;if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);cont.cycleTimeout=0;}if(typeof arg2=="string"){options.oneTimeFx=arg2;}go(options.elements,options,1,num>=options.currSlide);return false;}}return options;function checkInstantResume(isPaused,arg2,cont){if(!isPaused&&arg2===true){var options=$(cont).data("cycle.opts");if(!options){log("options not found, can not resume");return false;}if(cont.cycleTimeout){clearTimeout(cont.cycleTimeout);cont.cycleTimeout=0;}go(options.elements,options,1,(!opts.rev&&!opts.backwards));}}}function removeFilter(el,opts){if(!$.support.opacity&&opts.cleartype&&el.style.filter){try{el.style.removeAttribute("filter");}catch(smother){}}}function destroy(opts){if(opts.next){$(opts.next).unbind(opts.prevNextEvent);}if(opts.prev){$(opts.prev).unbind(opts.prevNextEvent);}if(opts.pager||opts.pagerAnchorBuilder){$.each(opts.pagerAnchors||[],function(){this.unbind().remove();});}opts.pagerAnchors=null;if(opts.destroy){opts.destroy(opts);}}function buildOptions($cont,$slides,els,options,o){var opts=$.extend({},$.fn.cycle.defaults,options||{},$.metadata?$cont.metadata():$.meta?$cont.data():{});if(opts.autostop){opts.countdown=opts.autostopCount||els.length;}var cont=$cont[0];$cont.data("cycle.opts",opts);opts.$cont=$cont;opts.stopCount=cont.cycleStop;opts.elements=els;opts.before=opts.before?[opts.before]:[];opts.after=opts.after?[opts.after]:[];opts.after.unshift(function(){opts.busy=0;});if(!$.support.opacity&&opts.cleartype){opts.after.push(function(){removeFilter(this,opts);});}if(opts.continuous){opts.after.push(function(){go(els,opts,0,(!opts.rev&&!opts.backwards));});}saveOriginalOpts(opts);if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($slides);}if($cont.css("position")=="static"){$cont.css("position","relative");}if(opts.width){$cont.width(opts.width);}if(opts.height&&opts.height!="auto"){$cont.height(opts.height);}if(opts.startingSlide){opts.startingSlide=parseInt(opts.startingSlide);}else{if(opts.backwards){opts.startingSlide=els.length-1;}}if(opts.random){opts.randomMap=[];for(var i=0;i<els.length;i++){opts.randomMap.push(i);}opts.randomMap.sort(function(a,b){return Math.random()-0.5;});opts.randomIndex=1;opts.startingSlide=opts.randomMap[1];}else{if(opts.startingSlide>=els.length){opts.startingSlide=0;}}opts.currSlide=opts.startingSlide||0;var first=opts.startingSlide;$slides.css({position:"absolute",top:0,left:0}).hide().each(function(i){var z;if(opts.backwards){z=first?i<=first?els.length+(i-first):first-i:els.length-i;}else{z=first?i>=first?els.length-(i-first):first-i:els.length-i;}$(this).css("z-index",z);});$(els[first]).css("opacity",1).show();removeFilter(els[first],opts);if(opts.fit&&opts.width){$slides.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}var reshape=opts.containerResize&&!$cont.innerHeight();if(reshape){var maxw=0,maxh=0;for(var j=0;j<els.length;j++){var $e=$(els[j]),e=$e[0],w=$e.outerWidth(),h=$e.outerHeight();if(!w){w=e.offsetWidth||e.width||$e.attr("width");}if(!h){h=e.offsetHeight||e.height||$e.attr("height");}maxw=w>maxw?w:maxw;maxh=h>maxh?h:maxh;}if(maxw>0&&maxh>0){$cont.css({width:maxw+"px",height:maxh+"px"});}}if(opts.pause){$cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});}if(supportMultiTransitions(opts)===false){return false;}var requeue=false;options.requeueAttempts=options.requeueAttempts||0;$slides.each(function(){var $el=$(this);this.cycleH=(opts.fit&&opts.height)?opts.height:($el.height()||this.offsetHeight||this.height||$el.attr("height")||0);this.cycleW=(opts.fit&&opts.width)?opts.width:($el.width()||this.offsetWidth||this.width||$el.attr("width")||0);if($el.is("img")){var loadingIE=($.browser.msie&&this.cycleW==28&&this.cycleH==30&&!this.complete);var loadingFF=($.browser.mozilla&&this.cycleW==34&&this.cycleH==19&&!this.complete);var loadingOp=($.browser.opera&&((this.cycleW==42&&this.cycleH==19)||(this.cycleW==37&&this.cycleH==17))&&!this.complete);var loadingOther=(this.cycleH==0&&this.cycleW==0&&!this.complete);if(loadingIE||loadingFF||loadingOp||loadingOther){if(o.s&&opts.requeueOnImageNotLoaded&&++options.requeueAttempts<100){log(options.requeueAttempts," - img slide not loaded, requeuing slideshow: ",this.src,this.cycleW,this.cycleH);setTimeout(function(){$(o.s,o.c).cycle(options);},opts.requeueTimeout);requeue=true;return false;}else{log("could not determine size of image: "+this.src,this.cycleW,this.cycleH);}}}return true;});if(requeue){return false;}opts.cssBefore=opts.cssBefore||{};opts.animIn=opts.animIn||{};opts.animOut=opts.animOut||{};$slides.not(":eq("+first+")").css(opts.cssBefore);if(opts.cssFirst){$($slides[first]).css(opts.cssFirst);}if(opts.timeout){opts.timeout=parseInt(opts.timeout);if(opts.speed.constructor==String){opts.speed=$.fx.speeds[opts.speed]||parseInt(opts.speed);}if(!opts.sync){opts.speed=opts.speed/2;}var buffer=opts.fx=="shuffle"?500:250;while((opts.timeout-opts.speed)<buffer){opts.timeout+=opts.speed;}}if(opts.easing){opts.easeIn=opts.easeOut=opts.easing;}if(!opts.speedIn){opts.speedIn=opts.speed;}if(!opts.speedOut){opts.speedOut=opts.speed;}opts.slideCount=els.length;opts.currSlide=opts.lastSlide=first;if(opts.random){if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{if(opts.backwards){opts.nextSlide=opts.startingSlide==0?(els.length-1):opts.startingSlide-1;}else{opts.nextSlide=opts.startingSlide>=(els.length-1)?0:opts.startingSlide+1;}}if(!opts.multiFx){var init=$.fn.cycle.transitions[opts.fx];if($.isFunction(init)){init($cont,$slides,opts);}else{if(opts.fx!="custom"&&!opts.multiFx){log("unknown transition: "+opts.fx,"; slideshow terminating");return false;}}}var e0=$slides[first];if(opts.before.length){opts.before[0].apply(e0,[e0,e0,opts,true]);}if(opts.after.length>1){opts.after[1].apply(e0,[e0,e0,opts,true]);}if(opts.next){$(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?-1:1);});}if(opts.prev){$(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?1:-1);});}if(opts.pager||opts.pagerAnchorBuilder){buildPager(els,opts);}exposeAddSlide(opts,els);return opts;}function saveOriginalOpts(opts){opts.original={before:[],after:[]};opts.original.cssBefore=$.extend({},opts.cssBefore);opts.original.cssAfter=$.extend({},opts.cssAfter);opts.original.animIn=$.extend({},opts.animIn);opts.original.animOut=$.extend({},opts.animOut);$.each(opts.before,function(){opts.original.before.push(this);});$.each(opts.after,function(){opts.original.after.push(this);});}function supportMultiTransitions(opts){var i,tx,txs=$.fn.cycle.transitions;if(opts.fx.indexOf(",")>0){opts.multiFx=true;opts.fxs=opts.fx.replace(/\s*/g,"").split(",");for(i=0;i<opts.fxs.length;i++){var fx=opts.fxs[i];tx=txs[fx];if(!tx||!txs.hasOwnProperty(fx)||!$.isFunction(tx)){log("discarding unknown transition: ",fx);opts.fxs.splice(i,1);i--;}}if(!opts.fxs.length){log("No valid transitions named; slideshow terminating.");return false;}}else{if(opts.fx=="all"){opts.multiFx=true;opts.fxs=[];for(p in txs){tx=txs[p];if(txs.hasOwnProperty(p)&&$.isFunction(tx)){opts.fxs.push(p);}}}}if(opts.multiFx&&opts.randomizeEffects){var r1=Math.floor(Math.random()*20)+30;for(i=0;i<r1;i++){var r2=Math.floor(Math.random()*opts.fxs.length);opts.fxs.push(opts.fxs.splice(r2,1)[0]);}debug("randomized fx sequence: ",opts.fxs);}return true;}function exposeAddSlide(opts,els){opts.addSlide=function(newSlide,prepend){var $s=$(newSlide),s=$s[0];if(!opts.autostopCount){opts.countdown++;}els[prepend?"unshift":"push"](s);if(opts.els){opts.els[prepend?"unshift":"push"](s);}opts.slideCount=els.length;$s.css("position","absolute");$s[prepend?"prependTo":"appendTo"](opts.$cont);if(prepend){opts.currSlide++;opts.nextSlide++;}if(!$.support.opacity&&opts.cleartype&&!opts.cleartypeNoBg){clearTypeFix($s);}if(opts.fit&&opts.width){$s.width(opts.width);}if(opts.fit&&opts.height&&opts.height!="auto"){$slides.height(opts.height);}s.cycleH=(opts.fit&&opts.height)?opts.height:$s.height();s.cycleW=(opts.fit&&opts.width)?opts.width:$s.width();$s.css(opts.cssBefore);if(opts.pager||opts.pagerAnchorBuilder){$.fn.cycle.createPagerAnchor(els.length-1,s,$(opts.pager),els,opts);}if($.isFunction(opts.onAddSlide)){opts.onAddSlide($s);}else{$s.hide();}};}$.fn.cycle.resetState=function(opts,fx){fx=fx||opts.fx;opts.before=[];opts.after=[];opts.cssBefore=$.extend({},opts.original.cssBefore);opts.cssAfter=$.extend({},opts.original.cssAfter);opts.animIn=$.extend({},opts.original.animIn);opts.animOut=$.extend({},opts.original.animOut);opts.fxFn=null;$.each(opts.original.before,function(){opts.before.push(this);});$.each(opts.original.after,function(){opts.after.push(this);});var init=$.fn.cycle.transitions[fx];if($.isFunction(init)){init(opts.$cont,$(opts.elements),opts);}};function go(els,opts,manual,fwd){if(manual&&opts.busy&&opts.manualTrump){debug("manualTrump in go(), stopping active transition");$(els).stop(true,true);opts.busy=false;}if(opts.busy){debug("transition active, ignoring new tx request");return;}var p=opts.$cont[0],curr=els[opts.currSlide],next=els[opts.nextSlide];if(p.cycleStop!=opts.stopCount||p.cycleTimeout===0&&!manual){return;}if(!manual&&!p.cyclePause&&!opts.bounce&&((opts.autostop&&(--opts.countdown<=0))||(opts.nowrap&&!opts.random&&opts.nextSlide<opts.currSlide))){if(opts.end){opts.end(opts);}return;}var changed=false;if((manual||!p.cyclePause)&&(opts.nextSlide!=opts.currSlide)){changed=true;var fx=opts.fx;curr.cycleH=curr.cycleH||$(curr).height();curr.cycleW=curr.cycleW||$(curr).width();next.cycleH=next.cycleH||$(next).height();next.cycleW=next.cycleW||$(next).width();if(opts.multiFx){if(opts.lastFx==undefined||++opts.lastFx>=opts.fxs.length){opts.lastFx=0;}fx=opts.fxs[opts.lastFx];opts.currFx=fx;}if(opts.oneTimeFx){fx=opts.oneTimeFx;opts.oneTimeFx=null;}$.fn.cycle.resetState(opts,fx);if(opts.before.length){$.each(opts.before,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});}var after=function(){$.each(opts.after,function(i,o){if(p.cycleStop!=opts.stopCount){return;}o.apply(next,[curr,next,opts,fwd]);});};debug("tx firing; currSlide: "+opts.currSlide+"; nextSlide: "+opts.nextSlide);opts.busy=1;if(opts.fxFn){opts.fxFn(curr,next,opts,after,fwd,manual&&opts.fastOnEvent);}else{if($.isFunction($.fn.cycle[opts.fx])){$.fn.cycle[opts.fx](curr,next,opts,after,fwd,manual&&opts.fastOnEvent);}else{$.fn.cycle.custom(curr,next,opts,after,fwd,manual&&opts.fastOnEvent);}}}if(changed||opts.nextSlide==opts.currSlide){opts.lastSlide=opts.currSlide;if(opts.random){opts.currSlide=opts.nextSlide;if(++opts.randomIndex==els.length){opts.randomIndex=0;}opts.nextSlide=opts.randomMap[opts.randomIndex];if(opts.nextSlide==opts.currSlide){opts.nextSlide=(opts.currSlide==opts.slideCount-1)?0:opts.currSlide+1;}}else{if(opts.backwards){var roll=(opts.nextSlide-1)<0;if(roll&&opts.bounce){opts.backwards=!opts.backwards;opts.nextSlide=1;opts.currSlide=0;}else{opts.nextSlide=roll?(els.length-1):opts.nextSlide-1;opts.currSlide=roll?0:opts.nextSlide+1;}}else{var roll=(opts.nextSlide+1)==els.length;if(roll&&opts.bounce){opts.backwards=!opts.backwards;opts.nextSlide=els.length-2;opts.currSlide=els.length-1;}else{opts.nextSlide=roll?0:opts.nextSlide+1;opts.currSlide=roll?els.length-1:opts.nextSlide-1;}}}}if(changed&&opts.pager){opts.updateActivePagerLink(opts.pager,opts.currSlide,opts.activePagerClass);}var ms=0;if(opts.timeout&&!opts.continuous){ms=getTimeout(els[opts.currSlide],els[opts.nextSlide],opts,fwd);}else{if(opts.continuous&&p.cyclePause){ms=10;}}if(ms>0){p.cycleTimeout=setTimeout(function(){go(els,opts,0,(!opts.rev&&!opts.backwards));},ms);}}$.fn.cycle.updateActivePagerLink=function(pager,currSlide,clsName){$(pager).each(function(){$(this).children().removeClass(clsName).eq(currSlide).addClass(clsName);});};function getTimeout(curr,next,opts,fwd){if(opts.timeoutFn){var t=opts.timeoutFn.call(curr,curr,next,opts,fwd);while((t-opts.speed)<250){t+=opts.speed;}debug("calculated timeout: "+t+"; speed: "+opts.speed);if(t!==false){return t;}}return opts.timeout;}$.fn.cycle.next=function(opts){advance(opts,opts.rev?-1:1);};$.fn.cycle.prev=function(opts){advance(opts,opts.rev?1:-1);};function advance(opts,val){var els=opts.elements;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}if(opts.random&&val<0){opts.randomIndex--;if(--opts.randomIndex==-2){opts.randomIndex=els.length-2;}else{if(opts.randomIndex==-1){opts.randomIndex=els.length-1;}}opts.nextSlide=opts.randomMap[opts.randomIndex];}else{if(opts.random){opts.nextSlide=opts.randomMap[opts.randomIndex];}else{opts.nextSlide=opts.currSlide+val;if(opts.nextSlide<0){if(opts.nowrap){return false;}opts.nextSlide=els.length-1;}else{if(opts.nextSlide>=els.length){if(opts.nowrap){return false;}opts.nextSlide=0;}}}}var cb=opts.onPrevNextEvent||opts.prevNextClick;if($.isFunction(cb)){cb(val>0,opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,val>=0);return false;}function buildPager(els,opts){var $p=$(opts.pager);$.each(els,function(i,o){$.fn.cycle.createPagerAnchor(i,o,$p,els,opts);});opts.updateActivePagerLink(opts.pager,opts.startingSlide,opts.activePagerClass);}$.fn.cycle.createPagerAnchor=function(i,el,$p,els,opts){var a;if($.isFunction(opts.pagerAnchorBuilder)){a=opts.pagerAnchorBuilder(i,el);debug("pagerAnchorBuilder("+i+", el) returned: "+a);}else{a='<a href="#">'+(i+1)+"</a>";}if(!a){return;}var $a=$(a);if($a.parents("body").length===0){var arr=[];if($p.length>1){$p.each(function(){var $clone=$a.clone(true);$(this).append($clone);arr.push($clone[0]);});$a=$(arr);}else{$a.appendTo($p);}}opts.pagerAnchors=opts.pagerAnchors||[];opts.pagerAnchors.push($a);$a.bind(opts.pagerEvent,function(e){e.preventDefault();opts.nextSlide=i;var p=opts.$cont[0],timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}var cb=opts.onPagerEvent||opts.pagerClick;if($.isFunction(cb)){cb(opts.nextSlide,els[opts.nextSlide]);}go(els,opts,1,opts.currSlide<i);});if(!/^click/.test(opts.pagerEvent)&&!opts.allowPagerClickBubble){$a.bind("click.cycle",function(){return false;});}if(opts.pauseOnPagerHover){$a.hover(function(){opts.$cont[0].cyclePause++;},function(){opts.$cont[0].cyclePause--;});}};$.fn.cycle.hopsFromLast=function(opts,fwd){var hops,l=opts.lastSlide,c=opts.currSlide;if(fwd){hops=c>l?c-l:opts.slideCount-l;}else{hops=c<l?l-c:l+opts.slideCount-c;}return hops;};function clearTypeFix($slides){debug("applying clearType background-color hack");function hex(s){s=parseInt(s).toString(16);return s.length<2?"0"+s:s;}function getBg(e){for(;e&&e.nodeName.toLowerCase()!="html";e=e.parentNode){var v=$.css(e,"background-color");if(v.indexOf("rgb")>=0){var rgb=v.match(/\d+/g);return"#"+hex(rgb[0])+hex(rgb[1])+hex(rgb[2]);}if(v&&v!="transparent"){return v;}}return"#ffffff";}$slides.each(function(){$(this).css("background-color",getBg(this));});}$.fn.cycle.commonReset=function(curr,next,opts,w,h,rev){$(opts.elements).not(curr).hide();opts.cssBefore.opacity=1;opts.cssBefore.display="block";if(w!==false&&next.cycleW>0){opts.cssBefore.width=next.cycleW;}if(h!==false&&next.cycleH>0){opts.cssBefore.height=next.cycleH;}opts.cssAfter=opts.cssAfter||{};opts.cssAfter.display="none";$(curr).css("zIndex",opts.slideCount+(rev===true?1:0));$(next).css("zIndex",opts.slideCount+(rev===true?0:1));};$.fn.cycle.custom=function(curr,next,opts,cb,fwd,speedOverride){var $l=$(curr),$n=$(next);var speedIn=opts.speedIn,speedOut=opts.speedOut,easeIn=opts.easeIn,easeOut=opts.easeOut;$n.css(opts.cssBefore);if(speedOverride){if(typeof speedOverride=="number"){speedIn=speedOut=speedOverride;}else{speedIn=speedOut=1;}easeIn=easeOut=null;}var fn=function(){$n.animate(opts.animIn,speedIn,easeIn,cb);};$l.animate(opts.animOut,speedOut,easeOut,function(){if(opts.cssAfter){$l.css(opts.cssAfter);}if(!opts.sync){fn();}});if(opts.sync){fn();}};$.fn.cycle.transitions={fade:function($cont,$slides,opts){$slides.not(":eq("+opts.currSlide+")").css("opacity",0);opts.before.push(function(curr,next,opts){$.fn.cycle.commonReset(curr,next,opts);opts.cssBefore.opacity=0;});opts.animIn={opacity:1};opts.animOut={opacity:0};opts.cssBefore={top:0,left:0};}};$.fn.cycle.ver=function(){return ver;};$.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,onPrevNextEvent:null,prevNextEvent:"click.cycle",pager:null,onPagerEvent:null,pagerEvent:"click.cycle",allowPagerClickBubble:false,pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!$.support.opacity,cleartypeNoBg:false,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250,activePagerClass:"activeSlide",updateActivePagerLink:null,backwards:false};})(jQuery);

/**
 * jQuery UI: Radiobutton- und Checkbox-Replacement
 * @author alexander.farkas
 * @version 1.4.1
 */
(function($){
    var baseClasses = /ui-checkbox|ui-radio/;
    $.widget('ui.checkBox', {
        options: {
            hideInput: true,
            addVisualElement: true,
            addLabel: true,
            _delegated: false
        },
        _create: function(){
            var that = this, 
                opts = this.options
            ;
            
            if(!this.element.is(':radio,:checkbox')){
                if($.nodeName(this.element[0], 'input')){return false;}
                this._addDelegate();
                this.updateContainer();
                return false;
            }
            this.labels = $([]);
            
            this.checkedStatus = false;
            this.disabledStatus = false;
            this.hoverStatus = false;
            
            this.radio = (this.element.is(':radio'));
                    
            this.visualElement = $([]);
            if (opts.hideInput) {
                this.element
                    .addClass('ui-helper-hidden-accessible')
                ;
                if(opts.addVisualElement){
                    this.visualElement = $('<span />')
                        .addClass(this.radio ? 'ui-radio' : 'ui-checkbox')
                    ;
                    this.element.after(this.visualElement[0]);
                }
            }
            
            if(opts.addLabel){
                this.labels = $('label[for=' + this.element.attr('id') + ']')
                    .addClass(this.radio ? 'ui-radio' : 'ui-checkbox')
                ;
            }
            if(!opts._delegated){
                this._addEvents();
            }
            this.initialized = true;
            this.reflectUI({type: 'initialReflect'});
            return undefined;
        },
        updateContainer: function(){
            if(!this.element.is(':radio,:checkbox') && !$.nodeName(this.element[0], 'input')){
                $('input', this.element[0])
                    .filter(function(){
                        return !($.data(this, 'checkBox'));
                    })
                    .checkBox($.extend({}, this.options, {_delegated: true}))
                ;
            }
        },
        _addDelegate: function(){
            var opts         = this.options,
                    
                toggleHover = function(e, that){
                    if(!that){return;}
                    that.hover = !!(e.type == 'focus' || e.type == 'mouseenter' || e.type == 'focusin' || e.type == 'mouseover');
                    that._changeStateClassChain.call(that);
                    return undefined;
                }
            ;
            
            
            this.element
                .bind('click', function(e){
                    if(!$.nodeName(e.target, 'input')){return;}
                    var inst = ($.data(e.target) || {}).checkBox;
                    if(!inst){return;}
                    inst.reflectUI.call(inst, e.target, e);
                })
                .bind('focusin.checkBox focusout.checkBox', function(e){
                    if(!$.nodeName(e.target, 'input')){return;}
                    var inst = ($.data(e.target) || {}).checkBox;
                    toggleHover(e, inst);
                })
            ;
            
            if (opts.hideInput){
                this.element
                    .bind('usermode', function(e){
                        if(!e.enabled){return;}
                        $('input', this).each(function(){
                            var inst = ($.data(this) || {}).checkBox;
                            (inst && inst.destroy.call(inst, true));
                        });
                    })
                ;
            }
            
            if(opts.addVisualElement){
                this.element
                    .bind('mouseover.checkBox mouseout.checkBox', function(e){
                        if(!$.nodeName(e.target, 'span')){return;}
                        var inst = ( $.data($(e.target).prev()[0]) || {} ).checkBox;
                        toggleHover(e, inst);
                    })
                    .bind('click.checkBox', function(e){
                        if(!$.nodeName(e.target, 'span') || !baseClasses.test( e.target.className || '' )){return;}
                        $(e.target).prev()[0].click();
                        return false;
                    })
                ;
            }
            if(opts.addLabel){
                this.element
                    .delegate('label.ui-radio, label.ui-checkbox', 'mouseenter.checkBox mouseleave.checkBox', function(e){
                        var inst = ( $.data(document.getElementById( $(this).attr('for') )) || {} ).checkBox;
                        toggleHover( e, inst );
                    });
            }
            
        },
        _addEvents: function(){
            var that         = this, 
            
                opts         = this.options,
                    
                toggleHover = function(e){
                    if(that.disabledStatus){
                        return false;
                    }
                    that.hover = (e.type == 'focus' || e.type == 'mouseenter');
                    that._changeStateClassChain();
                    return undefined;
                }
            ;
            
            this.element
                .bind('click.checkBox', $.proxy(this, 'reflectUI'))
                .bind('focus.checkBox blur.checkBox', toggleHover)
            ;
            if (opts.hideInput){
                this.element
                    .bind('usermode', function(e){
                        (e.enabled &&
                            that.destroy.call(that, true));
                    })
                ;
            }
            if(opts.addVisualElement){
                    this.visualElement
                        .bind('mouseenter.checkBox mouseleave.checkBox', toggleHover)
                        .bind('click.checkBox', function(e){
                            that.element[0].click();
                            return false;
                        })
                    ;
                }
            if(opts.addLabel){
                this.labels.bind('mouseenter.checkBox mouseleave.checkBox', toggleHover);
            }
        },
        _changeStateClassChain: function(){
            var allElements = this.labels.add(this.visualElement),
                stateClass     = '',
                baseClass     = 'ui-'+((this.radio) ? 'radio' : 'checkbox')
            ;
                
            if(this.checkedStatus){
                stateClass += '-checked'; 
                allElements.addClass(baseClass+'-checked');
            } else {
                allElements.removeClass(baseClass+'-checked');
            }
            
            if(this.disabledStatus){
                stateClass += '-disabled'; 
                allElements.addClass(baseClass+'-disabled');
            } else {
                allElements.removeClass(baseClass+'-disabled');
            }
            if(this.hover){
                stateClass += '-hover'; 
                allElements.addClass(baseClass+'-hover');
            } else {
                allElements.removeClass(baseClass+'-hover');
            }
            
            baseClass += '-state';
            if(stateClass){
                stateClass = baseClass + stateClass;
            }
            
            function switchStateClass(){
                var classes = this.className.split(' '),
                    found = false;
                $.each(classes, function(i, classN){
                    if(classN.indexOf(baseClass) === 0){
                        found = true;
                        classes[i] = stateClass;
                        return false;
                    }
                    return undefined;
                });
                if(!found){
                    classes.push(stateClass);
                }
                this.className = classes.join(' ');
            }
            
            this.labels.each(switchStateClass);
            this.visualElement.each(switchStateClass);
        },
        destroy: function(onlyCss){
            this.element.removeClass('ui-helper-hidden-accessible');
            this.visualElement.addClass('ui-helper-hidden');
            if (!onlyCss) {
                var o = this.options;
                this.element.unbind('.checkBox');
                this.visualElement.remove();
                this.labels
                    .unbind('.checkBox')
                    .removeClass('ui-state-hover ui-state-checked ui-state-disabled')
                ;
            }
        },
        
        disable: function(){
            this.element[0].disabled = true;
            this.reflectUI({type: 'manuallyDisabled'});
        },
        
        enable: function(){
            this.element[0].disabled = false;
            this.reflectUI({type: 'manuallyenabled'});
        },
        
        toggle: function(e){
            this.changeCheckStatus((this.element.is(':checked')) ? false : true, e);
        },
        
        changeCheckStatus: function(status, e){
            if(e && e.type == 'click' && this.element[0].disabled){
                return false;
            }
            this.element.attr({'checked': status});
            this.reflectUI(e || {
                type: 'changeCheckStatus'
            });
            return undefined;
        },
        
        propagate: function(n, e, _noGroupReflect){
            if(!e || e.type != 'initialReflect'){
                if (this.radio && !_noGroupReflect) {
                    //dynamic
                    $(document.getElementsByName(this.element.attr('name')))
                        .checkBox('reflectUI', e, true);
                }
                return this._trigger(n, e, {
                    options: this.options,
                    checked: this.checkedStatus,
                    labels: this.labels,
                    disabled: this.disabledStatus
                });
            }
            return undefined;
        },
        
        reflectUI: function(e){
            
            var oldChecked             = this.checkedStatus, 
                oldDisabledStatus     = this.disabledStatus
            ;
                                
            this.disabledStatus = this.element.is(':disabled');
            this.checkedStatus = this.element.is(':checked');
            
            if (this.disabledStatus != oldDisabledStatus || this.checkedStatus !== oldChecked) {
                this._changeStateClassChain();
                
                (this.disabledStatus != oldDisabledStatus &&
                    this.propagate('disabledChange', e));
                
                (this.checkedStatus !== oldChecked &&
                    this.propagate('change', e));
            }
            
        }
    });
})(jQuery);


/**
    Slimbox v2.03 - The ultimate lightweight Lightbox clone for jQuery
    (c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
    MIT-style license.
    
    Modified by Shopware AG 2010
    @author: S.Pohl <info@shopware.de>
    @date: 25-04-2010
    @version: 1.1
    
    changelog
    - removes caption
    - new close button
    - new overlay image
*/
(function ($) {
    var win = $(window),
        options, images, activeImage = -1,
        activeThumb, prevThumb, startThumb, single, activeURL, prevImage, nextImage, compatibleOverlay, middle, centerWidth, centerHeight, ie6 = !window.XMLHttpRequest,
        video, operaFix = window.opera && (document.compatMode == "CSS1Compat") && ($.browser.version >= 9.3),
        documentElement = document.documentElement,
        preload = {},
        preloadPrev = new Image(),
        preloadNext = new Image(),
        overlay, center, image, thumbs, closer, sizer, prevLink, nextLink, bottomContainer, bottom, caption, number;
    $(function () {
        $("body").append($([overlay = $('<div id="lbOverlay" />').click(close)[0], center = $('<div id="lbCenter" />')[0], bottomContainer = $('<div id="lbBottomContainer" />')[0], closer = $('<div id="lbCloser" />').click(close)[0], ]).css("display", "none"));
        image = $('<div id="lbImage" />').appendTo(center).click(close).append(sizer = $('<div style="position: relative;" />').append([prevLink = $('<a id="lbPrevLink" href="#" />').click(previous)[0], nextLink = $('<a id="lbNextLink" href="#" />').click(next)[0]])[0])[0];
        thumbs = $('<div id="lbThumbs" />').appendTo(center);
        $('#lbImage').css('cursor', 'pointer');
    });
    $.slimbox = function (_images, startImage, thumbList, video, _options) {
        options = $.extend({
            loop: false,
            overlayOpacity: 0.3,
            overlayFadeDuration: 400,
            resizeDuration: 400,
            resizeEasing: "swing",
            initialWidth: 250,
            initialHeight: 250,
            imageFadeDuration: 600,
            captionAnimationDuration: 200,
            counterText: "Bild {x} von {y}",
            closeKeys: [27, 88, 67],
            previousKeys: [37, 80],
            nextKeys: [39, 78]
        }, _options);
        single = false;
        if (typeof _images[3] == 'undefined') {
            single = true
        }
        if (typeof _images == "string") {
            _images = [
                [_images, startImage]
            ];
            startImage = 0
        }
        if (!single) {
            $.each(thumbList, function (i, el) {
                var thumbimg = $('<img>', {
                    src: el,
                    index: i
                }).click(function () {
                    if (startThumb.hasClass('active')) startThumb.removeClass('active');
                    if (activeThumb) activeThumb.removeClass('active');
                    changeImage(i);
                    $(this).addClass('active');
                    activeThumb = $(this)
                });
                if (i == startImage) {
                    thumbimg.addClass('active');
                    startThumb = thumbimg
                }
                var a = $('<a>', {
                    html: thumbimg
                }).appendTo(thumbs)
            })
        }
        middle = win.scrollTop() + ((operaFix ? documentElement.clientHeight : win.height()) / 2);
        centerWidth = options.initialWidth;
        centerHeight = options.initialHeight;
        $(center).css({
            top: Math.max(0, middle - (centerHeight / 2)),
            width: centerWidth,
            height: centerHeight,
            marginLeft: -centerWidth / 2
        }).show();
        /* compatibleOverlay = ie6 || (overlay.currentStyle && (overlay.currentStyle.position != "fixed"));
        if (compatibleOverlay) overlay.style.position = "absolute";*/
        $(overlay).css("opacity", options.overlayOpacity).fadeIn(options.overlayFadeDuration);
        position();
        setup(1);
        images = _images;
        options.loop = options.loop && (images.length > 1);
        return changeImage(startImage)
    };
    $.fn.slimbox = function (_options, linkMapper, linksFilter) {
        linkMapper = linkMapper ||
        function (el) {
            return [el.href, el.title]
        };
        linksFilter = linksFilter ||
        function () {
            return true
        };
        var thumbList = {};
        var links = this;
        return links.unbind("click").click(function () {
            var link = this,
                startIndex = 0,
                filteredLinks, i = 0,
                length;
            filteredLinks = $.grep(links, function (el, i) {
                return linksFilter.call(link, el, i)
            });
            thumbList = {};
            video = {};
            $.each(filteredLinks, function (i, el) {
                if ($(el).children('img').length) {
                    thumbList[i] = $(el).children('img').attr('src')
                } else {
                    var _img = $(el).css('background-image').split('"');
                    thumbList[i] = _img[1]
                }
            });
            for (length = filteredLinks.length; i < length; ++i) {
                if (filteredLinks[i] == link) startIndex = i;
                filteredLinks[i] = linkMapper(filteredLinks[i], i)
            }
            return $.slimbox(filteredLinks, startIndex, thumbList, _options)
        })
    };

    function position() {
        var l = win.scrollLeft(),
            w = operaFix ? documentElement.clientWidth : win.width();
        $([center, bottomContainer, closer]).css("left", l + (w / 2));
        if (compatibleOverlay) $(overlay).css({
            left: l,
            top: win.scrollTop(),
            width: w,
            height: win.height()
        })
    }
    function setup(open) {
        /*$("object").add(ie6 ? "select" : "embed").each(function (index, el) {
            if (open) $.data(el, "slimbox", el.style.visibility);
            el.style.visibility = open ? "hidden" : $.data(el, "slimbox")
        }); */
        var fn = open ? "bind" : "unbind";
        win[fn]("scroll resize", position);
    }
    function previous() {
        return changeImage(prevImage)
    }
    function next() {
        return changeImage(nextImage)
    }
    function changeImage(imageIndex) {
        if (imageIndex >= 0) {
            $('#lbThumbs a img[index=' + imageIndex + ']').addClass('active');
            if (prevThumb) prevThumb.removeClass('active');
            prevThumb = $('#lbThumbs a img[index=' + imageIndex + ']');
            activeImage = imageIndex;
            activeURL = images[activeImage][0];
            prevImage = (activeImage || (options.loop ? images.length : 0)) - 1;
            nextImage = ((activeImage + 1) % images.length) || (options.loop ? 0 : -1);
            stop();
            center.className = "lbLoading";
            if ($.isEmptyObject(video)) {
                preload = new Image();
                preload.onload = animateBox;
                preload.src = activeURL
            } else {
                animateBox()
            }
        }
        return false
    }
    function animateBox() {
        center.className = "";
        if ($.isEmptyObject(video)) {
            $(image).css({
                backgroundImage: "url(" + activeURL + ")",
                visibility: "hidden",
                display: ""
            });
            $(sizer).width(preload.width);
            $([sizer, prevLink, nextLink]).height(preload.height)
        }
        $(caption).html(images[activeImage][1] || "");
        $(number).html((((images.length > 1) && options.counterText) || "").replace(/{x}/, activeImage + 1).replace(/{y}/, images.length));
        if (prevImage >= 0) preloadPrev.src = images[prevImage][0];
        if (nextImage >= 0) preloadNext.src = images[nextImage][0];
        centerWidth = image.offsetWidth;
        centerHeight = image.offsetHeight;
        if (!$.isEmptyObject(video)) {
            centerHeight = 500;
            centerWidth = 660;
            var div = $('<div>', {
                'id': 'player',
                'href': $(video[0][0]).attr('href'),
                'css': {
                    'height': centerHeight - 20,
                    'width': centerWidth - 20
                }
            }).appendTo($(image));
            flowplayer('player', 'video/flowplayer-3.1.5.swf')
        }
        var top = Math.max(0, middle - (centerHeight / 2));
        if (center.offsetHeight != centerHeight) {
            $(center).animate({
                'height': centerHeight,
                'top': top
            }, options.resizeDuration, options.resizeEasing)
        }
        if (center.offsetWidth != centerWidth) {
            $(center).animate({
                'width': centerWidth,
                'marginLeft': -(centerWidth / 2)
            }, options.resizeDuration, options.resizeEasing)
        }
        $(center).queue(function () {
            $(image).hide().css('visibility', 'visible').fadeIn(options.imageFadeDuration, animateCaption)
        });
        centerWidth = centerWidth / 2;
        $(closer).css({
            'top': top,
            'marginLeft': centerWidth - 11
        });

        
        //Hide Prev and Next picture link
         $.ie6fix.selectHide();
    }
    function animateCaption() {
        $(closer).show();
    }
    function stop() {
        preload.onload = null;
        preload.src = preloadPrev.src = preloadNext.src = activeURL;
        $([center, image, bottom]).stop(true);
        $([prevLink, nextLink, image, bottomContainer, closer]).hide()
        $.ie6fix.selectShow();
    }
    function close() {

        if (activeImage >= 0) {
            stop();
            $(thumbs).empty();
            $('#player').remove();
            activeImage = prevImage = nextImage = -1;
            $(center).hide();
            $(overlay).stop().fadeOut(options.overlayFadeDuration, setup)
        }
        $.ie6fix.selectShow();
        return false
    }
})(jQuery);

//////////////////////////////////////////////////////////////////////////////////
// Cloud Zoom V1.0.2
// (c) 2010 by R Cecco. <http://www.professorcloud.com>
// MIT License
//
// Please retain this copyright header in all versions of the software
//////////////////////////////////////////////////////////////////////////////////
(function ($) {

    $(document).ready(function () {
        $('.cloud-zoom, .cloud-zoom-gallery').CloudZoom();
    });

    function CloudZoom(jWin, opts) {
        var sImg = $('img', jWin);
        var    img1;
        var    img2;
        var zoomDiv = null;
        var    $mouseTrap = null;
        var    lens = null;
        var    $tint = null;
        var    softFocus = null;
        var    $ie6Fix = null;
        var    zoomImage;
        var controlTimer = 0;      
        var cw, ch;
        var destU = 0;
        var    destV = 0;
        var currV = 0;
        var currU = 0;      
        var filesLoaded = 0;
        var mx,
            my; 
        var ctx = this, zw;
        
        // Display an image loading message. This message gets deleted when the images have loaded and the zoom init function is called.
        // We add a small delay before the message is displayed to avoid the message flicking on then off again virtually immediately if the
        // images load really fast, e.g. from the cache. 
        //var    ctx = this;
        setTimeout(function () {
            if ($mouseTrap === null) {
                var w = jWin.width();
                jWin.parent().append($.format('<div style="width:%0px;position:absolute;top:75%;left:%1px;text-align:center" class="cloud-zoom-loading" >Loading...</div>', w / 3, (w / 2) - (w / 6))).find(':last').css('opacity', 0.5);
            }
        }, 200);


        var ie6FixRemove = function () {
            
            if ($ie6Fix !== null) {
                $ie6Fix.remove();
                $ie6Fix = null;
            }
        };

        // Removes cursor, tint layer, blur layer etc.
        this.removeBits = function () {
            if (lens) {
                lens.remove();
                lens = null;             
            }
            if ($tint) {
                $tint.remove();
                $tint = null;
            }
            if (softFocus) {
                softFocus.remove();
                softFocus = null;
            }
               ie6FixRemove();

            $('.cloud-zoom-loading', jWin.parent()).remove();
        };

        
        
        this.destroy = function () {
            jWin.data('zoom', null);

            if ($mouseTrap) {
                $mouseTrap.unbind();
                $mouseTrap.remove();
                $mouseTrap = null;
            }
            if (zoomDiv) {
                zoomDiv.remove();
                zoomDiv = null;
            }
               //ie6FixRemove();
            this.removeBits();
            // DON'T FORGET TO REMOVE JQUERY 'DATA' VALUES
        };


        // This is called when the zoom window has faded out so it can be removed.
        this.fadedOut = function () {
            
            if (zoomDiv) {
                zoomDiv.remove();
                zoomDiv = null;
            }
             this.removeBits();
             ie6FixRemove();
        };

        this.controlLoop = function () {
            if (lens) {
                var x = (mx - sImg.offset().left - (cw * 0.5)) >> 0;
                var y = (my - sImg.offset().top - (ch * 0.5)) >> 0;
               
                if (x < 0) {
                    x = 0;
                }
                else if (x > (sImg.outerWidth() - cw)) {
                    x = (sImg.outerWidth() - cw);
                }
                if (y < 0) {
                    y = 0;
                }
                else if (y > (sImg.outerHeight() - ch)) {
                    y = (sImg.outerHeight() - ch);
                }

                lens.css({
                    left: x,
                    top: y
                });
                lens.css('background-position', (-x) + 'px ' + (-y) + 'px');

                destU = (((x) / sImg.outerWidth()) * zoomImage.width) >> 0;
                destV = (((y) / sImg.outerHeight()) * zoomImage.height) >> 0;
                currU += (destU - currU) / opts.smoothMove;
                currV += (destV - currV) / opts.smoothMove;

                zoomDiv.css('background-position', (-(currU >> 0) + 'px ') + (-(currV >> 0) + 'px'));              
            }
            controlTimer = setTimeout(function () {
                ctx.controlLoop();
            }, 30);
        };

        this.init2 = function (img, id) {
            
            var wrap = $('#wrap');
            var wrapimg = $('#zoom1 img');
            
            $('#wrap').css('width', wrapimg.innerWidth());
            
            filesLoaded++;
            if (id === 1) {
                zoomImage = img;
            }
            
            //this.images[id] = img;
            if (filesLoaded === 2) {
        
                  //wrap.css('width', wrapimg.outerWidth());
                
                this.init();
            }
        };

        /* Init function start.  */
        this.init = function () {
            // Remove loading message (if present);
            $('.cloud-zoom-loading', jWin.parent()).remove();


        /* Add a box (mouseTrap) over the small image to trap mouse events.
        It has priority over zoom window to avoid issues with inner zoom.
        We need the dummy background image as IE does not trap mouse events on
        transparent parts of a div.
        */
            $mouseTrap = jWin.parent().append($.format("<div class='mousetrap' style='z-index:999;position:absolute;width:%0px;height:%1px;left:%2px;top:%3px;\'></div>", sImg.outerWidth(), sImg.outerHeight(), 0, 0)).find(':last');
            
            if ($.browser.msie && parseInt($.browser.version) < 10) {
                $mouseTrap.css('background', 'url(".")');
            }
            
            $mouseTrap.bind('click', this, function (event) {
                $(this).prev().addClass('startimage');
                var relEl = $("a[rel^='" + $(this).prev().attr('rel') + "']");
                var images = [];
                var thumblist = {};
                var video = {};
                var startImage = 0;
                $.each(relEl, function (i, el) {
                    if ($(el).hasClass('startimage')) {
                        startImage = i
                    }
                    images[i] = [$(el).attr('href')];
                    if ($(el).children('img').attr('src')) {
                        thumblist[i] = $(el).children('img').attr('src')
                    } else {
                        thumblist[i] = $(el).attr('href')
                    }
                });
                $.slimbox(images, startImage, thumblist, video)
            });

            
            //////////////////////////////////////////////////////////////////////            
            /* Do as little as possible in mousemove event to prevent slowdown. */
            $mouseTrap.bind('mousemove', this, function (event) {
                // Just update the mouse position
                mx = event.pageX;
                my = event.pageY;
            });
            //////////////////////////////////////////////////////////////////////                    
            $mouseTrap.bind('mouseleave', this, function (event) {
                
                clearTimeout(controlTimer);
                //event.data.removeBits();                
                if(lens) { lens.fadeOut(299); }
                if($tint) { $tint.fadeOut(299); }
                if(softFocus) { softFocus.fadeOut(299); }
                
                zoomDiv.fadeOut(300, function () {
                    ctx.fadedOut();
                });            
                $.ie6fix.selectShow();                                                    
                return false;
            });
            //////////////////////////////////////////////////////////////////////            
            $mouseTrap.bind('mouseenter', this, function (event) {
            
                $.ie6fix.selectHide();
                    
                mx = event.pageX;
                my = event.pageY;
                zw = event.data;
                if (zoomDiv) {
                    zoomDiv.stop(true, false);
                    zoomDiv.remove();
                }

                var xPos = opts.adjustX,
                    yPos = opts.adjustY;
                             
                var siw = sImg.outerWidth();
                var sih = sImg.outerHeight();

                var w = opts.zoomWidth;
                var h = opts.zoomHeight;
                if (opts.zoomWidth == 'auto') {
                    w = siw;
                }
                if (opts.zoomHeight == 'auto') {
                    h = sih;
                }
                //$('#info').text( xPos + ' ' + yPos + ' ' + siw + ' ' + sih );
                var appendTo = jWin.parent(); // attach to the wrapper            
                switch (opts.position) {
                case 'top':
                    yPos -= h; // + opts.adjustY;
                    break;
                case 'right':
                    xPos += siw; // + opts.adjustX;                    
                    break;
                case 'bottom':
                    yPos += sih; // + opts.adjustY;
                    break;
                case 'left':
                    xPos -= w; // + opts.adjustX;                    
                    break;
                case 'inside':
                    w = siw;
                    h = sih;
                    break;
                    // All other values, try and find an id in the dom to attach to.
                default:
                    appendTo = $('#' + opts.position);
                    // If dom element doesn't exit, just use 'right' position as default.
                    if (!appendTo.length) {
                        appendTo = jWin;
                        xPos += siw; //+ opts.adjustX;
                        yPos += sih; // + opts.adjustY;    
                    } else {
                        w = appendTo.innerWidth();
                        h = appendTo.innerHeight();
                    }
                }
                   // xp24 01022011
                   w = w / 1.7;
                   h = h * 1.16;
                   zoomDiv = appendTo.append($.format('<div id="cloud-zoom-big" class="cloud-zoom-big" style="display:none;position:absolute;left:%0px;top:%1px;width:%2px;height:%3px;background-image:url(\'%4\');z-index:99;"></div>', xPos, yPos, w, h, zoomImage.src)).find(':last');
                   
                // Add the title from title tag.
                if (sImg.attr('title') && opts.showTitle) {
                    zoomDiv.append($.format('<div class="cloud-zoom-title">%0</div>', sImg.attr('title'))).find(':last').css('opacity', opts.titleOpacity);
                }
                
                /* Work out size of cursor */
                cw = (sImg.outerWidth() / zoomImage.width) * zoomDiv.width();
                ch = (sImg.outerHeight() / zoomImage.height) * zoomDiv.height();
                
                // if the zoom is larger than the actual picture
                if(cw > sImg.outerWidth()) {
                    cw = sImg.outerWidth();
                    zoomDiv.width(zoomImage.width); 
                }
                
                // Fix ie6 select elements wrong z-index bug. Placing an iFrame over the select element solves the issue...        
                if ($.browser.msie && parseInt($.browser.version) == 6) {
                    $ie6Fix = $('<iframe frameborder="0" src="#"></iframe>').css({
                        position: "absolute",
                        left: xPos,
                        top: yPos,
                        zIndex: 99,
                        width: cw,
                        height: h
                    }).insertBefore(zoomDiv);
                }

                zoomDiv.fadeIn(500);
                
                 if (lens) {
                    lens.remove();
                    lens = null;
                }

                // Attach mouse, initially invisible to prevent first frame glitch
                lens = jWin.append($.format("<div class='cloud-zoom-lens' style='display:none;z-index:98;position:absolute;width:%0px;height:%1px;'></div>", cw, ch)).find(':last').fadeTo(200, 0.4);
                

                $mouseTrap.css('cursor', lens.css('cursor'));

                var noTrans = false;

                // Init tint layer if needed. (Not relevant if using inside mode)            
                if (opts.tint) {
                    lens.css('background', 'url("' + sImg.attr('src') + '")');
                    $tint = jWin.append($.format('<div style="display:none;position:absolute; left:0px; top:0px; width:%0px; height:%1px; background-color:%2;" />', sImg.outerWidth(), sImg.outerHeight(), opts.tint)).find(':last');
                    $tint.css('opacity', opts.tintOpacity);                    
                    noTrans = true;
                    $tint.fadeIn(500);

                }
                if (opts.softFocus) {
                    lens.css('background', 'url("' + sImg.attr('src') + '")');
                    softFocus = jWin.append($.format('<div style="position:absolute;display:none;top:2px; left:2px; width:%0px; height:%1px;" />', sImg.outerWidth() - 2, sImg.outerHeight() - 2, opts.tint)).find(':last');
                    softFocus.css('background', 'url("' + sImg.attr('src') + '")');
                    softFocus.css('opacity', 0.5);
                    noTrans = true;
                    softFocus.fadeIn(500);
                }

                /*if (!noTrans) {
                    lens.css('opacity', opts.lensOpacity); // opacity for all modern browsers
                    if ($.browser.msie && parseInt($.browser.version) > 6) {
                        lens.css('-ms-filter', '"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"'); // opacity for ie 8
                    } else {
                        lens.css('filter', 'alpha(opacity=50)'); // opacity for ie 6-7
                    }                                
                }*/
                if ( opts.position !== 'inside' ) {
                    lens.fadeIn(200);
                }

                // Start processing. 
                zw.controlLoop();

                return; // Don't return false here otherwise opera will not detect change of the mouse pointer type.
            });
        };
       

        img1 = new Image();
        $(img1).load(function () {
            ctx.init2(this, 0);
            
        });
        img1.src = sImg.attr('src');

        img2 = new Image();
        $(img2).load(function () {
            ctx.init2(this, 1);
        });
        img2.src = jWin.attr('href');
    }

    $.fn.CloudZoom = function (options) {
       try {
            document.execCommand("BackgroundImageCache", false, true)
        } catch (e) {}
        this.each(function () {
            var relOpts, opts;
            if ($(this).is('.cloud-zoom')) {
                
                var img = $(this).find('img');
        
                $(this).css({
                    'position': 'relative',
                    'display': 'block',
                    'margin': '0 auto',
                    'text-align': 'center'
                });
                $('img', $(this)).css({
                    'display': 'block'
                });
                
                var img = $(this).find('img');
                
                if ($(this).parent().attr('id') != 'wrap') {
                    $(this).wrap('<div id="wrap" style="top:0px;z-index:9;position:relative;width:'+img.innerWidth()+'px;margin:0 auto"></div>')
                }
                opts = $.extend({}, $.fn.CloudZoom.defaults, options);
                opts = $.extend({}, opts, relOpts);
                $(this).data('zoom', new CloudZoom($(this), opts));
            } else if ($(this).is('.cloud-zoom-gallery')) {
                relOpts = {
                    useZoom: 'zoom1',
                    smallImage: $(this).attr('src')
                };
                  if(!$(this).parent().attr('id')) {
                      relOpts.smallImage = $(this).attr('rev');
                  } else {
                      relOpts.smallImage = $(this).attr('src');
                  }
                opts = $.extend({}, relOpts, options);
                $(this).data('relOpts', opts);
                $(this).bind('click', $(this), function (event) {
                    event.preventDefault();
                    var data = event.data.data('relOpts');
                       $('#' + data.useZoom).data('zoom').destroy();
                    $('#' + data.useZoom).attr('href', event.data.attr('href'));
                    $('#' + data.useZoom + ' img').attr('src', relOpts.smallImage);
                    $('#' + event.data.data('relOpts').useZoom).CloudZoom();
                    
                    //fading picture
                    if ($.browser.msie && parseInt($.browser.version) > 8) {
                        $('#wrap').fadeTo(0,0.01).delay(200).fadeTo(200,1);
                    }
                    if ($.browser.msie && parseInt($.browser.version) > 7) {
                        $('#wrap').fadeTo(0,0.01).delay(200).fadeTo(200,1);
                    }
                    return false;
                });
            }
        });
        return this
    };
    $.fn.CloudZoom.defaults = {
        zoomWidth: 487,
        zoomHeight: 260,
        position: 'right',
        tint: false,
        tintOpacity: 0.5,
        lensOpacity: 0.5,
        softFocus: false,
        smoothMove: 3,
        showTitle: true,
        titleOpacity: 0.5,
        adjustX: 20,
        adjustY: -5
    }
    
})(jQuery);


