


/**

 * Tabs - jQuery plugin for accessible, unobtrusive tabs

 * @requires jQuery v1.1.1

 *

 * http://stilbuero.de/tabs/

 *

 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)

 * Dual licensed under the MIT and GPL licenses:

 * http://www.opensource.org/licenses/mit-license.php

 * http://www.gnu.org/licenses/gpl.html

 *

 * Version: 2.7.4

 */



(function($) { // block scope



$.extend({

    tabs: {

        remoteCount: 0 // TODO in Tabs 3 this is going to be more cleanly in one single namespace

    }

});





$.fn.tabs = function(initial, settings) {



    // settings

    if (typeof initial == 'object') settings = initial; // no initial tab given but a settings object

    settings = $.extend({

        initial: (initial && typeof initial == 'number' && initial > 0) ? --initial : 0,

        disabled: null,

        bookmarkable: $.ajaxHistory ? true : false,

        remote: false,

        spinner: 'Loading&#8230;',

        hashPrefix: 'remote-tab-',

        fxFade: null,

        fxSlide: null,

        fxShow: null,

        fxHide: null,

        fxSpeed: 'normal',

        fxShowSpeed: null,

        fxHideSpeed: null,


        fxAutoHeight: false,

        onClick: null,

        onHide: null,

        onShow: null,

        navClass: 'tabs-nav',

        selectedClass: 'tabs-selected',

        disabledClass: 'tabs-disabled',

        containerClass: 'tabs-container',

        hideClass: 'tabs-hide',

        loadingClass: 'tabs-loading',

        tabStruct: 'div'

    }, settings || {});



    $.browser.msie6 = $.browser.msie && ($.browser.version && $.browser.version < 7 || /MSIE 6.0/.test(navigator.userAgent)); // do not check for 6.0 alone, userAgent in Windows Vista has "Windows NT 6.0"



    // helper to prevent scroll to fragment

    function unFocus() {

        scrollTo(0, 0);

    }



    // initialize tabs

    return this.each(function() {



        // remember wrapper for later

        var container = this;



        // setup nav

        var nav = $('ul.' + settings.navClass, container);

        nav = nav.size() && nav || $('>ul:eq(0)', container); // fallback to default structure

        var tabs = $('a', nav);



        // prepare remote tabs

        if (settings.remote) {

            tabs.each(function() {

                var id = settings.hashPrefix + (++$.tabs.remoteCount), hash = '#' + id, url = this.href;

                this.href = hash;

                $('<div id="' + id + '" class="' + settings.containerClass + '"></div>').appendTo(container);



                $(this).bind('loadRemoteTab', function(e, callback) {

                    var $$ = $(this).addClass(settings.loadingClass), span = $('span', this)[0], tabTitle = span.innerHTML;

                    if (settings.spinner) {

                        // TODO if spinner is image

                        span.innerHTML = '<em>' + settings.spinner + '</em>'; // WARNING: html(...) crashes Safari with jQuery 1.1.2

                    }

                    setTimeout(function() { // Timeout is again required in IE, "wait" for id being restored

                        $(hash).load(url, function() {

                            if (settings.spinner) {

                                span.innerHTML = tabTitle; // WARNING: html(...) crashes Safari with jQuery 1.1.2
                            }

                            $$.removeClass(settings.loadingClass);

                            callback && callback();

                        });

                    }, 0);

                });



            });

        }



        // set up containers

        var containers = $('div.' + settings.containerClass, container);

        containers = containers.size() && containers || $('>' + settings.tabStruct, container); // fallback to default structure



        // attach classes for styling if not present

        nav.is('.' + settings.navClass) || nav.addClass(settings.navClass);

        containers.each(function() {

            var $$ = $(this);

            $$.is('.' + settings.containerClass) || $$.addClass(settings.containerClass);

        });



        // try to retrieve active tab from class in HTML

        var hasSelectedClass = $('li', nav).index( $('li.' + settings.selectedClass, nav)[0] );

        if (hasSelectedClass >= 0) {

           settings.initial = hasSelectedClass;

        }



        // try to retrieve active tab from hash in url, will override class in HTML

        if (location.hash) {

            tabs.each(function(i) {

                if (this.hash == location.hash) {

                    settings.initial = i;

                    // prevent page scroll to fragment

                    if (($.browser.msie || $.browser.opera) && !settings.remote) {

                        var toShow = $(location.hash);

                        var toShowId = toShow.attr('id');

                        toShow.attr('id', '');

                        setTimeout(function() {

                            toShow.attr('id', toShowId); // restore id

                        }, 500);

                    }

                    unFocus();

                    return false; // break

                }

            });

        }

        if ($.browser.msie) {

            unFocus(); // fix IE focussing bottom of the page for some unknown reason

        }



        // highlight tab accordingly

        containers.filter(':eq(' + settings.initial + ')').show().end().not(':eq(' + settings.initial + ')').addClass(settings.hideClass);

        $('li', nav).removeClass(settings.selectedClass).eq(settings.initial).addClass(settings.selectedClass); // we need to remove classes eventually if hash takes precedence over class

        // trigger load of initial tab

        tabs.eq(settings.initial).trigger('loadRemoteTab').end();



        // setup auto height

        if (settings.fxAutoHeight) {

            // helper

            var _setAutoHeight = function(reset) {

                // get tab heights in top to bottom ordered array

                var heights = $.map(containers.get(), function(el) {

                    var h, jq = $(el);

                    if (reset) {

                        if ($.browser.msie6) {

                            el.style.removeExpression('behaviour');

                            el.style.height = '';

                            el.minHeight = null;

                        }

                        h = jq.css({'min-height': ''}).height(); // use jQuery's height() to get hidden element values

                    } else {

                        h = jq.height(); // use jQuery's height() to get hidden element values

                    }

                    return h;

                }).sort(function(a, b) {

                    return b - a;

                });

                if ($.browser.msie6) {

                    containers.each(function() {

                        this.minHeight = heights[0] + 'px';

                        this.style.setExpression('behaviour', 'this.style.height = this.minHeight ? this.minHeight : "1px"'); // using an expression to not make print styles useless

                    });

                } else {

                    containers.css({'min-height': heights[0] + 'px'});

                }

            };

            // call once for initialization

            _setAutoHeight();

            // trigger auto height adjustment if needed

            var cachedWidth = container.offsetWidth;

            var cachedHeight = container.offsetHeight;

            var watchFontSize = $('#tabs-watch-font-size').get(0) || $('<span id="tabs-watch-font-size">M</span>').css({display: 'block', position: 'absolute', visibility: 'hidden'}).appendTo(document.body).get(0);

            var cachedFontSize = watchFontSize.offsetHeight;

            setInterval(function() {

                var currentWidth = container.offsetWidth;

                var currentHeight = container.offsetHeight;

                var currentFontSize = watchFontSize.offsetHeight;

                if (currentHeight > cachedHeight || currentWidth != cachedWidth || currentFontSize != cachedFontSize) {

                    _setAutoHeight((currentWidth > cachedWidth || currentFontSize < cachedFontSize)); // if heights gets smaller reset min-height

                    cachedWidth = currentWidth;

                    cachedHeight = currentHeight;

                    cachedFontSize = currentFontSize;

                }

            }, 50);

        }



        // setup animations

        var showAnim = {}, hideAnim = {}, showSpeed = settings.fxShowSpeed || settings.fxSpeed, hideSpeed = settings.fxHideSpeed || settings.fxSpeed;

        if (settings.fxSlide || settings.fxFade) {

            if (settings.fxSlide) {

                showAnim['height'] = 'show';

                hideAnim['height'] = 'hide';

            }

            if (settings.fxFade) {

                showAnim['opacity'] = 'show';

                hideAnim['opacity'] = 'hide';

            }

        } else {

            if (settings.fxShow) {

                showAnim = settings.fxShow;

            } else { // use some kind of animation to prevent browser scrolling to the tab

                showAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox

                showSpeed = 1; // as little as 1 is sufficient

            }

            if (settings.fxHide) {

                hideAnim = settings.fxHide;

            } else { // use some kind of animation to prevent browser scrolling to the tab

                hideAnim['min-width'] = 0; // avoid opacity, causes flicker in Firefox

                hideSpeed = 1; // as little as 1 is sufficient

            }

        }



        // callbacks

        var onClick = settings.onClick, onHide = settings.onHide, onShow = settings.onShow;



        // attach activateTab event, required for activating a tab programmatically

        tabs.bind('triggerTab', function() {



            // if the tab is already selected or disabled or animation is still running stop here

            var li = $(this).parents('li:eq(0)');

            if (container.locked || li.is('.' + settings.selectedClass) || li.is('.' + settings.disabledClass)) {

                return false;

            }



            var hash = this.hash;



            if ($.browser.msie) {



                $(this).trigger('click');

                if (settings.bookmarkable) {

                    $.ajaxHistory.update(hash);

                    location.hash = hash.replace('#', '');

                }



            } else if ($.browser.safari) {



                // Simply setting location.hash puts Safari into the eternal load state... ugh! Submit a form instead.

                var tempForm = $('<form action="' + hash + '"><div><input type="submit" value="h" /></div></form>').get(0); // no need to append it to the body

                tempForm.submit(); // does not trigger the form's submit event...

                $(this).trigger('click'); // ...thus do stuff here

                if (settings.bookmarkable) {

                    $.ajaxHistory.update(hash);

                }



            } else {



                if (settings.bookmarkable) {

                    location.hash = hash.replace('#', '');

                } else {

                    $(this).trigger('click');

                }



            }



        });



        // attach disable event, required for disabling a tab

        tabs.bind('disableTab', function() {

            var li = $(this).parents('li:eq(0)');

            if ($.browser.safari) { /* fix opacity of tab after disabling in Safari... */

                li.animate({ opacity: 0 }, 1, function() {

                   li.css({opacity: ''});

                });

            }

            li.addClass(settings.disabledClass);



        });



        // disabled from settings

        if (settings.disabled && settings.disabled.length) {

            for (var i = 0, k = settings.disabled.length; i < k; i++) {

                tabs.eq(--settings.disabled[i]).trigger('disableTab').end();

            }

        };



        // attach enable event, required for reenabling a tab

        tabs.bind('enableTab', function() {

            var li = $(this).parents('li:eq(0)');

            li.removeClass(settings.disabledClass);

            if ($.browser.safari) { /* fix disappearing tab after enabling in Safari... */

                li.animate({ opacity: 1 }, 1, function() {

                    li.css({opacity: ''});

                });

            }

        });



        // attach click event

        tabs.bind('click', function(e) {



            var trueClick = e.clientX; // add to history only if true click occured, not a triggered click

            var clicked = this, li = $(this).parents('li:eq(0)'), toShow = $(this.hash), toHide = containers.filter(':visible');



            // if animation is still running, tab is selected or disabled or onClick callback returns false stop here

            // check if onClick returns false last so that it is not executed for a disabled tab

            if (container['locked'] || li.is('.' + settings.selectedClass) || li.is('.' + settings.disabledClass) || typeof onClick == 'function' && onClick(this, toShow[0], toHide[0]) === false) {

                this.blur();

                return false;

            }



            container['locked'] = true;



            // show new tab

            if (toShow.size()) {



                // prevent scrollbar scrolling to 0 and than back in IE7, happens only if bookmarking/history is enabled

                if ($.browser.msie && settings.bookmarkable) {

                    var toShowId = this.hash.replace('#', '');

                    toShow.attr('id', '');

                    setTimeout(function() {

                        toShow.attr('id', toShowId); // restore id

                    }, 0);

                }



                var resetCSS = { display: '', overflow: '', height: '' };

                if (!$.browser.msie) { // not in IE to prevent ClearType font issue

                    resetCSS['opacity'] = '';

                }

                

                // switch tab, animation prevents browser scrolling to the fragment

                function switchTab() {

                    if (settings.bookmarkable && trueClick) { // add to history only if true click occured, not a triggered click

                        $.ajaxHistory.update(clicked.hash);

                    }

                    toHide.animate(hideAnim, hideSpeed, function() { //

                        $(clicked).parents('li:eq(0)').addClass(settings.selectedClass).siblings().removeClass(settings.selectedClass);

                        toHide.addClass(settings.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.                        

                        if (typeof onHide == 'function') {

                            onHide(clicked, toShow[0], toHide[0]);

                        }

                        if (!(settings.fxSlide || settings.fxFade || settings.fxShow)) {

                            toShow.css('display', 'block'); // prevent occasionally occuring flicker in Firefox cause by gap between showing and hiding the tab containers

                        }

                        toShow.animate(showAnim, showSpeed, function() {

                            toShow.removeClass(settings.hideClass).css(resetCSS); // maintain flexible height and accessibility in print etc.

                            if ($.browser.msie) {

                                toHide[0].style.filter = '';

                                toShow[0].style.filter = '';

                            }

                            if (typeof onShow == 'function') {

                                onShow(clicked, toShow[0], toHide[0]);

                            }

                            container['locked'] = null;

                        });

                    });

                }



                if (!settings.remote) {

                    switchTab();

                } else {

                    $(clicked).trigger('loadRemoteTab', [switchTab]);

                }



            } else {

                alert('There is no such container.');

            }



            // Set scrollbar to saved position - need to use timeout with 0 to prevent browser scroll to target of hash

            var scrollX = window.pageXOffset || document.documentElement && document.documentElement.scrollLeft || document.body.scrollLeft || 0;

            var scrollY = window.pageYOffset || document.documentElement && document.documentElement.scrollTop || document.body.scrollTop || 0;


            setTimeout(function() {

                window.scrollTo(scrollX, scrollY);

            }, 0);



            this.blur(); // prevent IE from keeping other link focussed when using the back button



            return settings.bookmarkable && !!trueClick; // convert undefined to Boolean for IE



        });



        // enable history support if bookmarking and history is turned on

        if (settings.bookmarkable) {

            $.ajaxHistory.initialize(function() {

                tabs.eq(settings.initial).trigger('click').end();

            });

        }



    });



};



/**

 * Activate a tab programmatically with the given position (no zero-based index)

 * or its id, e.g. the URL's fragment identifier/hash representing a tab, as if the tab

 * itself were clicked.

 *

 * @example $('#container').triggerTab(2);

 * @desc Activate the second tab of the tab interface contained in <div id="container">.

 * @example $('#container').triggerTab(1);

 * @desc Activate the first tab of the tab interface contained in <div id="container">.

 * @example $('#container').triggerTab();

 * @desc Activate the first tab of the tab interface contained in <div id="container">.

 * @example $('#container').triggerTab('fragment-2');

 * @desc Activate a tab via its URL fragment identifier representation.

 *

 * @param String|Number tab Either a string that matches the id of the tab (the URL's

 *                          fragment identifier/hash representing a tab) or an integer

 *                          specifying the position of the tab (no zero-based index) to

 *                          be activated. If this parameter is omitted, the first tab

 *                          will be activated.

 * @type jQuery

 *

 * @name triggerTab

 * @cat Plugins/Tabs

 * @author Klaus Hartl/klaus.hartl@stilbuero.de

 */



/**

 * Disable a tab, so that clicking it has no effect.

 *

 * @example $('#container').disableTab(2);

 * @desc Disable the second tab of the tab interface contained in <div id="container">.

 *

 * @param String|Number tab Either a string that matches the id of the tab (the URL's

 *                          fragment identifier/hash representing a tab) or an integer

 *                          specifying the position of the tab (no zero-based index) to

 *                          be disabled. If this parameter is omitted, the first tab

 *                          will be disabled.

 * @type jQuery

 *

 * @name disableTab

 * @cat Plugins/Tabs

 * @author Klaus Hartl/klaus.hartl@stilbuero.de

 */



/**

 * Enable a tab that has been disabled.

 *

 * @example $('#container').enableTab(2);

 * @desc Enable the second tab of the tab interface contained in <div id="container">.

 *

 * @param String|Number tab Either a string that matches the id of the tab (the URL's

 *                          fragment identifier/hash representing a tab) or an integer

 *                          specifying the position of the tab (no zero-based index) to

 *                          be enabled. If this parameter is omitted, the first tab

 *                          will be enabled.

 * @type jQuery

 *

 * @name enableTab

 * @cat Plugins/Tabs

 * @author Klaus Hartl/klaus.hartl@stilbuero.de

 */



var tabEvents = ['triggerTab', 'disableTab', 'enableTab'];

for (var i = 0; i < tabEvents.length; i++) {

    $.fn[tabEvents[i]] = (function(tabEvent) {

        return function(tab) {

            return this.each(function() {

                var nav = $('ul.tabs-nav' , this);

                nav = nav.size() && nav || $('>ul:eq(0)', this); // fallback to default structure

                var a;

                if (!tab || typeof tab == 'number') {

                    a = $('li a', nav).eq((tab && tab > 0 && tab - 1 || 0)); // fall back to 0

                } else if (typeof tab == 'string') {

                    a = $('li a[@href$="#' + tab + '"]', nav);

                }

                a.trigger(tabEvent);

            });

        };

    })(tabEvents[i]);

}



/**

 * Get the position of the currently selected tab (no zero-based index).

 *

 * @example $('#container').activeTab();

 * @desc Get the position of the currently selected tab of an interface

 * contained in <div id="container">.

 *

 * @type Number

 *

 * @name activeTab

 * @cat Plugins/Tabs

 * @author Klaus Hartl/klaus.hartl@stilbuero.de

 */



$.fn.activeTab = function() {

    var selectedTabs = [];

    this.each(function() {

        var nav = $('ul.tabs-nav' , this);

        nav = nav.size() && nav || $('>ul:eq(0)', this); //fallback to default structure

        var lis = $('li', nav);

        selectedTabs.push(lis.index( lis.filter('.tabs-selected')[0] ) + 1);

    });

    return selectedTabs[0];

};



})(jQuery);

(function(a){a.fn.lavaLamp=function(b){b=a.extend({fx:"swing",speed:500,click:function(){return true},startItem:"no",autoReturn:true,returnDelay:0,setOnClick:true,homeTop:0,homeLeft:0,homeWidth:0,homeHeight:0,returnHome:false},b||{});return this.each(function(){var h=location.pathname+location.search+location.hash;var e=new Object;var d;var i;var f;var g;if(b.homeTop||b.homeLeft){f=a('<li class="homeLava selectedLava"></li>').css({left:b.homeLeft,top:b.homeTop,width:b.homeWidth,height:b.homeHeight,position:"absolute"});a(this).prepend(f)}var j=a("li",this);if(b.startItem=="no"){e=a('li a[href$="'+h+'"]',this).parent("li")}if(e.length==0&&b.startItem=="no"&&location.hash){e=a('li a[href$="'+location.hash+'"]',this).parent("li")}if(e.length==0||b.startItem!="no"){if(b.startItem=="no"){b.startItem=0}e=a(j[b.startItem])}g=a("li.selectedLava",this)[0]||a(e).addClass("selectedLava")[0];j.mouseover(function(){if(a(this).hasClass("homeLava")){g=a(this)[0]}c(this)});i=a('<li class="backLava"><div class="leftLava"></div><div class="bottomLava"></div><div class="cornerLava"></div></li>').appendTo(this);a(this).mouseout(function(){if(b.autoReturn){if(b.returnHome&&f){c(f[0])}else{if(b.returnDelay){if(d){clearTimeout(d)}d=setTimeout(c,b.returnDelay+b.speed)}else{c()}}}});j.click(function(k){if(b.setOnClick){a(g).removeClass("selectedLava");a(this).addClass("selectedLava");g=this}return b.click.apply(this,[k,this])});if(b.homeTop||b.homeLeft){i.css({left:b.homeLeft,top:b.homeTop,width:b.homeWidth,height:b.homeHeight})}else{i.css({left:g.offsetLeft,top:g.offsetTop,width:g.offsetWidth,height:g.offsetHeight})}function c(k){if(!k){k=g}var m=0,l=0;if(!a.browser.msie){m=(i.outerWidth()-i.innerWidth())/2;l=(i.outerHeight()-i.innerHeight())/2}i.stop().animate({left:k.offsetLeft-m,top:k.offsetTop-l,width:k.offsetWidth,height:k.offsetHeight},b.speed,b.fx)}})}})(jQuery);

/**
 * History/Remote - jQuery plugin for enabling history support and bookmarking
 * @requires jQuery v1.0.3
 *
 * http://stilbuero.de/jquery/history/
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Version: 0.2.3
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(2($){$.D=16 2(){4 c=\'15\';4 k=7.6;4 d=z;4 g;5.o=2(){};4 h=2(){$(\'.x-R\').1i()};$(8).K(c,h);3($.v.19){4 e,p=q;$(2(){e=$(\'<H 13="12: Z;"></H>\').E(8.U).1o(0);4 a=e.C.8;a.P();a.M();3(k&&k!=\'#\'){a.7.6=k.B(\'#\',\'\')}});5.o=2(a){k=a;4 b=e.C.8;b.P();b.M();b.7.6=a.B(\'#\',\'\')};g=2(){4 a=e.C.8;4 b=a.7.6;3(b!=k){k=b;3(b&&b!=\'#\'){$(\'a[@l$="\'+b+\'"]\').m();7.6=b}n 3(p){7.6=\'\';$(8).u(c)}}p=A}}n 3($.v.18||$.v.17){5.o=2(a){k=a};g=2(){3(7.6){3(k!=7.6){k=7.6;$(\'a[@l$="\'+k+\'"]\').m()}}n 3(k){k=\'\';$(8).u(c)}}}n 3($.v.14){4 f,r,t;$(2(){f=[];f.9=y.9;r=[]});4 j=q,p=q;t=2(a){f.G(a);r.9=0;j=q};5.o=2(a){k=a;t(k)};g=2(){4 b=y.9-f.9;3(b){j=q;3(b<0){F(4 i=0;i<11.10(b);i++)r.Y(f.X())}n{F(4 i=0;i<b;i++)f.G(r.W())}4 a=f[f.9-1];$(\'a[@l$="\'+a+\'"]\').m();k=7.6}n 3(f[f.9-1]==T&&!j){3(8.S.1n(\'#\')>=0){$(\'a[@l$="\'+\'#\'+8.S.1m(\'#\')[1]+\'"]\').m()}n 3(p){$(8).u(c)}j=A}p=A}}5.1l=2(a){3(w a==\'2\'){$(8).1k(c,h).K(c,a)}3(7.6&&w t==\'T\'){$(\'a[@l$="\'+7.6+\'"]\').u(\'m\')}3(g&&d==z){d=1j(g,1h)}}};$.Q.x=2(g,f,c){c=c||2(){};3(w f==\'2\'){c=f}f=$.1g({O:\'x-\'},f||{});4 d=$(g).1f()&&$(g)||$(\'<I></I>\').E(\'U\');d.1e(\'x-R\');L 5.1d(2(i){4 a=5.l;4 b=\'#\'+(5.N&&5.N.B(/\\s/g,\'1c\')||f.O+(i+1));5.l=b;$(5).m(2(e){3(!d[\'J\']){3(e.V){$.D.o(b)}d.1b(a,2(){d[\'J\']=z;c()})}})})};$.Q.y=2(a){L 5.m(2(e){3(e.V){$.D.o(5.6)}w a==\'2\'&&a()})}})(1a);',62,87,'||function|if|var|this|hash|location|document|length||||||||||||href|click|else|update|initialized|false|_forwardStack||_addHistory|trigger|browser|typeof|remote|history|null|true|replace|contentWindow|ajaxHistory|appendTo|for|push|iframe|div|locked|bind|return|close|title|hashPrefix|open|fn|output|URL|undefined|body|clientX|shift|pop|unshift|none|abs|Math|display|style|safari|historyReset|new|opera|mozilla|msie|jQuery|load|_|each|addClass|size|extend|200|empty|setInterval|unbind|initialize|split|indexOf|get'.split('|'),0,{}))


/*

 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/

 *

 * Uses the built In easIng capabilities added In jQuery 1.1

 * to offer multiple easIng options

 *

 * Copyright (c) 2007 George Smith

 * Licensed under the MIT License:

 *   http://www.opensource.org/licenses/mit-license.php

 */



// t: current time, b: begInnIng value, c: change In value, d: duration

jQuery.easing['jswing'] = jQuery.easing['swing'];



jQuery.extend( jQuery.easing,

{

	def: 'easeOutQuad',

	swing: function (x, t, b, c, d) {

		//alert(jQuery.easing.default);

		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);

	},

	easeInQuad: function (x, t, b, c, d) {

		return c*(t/=d)*t + b;

	},

	easeOutQuad: function (x, t, b, c, d) {

		return -c *(t/=d)*(t-2) + b;

	},

	easeInOutQuad: function (x, t, b, c, d) {

		if ((t/=d/2) < 1) return c/2*t*t + b;

		return -c/2 * ((--t)*(t-2) - 1) + b;

	},

	easeInCubic: function (x, t, b, c, d) {

		return c*(t/=d)*t*t + b;

	},

	easeOutCubic: function (x, t, b, c, d) {

		return c*((t=t/d-1)*t*t + 1) + b;

	},

	easeInOutCubic: function (x, t, b, c, d) {

		if ((t/=d/2) < 1) return c/2*t*t*t + b;

		return c/2*((t-=2)*t*t + 2) + b;

	},

	easeInQuart: function (x, t, b, c, d) {

		return c*(t/=d)*t*t*t + b;

	},

	easeOutQuart: function (x, t, b, c, d) {

		return -c * ((t=t/d-1)*t*t*t - 1) + b;

	},

	easeInOutQuart: function (x, t, b, c, d) {

		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;

		return -c/2 * ((t-=2)*t*t*t - 2) + b;

	},

	easeInQuint: function (x, t, b, c, d) {

		return c*(t/=d)*t*t*t*t + b;

	},

	easeOutQuint: function (x, t, b, c, d) {

		return c*((t=t/d-1)*t*t*t*t + 1) + b;

	},

	easeInOutQuint: function (x, t, b, c, d) {

		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;

		return c/2*((t-=2)*t*t*t*t + 2) + b;

	},

	easeInSine: function (x, t, b, c, d) {

		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;

	},

	easeOutSine: function (x, t, b, c, d) {

		return c * Math.sin(t/d * (Math.PI/2)) + b;

	},

	easeInOutSine: function (x, t, b, c, d) {

		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;

	},

	easeInExpo: function (x, t, b, c, d) {

		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;

	},

	easeOutExpo: function (x, t, b, c, d) {

		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;

	},

	easeInOutExpo: function (x, t, b, c, d) {

		if (t==0) return b;

		if (t==d) return b+c;

		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;

		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;

	},

	easeInCirc: function (x, t, b, c, d) {

		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;

	},

	easeOutCirc: function (x, t, b, c, d) {

		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;

	},

	easeInOutCirc: function (x, t, b, c, d) {

		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;

		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;

	},

	easeInElastic: function (x, t, b, c, d) {

		var s=1.70158;var p=0;var a=c;

		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;

		if (a < Math.abs(c)) { a=c; var s=p/4; }

		else var s = p/(2*Math.PI) * Math.asin (c/a);

		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;

	},

	easeOutElastic: function (x, t, b, c, d) {

		var s=1.70158;var p=0;var a=c;

		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;

		if (a < Math.abs(c)) { a=c; var s=p/4; }

		else var s = p/(2*Math.PI) * Math.asin (c/a);

		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;

	},

	easeInOutElastic: function (x, t, b, c, d) {

		var s=1.70158;var p=0;var a=c;

		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);

		if (a < Math.abs(c)) { a=c; var s=p/4; }

		else var s = p/(2*Math.PI) * Math.asin (c/a);

		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;

		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;

	},

	easeInBack: function (x, t, b, c, d, s) {

		if (s == undefined) s = 1.70158;

		return c*(t/=d)*t*((s+1)*t - s) + b;

	},

	easeOutBack: function (x, t, b, c, d, s) {

		if (s == undefined) s = 1.70158;

		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;

	},

	easeInOutBack: function (x, t, b, c, d, s) {

		if (s == undefined) s = 1.70158; 

		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;

		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;

	},

	easeInBounce: function (x, t, b, c, d) {

		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;

	},

	easeOutBounce: function (x, t, b, c, d) {

		if ((t/=d) < (1/2.75)) {

			return c*(7.5625*t*t) + b;

		} else if (t < (2/2.75)) {

			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;

		} else if (t < (2.5/2.75)) {

			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;

		} else {

			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;

		}

	},

	easeInOutBounce: function (x, t, b, c, d) {

		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;

		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;

	}

});

/*

    anythingSlider v1.2

    

    By Chris Coyier: http:/css-tricks.com

    with major improvements by Doug Neiner: http://pixelgraphics.us/

    based on work by Remy Sharp: http://jqueryfordesigners.com/





	To use the navigationFormatter function, you must have a function that

	accepts two paramaters, and returns a string of HTML text.

	

	index = integer index (1 based);

	panel = jQuery wrapped LI item this tab references

	@return = Must return a string of HTML/Text

	

	navigationFormatter: function(index, panel){

		return index + " Panel"; // This would have each tab with the text 'X Panel' where X = index

	}

*/



(function($){

	

    $.anythingSlider = function(el, options){

        // To avoid scope issues, use 'base' instead of 'this'

        // to reference this class from internal events and functions.

        var base = this;

        

        // Access to jQuery and DOM versions of element

        base.$el = $(el);

        base.el = el; 



		// Set up a few defaults

        base.currentPage = 1;

		base.timer = null;

		base.playing = false;



        // Add a reverse reference to the DOM object

        base.$el.data("AnythingSlider", base);

        

        base.init = function(){

            base.options = $.extend({},$.anythingSlider.defaults, options);

			

			// Cache existing DOM elements for later 

			base.$wrapper = base.$el.find('> div').css('overflow', 'hidden');

            base.$slider  = base.$wrapper.find('> ul');

            base.$items   = base.$slider.find('> li');

            base.$single  = base.$items.filter(':first');



			// Build the navigation if needed

			if(base.options.buildNavigation) base.buildNavigation();

        

        	// Get the details

            base.singleWidth = base.$single.outerWidth();

            base.pages = base.$items.length;



            // Top and tail the list with 'visible' number of items, top has the last section, and tail has the first

			// This supports the "infinite" scrolling

			base.$items.filter(':first').before(base.$items.filter(':last').clone().addClass('cloned'));

            base.$items.filter(':last' ).after(base.$items.filter(':first').clone().addClass('cloned'));



			// We just added two items, time to re-cache the list

            base.$items = base.$slider.find('> li'); // reselect

            

			// Setup our forward/backward navigation

			base.buildNextBackButtons();

		

			// If autoPlay functionality is included, then initialize the settings

			if(base.options.autoPlay) {

				base.playing = !base.options.startStopped; // Sets the playing variable to false if startStopped is true

				base.buildAutoPlay();

			};

			

			// If pauseOnHover then add hover effects

			if(base.options.pauseOnHover) {

				base.$el.hover(function(){

					base.clearTimer();

				}, function(){

					base.startStop(base.playing);

				});

			}

			

			// If a hash can not be used to trigger the plugin, then go to page 1

			if((base.options.hashTags == true && !base.gotoHash()) || base.options.hashTags == false){

				base.setCurrentPage(1);

			};

        };



		base.gotoPage = function(page, autoplay){

			// When autoplay isn't passed, we stop the timer

			if(autoplay !== true) autoplay = false;

			if(!autoplay) base.startStop(false);

			

			if(typeof(page) == "undefined" || page == null) {

				page = 1;

				base.setCurrentPage(1);

			};

			

			// Just check for bounds

			if(page > base.pages + 1) page = base.pages;

			if(page < 0 ) page = 1;



			var dir = page < base.currentPage ? -1 : 1,

                n = Math.abs(base.currentPage - page),

                left = base.singleWidth * dir * n;

			

			base.$wrapper.filter(':not(:animated)').animate({

                scrollLeft : '+=' + left

            }, base.options.animationTime, base.options.easing, function () {


                if (page == 0) {

                    base.$wrapper.scrollLeft(base.singleWidth * base.pages);

					page = base.pages;

                } else if (page > base.pages) {

                    base.$wrapper.scrollLeft(base.singleWidth);

                    // reset back to start position

                    page = 1;

                };

				base.setCurrentPage(page);

				

            });

		};

		

		base.setCurrentPage = function(page, move){

			// Set visual

			if(base.options.buildNavigation){

				base.$nav.find('.cur').removeClass('cur');

				$(base.$navLinks[page - 1]).addClass('cur');	

			};

			

			// Only change left if move does not equal false

			if(move !== false) base.$wrapper.scrollLeft(base.singleWidth * page);



			// Update local variable

			base.currentPage = page;

		};

		

		base.goForward = function(autoplay){

			if(autoplay !== true) autoplay = false;

			base.gotoPage(base.currentPage + 1, autoplay);

		};

		

		base.goBack = function(){

			base.gotoPage(base.currentPage - 1);

		};

		

		// This method tries to find a hash that matches panel-X

		// If found, it tries to find a matching item

		// If that is found as well, then that item starts visible

		base.gotoHash = function(){

			if(/^#?panel-\d+$/.test(window.location.hash)){

				var index = parseInt(window.location.hash.substr(7));

				var $item = base.$items.filter(':eq(' + index + ')');

				if($item.length != 0){

					base.setCurrentPage(index);

					return true;

				};

			};

			return false; // A item wasn't found;

		};

        

		// Creates the numbered navigation links

		base.buildNavigation = function(){

			base.$nav = $("<div id='thumbNav'></div>").appendTo(base.$el);

			base.$items.each(function(i,el){

				var index = i + 1;

				var $a = $("<a href='#'></a>");

				

				// If a formatter function is present, use it

				if( typeof(base.options.navigationFormatter) == "function"){

					$a.html(base.options.navigationFormatter(index, $(this)));

				} else {

					$a.text(index);

				}

				$a.click(function(e){
                    base.gotoPage(index);

                    

                    if (base.options.hashTags)

						base.setHash('panel-' + index);

						

                    e.preventDefault();

				});

				base.$nav.append($a);

			});

			base.$navLinks = base.$nav.find('> a');

		};

		

		

		// Creates the Forward/Backward buttons

		base.buildNextBackButtons = function(){

			var $forward = $('<a class="arrow forward">&gt;</a>'),

				$back    = $('<a class="arrow back">&lt;</a>');

				

            // Bind to the forward and back buttons

            $back.click(function(e){

                base.goBack();

				e.preventDefault();

            });



            $forward.click(function(e){

                base.goForward();

				e.preventDefault();

            });



			// Append elements to page

			base.$wrapper.after($back).after($forward);

		};

		

		// Creates the Start/Stop button

		base.buildAutoPlay = function(){



			base.$startStop = $("<a></a>").html(base.playing ? base.options.stopText :  base.options.startText);

			base.$el.append(base.$startStop);            

            base.$startStop.click(function(e){

				base.startStop(!base.playing);

				e.preventDefault();

            });



			// Use the same setting, but trigger the start;

			base.startStop(base.playing);

		};

		

		// Handles stopping and playing the slideshow

		// Pass startStop(false) to stop and startStop(true) to play

		base.startStop = function(playing){

			if(playing !== true) playing = false; // Default if not supplied is false

			

			// Update variable

			base.playing = playing;

			

			// Toggle playing and text

			if(base.options.autoPlay) base.$startStop.toggleClass("playing", playing).html( playing ? base.options.stopText : base.options.startText );

			

			if(playing){

				base.clearTimer(); // Just in case this was triggered twice in a row

				base.timer = window.setInterval(function(){

					base.goForward(true);

				}, base.options.delay);

			} else {

				base.clearTimer();

			};

		};

		

		base.clearTimer = function(){

			// Clear the timer only if it is set

			if(base.timer) window.clearInterval(base.timer);

		};

		

		// Taken from AJAXY jquery.history Plugin

		base.setHash = function ( hash ) {

			// Write hash

			if ( typeof window.location.hash !== 'undefined' ) {

				if ( window.location.hash !== hash ) {

					window.location.hash = hash;

				};

			} else if ( location.hash !== hash ) {

				location.hash = hash;

			};

			

			// Done

			return hash;

		};

		// <-- End AJAXY code





		// Trigger the initialization

        base.init();

    };



	

    $.anythingSlider.defaults = {

        easing: "swing",                // Anything other than "linear" or "swing" requires the easing plugin

        autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not

        startStopped: false,            // If autoPlay is on, this can force it to start stopped

        delay: 3000,                    // How long between slide transitions in AutoPlay mode

        animationTime: 600,             // How long the slide transition takes

        hashTags: true,                 // Should links change the hashtag in the URL?

        buildNavigation: true,          // If true, builds and list of anchor links to link to each slide

        pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover

		startText: "",             // Start text

		stopText: "",               // Stop text

		navigationFormatter: null       // Details at the top of the file on this use (advanced use)

    };

	



    $.fn.anythingSlider = function(options){

		if(typeof(options) == "object"){

		    return this.each(function(i){			

				(new $.anythingSlider(this, options));



	            // This plugin supports multiple instances, but only one can support hash-tag support

				// This disables hash-tags on all items but the first one

				options.hashTags = false;

	        });	

		} else if (typeof(options) == "number") {



			return this.each(function(i){

				var anySlide = $(this).data('AnythingSlider');

				if(anySlide){

					anySlide.gotoPage(options);

				}

			});

		}

    };



	

})(jQuery);


/**

 * jCarouselLite - jQuery plugin to navigate images/any content in a carousel style widget.

 * @requires jQuery v1.2 or above

 *

 * http://gmarwaha.com/jquery/jcarousellite/

 *

 * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com)

 * Dual licensed under the MIT and GPL licenses:

 * http://www.opensource.org/licenses/mit-license.php

 * http://www.gnu.org/licenses/gpl.html

 *

 * Version: 1.0.1

 * Note: Requires jquery 1.2 or above from version 1.0.1

 */



/**

 * Creates a carousel-style navigation widget for images/any-content from a simple HTML markup.

 *

 * The HTML markup that is used to build the carousel can be as simple as...

 *

 *  <div class="carousel">

 *      <ul>

 *          <li><img src="image/1.jpg" alt="1"></li>

 *          <li><img src="image/2.jpg" alt="2"></li>

 *          <li><img src="image/3.jpg" alt="3"></li>

 *      </ul>

 *  </div>

 *

 * As you can see, this snippet is nothing but a simple div containing an unordered list of images.

 * You don't need any special "class" attribute, or a special "css" file for this plugin.

 * I am using a class attribute just for the sake of explanation here.

 *

 * To navigate the elements of the carousel, you need some kind of navigation buttons.

 * For example, you will need a "previous" button to go backward, and a "next" button to go forward.

 * This need not be part of the carousel "div" itself. It can be any element in your page.

 * Lets assume that the following elements in your document can be used as next, and prev buttons...

 *

 * <button class="prev">&lt;&lt;</button>

 * <button class="next">&gt;&gt;</button>

 *

 * Now, all you need to do is call the carousel component on the div element that represents it, and pass in the

 * navigation buttons as options.

 *

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev"

 * });

 *

 * That's it, you would have now converted your raw div, into a magnificient carousel.

 *

 * There are quite a few other options that you can use to customize it though.

 * Each will be explained with an example below.

 *

 * @param an options object - You can specify all the options shown below as an options object param.

 *

 * @option btnPrev, btnNext : string - no defaults

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev"

 * });

 * @desc Creates a basic carousel. Clicking "btnPrev" navigates backwards and "btnNext" navigates forward.

 *

 * @option btnGo - array - no defaults

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      btnGo: [".0", ".1", ".2"]

 * });

 * @desc If you don't want next and previous buttons for navigation, instead you prefer custom navigation based on

 * the item number within the carousel, you can use this option. Just supply an array of selectors for each element

 * in the carousel. The index of the array represents the index of the element. What i mean is, if the

 * first element in the array is ".0", it means that when the element represented by ".0" is clicked, the carousel

 * will slide to the first element and so on and so forth. This feature is very powerful. For example, i made a tabbed

 * interface out of it by making my navigation elements styled like tabs in css. As the carousel is capable of holding

 * any content, not just images, you can have a very simple tabbed navigation in minutes without using any other plugin.

 * The best part is that, the tab will "slide" based on the provided effect. :-)

 *

 * @option mouseWheel : boolean - default is false

 * @example

 * $(".carousel").jCarouselLite({

 *      mouseWheel: true

 * });

 * @desc The carousel can also be navigated using the mouse wheel interface of a scroll mouse instead of using buttons.

 * To get this feature working, you have to do 2 things. First, you have to include the mouse-wheel plugin from brandon.

 * Second, you will have to set the option "mouseWheel" to true. That's it, now you will be able to navigate your carousel

 * using the mouse wheel. Using buttons and mouseWheel or not mutually exclusive. You can still have buttons for navigation

 * as well. They complement each other. To use both together, just supply the options required for both as shown below.

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      mouseWheel: true

 * });

 *

 * @option auto : number - default is null, meaning autoscroll is disabled by default

 * @example

 * $(".carousel").jCarouselLite({

 *      auto: 800,

 *      speed: 500

 * });

 * @desc You can make your carousel auto-navigate itself by specfying a millisecond value in this option.

 * The value you specify is the amount of time between 2 slides. The default is null, and that disables auto scrolling.

 * Specify this value and magically your carousel will start auto scrolling.

 *

 * @option speed : number - 200 is default

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      speed: 800

 * });

 * @desc Specifying a speed will slow-down or speed-up the sliding speed of your carousel. Try it out with

 * different speeds like 800, 600, 1500 etc. Providing 0, will remove the slide effect.

 *

 * @option easing : string - no easing effects by default.

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      easing: "bounceout"

 * });

 * @desc You can specify any easing effect. Note: You need easing plugin for that. Once specified,

 * the carousel will slide based on the provided easing effect.

 *

 * @option vertical : boolean - default is false

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      vertical: true

 * });

 * @desc Determines the direction of the carousel. true, means the carousel will display vertically. The next and

 * prev buttons will slide the items vertically as well. The default is false, which means that the carousel will

 * display horizontally. The next and prev items will slide the items from left-right in this case.

 *

 * @option circular : boolean - default is true

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      circular: false

 * });

 * @desc Setting it to true enables circular navigation. This means, if you click "next" after you reach the last

 * element, you will automatically slide to the first element and vice versa. If you set circular to false, then

 * if you click on the "next" button after you reach the last element, you will stay in the last element itself

 * and similarly for "previous" button and first element.

 *

 * @option visible : number - default is 3

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      visible: 4

 * });

 * @desc This specifies the number of items visible at all times within the carousel. The default is 3.

 * You are even free to experiment with real numbers. Eg: "3.5" will have 3 items fully visible and the

 * last item half visible. This gives you the effect of showing the user that there are more images to the right.

 *

 * @option start : number - default is 0

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      start: 2

 * });

 * @desc You can specify from which item the carousel should start. Remember, the first item in the carousel

 * has a start of 0, and so on.

 *

 * @option scrool : number - default is 1

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      scroll: 2

 * });

 * @desc The number of items that should scroll/slide when you click the next/prev navigation buttons. By

 * default, only one item is scrolled, but you may set it to any number. Eg: setting it to "2" will scroll

 * 2 items when you click the next or previous buttons.

 *

 * @option beforeStart, afterEnd : function - callbacks

 * @example

 * $(".carousel").jCarouselLite({

 *      btnNext: ".next",

 *      btnPrev: ".prev",

 *      beforeStart: function(a) {

 *          alert("Before animation starts:" + a);

 *      },

 *      afterEnd: function(a) {

 *          alert("After animation ends:" + a);

 *      }

 * });

 * @desc If you wanted to do some logic in your page before the slide starts and after the slide ends, you can

 * register these 2 callbacks. The functions will be passed an argument that represents an array of elements that

 * are visible at the time of callback.

 *

 *

 * @cat Plugins/Image Gallery

 * @author Ganeshji Marwaha/ganeshread@gmail.com

 */



(function($) {                                          // Compliant with jquery.noConflict()

$.fn.jCarouselLite = function(o) {

    o = $.extend({

        btnPrev: null,

        btnNext: null,

        btnGo: null,

        mouseWheel: false,

        auto: null,

        hoverPause: false,



        speed: 200,

        easing: null,



        vertical: false,

        circular: true,

        visible: 3,

        start: 0,

        scroll: 1,



        beforeStart: null,

        afterEnd: null

    }, o || {});



    return this.each(function() {                           // Returns the element collection. Chainable.



        var running = false, animCss=o.vertical?"top":"left", sizeCss=o.vertical?"height":"width";

        var div = $(this), ul = $("ul", div), tLi = $("li", ul), tl = tLi.size(), v = o.visible;



        if(o.circular) {

            ul.prepend(tLi.slice(tl-v+1).clone())

              .append(tLi.slice(0,o.scroll).clone());

            o.start += v-1;

        }



        var li = $("li", ul), itemLength = li.size(), curr = o.start;

        div.css("visibility", "visible");



        li.css({overflow: "hidden", float: o.vertical ? "none" : "left"});

        ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});

        div.css({overflow: "hidden", position: "relative", "z-index": "2", left: "0px"});



        var liSize = o.vertical ? height(li) : width(li);   // Full li size(incl margin)-Used for animation

        var ulSize = liSize * itemLength;                   // size of full ul(total length, not just for the visible items)

        var divSize = liSize * v;                           // size of entire div(total length for just the visible items)



        li.css({width: li.width(), height: li.height()});

        ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));



        div.css(sizeCss, divSize+"px");                     // Width of the DIV. length of visible images



        if(o.btnPrev) {

            $(o.btnPrev).click(function() {

                return go(curr-o.scroll);

            });

            if(o.hoverPause) {

                $(o.btnPrev).hover(function(){stopAuto();}, function(){startAuto();});

            }

        }





        if(o.btnNext) {

            $(o.btnNext).click(function() {

                return go(curr+o.scroll);

            });

            if(o.hoverPause) {

                $(o.btnNext).hover(function(){stopAuto();}, function(){startAuto();});

            }

        }



        if(o.btnGo)

            $.each(o.btnGo, function(i, val) {

                $(val).click(function() {

                    return go(o.circular ? o.visible+i : i);

                });

            });



        if(o.mouseWheel && div.mousewheel)

            div.mousewheel(function(e, d) {

                return d>0 ? go(curr-o.scroll) : go(curr+o.scroll);

            });



        var autoInterval;



        function startAuto() {

          stopAuto();

          autoInterval = setInterval(function() {

                  go(curr+o.scroll);

              }, o.auto+o.speed);

        };



        function stopAuto() {

            clearInterval(autoInterval);

        };



        if(o.auto) {

            if(o.hoverPause) {

                div.hover(function(){stopAuto();}, function(){startAuto();});

            }

            startAuto();

        };



        function vis() {

            return li.slice(curr).slice(0,v);

        };



        function go(to) {

            if(!running) {



                if(o.beforeStart)

                    o.beforeStart.call(this, vis());



                if(o.circular) {            // If circular we are in first or last, then goto the other end

                    if(to<0) {           // If before range, then go around

                        ul.css(animCss, -( (curr + tl) * liSize)+"px");

                        curr = to + tl;

                    } else if(to>itemLength-v) { // If beyond range, then come around

                        ul.css(animCss, -( (curr - tl) * liSize ) + "px" );

                        curr = to - tl;

                    } else curr = to;

                } else {                    // If non-circular and to points to first or last, we just return.

                    if(to<0 || to>itemLength-v) return;

                    else curr = to;

                }                           // If neither overrides it, the curr will still be "to" and we can proceed.



                running = true;



                ul.animate(

                    animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,

                    function() {

                        if(o.afterEnd)

                            o.afterEnd.call(this, vis());

                        running = false;

                    }

                );

                // Disable buttons when the carousel reaches the last/first, and enable when not

                if(!o.circular) {

                    $(o.btnPrev + "," + o.btnNext).removeClass("disabled");

                    $( (curr-o.scroll<0 && o.btnPrev)

                        ||

                       (curr+o.scroll > itemLength-v && o.btnNext)

                        ||

                       []

                     ).addClass("disabled");

                }



            }

            return false;

        };

    });

};



function css(el, prop) {

    return parseInt($.css(el[0], prop)) || 0;

};

function width(el) {

    return  el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');

};

function height(el) {

    return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');

};



})(jQuery);


