
(function ($)
{
    jQuery.fn.boutique = function (o)
    {
        var p = $.extend(
        {
            starter: 1,
            speed: 600,
            behind_opac: 0.4,
            back_opac: 0.15,
            behind_size: 0.7,
            back_size: 0.4,
            behind_distance: 'auto',
            autoplay: false,
            autointerval: 3000,
            freescroll: true,
            hovergrowth: 0.08,
            easing: 'easeInOutQuad',
            move_twice_easein: 'easeInCirc',
            move_twice_easeout: 'easeOutCirc',
            text_front_only: false,
            keyboard: true,
            move_on_hover: false
        }, o);
        $(this).each(function ()
        {
            var d = $(this),
                $lis = $('li', d);
            var f, easingplugin, hoverspeed, $newitem1, $newitem2, $newitem3, $newitem4, $newitem5, eazing, zpeed, next, iegrow, container_width, container_height, front_img_width, front_img_height, text_opacity, containerid = d.attr('id'),
                busy = false,
                current = p.starter,
                items = $lis.length,
                ie = false,
                ie6 = false,
                container_100 = false;
            if ($.browser.msie)
            {
                ie = true;
                if ($.browser.version < 7)
                {
                    ie6 = true
                }
            }
            if (p.hoverspeed)
            {
                hoverspeed = p.hoverspeed
            }
            else
            {
                hoverspeed = (p.speed / 4)
            }
            if (p.starter > items)
            {
                p.starter = items
            }
            if ($.easing.def)
            {
                easingplugin = true;
                $.easing.def = p.easing
            }
            else
            {
                easingplugin = false
            }
            var x = 1;
            var g = [];
            $lis.each(function ()
            {
                var a = $(this);
                a.addClass('li' + x);
                var b = a.find('img').attr('alt'),
                    $span;
                if (!a.find('span').length)
                {
                    if (a.find('a').length)
                    {
                        a.children('a').append('<span/>')
                    }
                    else
                    {
                        a.append('<span/>')
                    }
                    $span = a.find('span');
                    if (b == '')
                    {
                        $span.hide()
                    }
                }
                else
                {
                    $span = a.find('span')
                }
                var c = $('<h6>' + b + '</h6>').prependTo($span);
                if (b == '')
                {
                    c.hide()
                }
                g[x] = a;
                x++
            });
            if (items == 1)
            {
                g[1].clone().addClass('frame1').prependTo(d);
                g[1].clone().addClass('frame2').prependTo(d)
            }
            else if (p.starter == 2)
            {
                g[1].clone().addClass('frame2').prependTo(d);
                g[items].clone().addClass('frame1').prependTo(d)
            }
            else if (p.starter == 1)
            {
                g[items - 1].clone().addClass('frame1').prependTo(d);
                g[items].clone().addClass('frame2').prependTo(d)
            }
            else
            {
                g[p.starter - 1].clone().addClass('frame2').prependTo(d);
                g[p.starter - 2].clone().addClass('frame1').prependTo(d)
            }
            g[p.starter].clone().addClass('frame3').prependTo(d);
            if (items == 1)
            {
                g[1].clone().addClass('frame4').prependTo(d);
                g[1].clone().addClass('frame5').prependTo(d)
            }
            else if (p.starter == (items - 1))
            {
                g[items].clone().addClass('frame4').prependTo(d);
                g[1].clone().addClass('frame5').prependTo(d)
            }
            else if (p.starter == items)
            {
                g[1].clone().addClass('frame4').prependTo(d);
                g[2].clone().addClass('frame5').prependTo(d)
            }
            else
            {
                g[p.starter + 1].clone().addClass('frame4').prependTo(d);
                g[p.starter + 2].clone().addClass('frame5').prependTo(d)
            }
            var h = d.find('.frame1'),
                $item2 = d.find('.frame2'),
                $item3 = d.find('.frame3'),
                $item4 = d.find('.frame4'),
                $item5 = d.find('.frame5');
            h.add($item5).show().animate(
            {
                opacity: 0
            }, 0).addClass('back');
            $item2.add($item4).show().animate(
            {
                opacity: 0
            }, 0).addClass('behind');
            $item3.show().animate(
            {
                opacity: 0
            }, 0).addClass('front');
            var i = $('.back', d),
                $behind = $('.behind', d),
                $front = $('.front', d);
            if (p.container_width)
            {
                container_width = p.container_width
            }
            else
            {
                container_width = d.css('width')
            }
            if (container_width == '100%')
            {
                container_100 = true;
                container_width = parseInt($(window).width(), 10)
            }
            else
            {
                container_width = parseInt(container_width, 10)
            }
            if (p.front_img_width)
            {
                front_img_width = p.front_img_width
            }
            else
            {
                front_img_width = parseInt($('img', $front).css('width'), 10)
            }
            if (p.front_img_height)
            {
                front_img_height = p.front_img_height
            }
            else
            {
                front_img_height = parseInt($('img', $front).css('height'))
            }
            if (p.text_opacity)
            {
                text_opacity = p.text_opacity
            }
            else
            {
                text_opacity = parseFloat($('span', d).css('opacity'))
            }
            var j = parseInt($lis.css('borderLeftWidth'), 10),
                li_padding = parseInt($lis.css('padding-left'), 10),
                front_header = $('h6', $front).css('font-size'),
                front_span = $('span', $front).css('font-size'),
                front_top = $front.css('margin-top'),
                front_margin = parseInt($('img', $front).css('margin-left'), 10),
                front_width = Math.round(front_img_width + (front_margin * 2) + (li_padding * 2) + (j * 2)),
                front_height = Math.round(front_img_height + (front_margin * 2) + (li_padding * 2) + (j * 2)),
                behind_img_width = Math.round(front_img_width * p.behind_size),
                behind_img_height = Math.round(front_img_height * p.behind_size),
                behind_header = $('h6', $behind).css('font-size'),
                behind_span = $('span', $behind).css('font-size'),
                behind_top = $behind.css('margin-top'),
                behind_margin = parseInt($('img', $behind).css('margin-left'), 10),
                behind_width = Math.round(behind_img_width + (behind_margin * 2) + (li_padding * 2) + (j * 2)),
                behind_height = Math.round(behind_img_height + (behind_margin * 2) + (li_padding * 2) + (j * 2)),
                back_img_width = Math.round(front_img_width * p.back_size),
                back_img_height = Math.round(front_img_height * p.back_size),
                back_header = $('h6', i).css('font-size'),
                back_span = $('span', i).css('font-size'),
                back_top = i.css('margin-top'),
                back_margin = parseInt($('img', i).css('margin-left'), 10),
                back_width = Math.round(back_img_width + (back_margin * 2) + (li_padding * 2) + (j * 2)),
                back_height = Math.round(back_img_height + (back_margin * 2) + (li_padding * 2) + (j * 2)),
                item3_pos = Math.round((container_width / 2) - (front_width / 2)),
                item5_pos = (container_width - back_width),
                item2_pos;
            if (p.behind_distance != 'auto')
            {
                item2_pos = parseInt(p.behind_distance, 10)
            }
            else
            {
                item2_pos = Math.round((container_width / 4) - (behind_width / 2))
            }
            var k = (container_width - item2_pos - behind_width);
            i.removeClass('back');
            $behind.removeClass('behind');
            $front.removeClass('front');
            var l = $('span', $lis).css('padding-top'),
                front_span_paddingRight = $('span', $lis).css('padding-right'),
                front_span_paddingBottom = $('span', $lis).css('padding-bottom'),
                front_span_paddingLeft = $('span', $lis).css('padding-left'),
                behind_span_paddingTop = Math.round(parseInt(l, 10) * 0.8) + 'px',
                behind_span_paddingRight = Math.round(parseInt(front_span_paddingRight, 10) * 0.8) + 'px',
                behind_span_paddingBottom = Math.round(parseInt(front_span_paddingBottom, 10) * 0.8) + 'px',
                behind_span_paddingLeft = Math.round(parseInt(front_span_paddingLeft, 10) * 0.8) + 'px',
                back_span_paddingTop = Math.round(parseInt(l, 10) * 0.6) + 'px',
                back_span_paddingRight = Math.round(parseInt(front_span_paddingRight, 10) * 0.6) + 'px',
                back_span_paddingBottom = Math.round(parseInt(front_span_paddingBottom, 10) * 0.6) + 'px',
                back_span_paddingLeft = Math.round(parseInt(front_span_paddingLeft, 10) * 0.6) + 'px',
                front_span_animate = {
                    'font-size': front_span,
                    'padding-top': l,
                    'padding-right': front_span_paddingRight,
                    'padding-bottom': front_span_paddingBottom,
                    'padding-left': front_span_paddingLeft
                },
                behind_span_animate = {
                    'font-size': behind_span,
                    'padding-top': behind_span_paddingTop,
                    'padding-right': behind_span_paddingRight,
                    'padding-bottom': behind_span_paddingBottom,
                    'padding-left': behind_span_paddingLeft
                },
                back_span_animate = {
                    'font-size': back_span,
                    'padding-top': back_span_paddingTop,
                    'padding-right': back_span_paddingRight,
                    'padding-bottom': back_span_paddingBottom,
                    'padding-left': back_span_paddingLeft
                };
            if (p.text_front_only)
            {
                front_span_animate = $.extend(
                {
                    opacity: text_opacity
                }, front_span_animate);
                behind_span_animate = $.extend(
                {
                    opacity: 0
                }, behind_span_animate);
                back_span_animate = $.extend(
                {
                    opacity: 0
                }, back_span_animate)
            }
            if (ie6)
            {
                var m = (parseInt($('span:visible', $front).css('margin-left'), 10) + parseInt($('span:visible', $front).css('margin-right'), 10)),
                    behind_span_margin = (parseInt($('span:visible', $behind).css('margin-left'), 10) + parseInt($('span:visible', $behind).css('margin-right'), 10)),
                    back_span_margin = (parseInt($('span:visible', i).css('margin-left'), 10) + parseInt($('span:visible', i).css('margin-right'), 10)),
                    ie6_front_span_animate = $.extend(
                    {
                        width: front_width - parseInt(front_span_paddingRight, 10) - parseInt(front_span_paddingLeft, 10) - m - (j * 2)
                    }, front_span_animate),
                    ie6_behind_span_animate = $.extend(
                    {
                        width: behind_width - parseInt(behind_span_paddingRight, 10) - parseInt(behind_span_paddingLeft, 10) - behind_span_margin - (j * 2)
                    }, behind_span_animate),
                    ie6_back_span_animate = $.extend(
                    {
                        width: back_width - parseInt(back_span_paddingRight, 10) - parseInt(back_span_paddingLeft, 10) - back_span_margin - (j * 2)
                    }, back_span_animate)
            }
            var n = (front_height + parseInt(front_top, 10)),
                behind_space = (behind_height + parseInt(behind_top, 10)),
                back_space = (back_height + parseInt(back_top, 10));
            if (n > behind_space && n > back_space)
            {
                container_height = n
            }
            else if (behind_space > n && behind_space > back_space)
            {
                container_height = behind_space
            }
            else
            {
                container_height = back_space
            }
            d.height(container_height);
            h.css(
            {
                left: 0,
                top: back_top
            }).animate(
            {
                opacity: p.back_opac
            }, 0).find('img').animate(
            {
                width: back_img_width + 'px',
                height: back_img_height + 'px',
                margin: back_margin + 'px',
                opacity: 1
            }, 0).siblings('span:visible').css(back_span_animate).children('h6:visible').css(
            {
                'font-size': back_header
            });
            $item2.css(
            {
                left: item2_pos + 'px',
                top: behind_top,
                'z-index': 2
            }).animate(
            {
                opacity: p.behind_opac
            }, 0).find('img').animate(
            {
                width: behind_img_width + 'px',
                height: behind_img_height + 'px',
                margin: behind_margin + 'px',
                opacity: 1
            }, 0).siblings('span:visible').css(behind_span_animate).children('h6:visible').css(
            {
                'font-size': behind_header
            });
            $item3.css(
            {
                left: item3_pos + 'px',
                top: front_top,
                'z-index': 3
            }).animate(
            {
                opacity: 1
            }, 0).find('a *').css(
            {
                cursor: 'pointer'
            }).end().find('img').animate(
            {
                width: front_img_width + 'px',
                height: front_img_height + 'px',
                margin: front_margin + 'px',
                opacity: 1
            }, 0).siblings('span:visible').css(front_span_animate).children('h6:visible').css(
            {
                'font-size': front_header
            });
            $item4.css(
            {
                left: k + 'px',
                top: behind_top,
                'z-index': 2
            }).animate(
            {
                opacity: p.behind_opac
            }, 0).find('img').animate(
            {
                width: behind_img_width + 'px',
                height: behind_img_height + 'px',
                margin: behind_margin + 'px',
                opacity: 1
            }, 0).siblings('span:visible').css(behind_span_animate).children('h6:visible').css(
            {
                'font-size': behind_header
            });
            $item5.css(
            {
                left: item5_pos + 'px',
                top: back_top
            }).animate(
            {
                opacity: p.back_opac
            }, 0).find('img').animate(
            {
                width: back_img_width + 'px',
                height: back_img_height + 'px',
                margin: back_margin + 'px',
                opacity: 1
            }, 0).siblings('span:visible').css(back_span_animate).children('h6:visible').css(
            {
                'font-size': back_header
            });
            if (ie6)
            {
                $('span:visible', i).css(ie6_back_span_animate);
                $('span:visible', $behind).css(ie6_behind_span_animate);
                $('span:visible', $front).css(ie6_front_span_animate)
            }
            function setContainerWidth()
            {
                var a = parseInt($(window).width(), 10);
                d.width(a);
                item2_pos = Math.round((a / 4) - (behind_width / 2));
                item3_pos = Math.round((a / 2) - (front_width / 2));
                k = (a - item2_pos - behind_width);
                item5_pos = (a - back_width);
                $item2.css(
                {
                    left: item2_pos
                });
                $item3.css(
                {
                    left: item3_pos
                });
                $item4.css(
                {
                    left: k
                });
                $item5.css(
                {
                    left: item5_pos
                })
            }
            if (container_100)
            {
                setContainerWidth()
            }
            function stopInterval()
            {
                if (f)
                {
                    clearInterval(f);
                    f = false
                }
            }
            function startInterval()
            {
                if (f)
                {
                    stopInterval()
                }
                f = setInterval(function ()
                {
                    $item4.click()
                }, p.autointerval)
            }
            function moveRight(b)
            {
                busy = true;
                eazing = '';
                zpeed = p.speed;
                if (easingplugin)
                {
                    if (b == 'twice')
                    {
                        eazing = p.move_twice_easein;
                        zpeed = Math.round(p.speed * 0.5)
                    }
                    else if (b == 'twice_end')
                    {
                        eazing = p.move_twice_easeout
                    }
                    else
                    {
                        eazing = p.easing
                    }
                }
                if (p.autoplay)
                {
                    stopInterval()
                }
                if (current == (items - 2))
                {
                    next = 1
                }
                else if (current == (items - 1))
                {
                    next = 2;
                    if (next > items)
                    {
                        next = 1
                    }
                }
                else if (current == items)
                {
                    next = 3;
                    if (next > items)
                    {
                        next = 1
                    }
                }
                else
                {
                    next = (current + 3)
                }
                h.removeClass('frame1').addClass('remove').css('z-index', -1);
                $newitem1 = $item2;
                $newitem1.removeClass('frame2').addClass('frame1').stop().animate(
                {
                    opacity: p.back_opac,
                    left: 0,
                    top: back_top
                }, zpeed, eazing).find('img').stop().animate(
                {
                    width: back_img_width + 'px',
                    height: back_img_height + 'px',
                    marginTop: back_margin + 'px',
                    marginRight: back_margin + 'px',
                    marginBottom: back_margin + 'px',
                    marginLeft: back_margin + 'px',
                    opacity: 1
                }, zpeed, eazing).end().find('h6:visible').stop().animate(
                {
                    'font-size': back_header
                }, zpeed, eazing);
                if (ie6)
                {
                    $newitem1.find('span:visible').stop().animate(ie6_back_span_animate, zpeed, eazing)
                }
                else
                {
                    $newitem1.find('span').stop().animate(back_span_animate, zpeed, eazing)
                }
                setTimeout(function ()
                {
                    $newitem1.css('z-index', 1)
                }, (zpeed / 4));
                $newitem2 = $item3;
                $newitem2.removeClass('frame3').addClass('frame2').stop().animate(
                {
                    opacity: p.behind_opac,
                    left: item2_pos + 'px',
                    top: behind_top
                }, zpeed, eazing).find('img').stop().animate(
                {
                    width: behind_img_width + 'px',
                    height: behind_img_height + 'px',
                    marginTop: behind_margin + 'px',
                    marginRight: behind_margin + 'px',
                    marginBottom: behind_margin + 'px',
                    marginLeft: behind_margin + 'px',
                    opacity: 1
                }, zpeed, eazing).end().find('h6:visible').stop().animate(
                {
                    'font-size': behind_header
                }, zpeed, eazing);
                if (ie6)
                {
                    $newitem2.find('span:visible').stop().animate(ie6_behind_span_animate, zpeed, eazing)
                }
                else
                {
                    $newitem2.find('span').stop().animate(behind_span_animate, zpeed, eazing)
                }
                setTimeout(function ()
                {
                    $newitem2.css('z-index', 2)
                }, (zpeed / 4));
                $newitem3 = $item4;
                $newitem3.removeClass('frame4').addClass('frame3').stop().animate(
                {
                    opacity: 1,
                    left: item3_pos + 'px',
                    top: front_top
                }, zpeed, eazing).find('img').stop().animate(
                {
                    width: front_img_width + 'px',
                    height: front_img_height + 'px',
                    marginTop: front_margin + 'px',
                    marginRight: front_margin + 'px',
                    marginBottom: front_margin + 'px',
                    marginLeft: front_margin + 'px',
                    opacity: 1
                }, zpeed, eazing).end().find('h6:visible').stop().animate(
                {
                    'font-size': front_header
                }, zpeed, eazing);
                if (ie6)
                {
                    $newitem3.find('span:visible').stop().animate(ie6_front_span_animate, zpeed, eazing)
                }
                else
                {
                    $newitem3.find('span').stop().animate(front_span_animate, zpeed, eazing)
                }
                setTimeout(function ()
                {
                    $newitem3.css('z-index', 3)
                }, (zpeed / 4));
                $newitem4 = $item5;
                $newitem4.removeClass('frame5').addClass('frame4').stop().animate(
                {
                    opacity: p.behind_opac,
                    left: k + 'px',
                    top: behind_top
                }, zpeed, eazing).find('img').stop().animate(
                {
                    width: behind_img_width + 'px',
                    height: behind_img_height + 'px',

                    marginTop: behind_margin + 'px',
                    marginRight: behind_margin + 'px',
                    marginBottom: behind_margin + 'px',
                    marginLeft: behind_margin + 'px',
                    opacity: 1
                }, zpeed, eazing).end().find('h6:visible').stop().animate(
                {
                    'font-size': behind_header
                }, zpeed, eazing);
                if (ie6)
                {
                    $newitem4.find('span:visible').stop().animate(ie6_behind_span_animate, zpeed, eazing)
                }
                else
                {
                    $newitem4.find('span').stop().animate(behind_span_animate, zpeed, eazing)
                }
                setTimeout(function ()
                {
                    $newitem4.css('z-index', 2)
                }, (zpeed / 4));
                g[next].clone().addClass('frame5').prependTo(d).show().animate(
                {
                    opacity: 0,
                    left: item5_pos + 'px',
                    top: back_top
                }, 0).animate(
                {
                    opacity: p.back_opac
                }, zpeed, function ()
                {
                    $newitem2.find('a *').css(
                    {
                        cursor: 'default'
                    });
                    if (p.autoplay)
                    {
                        startInterval()
                    }
                    if (b == 'twice')
                    {
                        moveRight('twice_end')
                    }
                    else
                    {
                        $newitem3.find('a *').css(
                        {
                            cursor: 'pointer'
                        })
                    }
                    if (!$newitem3.is(':animated'))
                    {
                        busy = false;
                        d.find('.remove').stop().fadeOut(zpeed, function ()
                        {
                            $(this).remove()
                        });
                        if (typeof move_callback == 'function')
                        {
                            var a = $newitem3.find('a').attr('href');
                            if (a != undefined && a != '')
                            {
                                move_callback(a)
                            }
                        }
                    }
                }).find('img').animate(
                {
                    width: back_img_width + 'px',
                    height: back_img_height + 'px',
                    margin: back_margin + 'px',
                    opacity: 1
                }, 0).end().find('h6:visible').css(
                {
                    'font-size': back_header
                });
                h = $newitem1, $item2 = $newitem2, $item3 = $newitem3, $item4 = $newitem4, $item5 = d.find('.frame5');
                if (ie6)
                {
                    $item5.find('span:visible').animate(ie6_back_span_animate, 0)
                }
                else
                {
                    $item5.find('span').animate(back_span_animate, 0)
                }
                d.find('.remove').fadeOut(zpeed, function ()
                {
                    $(this).remove()
                });
                if (current == items)
                {
                    current = 1
                }
                else
                {
                    current = (current + 1)
                }
            }
            function moveLeft(b)
            {
                busy = true;
                eazing = '';
                zpeed = p.speed;
                if (easingplugin)
                {
                    if (b == 'twice')
                    {
                        eazing = p.move_twice_easein;
                        zpeed = Math.round(p.speed * 0.5)
                    }
                    else if (b == 'twice_end')
                    {
                        eazing = p.move_twice_easeout
                    }
                    else
                    {
                        eazing = p.easing
                    }
                }
                if (p.autoplay)
                {
                    stopInterval()
                }
                if (current == 3)
                {
                    next = items
                }
                else if (current == 2)
                {
                    next = (items - 1);
                    if (next < 1)
                    {
                        next = items
                    }
                }
                else if (current == 1)
                {
                    next = (items - 2);
                    if (next < 1)
                    {
                        next = items
                    }
                }
                else
                {
                    next = (current - 3)
                }
                $item5.removeClass('frame5').addClass('remove').css('z-index', -1);
                $newitem5 = $item4;
                $newitem5.removeClass('frame4').addClass('frame5').stop().animate(
                {
                    opacity: p.back_opac,
                    left: item5_pos + 'px',
                    top: back_top
                }, zpeed, eazing).find('img').stop().animate(
                {
                    width: back_img_width + 'px',
                    height: back_img_height + 'px',
                    marginTop: back_margin + 'px',
                    marginRight: back_margin + 'px',
                    marginBottom: back_margin + 'px',
                    marginLeft: back_margin + 'px',
                    opacity: 1
                }, zpeed, eazing).end().find('h6:visible').stop().animate(
                {
                    'font-size': back_header
                }, zpeed, eazing);
                if (ie6)
                {
                    $newitem5.find('span:visible').stop().animate(ie6_back_span_animate, zpeed, eazing)
                }
                else
                {
                    $newitem5.find('span').stop().animate(back_span_animate, zpeed, eazing)
                }
                setTimeout(function ()
                {
                    $newitem5.css('z-index', 1)
                }, (zpeed / 4));
                $newitem4 = $item3;
                $newitem4.removeClass('frame3').addClass('frame4').stop().animate(
                {
                    opacity: p.behind_opac,
                    left: k + 'px',
                    top: behind_top
                }, zpeed, eazing).find('img').stop().animate(
                {
                    width: behind_img_width + 'px',
                    height: behind_img_height + 'px',
                    marginTop: behind_margin + 'px',
                    marginRight: behind_margin + 'px',
                    marginBottom: behind_margin + 'px',
                    marginLeft: behind_margin + 'px',
                    opacity: 1
                }, zpeed, eazing).end().find('h6:visible').stop().animate(
                {
                    'font-size': behind_header
                }, zpeed, eazing);
                if (ie6)
                {
                    $newitem4.find('span:visible').stop().animate(ie6_behind_span_animate, zpeed, eazing)
                }
                else
                {
                    $newitem4.find('span').stop().animate(behind_span_animate, zpeed, eazing)
                }
                setTimeout(function ()
                {
                    $newitem4.css('z-index', 2)
                }, (zpeed / 4));
                $newitem3 = $item2;
                $newitem3.removeClass('frame2').addClass('frame3').stop().animate(
                {
                    opacity: 1,
                    left: item3_pos + 'px',
                    top: front_top
                }, zpeed, eazing).find('img').stop().animate(
                {
                    width: front_img_width + 'px',
                    height: front_img_height + 'px',
                    marginTop: front_margin + 'px',
                    marginRight: front_margin + 'px',
                    marginBottom: front_margin + 'px',
                    marginLeft: front_margin + 'px',
                    opacity: 1
                }, zpeed, eazing).end().find('h6:visible').stop().animate(
                {
                    'font-size': front_header
                }, zpeed, eazing);
                if (ie6)
                {
                    $newitem3.find('span:visible').stop().animate(ie6_front_span_animate, zpeed, eazing)
                }
                else
                {
                    $newitem3.find('span').stop().animate(front_span_animate, zpeed, eazing)
                }
                setTimeout(function ()
                {
                    $newitem3.css('z-index', 3)
                }, (zpeed / 4));
                $newitem2 = h;
                $newitem2.removeClass('frame1').addClass('frame2').stop().animate(
                {
                    opacity: p.behind_opac,
                    left: item2_pos + 'px',
                    top: behind_top
                }, zpeed, eazing).find('img').stop().animate(
                {
                    width: behind_img_width + 'px',
                    height: behind_img_height + 'px',
                    marginTop: behind_margin + 'px',
                    marginRight: behind_margin + 'px',
                    marginBottom: behind_margin + 'px',
                    marginLeft: behind_margin + 'px',
                    opacity: 1
                }, zpeed, eazing).end().find('h6:visible').stop().animate(
                {
                    'font-size': behind_header
                }, zpeed, eazing);
                if (ie6)
                {
                    $newitem2.find('span:visible').stop().animate(ie6_behind_span_animate, zpeed, eazing)
                }
                else
                {
                    $newitem2.find('span').stop().animate(behind_span_animate, zpeed, eazing)
                }
                setTimeout(function ()
                {
                    $newitem2.css('z-index', 2)
                }, (zpeed / 4));
                g[next].clone().addClass('frame1').prependTo(d).show().animate(
                {
                    opacity: 0,
                    left: 0,
                    top: back_top
                }, 0).animate(
                {
                    opacity: p.back_opac
                }, zpeed, function ()
                {
                    $newitem4.find('a *').css(
                    {
                        cursor: 'default'
                    });
                    if (p.autoplay)
                    {
                        startInterval()
                    }
                    if (b == 'twice')
                    {
                        moveLeft('twice_end')
                    }
                    else
                    {
                        $newitem3.find('a *').css(
                        {
                            cursor: 'pointer'
                        })
                    }
                    if (!$newitem3.is(':animated'))
                    {
                        busy = false;
                        d.find('.remove').stop().fadeOut(zpeed, function ()
                        {
                            $(this).remove()
                        });
                        if (typeof move_callback == 'function')
                        {
                            var a = $newitem3.find('a').attr('href');
                            if (a != undefined && a != '')
                            {
                                move_callback(a)
                            }
                        }
                    }
                }).find('img').animate(
                {
                    width: back_img_width + 'px',
                    height: back_img_height + 'px',
                    margin: back_margin + 'px',
                    opacity: 1
                }, 0).end().find('h6:visible').css(
                {
                    'font-size': back_header
                });
                h = d.find('.frame1'), $item2 = $newitem2, $item3 = $newitem3, $item4 = $newitem4, $item5 = $newitem5;
                if (ie6)
                {
                    h.find('span:visible').animate(ie6_back_span_animate, 0)
                }
                else
                {
                    h.find('span').animate(back_span_animate, 0)
                }
                d.find('.remove').fadeOut(zpeed, function ()
                {
                    $(this).remove()
                });
                if (current == 1)
                {
                    current = items
                }
                else
                {
                    current = (current - 1)
                }
            }
            window[containerid + '_ext_prev'] = function ()
            {
                $item2.click()
            };
            window[containerid + '_ext_next'] = function ()
            {
                $item4.click()
            };
            h.live('click', function (e)
            {
                if (p.freescroll || !busy)
                {
                    moveLeft('twice');
                    e.preventDefault()
                }
            });
            $item2.live('click', function (e)
            {
                if (p.freescroll || !busy)
                {
                    moveLeft();
                    e.preventDefault()
                }
            });
            $item4.live('click', function (e)
            {
                if (p.freescroll || !busy)
                {
                    moveRight();
                    e.preventDefault()
                }
            });
            $item5.live('click', function (e)
            {
                if (p.freescroll || !busy)
                {
                    moveRight('twice');
                    e.preventDefault()
                }
            });
            if (p.move_on_hover)
            {
                h.live('mousemove', function ()
                {
                    h.click()
                });
                $item2.live('mousemove', function ()
                {
                    $item2.click()
                });
                $item4.live('mousemove', function ()
                {
                    $item4.click()
                });
                $item5.live('mousemove', function ()
                {
                    $item5.click()
                })
            }
            $item3.live('hover', function (e)
            {
                if ((e.type == 'mouseover' || e.type == 'mouseenter') && !busy)
                {
                    if (p.autoplay)
                    {
                        stopInterval()
                    }
                    $item3.addClass('zoomed').stop(true, true).animate(
                    {
                        left: '-=' + (front_img_width * (p.hovergrowth / 2)) + 'px',
                        top: '-=' + (front_img_height * p.hovergrowth) + 'px'
                    }, hoverspeed).find('img').stop().animate(
                    {
                        width: (front_img_width * (1 + p.hovergrowth)) + 'px',
                        height: (front_img_height * (1 + p.hovergrowth)) + 'px'
                    }, hoverspeed);
                    $item2.stop(true, true).animate(
                    {
                        left: '-=' + (behind_img_width * p.hovergrowth) + 'px'
                    }, hoverspeed);
                    $item4.stop(true, true).animate(
                    {
                        left: '+=' + (behind_img_width * p.hovergrowth) + 'px'
                    }, hoverspeed);
                    if (ie6)
                    {
                        iegrow = Math.round(p.hovergrowth * front_img_width);
                        $item3.find('span:visible').animate(
                        {
                            width: '+=' + iegrow
                        }, hoverspeed)
                    }
                }
                else if (!busy)
                {
                    if (p.autoplay)
                    {
                        startInterval()
                    }
                    $item3.stop().animate(
                    {
                        left: item3_pos + 'px',
                        top: front_top
                    }, hoverspeed).find('img').stop().animate(
                    {
                        width: front_img_width + 'px',
                        height: front_img_height + 'px'
                    }, hoverspeed, function ()
                    {
                        $item3.removeClass('zoomed')
                    });
                    $item2.stop().animate(
                    {
                        left: item2_pos
                    }, hoverspeed);
                    $item4.stop().animate(
                    {
                        left: k
                    }, hoverspeed);
                    if (ie6)
                    {
                        iegrow = Math.round(p.hovergrowth * front_img_width);
                        d.find('.zoomed span:visible').animate(
                        {
                            width: '-=' + iegrow
                        }, hoverspeed)
                    }
                }
            });
            if (!ie)
            {
                d.find('.frame3:not(.zoomed)').live('mousemove', function ()
                {
                    $item3.mouseover()
                })
            }
            $item3.find('a').live('click', function ()
            {
                if (typeof link_callback == 'function')
                {
                    link_callback($(this).attr('href'))
                }
            });
            if (p.keyboard)
            {
                $(document).keydown(function (e)
                {
                    if (e.keyCode == 13 || e.keyCode == 32 || e.keyCode == 39)
                    {
                        $item4.click()
                    }
                    if (e.keyCode == 37)
                    {
                        $item2.click()
                    }
                })
            }
            if (p.autoplay)
            {
                startInterval()
            }
            if (container_100)
            {
                $(window).resize(function ()
                {
                    setContainerWidth()
                })
            }
        })
    }
})(jQuery);

 
function move_callback(anchor){
	jQuery('#testimonial').html(jQuery(anchor).html()).slideDown();
}
function link_callback(anchor){
	//$('#alert').html('Callback example: You clicked a frame with the link "'+anchor+'".').slideDown();
}
