﻿/*
* jQuery verticalScroll
* Copyright (c) 2011 SaCaWeb www.sacaweb.com
* 
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:

* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE. 
*/

/*
* Version: V1.0
* Release: 23-02-2011
* Based on jQuery 1.4.2
*/



(function ($) {
    $.fn.verticalScrollPlus = function (options) {
        var options = $.extend({}, { speed: 500, step: 60, upID: "#textscrollup", downID: "#textscrolldown", scrollerID: "#scrollme" }, options);

        return this.each(function () {
            obj = $(this); //il wrapper
            obj.css("overflow", "hidden");
            obj.css("position", "relative");
            /*obj.css("height", options.height + "px");*/
            var wrapper_h = obj.outerHeight();
            var scroller_h = $(options.scrollerID).outerHeight();

            $(options.scrollerID).css("position", "absolute");
            $(options.scrollerID).css("top", "0px");
//            alert($(options.upID).width());

            function enableButtons() {
                //alert($(options.scrollerID).css("bottom"));
                var top = parseInt($(options.scrollerID).css("top"));
                var bot = top + scroller_h - wrapper_h;
                if (wrapper_h > scroller_h) {
                    $(options.upID).hide();
                    $(options.downID).hide();
                }
                if (top == 0) {
                    //alert('at top');
                    $(options.upID).removeClass('enabled');
                    //$(options.upID).addClass('arrowoff');
                } else {
                    //$(options.upID).removeClass('arrowoff');
                    $(options.upID).addClass('enabled');
                }
                if (bot == 0) {
                    //alert(bot);
                    $(options.downID).removeClass('enabled');
                    //$(options.downID).addClass('arrowoff');
                } else {
                    //$(options.downID).removeClass('arrowoff');
                    $(options.downID).addClass('enabled');
                }
                //alert('hello');
                //$(options.upID).removeClass('arrow');
                //$(options.upID).addClass('arrowoff');
            }

            $(options.downID).click(function () {
                var scroller_top2 = parseInt($(options.scrollerID).css("top"));
                if ((scroller_top2 - wrapper_h - options.step) < -scroller_h) {
                    var offset2 = scroller_h - wrapper_h;
                    $(options.scrollerID).stop().animate({ top: "-" + offset2 + "px" }, options.speed, function () { enableButtons() });
                    //enablebuttons();
                    return;
                }
                $(options.scrollerID).stop().animate({
                    top: "-=" + options.step + "px"
                }, options.speed, function () { enableButtons() });
                //enablebuttons();
            });

            $(options.upID).click(function () {
                var scroller_top = parseInt($(options.scrollerID).css("top"));
                var offset = scroller_top + wrapper_h;
                if (offset > 0) {
                    $(options.scrollerID).stop().animate({ top: 0 }, options.speed, function () { enableButtons() });
                    //enablebuttons();
                    return;
                }
                $(options.scrollerID).stop().animate({
                    top: "+=" + options.step + "px"
                }, options.speed, function () { enableButtons() });
                //enablebuttons();
            });

            enableButtons();
        });

    };

})(jQuery);






/*
* jQuery Cycle Lite Plugin
* http://malsup.com/jquery/cycle/lite/
* Copyright (c) 2008-2011 M. Alsup
* Version: 1.3 (01-JUN-2011)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
* Requires: jQuery v1.3.2 or later
*/
(function ($) {

    var ver = 'Lite-1.3';

    $.fn.cycle = function (options) {
        return this.each(function () {
            options = options || {};

            if (this.cycleTimeout) clearTimeout(this.cycleTimeout);
            this.cycleTimeout = 0;
            this.cyclePause = 0;

            var $cont = $(this);
            var $slides = options.slideExpr ? $(options.slideExpr, this) : $cont.children();
            var els = $slides.get();
            if (els.length < 2) {
                window.console && console.log('terminating; too few slides: ' + els.length);
                return; // don't bother
            }

            // support metadata plugin (v1.0 and v2.0)
            var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
            var meta = $.isFunction($cont.data) ? $cont.data(opts.metaAttr) : null;
            if (meta)
                opts = $.extend(opts, meta);

            opts.before = opts.before ? [opts.before] : [];
            opts.after = opts.after ? [opts.after] : [];
            opts.after.unshift(function () { opts.busy = 0; });

            // allow shorthand overrides of width, height and timeout
            var cls = this.className;
            opts.width = parseInt((cls.match(/w:(\d+)/) || [])[1]) || opts.width;
            opts.height = parseInt((cls.match(/h:(\d+)/) || [])[1]) || opts.height;
            opts.timeout = parseInt((cls.match(/t:(\d+)/) || [])[1]) || opts.timeout;

            if ($cont.css('position') == 'static')
                $cont.css('position', 'relative');
            if (opts.width)
                $cont.width(opts.width);
            if (opts.height && opts.height != 'auto')
                $cont.height(opts.height);

            var first = 0;
            $slides.css({ position: 'absolute', top: 0, left: 0 }).each(function (i) {
                $(this).css('z-index', els.length - i)
            });

            $(els[first]).css('opacity', 1).show(); // opacity bit needed to handle reinit case
            if ($.browser.msie) els[first].style.removeAttribute('filter');

            if (opts.fit && opts.width)
                $slides.width(opts.width);
            if (opts.fit && opts.height && opts.height != 'auto')
                $slides.height(opts.height);
            if (opts.pause)
                $cont.hover(function () { this.cyclePause = 1; }, function () { this.cyclePause = 0; });

            var txFn = $.fn.cycle.transitions[opts.fx];
            txFn && txFn($cont, $slides, opts);

            $slides.each(function () {
                var $el = $(this);
                this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
                this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
            });

            if (opts.cssFirst)
                $($slides[first]).css(opts.cssFirst);

            if (opts.timeout) {
                // ensure that timeout and speed settings are sane
                if (opts.speed.constructor == String)
                    opts.speed = { slow: 600, fast: 200}[opts.speed] || 400;
                if (!opts.sync)
                    opts.speed = opts.speed / 2;
                while ((opts.timeout - opts.speed) < 250)
                    opts.timeout += opts.speed;
            }
            opts.speedIn = opts.speed;
            opts.speedOut = opts.speed;

            opts.slideCount = els.length;
            opts.currSlide = first;
            opts.nextSlide = 1;

            // fire artificial events
            var e0 = $slides[first];
            if (opts.before.length)
                opts.before[0].apply(e0, [e0, e0, opts, true]);
            if (opts.after.length > 1)
                opts.after[1].apply(e0, [e0, e0, opts, true]);

            if (opts.click && !opts.next)
                opts.next = opts.click;
            if (opts.next)
                $(opts.next).bind('click', function () { return advance(els, opts, opts.rev ? -1 : 1) });
            if (opts.prev)
                $(opts.prev).bind('click', function () { return advance(els, opts, opts.rev ? 1 : -1) });

            if (opts.timeout)
                this.cycleTimeout = setTimeout(function () {
                    go(els, opts, 0, !opts.rev)
                }, opts.timeout + (opts.delay || 0));
        });
    };

    function go(els, opts, manual, fwd) {
        if (opts.busy) return;
        var p = els[0].parentNode, curr = els[opts.currSlide], next = els[opts.nextSlide];
        if (p.cycleTimeout === 0 && !manual)
            return;

        if (manual || !p.cyclePause) {
            if (opts.before.length)
                $.each(opts.before, function (i, o) { o.apply(next, [curr, next, opts, fwd]); });
            var after = function () {
                if ($.browser.msie)
                    this.style.removeAttribute('filter');
                $.each(opts.after, function (i, o) { o.apply(next, [curr, next, opts, fwd]); });
            };

            if (opts.nextSlide != opts.currSlide) {
                opts.busy = 1;
                $.fn.cycle.custom(curr, next, opts, after);
            }
            var roll = (opts.nextSlide + 1) == els.length;
            opts.nextSlide = roll ? 0 : opts.nextSlide + 1;
            opts.currSlide = roll ? els.length - 1 : opts.nextSlide - 1;
        }
        if (opts.timeout)
            p.cycleTimeout = setTimeout(function () { go(els, opts, 0, !opts.rev) }, opts.timeout);
    };

    // advance slide forward or back
    function advance(els, opts, val) {
        var p = els[0].parentNode, timeout = p.cycleTimeout;
        if (timeout) {
            clearTimeout(timeout);
            p.cycleTimeout = 0;
        }
        opts.nextSlide = opts.currSlide + val;
        if (opts.nextSlide < 0) {
            opts.nextSlide = els.length - 1;
        }
        else if (opts.nextSlide >= els.length) {
            opts.nextSlide = 0;
        }
        go(els, opts, 1, val >= 0);
        return false;
    };

    $.fn.cycle.custom = function (curr, next, opts, cb) {
        var $l = $(curr), $n = $(next);
        $n.css(opts.cssBefore);
        var fn = function () { $n.animate(opts.animIn, opts.speedIn, opts.easeIn, cb) };
        $l.animate(opts.animOut, opts.speedOut, opts.easeOut, function () {
            $l.css(opts.cssAfter);
            if (!opts.sync) fn();
        });
        if (opts.sync) fn();
    };

    $.fn.cycle.transitions = {
        fade: function ($cont, $slides, opts) {
            $slides.not(':eq(0)').hide();
            opts.cssBefore = { opacity: 0, display: 'block' };
            opts.cssAfter = { display: 'none' };
            opts.animOut = { opacity: 0 };
            opts.animIn = { opacity: 1 };
        },
        fadeout: function ($cont, $slides, opts) {
            opts.before.push(function (curr, next, opts, fwd) {
                $(curr).css('zIndex', opts.slideCount + (fwd === true ? 1 : 0));
                $(next).css('zIndex', opts.slideCount + (fwd === true ? 0 : 1));
            });
            $slides.not(':eq(0)').hide();
            opts.cssBefore = { opacity: 1, display: 'block', zIndex: 1 };
            opts.cssAfter = { display: 'none', zIndex: 0 };
            opts.animOut = { opacity: 0 };
        }
    };

    $.fn.cycle.ver = function () { return ver; };

    $.fn.cycle.defaults = {
        animIn: {},
        animOut: {},
        fx: 'fade',
        after: null,
        before: null,
        cssBefore: {},
        cssAfter: {},
        delay: 0,
        fit: 0,
        height: 'auto',
        metaAttr: 'cycle',
        next: null,
        pause: 0,
        prev: null,
        speed: 1000,
        slideExpr: null,
        sync: 1,
        timeout: 3000
    };

})(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
*/



(function ($) {                                          // Compliant with jquery.noConflict()
    $.fn.jCarouselLite = function (o) {
        o = $.extend({
            btnPrev: null,
            btnNext: null,
            btnGo: null,
            mouseWheel: false,
            auto: null,

            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 + 1).clone())
              .append(tLi.slice(0, v).clone());
                o.start += v;
            }

            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.btnNext)
                $(o.btnNext).click(function () {
                    return go(curr + o.scroll);
                });

            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);
                });

            if (o.auto)
                setInterval(function () {
                    go(curr + o.scroll);
                }, o.auto + o.speed);

            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 <= o.start - v - 1) {           // If first, then goto last
                            ul.css(animCss, -((itemLength - (v * 2)) * liSize) + "px");
                            // If "scroll" > 1, then the "to" might not be equal to the condition; it can be lesser depending on the number of elements.
                            curr = to == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll;
                        } else if (to >= itemLength - v + 1) { // If last, then goto first
                            ul.css(animCss, -((v) * liSize) + "px");
                            // If "scroll" > 1, then the "to" might not be equal to the condition; it can be greater depending on the number of elements.
                            curr = to == itemLength - v + 1 ? v + 1 : v + o.scroll;
                        } 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).addClass("enabled");
                        $((curr - o.scroll < 0 && o.btnPrev)
                        ||
                       (curr + o.scroll > itemLength - v && o.btnNext)
                        ||
                       []
                     ).removeClass("enabled");
                    }

                }
                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);



