/* ------------------------------------------------------------------------------------------------------------------------------------
* All plugin are made by Boris Strahija
* Copyright 2009, Boris Strahija
* http://www.creolab.hr/
*
* ------------------------------------------------------------------------------------------------------------------------------------ */

/* ------------------------------------------------------------------------------------------------------------------------------------ */
// !/===> Div link
// searches the element for anchor tags and adds the first one as the click action
/* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($) {
    $.fn.divlink = function(params) {
        // Default options
        var params = jQuery.extend({

    }, params);

    $(this).each(function() {
        var $el = $(this);
        var $first_link = $el.find("a")[0];
        $el.css("cursor", "pointer");
        $el.hover(
				 function() { $(this).addClass("hover"); }
				, function() { $(this).removeClass("hover"); }
			);
        $(this).click(function() {
            document.location = $($first_link).attr("href");
        });
    }); //end each()

}; //end function()
})(jQuery);

/* ------------------------------------------------------------------------------------------------------------------------------------ */
// !/===> Select Widget
// custom select box
/* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($) {
    $.fn.selectWidget = function(params) {
        // Default options
        var params = jQuery.extend({
            onSelect: false
			 , href: false
			 , extra_class: false
			 , hide_label: false
        }, params);

        $(this).each(function() {
            // Read combo data
            var $combo = $(this);
            var init_label = "-";
            var init_val = "";
            var visible_el = 0; // Number of visible elemets (default 0 = all)

            // Hide the combobox
            $combo.hide();

            // First we prepare the required HTML
            var $el = $('<div class="select-widget"></div>'); $combo.after($el);
            var $handle = $('<p class="selected"><a href="#"><span>' + init_label + '</span></a></p>'); $el.append($handle);
            var $drop = $('<div class="drop"></div>');
            var $scrollable = $('<div class="scrollable"></div>');
            var $list = $('<ul></ul>');

            // Add extra class
            if (params.extra_class) {
                $el.addClass(params.extra_class);
            } //end if

            // Get number of visible elements
            visible_el = $combo.attr("rel");

            // Add options
            $combo.children('option').each(function() {
                // Selected class
                var sel_class = ' class="';
                if ($(this).attr("value") == $combo.val()) sel_class += 'sel';
                if ($(this).hasClass("label")) sel_class += ' label';
                sel_class += '"';

                // Prepare HTML
                var html = $(this).text();
                html = html.replace('*(', '<strong>(');
                html = html.replace(')*', ')</strong>');
                html = html.replace('_(', '<em>(');
                html = html.replace(')_', ')</em>');

                // Append to list
                $list.append('<li' + sel_class + '><a href="#" rel="' + $(this).attr("value") + '">' + html + '</a></li>');
            });

            // And add to list
            if (visible_el > 0) { // If number of visible elements shoul be limited, we add a new scroll container
                $scrollable.append($list);
                $drop.append($scrollable);
                $el.append($drop);
            } else {
                $drop.append($list);
                $el.append($drop);
            } // end if

            // Rest of options
            var href = params.href;
            var selected_value = 0;
            var init = true;

            // Hide the list and align it
            $drop.hide().css({
                top: $handle.height() - 2
            });

            // Add click event on handle
            $handle.children("a").click(function() {
                $el.toggleClass("select-widget-open");
                $drop.toggle().css({
                    top: $handle.height() - 2
                });
                $(".select-widget").not($el).removeClass("select-widget-open");
                $(".select-widget .drop").not($drop).hide();
                $drop.find(".jspPane").hide().show(); // IE rendering bug
                return false;
            });

            // Add click event on select elements
            $list.children("li").children("a").click(function() {
                var label = $(this).html();
                selected_value = $(this).attr("rel");

                // Hide the label
                if (params.hide_label) {
                    $thisli = $(this).parent("li");
                    if (!$thisli.hasClass("label")) {
                        $list.children("li.label").hide();
                    } //end if
                } //end if

                // Set values
                $handle.children("a").children("span").html('<b>' + label + '</b>');
                $combo.val(selected_value);

                // Hide the list and open class
                $el.removeClass("select-widget-open");
                $drop.hide();
                if (init === false) $combo.change();

                // Redirect on select
                if (init == false && params.onSelect == "submit" && href) {
                    document.location = href + "?" + $combo.attr("name") + "=" + selected_value;
                } // end if

                return false;
            });

            // Select initial if it exists
            $list.children("li.sel").children("a").click();

            // Hide label from selection
            if (params.hide_label) {
                $list.children("li.label").remove();
            } //end if

            // Reset init
            init = false;

            // Add blur action
            $el.blur(function() {
                $el.removeClass("select-widget-open");
                $drop.hide();
            });

            // Run the scroll plugin if necesary
            if (visible_el > 0 && visible_el < $list.children("li").length) {
                // The drop box should be visible
                $drop.show();

                // Get the required height and set height for scrollable area
                var required_height = (visible_el * $list.children("li").height()) + 10;
                $scrollable.height(required_height);

                // Run scroll plugin
                $scrollable.jScrollPane({
                    verticalGutter: -5
					, showArrows: true
                });
                $drop.hide();
            } // end if

        }); //end each()

    }; //end selectWidget()
})(jQuery);


/* ------------------------------------------------------------------------------------------------------------------------------------ */
// !/===> Select Widget
// custom select box
/* ------------------------------------------------------------------------------------------------------------------------------------ */
/*(function($) {
    $.fn.selectWidget = function(params) {
        // Default options
        var params = jQuery.extend({
            onSelect: false
			 , href: false
			 , extra_class: false
			 , hide_label: false
        }, params);

        $(this).each(function() {
            // Read combo data
        var $combo = $(this);
            var init_label = "-";
            var init_val = "";

            // Hide the combobox
            $combo.hide();

            // First we prepare the required HTML
            /* AP 2010-11-30 ADDING z-index information for IE /
            var $el = $('<div class="select-widget" style="z-index: ' + $combo.parent().css("z-index") + ';"></div>'); $combo.after($el);
            var $handle = $('<p class="selected"><a href="#"><span>' + init_label + '</span></a></p>'); $el.append($handle);
            var $drop = $('<div class="drop"></div>');
            var $list = $('<ul style="z-index: 1000;"></ul>');

            // Add extra class
            if (params.extra_class) {
                $el.addClass(params.extra_class);
            } //end if

            // Add options
            $combo.children('option').each(function() {
                // Selected class
                var sel_class = ' class="';
                if ($(this).attr("value") == $combo.val()) sel_class += 'sel';
                if ($(this).hasClass("label")) sel_class += ' label';
                sel_class += '"';

                // Prepare HTML
                var html = $(this).text();
                html = html.replace('*(', '<strong>(');
                html = html.replace(')*', ')</strong>');
                html = html.replace('_(', '<em>(');
                html = html.replace(')_', ')</em>');

                // Append to list
                $list.append('<li' + sel_class + '><a href="#" rel="' + $(this).attr("value") + '">' + html + '</a></li>');
            });

            // And add to list
            $drop.append($list);
            $el.append($drop);

            // Rest of options
            var href = params.href;
            var selected_value = 0;
            var init = true;

            // Hide the list and align it
            $drop.hide().css({
                top: $handle.height() - 2
            });

            // Add click event on handle
            $handle.children("a").click(function() {
                $el.toggleClass("select-widget-open");
                $drop.toggle().css({
                    top: $handle.height() - 2
                });
                $(".select-widget").not($el).removeClass("select-widget-open");
                $(".select-widget .drop").not($drop).hide();
                return false;
            });

            // Add click event on select elements
            $list.children("li").children("a").click(function() {
                var label = $(this).html();
                selected_value = $(this).attr("rel");

                // Hide the label
                if (params.hide_label) {
                    $thisli = $(this).parent("li");
                    if (!$thisli.hasClass("label")) {
                        $list.children("li.label").hide();
                    } //end if
                } //end if

                // Set values
                $handle.children("a").children("span").html(label);
                $combo.val(selected_value);

                // Hide the list and open class
                $el.removeClass("select-widget-open");
                $drop.hide();
                if (init === false) $combo.change();

                // Redirect on select
                if (init == false && params.onSelect == "submit" && href) {
                    document.location = href + "?" + $combo.attr("name") + "=" + selected_value;
                } // end if

                return false;
            });

            // Select initial if it exists
            $list.children("li.sel").children("a").click();

            // Hide label from selection
            if (params.hide_label) {
                $list.children("li.label").remove();
            } //end if

            // Reset init
            init = false;

            // Add blur action
            $el.blur(function() {
                $el.removeClass("select-widget-open");
                $drop.hide();
            });

        }); //end each()

    }; //end selectWidget()
})(jQuery); */



/* ------------------------------------------------------------------------------------------------------------------------------------
/* !/===> Tabs */
/* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($) {
    $.fn.tabbed = function(params) {
        // Default options
        var params = jQuery.extend({
            hashnav: true
			  , scroll: false
        }, params);

        $(this).each(function() {
            var el = $(this);

            // Init marker
            $(el).find(".tabs a").css("outline", "none");
            $(el).find(".tabs a").removeClass("on");
            $(el).find(".tab-cont > .cx").hide();

            // Init content
            var tab_hash = hash.split("-");
            if (params.hashnav && tab_hash && tab_hash[0] && tab_hash[1] && tab_hash[0] == 'tabbed') {
                $(el).find(".tabs a:eq(" + tab_hash[1] + ")").addClass("on");
                $(el).find(".tab-cont > .cx:eq(" + tab_hash[1] + ")").show();
            } else {
                $(el).find(".tabs a:eq(0)").addClass("on");
                $(el).find(".tab-cont > .cx:eq(0)").show();
            } //end if

            // Fix tabs in IE6
            //if ($.browser.msie) $(el).find(".tabs a em").wrapInner('<span></span>');

            // Add click events
            $(el).find(".tabs a").each(function(num) {
                $(this).click(function() {
                    // Marker
                    $(el).find(".tabs a").removeClass("on");
                    $(this).addClass("on");

                    // Content
                    $(el).find(".tab-cont .cx").hide();
                    $(el).find(".tab-cont .cx:eq(" + num + ")").show();

                    // Set URL hash
                    if (params.hashnav) document.location.hash = "#tabbed-" + num;

                    return false;
                }); //end click()
            }); //end each()
        }); // end each()
    }; //end function()
})(jQuery);







/* ------------------------------------------------------------------------------------------------------------------------------------
* Equal height columns
* ------------------------------------------------------------------------------------------------------------------------------------ */
(function($) {
    $.fn.equalHeight = function(substract) {
        var tallest = 0;
        $(this).each(function() {
            var $el = $(this);
            var this_height = $el.height();
            if ($.browser.msie || $.browser.opera) this_height = $el.innerHeight();
            if (this_height > tallest) {
                tallest = this_height;
            } //end if
        });
        if (substract) tallest -= substract;
        //$(this).height(tallest);
        $(this).css({ "height": tallest + "px" });
    };
})(jQuery);



/* ------------------------------------------------------------------------------------------------------------------------------------
* Console log
* ------------------------------------------------------------------------------------------------------------------------------------ */
// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
window.log = function() {
    log.history = log.history || [];   // store logs to an array for reference
    log.history.push(arguments);
    if (this.console) {
        console.log(Array.prototype.slice.call(arguments));
    }
};




/* ------------------------------------------------------------------------------------------------------------------------------------
* Jcarousel Lite
* ------------------------------------------------------------------------------------------------------------------------------------ */
(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;
            if (typeof (li[0]) != "undefined") {
                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);
                return curr;
            };

            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
/* AP 2010-11-22 REMOVED */                    
/*                    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);

/*
* jScrollPane - v2.0.0beta6 - 2010-10-28
* http://jscrollpane.kelvinluck.com/
*
* Copyright (c) 2010 Kelvin Luck
* Dual licensed under the MIT and GPL licenses.
*/
(function(b, a, c) {
    b.fn.jScrollPane = function(f) {
        function d(C, L) {
            var au, N = this, V, ah, v, aj, Q, W, y, q, av, aB, ap, i, H, h, j, X, R, al, U, t, A, am, ac, ak, F, l, ao, at, x, aq, aE, g, aA, ag = true, M = true, aD = false, k = false, Z = b.fn.mwheelIntent ? "mwheelIntent.jsp" : "mousewheel.jsp"; aE = C.css("paddingTop") + " " + C.css("paddingRight") + " " + C.css("paddingBottom") + " " + C.css("paddingLeft"); g = (parseInt(C.css("paddingLeft")) || 0) + (parseInt(C.css("paddingRight")) || 0); an(L); function an(aH) { var aL, aK, aJ, aG, aF, aI; au = aH; if (V == c) { C.css({ overflow: "hidden", padding: 0 }); ah = C.innerWidth() + g; v = C.innerHeight(); C.width(ah); V = b('<div class="jspPane" />').wrap(b('<div class="jspContainer" />').css({ width: ah + "px", height: v + "px" })); C.wrapInner(V.parent()); aj = C.find(">.jspContainer"); V = aj.find(">.jspPane"); V.css("padding", aE) } else { C.css("width", ""); aI = C.outerWidth() + g != ah || C.outerHeight() != v; if (aI) { ah = C.innerWidth() + g; v = C.innerHeight(); aj.css({ width: ah + "px", height: v + "px" }) } aA = V.innerWidth(); if (!aI && V.outerWidth() == Q && V.outerHeight() == W) { if (aB || av) { V.css("width", aA + "px"); C.css("width", (aA + g) + "px") } return } V.css("width", ""); C.css("width", (ah) + "px"); aj.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end() } aL = V.clone().css("position", "absolute"); aK = b('<div style="width:1px; position: relative;" />').append(aL); b("body").append(aK); Q = Math.max(V.outerWidth(), aL.outerWidth()); aK.remove(); W = V.outerHeight(); y = Q / ah; q = W / v; av = q > 1; aB = y > 1; if (!(aB || av)) { C.removeClass("jspScrollable"); V.css({ top: 0, width: aj.width() - g }); n(); D(); O(); w(); af() } else { C.addClass("jspScrollable"); aJ = au.maintainPosition && (H || X); if (aJ) { aG = ay(); aF = aw() } aC(); z(); E(); if (aJ) { K(aG); J(aF) } I(); ad(); if (au.enableKeyboardNavigation) { P() } if (au.clickOnTrack) { p() } B(); if (au.hijackInternalLinks) { m() } } if (au.autoReinitialise && !aq) { aq = setInterval(function() { an(au) }, au.autoReinitialiseDelay) } else { if (!au.autoReinitialise && aq) { clearInterval(aq) } } C.trigger("jsp-initialised", [aB || av]) } function aC() { if (av) { aj.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'), b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'), b('<div class="jspDragBottom" />'))), b('<div class="jspCap jspCapBottom" />'))); R = aj.find(">.jspVerticalBar"); al = R.find(">.jspTrack"); ap = al.find(">.jspDrag"); if (au.showArrows) { am = b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp", az(0, -1)).bind("click.jsp", ax); ac = b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp", az(0, 1)).bind("click.jsp", ax); if (au.arrowScrollOnHover) { am.bind("mouseover.jsp", az(0, -1, am)); ac.bind("mouseover.jsp", az(0, 1, ac)) } ai(al, au.verticalArrowPositions, am, ac) } t = v; aj.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function() { t -= b(this).outerHeight() }); ap.hover(function() { ap.addClass("jspHover") }, function() { ap.removeClass("jspHover") }).bind("mousedown.jsp", function(aF) { b("html").bind("dragstart.jsp selectstart.jsp", function() { return false }); ap.addClass("jspActive"); var s = aF.pageY - ap.position().top; b("html").bind("mousemove.jsp", function(aG) { S(aG.pageY - s, false) }).bind("mouseup.jsp mouseleave.jsp", ar); return false }); o() } } function o() { al.height(t + "px"); H = 0; U = au.verticalGutter + al.outerWidth(); V.width(ah - U - g); if (R.position().left == 0) { V.css("margin-left", U + "px") } } function z() {
                if (aB) {
                    aj.append(b('<div class="jspHorizontalBar" style="display: none;" />').append(b('<div class="jspCap jspCapLeft" />'), b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'), b('<div class="jspDragRight" />'))), b('<div class="jspCap jspCapRight" />'))); ak = aj.find(">.jspHorizontalBar"); F = ak.find(">.jspTrack"); h = F.find(">.jspDrag"); if (au.showArrows) {
                        at = b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp", az(-1, 0)).bind("click.jsp", ax); x = b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp", az(1, 0)).bind("click.jsp", ax); if (au.arrowScrollOnHover) {
                            at.bind("mouseover.jsp", az(-1, 0, at));
                            x.bind("mouseover.jsp", az(1, 0, x))
                        } ai(F, au.horizontalArrowPositions, at, x)
                    } h.hover(function() { h.addClass("jspHover") }, function() { h.removeClass("jspHover") }).bind("mousedown.jsp", function(aF) { b("html").bind("dragstart.jsp selectstart.jsp", function() { return false }); h.addClass("jspActive"); var s = aF.pageX - h.position().left; b("html").bind("mousemove.jsp", function(aG) { T(aG.pageX - s, false) }).bind("mouseup.jsp mouseleave.jsp", ar); return false }); l = aj.innerWidth(); ae()
                } else { } 
            } function ae() { aj.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function() { l -= b(this).outerWidth() }); F.width(l + "px"); X = 0 } function E() { if (aB && av) { var aF = F.outerHeight(), s = al.outerWidth(); t -= aF; b(ak).find(">.jspCap:visible,>.jspArrow").each(function() { l += b(this).outerWidth() }); l -= s; v -= s; ah -= aF; F.parent().append(b('<div class="jspCorner" />').css("width", aF + "px")); o(); ae() } if (aB) { V.width((aj.outerWidth() - g) + "px") } W = V.outerHeight(); q = W / v; if (aB) { ao = 1 / y * l; if (ao > au.horizontalDragMaxWidth) { ao = au.horizontalDragMaxWidth } else { if (ao < au.horizontalDragMinWidth) { ao = au.horizontalDragMinWidth } } h.width(ao + "px"); j = l - ao; ab(X) } if (av) { A = 1 / q * t; if (A > au.verticalDragMaxHeight) { A = au.verticalDragMaxHeight } else { if (A < au.verticalDragMinHeight) { A = au.verticalDragMinHeight } } ap.height(A + "px"); i = t - A; aa(H) } } function ai(aG, aI, aF, s) { var aK = "before", aH = "after", aJ; if (aI == "os") { aI = /Mac/.test(navigator.platform) ? "after" : "split" } if (aI == aK) { aH = aI } else { if (aI == aH) { aK = aI; aJ = aF; aF = s; s = aJ } } aG[aK](aF)[aH](s) } function az(aF, s, aG) { return function() { G(aF, s, this, aG); this.blur(); return false } } function G(aH, aF, aK, aJ) { aK = b(aK).addClass("jspActive"); var aI, s = function() { if (aH != 0) { T(X + aH * au.arrowButtonSpeed, false) } if (aF != 0) { S(H + aF * au.arrowButtonSpeed, false) } }, aG = setInterval(s, au.arrowRepeatFreq); s(); aI = aJ == c ? "mouseup.jsp" : "mouseout.jsp"; aJ = aJ || b("html"); aJ.bind(aI, function() { aK.removeClass("jspActive"); clearInterval(aG); aJ.unbind(aI) }) } function p() { w(); if (av) { al.bind("mousedown.jsp", function(aH) { if (aH.originalTarget == c || aH.originalTarget == aH.currentTarget) { var aG = b(this), s = setInterval(function() { var aI = aG.offset(), aJ = aH.pageY - aI.top; if (H + A < aJ) { S(H + au.trackClickSpeed) } else { if (aJ < H) { S(H - au.trackClickSpeed) } else { aF() } } }, au.trackClickRepeatFreq), aF = function() { s && clearInterval(s); s = null; b(document).unbind("mouseup.jsp", aF) }; b(document).bind("mouseup.jsp", aF); return false } }) } if (aB) { F.bind("mousedown.jsp", function(aH) { if (aH.originalTarget == c || aH.originalTarget == aH.currentTarget) { var aG = b(this), s = setInterval(function() { var aI = aG.offset(), aJ = aH.pageX - aI.left; if (X + ao < aJ) { T(X + au.trackClickSpeed) } else { if (aJ < X) { T(X - au.trackClickSpeed) } else { aF() } } }, au.trackClickRepeatFreq), aF = function() { s && clearInterval(s); s = null; b(document).unbind("mouseup.jsp", aF) }; b(document).bind("mouseup.jsp", aF); return false } }) } } function w() { F && F.unbind("mousedown.jsp"); al && al.unbind("mousedown.jsp") } function ar() { b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp"); ap && ap.removeClass("jspActive"); h && h.removeClass("jspActive") } function S(s, aF) { if (!av) { return } if (s < 0) { s = 0 } else { if (s > i) { s = i } } if (aF == c) { aF = au.animateScroll } if (aF) { N.animate(ap, "top", s, aa) } else { ap.css("top", s); aa(s) } } function aa(aF) { if (aF == c) { aF = ap.position().top } aj.scrollTop(0); H = aF; var aI = H == 0, aG = H == i, aH = aF / i, s = -aH * (W - v); if (ag != aI || aD != aG) { ag = aI; aD = aG; C.trigger("jsp-arrow-change", [ag, aD, M, k]) } u(aI, aG); V.css("top", s); C.trigger("jsp-scroll-y", [-s, aI, aG]) } function T(aF, s) { if (!aB) { return } if (aF < 0) { aF = 0 } else { if (aF > j) { aF = j } } if (s == c) { s = au.animateScroll } if (s) { N.animate(h, "left", aF, ab) } else { h.css("left", aF); ab(aF) } } function ab(aF) { if (aF == c) { aF = h.position().left } aj.scrollTop(0); X = aF; var aI = X == 0, aH = X == j, aG = aF / j, s = -aG * (Q - ah); if (M != aI || k != aH) { M = aI; k = aH; C.trigger("jsp-arrow-change", [ag, aD, M, k]) } r(aI, aH); V.css("left", s); C.trigger("jsp-scroll-x", [-s, aI, aH]) } function u(aF, s) { if (au.showArrows) { am[aF ? "addClass" : "removeClass"]("jspDisabled"); ac[s ? "addClass" : "removeClass"]("jspDisabled") } } function r(aF, s) {
                if (au.showArrows) {
                    at[aF ? "addClass" : "removeClass"]("jspDisabled");
                    x[s ? "addClass" : "removeClass"]("jspDisabled")
                } 
            } function J(s, aF) { var aG = s / (W - v); S(aG * i, aF) } function K(aF, s) { var aG = aF / (Q - ah); T(aG * j, s) } function Y(aR, aM, aG) { var aK, aH, aI, s = 0, aQ = 0, aF, aL, aO, aN, aP; try { aK = b(aR) } catch (aJ) { return } aH = aK.outerHeight(); aI = aK.outerWidth(); aj.scrollTop(0); aj.scrollLeft(0); while (!aK.is(".jspPane")) { s += aK.position().top; aQ += aK.position().left; aK = aK.offsetParent(); if (/^body|html$/i.test(aK[0].nodeName)) { return } } aF = aw(); aL = aF + v; if (s < aF || aM) { aN = s - au.verticalGutter } else { if (s + aH > aL) { aN = s - v + aH + au.verticalGutter } } if (aN) { J(aN, aG) } viewportLeft = ay(); aO = viewportLeft + ah; if (aQ < viewportLeft || aM) { aP = aQ - au.horizontalGutter } else { if (aQ + aI > aO) { aP = aQ - ah + aI + au.horizontalGutter } } if (aP) { K(aP, aG) } } function ay() { return -V.position().left } function aw() { return -V.position().top } function ad() { aj.unbind(Z).bind(Z, function(aI, aJ, aH, aF) { var aG = X, s = H; T(X + aH * au.mouseWheelSpeed, false); S(H - aF * au.mouseWheelSpeed, false); return aG == X && s == H }) } function n() { aj.unbind(Z) } function ax() { return false } function I() { V.unbind("focusin.jsp").bind("focusin.jsp", function(s) { if (s.target === V[0]) { return } Y(s.target, false) }) } function D() { V.unbind("focusin.jsp") } function P() { var aF, s; C.attr("tabindex", 0).unbind("keydown.jsp").bind("keydown.jsp", function(aJ) { if (aJ.target !== C[0]) { return } var aH = X, aG = H, aI = aF ? 2 : 16; switch (aJ.keyCode) { case 40: S(H + aI, false); break; case 38: S(H - aI, false); break; case 34: case 32: J(aw() + Math.max(32, v) - 16); break; case 33: J(aw() - v + 16); break; case 35: J(W - v); break; case 36: J(0); break; case 39: T(X + aI, false); break; case 37: T(X - aI, false); break } if (!(aH == X && aG == H)) { aF = true; clearTimeout(s); s = setTimeout(function() { aF = false }, 260); return false } }); if (au.hideFocus) { C.css("outline", "none"); if ("hideFocus" in aj[0]) { C.attr("hideFocus", true) } } else { C.css("outline", ""); if ("hideFocus" in aj[0]) { C.attr("hideFocus", false) } } } function O() { C.attr("tabindex", "-1").removeAttr("tabindex").unbind("keydown.jsp") } function B() { if (location.hash && location.hash.length > 1) { var aG, aF; try { aG = b(location.hash) } catch (s) { return } if (aG.length && V.find(aG)) { if (aj.scrollTop() == 0) { aF = setInterval(function() { if (aj.scrollTop() > 0) { Y(location.hash, true); b(document).scrollTop(aj.position().top); clearInterval(aF) } }, 50) } else { Y(location.hash, true); b(document).scrollTop(aj.position().top) } } } } function af() { b("a.jspHijack").unbind("click.jsp-hijack").removeClass("jspHijack") } function m() { af(); b("a[href^=#]").addClass("jspHijack").bind("click.jsp-hijack", function() { var s = this.href.split("#"), aF; if (s.length > 1) { aF = s[1]; if (aF.length > 0 && V.find("#" + aF).length > 0) { Y("#" + aF, true); return false } } }) } b.extend(N, { reinitialise: function(aF) { aF = b.extend({}, aF, au); an(aF) }, scrollToElement: function(aG, aF, s) { Y(aG, aF, s) }, scrollTo: function(aG, s, aF) { K(aG, aF); J(s, aF) }, scrollToX: function(aF, s) { K(aF, s) }, scrollToY: function(s, aF) { J(s, aF) }, scrollBy: function(aF, s, aG) { N.scrollByX(aF, aG); N.scrollByY(s, aG) }, scrollByX: function(s, aG) { var aF = ay() + s, aH = aF / (Q - ah); T(aH * j, aG) }, scrollByY: function(s, aG) { var aF = aw() + s, aH = aF / (W - v); S(aH * i, aG) }, animate: function(aF, aI, s, aH) { var aG = {}; aG[aI] = s; aF.animate(aG, { duration: au.animateDuration, ease: au.animateEase, queue: false, step: aH }) }, getContentPositionX: function() { return ay() }, getContentPositionY: function() { return aw() }, getIsScrollableH: function() { return aB }, getIsScrollableV: function() { return av }, getContentPane: function() { return V }, scrollToBottom: function(s) { S(i, s) }, hijackInternalLinks: function() { m() } })
        } f = b.extend({}, b.fn.jScrollPane.defaults, f); var e; this.each(function() { var g = b(this), h = g.data("jsp"); if (h) { h.reinitialise(f) } else { h = new d(g, f); g.data("jsp", h) } e = e ? e.add(g) : g }); return e
    }; b.fn.jScrollPane.defaults = { showArrows: false, maintainPosition: true, clickOnTrack: true, autoReinitialise: false, autoReinitialiseDelay: 500, verticalDragMinHeight: 0, verticalDragMaxHeight: 99999, horizontalDragMinWidth: 0, horizontalDragMaxWidth: 99999, animateScroll: false, animateDuration: 300, animateEase: "linear", hijackInternalLinks: false, verticalGutter: 4, horizontalGutter: 4, mouseWheelSpeed: 10, arrowButtonSpeed: 10, arrowRepeatFreq: 100, arrowScrollOnHover: false, trackClickSpeed: 30, trackClickRepeatFreq: 100, verticalArrowPositions: "split", horizontalArrowPositions: "split", enableKeyboardNavigation: true, hideFocus: false }
})(jQuery, this);




/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.4
* 
* Requires: 1.2.2+
*/

(function($) {

    var types = ['DOMMouseScroll', 'mousewheel'];

    $.event.special.mousewheel = {
        setup: function() {
            if (this.addEventListener) {
                for (var i = types.length; i; ) {
                    this.addEventListener(types[--i], handler, false);
                }
            } else {
                this.onmousewheel = handler;
            }
        },

        teardown: function() {
            if (this.removeEventListener) {
                for (var i = types.length; i; ) {
                    this.removeEventListener(types[--i], handler, false);
                }
            } else {
                this.onmousewheel = null;
            }
        }
    };

    $.fn.extend({
        mousewheel: function(fn) {
            return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
        },

        unmousewheel: function(fn) {
            return this.unbind("mousewheel", fn);
        }
    });


    function handler(event) {
        var orgEvent = event || window.event, args = [].slice.call(arguments, 1), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
        event = $.event.fix(orgEvent);
        event.type = "mousewheel";

        // Old school scrollwheel delta
        if (event.wheelDelta) { delta = event.wheelDelta / 120; }
        if (event.detail) { delta = -event.detail / 3; }

        // New school multidimensional scroll (touchpads) deltas
        deltaY = delta;

        // Gecko
        if (orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS) {
            deltaY = 0;
            deltaX = -1 * delta;
        }

        // Webkit
        if (orgEvent.wheelDeltaY !== undefined) { deltaY = orgEvent.wheelDeltaY / 120; }
        if (orgEvent.wheelDeltaX !== undefined) { deltaX = -1 * orgEvent.wheelDeltaX / 120; }

        // Add event and delta to the front of the arguments
        args.unshift(event, delta, deltaX, deltaY);

        return $.event.handle.apply(this, args);
    }

})(jQuery);
