/* Copyright (c) 2006 Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* 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.
*
* $LastChangedDate: 2007-12-20 09:02:08 -0600 (Thu, 20 Dec 2007) $
* $Rev: 4265 $
*
* Version: 3.0
* 
* Requires: $ 1.2.2+
*/

(function($)
{

    $.event.special.mousewheel = {
        setup: function()
        {
            var handler = $.event.special.mousewheel.handler;

            // Fix pageX, pageY, clientX and clientY for mozilla
            if ($.browser.mozilla)
                $(this).bind('mousemove.mousewheel', function(event)
                {
                    $.data(this, 'mwcursorposdata', {
                        pageX: event.pageX,
                        pageY: event.pageY,
                        clientX: event.clientX,
                        clientY: event.clientY
                    });
                });

            if (this.addEventListener)
                this.addEventListener(($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false);
            else
                this.onmousewheel = handler;
        },

        teardown: function()
        {
            var handler = $.event.special.mousewheel.handler;

            $(this).unbind('mousemove.mousewheel');

            if (this.removeEventListener)
                this.removeEventListener(($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false);
            else
                this.onmousewheel = function() { };

            $.removeData(this, 'mwcursorposdata');
        },

        handler: function(event)
        {
            var args = Array.prototype.slice.call(arguments, 1);

            event = $.event.fix(event || window.event);
            // Get correct pageX, pageY, clientX and clientY for mozilla
            $.extend(event, $.data(this, 'mwcursorposdata') || {});
            var delta = 0, returnValue = true;

            if (event.wheelDelta) delta = event.wheelDelta / 120;
            if (event.detail) delta = -event.detail / 3;
            //		if ( $.browser.opera  ) delta = -event.wheelDelta;

            event.data = event.data || {};
            event.type = "mousewheel";

            // Add delta to the front of the arguments
            args.unshift(delta);
            // Add event to the front of the arguments
            args.unshift(event);

            return $.event.handle.apply(this, args);
        }
    };

    $.fn.extend({
        mousewheel: function(fn)
        {
            return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
        },

        unmousewheel: function(fn)
        {
            return this.unbind("mousewheel", fn);
        }
    });

})(jQuery);






/* Copyright (c) 2009 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) 
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
* 
* See http://kelvinluck.com/assets/jquery/jScrollPane/
* $Id: jScrollPane.js 93 2010-06-01 08:17:28Z kelvin.luck $
*/

/**
* Replace the vertical scroll bars on any matched elements with a fancy
* styleable (via CSS) version. With JS disabled the elements will
* gracefully degrade to the browsers own implementation of overflow:auto.
* If the mousewheel plugin has been included on the page then the scrollable areas will also
* respond to the mouse wheel.
*
* @example jQuery(".scroll-pane").jScrollPane();
*
* @name jScrollPane
* @type jQuery
* @param Object	settings	hash with options, described below.
*								scrollbarWidth	-	The width of the generated scrollbar in pixels
*								scrollbarMargin	-	The amount of space to leave on the side of the scrollbar in pixels
*								wheelSpeed		-	The speed the pane will scroll in response to the mouse wheel in pixels
*								showArrows		-	Whether to display arrows for the user to scroll with
*								arrowSize		-	The height of the arrow buttons if showArrows=true
*								animateTo		-	Whether to animate when calling scrollTo and scrollBy
*								dragMinHeight	-	The minimum height to allow the drag bar to be
*								dragMaxHeight	-	The maximum height to allow the drag bar to be
*								animateInterval	-	The interval in milliseconds to update an animating scrollPane (default 100)
*								animateStep		-	The amount to divide the remaining scroll distance by when animating (default 3)
*								maintainPosition-	Whether you want the contents of the scroll pane to maintain it's position when you re-initialise it - so it doesn't scroll as you add more content (default true)
*								tabIndex		-	The tabindex for this jScrollPane to control when it is tabbed to when navigating via keyboard (default 0)
*								enableKeyboardNavigation - Whether to allow keyboard scrolling of this jScrollPane when it is focused (default true)
*								animateToInternalLinks - Whether the move to an internal link (e.g. when it's focused by tabbing or by a hash change in the URL) should be animated or instant (default false)
*								scrollbarOnLeft	-	Display the scrollbar on the left side?  (needs stylesheet changes, see examples.html)
*								reinitialiseOnImageLoad - Whether the jScrollPane should automatically re-initialise itself when any contained images are loaded (default false)
*								topCapHeight	-	The height of the "cap" area between the top of the jScrollPane and the top of the track/ buttons
*								bottomCapHeight	-	The height of the "cap" area between the bottom of the jScrollPane and the bottom of the track/ buttons
*								observeHash		-	Whether jScrollPane should attempt to automagically scroll to the correct place when an anchor inside the scrollpane is linked to (default true)
* @return jQuery
* @cat Plugins/jScrollPane
* @author Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
*/

(function($)
{

    $.jScrollPane = {
        active: []
    };
    $.fn.jScrollPane = function(settings)
    {
        settings = $.extend({}, $.fn.jScrollPane.defaults, settings);

        var rf = function() { return false; };

        return this.each(
		function()
		{
		    var $this = $(this);
		    var paneEle = this;
		    var currentScrollPosition = 0;
		    var paneWidth;
		    var paneHeight;
		    var trackHeight;
		    var trackOffset = settings.topCapHeight;
		    var $container;

		    if ($(this).parent().is('.jScrollPaneContainer'))
		    {
		        $container = $(this).parent();
		        currentScrollPosition = settings.maintainPosition ? $this.position().top : 0;
		        var $c = $(this).parent();
		        paneWidth = $c.innerWidth();
		        paneHeight = $c.outerHeight();
		        $('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScrollCap', $c).remove();
		        $this.css({ 'top': 0 });
		    } else
		    {
		        $this.data('originalStyleTag', $this.attr('style'));
		        // Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208]
		        $this.css('overflow', 'hidden');
		        this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft');
		        this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0);
		        paneWidth = $this.innerWidth();
		        paneHeight = $this.innerHeight();
		        $container = $('<div></div>')
					.attr({ 'className': 'jScrollPaneContainer' })
					.css(
						{
						    'height': paneHeight + 'px',
						    'width': paneWidth + 'px'
						}
					);
		        if (settings.enableKeyboardNavigation)
		        {
		            $container.attr(
						'tabindex',
						settings.tabIndex
					);
		        }
		        $this.wrap($container);
		        $container = $this.parent();
		        // deal with text size changes (if the jquery.em plugin is included)
		        // and re-initialise the scrollPane so the track maintains the
		        // correct size
		        $(document).bind(
					'emchange',
					function(e, cur, prev)
					{
					    $this.jScrollPane(settings);
					}
				);

		    }
		    trackHeight = paneHeight;

		    if (settings.reinitialiseOnImageLoad)
		    {
		        // code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad
		        // except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size...
		        // TODO: Do I even need to store it in $.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise?
		        var $imagesToLoad = $.data(paneEle, 'jScrollPaneImagesToLoad') || $('img', $this);
		        var loadedImages = [];

		        if ($imagesToLoad.length)
		        {
		            $imagesToLoad.each(function(i, val)
		            {
		                $(this).bind('load readystatechange', function()
		                {
		                    if ($.inArray(i, loadedImages) == -1)
		                    { //don't double count images
		                        loadedImages.push(val); //keep a record of images we've seen
		                        $imagesToLoad = $.grep($imagesToLoad, function(n, i)
		                        {
		                            return n != val;
		                        });
		                        $.data(paneEle, 'jScrollPaneImagesToLoad', $imagesToLoad);
		                        var s2 = $.extend(settings, { reinitialiseOnImageLoad: false });
		                        $this.jScrollPane(s2); // re-initialise
		                    }
		                }).each(function(i, val)
		                {
		                    if (this.complete || this.complete === undefined)
		                    {
		                        //needed for potential cached images
		                        this.src = this.src;
		                    }
		                });
		            });
		        };
		    }

		    var p = this.originalSidePaddingTotal;
		    var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p;

		    var cssToApply = {
		        'height': 'auto',
		        'width': realPaneWidth + 'px'
		    }

		    if (settings.scrollbarOnLeft)
		    {
		        cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px';
		    } else
		    {
		        cssToApply.paddingRight = settings.scrollbarMargin + 'px';
		    }

		    $this.css(cssToApply);

		    var contentHeight = $this.outerHeight();
		    var percentInView = paneHeight / contentHeight;

		    var isScrollable = percentInView < .99;
		    //$container[isScrollable ? 'addClass' : 'removeClass']('jScrollPaneScrollable');
		    if (percentInView < .99)
		    {
		        $container.addClass('jScrollPaneScrollable')
		        $container.children().children().children().addClass('pane');
		    } else
		    {
		        $container.removeClass('jScrollPaneScrollable')
		    }


		    if (isScrollable)
		    {
		        $container.append(
					$('<div></div>').addClass('jScrollCap jScrollCapTop').css({ height: settings.topCapHeight }),
					$('<div></div>').addClass('rounded jScrollPaneTrack').css({ 'width': settings.scrollbarWidth + 'px' }).append(
						$('<div></div>').addClass('rounded jScrollPaneDrag').css({ 'width': settings.scrollbarWidth + 'px' }).append(
							$('<div></div>').attr({ 'className': 'jScrollPaneDragTop' }).css({ 'width': settings.scrollbarWidth + 'px' }),
							$('<div></div>').attr({ 'className': 'jScrollPaneDragBottom' }).css({ 'width': settings.scrollbarWidth + 'px' })
						)
					),
					$('<div></div>').addClass('jScrollCap jScrollCapBottom').css({ height: settings.bottomCapHeight })
				);

		        var $track = $('>.jScrollPaneTrack', $container);
		        var $drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container);


		        var currentArrowDirection;
		        var currentArrowTimerArr = []; // Array is used to store timers since they can stack up when dealing with keyboard events. This ensures all timers are cleaned up in the end, preventing an acceleration bug.
		        var currentArrowInc;
		        var whileArrowButtonDown = function()
		        {
		            if (currentArrowInc > 4 || currentArrowInc % 4 == 0)
		            {
		                positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier);
		            }
		            currentArrowInc++;
		        };

		        if (settings.enableKeyboardNavigation)
		        {
		            $container.bind(
						'keydown.jscrollpane',
						function(e)
						{
						    switch (e.keyCode)
						    {
						        case 38: //up
						            currentArrowDirection = -1;
						            currentArrowInc = 0;
						            whileArrowButtonDown();
						            currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
						            return false;
						        case 40: //down
						            currentArrowDirection = 1;
						            currentArrowInc = 0;
						            whileArrowButtonDown();
						            currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
						            return false;
						        case 33: // page up
						        case 34: // page down
						            // TODO
						            return false;
						        default:
						    }
						}
					).bind(
						'keyup.jscrollpane',
						function(e)
						{
						    if (e.keyCode == 38 || e.keyCode == 40)
						    {
						        for (var i = 0; i < currentArrowTimerArr.length; i++)
						        {
						            clearInterval(currentArrowTimerArr[i]);
						        }
						        return false;
						    }
						}
					);
		        }

		        if (settings.showArrows)
		        {

		            var currentArrowButton;
		            var currentArrowInterval;

		            var onArrowMouseUp = function(event)
		            {
		                $('html').unbind('mouseup', onArrowMouseUp);
		                currentArrowButton.removeClass('jScrollActiveArrowButton');
		                clearInterval(currentArrowInterval);
		            };
		            var onArrowMouseDown = function()
		            {
		                $('html').bind('mouseup', onArrowMouseUp);
		                currentArrowButton.addClass('jScrollActiveArrowButton');
		                currentArrowInc = 0;
		                whileArrowButtonDown();
		                currentArrowInterval = setInterval(whileArrowButtonDown, 100);
		            };
		            $container
						.append(
							$('<a></a>')
								.attr(
									{
									    'href': 'javascript:;',
									    'className': 'jScrollArrowUp',
									    'tabindex': -1
									}
								)
								.css(
									{
									    'width': settings.scrollbarWidth + 'px',
									    'top': settings.topCapHeight + 'px'
									}
								)
								.html('Scroll up')
								.bind('mousedown', function()
								{
								    currentArrowButton = $(this);
								    currentArrowDirection = -1;
								    onArrowMouseDown();
								    this.blur();
								    return false;
								})
								.bind('click', rf),
							$('<a></a>')
								.attr(
									{
									    'href': 'javascript:;',
									    'className': 'jScrollArrowDown',
									    'tabindex': -1
									}
								)
								.css(
									{
									    'width': settings.scrollbarWidth + 'px',
									    'bottom': settings.bottomCapHeight + 'px'
									}
								)
								.html('Scroll down')
								.bind('mousedown', function()
								{
								    currentArrowButton = $(this);
								    currentArrowDirection = 1;
								    onArrowMouseDown();
								    this.blur();
								    return false;
								})
								.bind('click', rf)
						);
		            var $upArrow = $('>.jScrollArrowUp', $container);
		            var $downArrow = $('>.jScrollArrowDown', $container);
		        }

		        if (settings.arrowSize)
		        {
		            trackHeight = paneHeight - settings.arrowSize - settings.arrowSize;
		            trackOffset += settings.arrowSize;
		        } else if ($upArrow)
		        {
		            var topArrowHeight = $upArrow.height();
		            settings.arrowSize = topArrowHeight;
		            trackHeight = paneHeight - topArrowHeight - $downArrow.height();
		            trackOffset += topArrowHeight;
		        }
		        trackHeight -= settings.topCapHeight + settings.bottomCapHeight;
		        $track.css({ 'height': trackHeight - 8 + 'px', top: trackOffset + 'px' })

		        var $pane = $(this).css({ 'position': 'absolute', 'overflow': 'visible' });

		        var currentOffset;
		        var maxY;
		        var mouseWheelMultiplier;
		        // store this in a seperate variable so we can keep track more accurately than just updating the css property..
		        var dragPosition = 0;
		        var dragMiddle = percentInView * paneHeight / 2;

		        // pos function borrowed from tooltip plugin and adapted...
		        var getPos = function(event, c)
		        {
		            var p = c == 'X' ? 'Left' : 'Top';
		            return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
		        };

		        var ignoreNativeDrag = function() { return false; };

		        var initDrag = function()
		        {
		            ceaseAnimation();
		            currentOffset = $drag.offset(false);
		            currentOffset.top -= dragPosition;
		            maxY = trackHeight - $drag[0].offsetHeight - 8;
		            mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight;
		        };

		        var onStartDrag = function(event)
		        {
		            initDrag();
		            dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top;
		            $('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll).bind('mouseleave', onStopDrag)
		            if ($.browser.msie)
		            {
		                $('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag);
		            }
		            return false;
		        };
		        var onStopDrag = function()
		        {
		            $('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll);
		            dragMiddle = percentInView * paneHeight / 2;
		            if ($.browser.msie)
		            {
		                $('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag);
		            }
		        };
		        var positionDrag = function(destY)
		        {
		            $container.scrollTop(0);
		            destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY);
		            dragPosition = destY;
		            $drag.css({ 'top': destY + 4 + 'px' });
		            var p = destY / maxY;
		            $this.data('jScrollPanePosition', (paneHeight - contentHeight) * -p);
		            $pane.css({ 'top': ((paneHeight - contentHeight) * p) + 'px' });
		            $this.trigger('scroll');
		            if (settings.showArrows)
		            {
		                $upArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled');
		                $downArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled');
		            }
		        };
		        var updateScroll = function(e)
		        {
		            positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle);
		        };

		        var dragH = Math.max(Math.min(percentInView * (paneHeight - settings.arrowSize * 2), settings.dragMaxHeight), settings.dragMinHeight);

		        $drag.css(
					{ 'height': dragH + 'px' }
				).bind('mousedown', onStartDrag);

		        var trackScrollInterval;
		        var trackScrollInc;
		        var trackScrollMousePos;
		        var doTrackScroll = function()
		        {
		            if (trackScrollInc > 8 || trackScrollInc % 4 == 0)
		            {
		                positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2)));
		            }
		            trackScrollInc++;
		        };
		        var onStopTrackClick = function()
		        {
		            clearInterval(trackScrollInterval);
		            $('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove);
		        };
		        var onTrackMouseMove = function(event)
		        {
		            trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle;
		        };
		        var onTrackClick = function(event)
		        {
		            initDrag();
		            onTrackMouseMove(event);
		            trackScrollInc = 0;
		            $('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove);
		            trackScrollInterval = setInterval(doTrackScroll, 100);
		            doTrackScroll();
		            return false;
		        };

		        $track.bind('mousedown', onTrackClick);

		        $container.bind(
					'mousewheel',
					function(event, delta)
					{
					    delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ?
-event.detail / 3 : 0);
					    initDrag();
					    ceaseAnimation();
					    var d = dragPosition;
					    positionDrag(dragPosition - delta * mouseWheelMultiplier);
					    var dragOccured = d != dragPosition;
					    return !dragOccured;
					}
				);

		        var _animateToPosition;
		        var _animateToInterval;
		        function animateToPosition()
		        {
		            var diff = (_animateToPosition - dragPosition) / settings.animateStep;
		            if (diff > 1 || diff < -1)
		            {
		                positionDrag(dragPosition + diff);
		            } else
		            {
		                positionDrag(_animateToPosition);
		                ceaseAnimation();
		            }
		        }
		        var ceaseAnimation = function()
		        {
		            if (_animateToInterval)
		            {
		                clearInterval(_animateToInterval);
		                delete _animateToPosition;
		            }
		        };
		        var scrollTo = function(pos, preventAni)
		        {
		            if (typeof pos == "string")
		            {
		                // Legal hash values aren't necessarily legal jQuery selectors so we need to catch any
		                // errors from the lookup...
		                try
		                {
		                    $e = $(pos, $this);
		                } catch (err)
		                {
		                    return;
		                }
		                if (!$e.length) return;
		                pos = $e.offset().top - $this.offset().top;
		            }
		            ceaseAnimation();
		            var maxScroll = contentHeight - paneHeight;
		            pos = pos > maxScroll ? maxScroll : pos;
		            $this.data('jScrollPaneMaxScroll', maxScroll);
		            var destDragPosition = pos / maxScroll * maxY;
		            if (preventAni || !settings.animateTo)
		            {
		                positionDrag(destDragPosition);
		            } else
		            {
		                $container.scrollTop(0);
		                _animateToPosition = destDragPosition;
		                _animateToInterval = setInterval(animateToPosition, settings.animateInterval);
		            }
		        };
		        $this[0].scrollTo = scrollTo;

		        $this[0].scrollBy = function(delta)
		        {
		            var currentPos = -parseInt($pane.css('top')) || 0;
		            scrollTo(currentPos + delta);
		        };

		        initDrag();

		        scrollTo(-currentScrollPosition, true);

		        // Deal with it when the user tabs to a link or form element within this scrollpane
		        $('*', this).bind(
					'focus',
					function(event)
					{
					    var $e = $(this);

					    // loop through parents adding the offset top of any elements that are relatively positioned between
					    // the focused element and the jScrollPaneContainer so we can get the true distance from the top
					    // of the focused element to the top of the scrollpane...
					    var eleTop = 0;

					    var preventInfiniteLoop = 100;

					    while ($e[0] != $this[0])
					    {
					        eleTop += $e.position().top;
					        $e = $e.offsetParent();
					        if (!preventInfiniteLoop--)
					        {
					            return;
					        }
					    }

					    var viewportTop = -parseInt($pane.css('top')) || 0;
					    var maxVisibleEleTop = viewportTop + paneHeight;
					    var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop;
					    if (!eleInView)
					    {
					        var destPos = eleTop - settings.scrollbarMargin;
					        if (eleTop > viewportTop)
					        { // element is below viewport - scroll so it is at bottom.
					            destPos += $(this).height() + 15 + settings.scrollbarMargin - paneHeight;
					        }
					        scrollTo(destPos);
					    }
					}
				)


		        if (settings.observeHash)
		        {
		            if (location.hash && location.hash.length > 1)
		            {
		                setTimeout(function()
		                {
		                    scrollTo(location.hash);
		                }, $.browser.safari ? 100 : 0);
		            }

		            // use event delegation to listen for all clicks on links and hijack them if they are links to
		            // anchors within our content...
		            $(document).bind('click', function(e)
		            {
		                $target = $(e.target);
		                if ($target.is('a'))
		                {
		                    var h = $target.attr('href');
		                    if (h && h.substr(0, 1) == '#' && h.length > 1)
		                    {
		                        setTimeout(function()
		                        {
		                            scrollTo(h, !settings.animateToInternalLinks);
		                        }, $.browser.safari ? 100 : 0);
		                    }
		                }
		            });
		        }

		        // Deal with dragging and selecting text to make the scrollpane scroll...
		        function onSelectScrollMouseDown(e)
		        {
		            $(document).bind('mousemove.jScrollPaneDragging', onTextSelectionScrollMouseMove);
		            $(document).bind('mouseup.jScrollPaneDragging', onSelectScrollMouseUp);

		        }

		        var textDragDistanceAway;
		        var textSelectionInterval;

		        function onTextSelectionInterval()
		        {
		            direction = textDragDistanceAway < 0 ? -1 : 1;
		            $this[0].scrollBy(textDragDistanceAway / 2);
		        }

		        function clearTextSelectionInterval()
		        {
		            if (textSelectionInterval)
		            {
		                clearInterval(textSelectionInterval);
		                textSelectionInterval = undefined;
		            }
		        }

		        function onTextSelectionScrollMouseMove(e)
		        {
		            var offset = $this.parent().offset().top;
		            var maxOffset = offset + paneHeight;
		            var mouseOffset = getPos(e, 'Y');
		            textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0);
		            if (textDragDistanceAway == 0)
		            {
		                clearTextSelectionInterval();
		            } else
		            {
		                if (!textSelectionInterval)
		                {
		                    textSelectionInterval = setInterval(onTextSelectionInterval, 100);
		                }
		            }
		        }

		        function onSelectScrollMouseUp(e)
		        {
		            $(document)
					  .unbind('mousemove.jScrollPaneDragging')
					  .unbind('mouseup.jScrollPaneDragging');
		            clearTextSelectionInterval();
		        }

		        $container.bind('mousedown.jScrollPane', onSelectScrollMouseDown);


		        $.jScrollPane.active.push($this[0]);

		    } else
		    {
		        $this.css(
					{
					    'height': paneHeight + 'px',
					    'width': paneWidth - this.originalSidePaddingTotal + 'px',
					    'padding': this.originalPadding
					}
				);
		        $this[0].scrollTo = $this[0].scrollBy = function() { };
		        // clean up listeners
		        $this.parent().unbind('mousewheel').unbind('mousedown.jScrollPane').unbind('keydown.jscrollpane').unbind('keyup.jscrollpane');
		    }

		}
	)
    };

    $.fn.jScrollPaneRemove = function()
    {
        $(this).each(function()
        {
            $this = $(this);
            var $c = $this.parent();
            if ($c.is('.jScrollPaneContainer'))
            {
                $this.css(
				{
				    'top': '',
				    'height': '',
				    'width': '',
				    'padding': '',
				    'overflow': '',
				    'position': ''
				}
			);
                $this.attr('style', $this.data('originalStyleTag'));
                $c.after($this).remove();
            }
        });
    }

    $.fn.jScrollPane.defaults = {
        scrollbarWidth: 10,
        scrollbarMargin: 5,
        wheelSpeed: 18,
        showArrows: false,
        arrowSize: 0,
        animateTo: false,
        dragMinHeight: 1,
        dragMaxHeight: 99999,
        animateInterval: 100,
        animateStep: 3,
        maintainPosition: true,
        scrollbarOnLeft: false,
        reinitialiseOnImageLoad: false,
        tabIndex: 0,
        enableKeyboardNavigation: true,
        animateToInternalLinks: false,
        topCapHeight: 0,
        bottomCapHeight: 0,
        observeHash: true
    };

    // clean up the scrollTo expandos
    $(window)
	.bind('unload', function()
	{
	    var els = $.jScrollPane.active;
	    for (var i = 0; i < els.length; i++)
	    {
	        els[i].scrollTo = els[i].scrollBy = null;
	    }
	}
);

})(jQuery);

/**********************************/
/*jquery.nyroModal-1.5.2.min.js   */
/**********************************/
jQuery(function($) { var userAgent = navigator.userAgent.toLowerCase(); var browserVersion = (userAgent.match(/.+(?:rv|webkit|khtml|opera|msie)[\/: ]([\d.]+)/) || [0, '0'])[1]; var isIE6 = (/msie/.test(userAgent) && !/opera/.test(userAgent) && parseInt(browserVersion) < 7 && (!window.XMLHttpRequest || typeof (XMLHttpRequest) === 'function')); var body = $('body'); var currentSettings; var callingSettings; var shouldResize = false; var gallery = {}; var fixFF = false; var contentElt; var contentEltLast; var modal = { started: false, ready: false, dataReady: false, anim: false, animContent: false, loadingShown: false, transition: false, resizing: false, closing: false, error: false, blocker: null, blockerVars: null, full: null, bg: null, loading: null, tmp: null, content: null, wrapper: null, contentWrapper: null, scripts: new Array(), scriptsShown: new Array() }; var resized = { width: false, height: false, windowResizing: false }; var initSettingsSize = { width: null, height: null, windowResizing: true }; var windowResizeTimeout; $.fn.nyroModal = function(settings) { if (!this) return false; return this.each(function() { var me = $(this); if (this.nodeName.toLowerCase() == 'form') { me.unbind('submit.nyroModal').bind('submit.nyroModal', function(e) { if (e.isDefaultPrevented()) return false; if (me.data('nyroModalprocessing')) return true; if (this.enctype == 'multipart/form-data') { processModal($.extend(settings, { from: this })); return true } e.preventDefault(); processModal($.extend(settings, { from: this })); return false }) } else { me.unbind('click.nyroModal').bind('click.nyroModal', function(e) { if (e.isDefaultPrevented()) return false; e.preventDefault(); processModal($.extend(settings, { from: this })); return false }) } }) }; $.fn.nyroModalManual = function(settings) { if (!this.length) processModal(settings); return this.each(function() { processModal($.extend(settings, { from: this })) }) }; $.nyroModalManual = function(settings) { processModal(settings) }; $.nyroModalSettings = function(settings, deep1, deep2) { setCurrentSettings(settings, deep1, deep2); if (!deep1 && modal.started) { if (modal.bg && settings.bgColor) currentSettings.updateBgColor(modal, currentSettings, function() { }); if (modal.contentWrapper && settings.title) setTitle(); if (!modal.error && (settings.windowResizing || (!modal.resizing && (('width' in settings && settings.width == currentSettings.width) || ('height' in settings && settings.height == currentSettings.height))))) { modal.resizing = true; if (modal.contentWrapper) calculateSize(true); if (modal.contentWrapper && modal.contentWrapper.is(':visible') && !modal.animContent) { if (fixFF) modal.content.css({ position: '' }); currentSettings.resize(modal, currentSettings, function() { currentSettings.windowResizing = false; modal.resizing = false; if (fixFF) modal.content.css({ position: 'fixed' }); if ($.isFunction(currentSettings.endResize)) currentSettings.endResize(modal, currentSettings) }) } } } }; $.nyroModalRemove = function() { removeModal() }; $.nyroModalNext = function() { var link = getGalleryLink(1); if (link) return link.nyroModalManual(getCurrentSettingsNew()); return false }; $.nyroModalPrev = function() { var link = getGalleryLink(-1); if (link) return link.nyroModalManual(getCurrentSettingsNew()); return false }; $.fn.nyroModal.settings = { debug: false, blocker: false, windowResize: true, modal: false, type: '', forceType: null, from: '', hash: '', processHandler: null, selIndicator: 'nyroModalSel', formIndicator: 'nyroModal', content: null, bgColor: '#000000', ajax: {}, swf: { wmode: 'transparent' }, width: null, height: null, minWidth: 400, minHeight: 300, resizable: true, autoSizable: true, padding: 25, regexImg: '[^\.]\.(jpg|jpeg|png|tiff|gif|bmp)\s*$', addImageDivTitle: false, defaultImgAlt: 'Image', setWidthImgTitle: true, ltr: true, gallery: null, galleryLinks: '<a href="#" class="nyroModalPrev">Prev</a><a href="#"  class="nyroModalNext">Next</a>', galleryCounts: galleryCounts, galleryLoop: false, zIndexStart: 100, cssOpt: { bg: { position: 'absolute', overflow: 'hidden', top: 0, left: 0, height: '100%', width: '100%' }, wrapper: { position: 'absolute', top: '50%', left: '50%' }, wrapper2: {}, content: {}, loading: { position: 'absolute', top: '50%', left: '50%', marginTop: '-50px', marginLeft: '-50px'} }, wrap: { div: '<div class="wrapper"></div>', ajax: '<div class="wrapper"></div>', form: '<div class="wrapper"></div>', formData: '<div class="wrapper"></div>', image: '<div class="wrapperImg"></div>', swf: '<div class="wrapperSwf"></div>', iframe: '<div class="wrapperIframe"></div>', iframeForm: '<div class="wrapperIframe"></div>', manual: '<div class="wrapper"></div>' }, closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="close">Close</a>', title: null, titleFromIframe: true, openSelector: '.nyroModal', closeSelector: '.nyroModalClose', contentLoading: '<a href="#" class="nyroModalClose">Cancel</a>', errorClass: 'error', contentError: 'The requested content cannot be loaded.<br />Please try again later.<br /><a href="#" class="nyroModalClose">Close</a>', handleError: null, showBackground: showBackground, hideBackground: hideBackground, endFillContent: null, showContent: showContent, endShowContent: null, beforeHideContent: null, hideContent: hideContent, showTransition: showTransition, hideTransition: hideTransition, showLoading: showLoading, hideLoading: hideLoading, resize: resize, endResize: null, updateBgColor: updateBgColor, endRemove: null }; function processModal(settings) { if (modal.loadingShown || modal.transition || modal.anim) return; debug('processModal'); modal.started = true; callingSettings = $.extend(true, settings); setDefaultCurrentSettings(settings); if (!modal.full) modal.blockerVars = modal.blocker = null; modal.error = false; modal.closing = false; modal.dataReady = false; modal.scripts = new Array(); modal.scriptsShown = new Array(); currentSettings.type = fileType(); if (currentSettings.forceType) { if (!currentSettings.content) currentSettings.from = true; currentSettings.type = currentSettings.forceType; currentSettings.forceType = null } if ($.isFunction(currentSettings.processHandler)) currentSettings.processHandler(currentSettings); var from = currentSettings.from; var url = currentSettings.url; initSettingsSize.width = currentSettings.width; initSettingsSize.height = currentSettings.height; if (currentSettings.type == 'swf') { setCurrentSettings({ overflow: 'visible' }, 'cssOpt', 'content'); currentSettings.content = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + currentSettings.width + '" height="' + currentSettings.height + '"><param name="movie" value="' + url + '"></param>'; var tmp = ''; $.each(currentSettings.swf, function(name, val) { currentSettings.content += '<param name="' + name + '" value="' + val + '"></param>'; tmp += ' ' + name + '="' + val + '"' }); currentSettings.content += '<embed src="' + url + '" type="application/x-shockwave-flash" width="' + currentSettings.width + '" height="' + currentSettings.height + '"' + tmp + '></embed></object>' } if (from) { var jFrom = $(from).blur(); if (currentSettings.type == 'form') { var data = $(from).serializeArray(); data.push({ name: currentSettings.formIndicator, value: 1 }); if (currentSettings.selector) data.push({ name: currentSettings.selIndicator, value: currentSettings.selector.substring(1) }); showModal(); $.ajax($.extend({}, currentSettings.ajax, { url: url, data: data, type: jFrom.attr('method') ? jFrom.attr('method') : 'get', success: ajaxLoaded, error: loadingError })); debug('Form Ajax Load: ' + jFrom.attr('action')) } else if (currentSettings.type == 'formData') { initModal(); jFrom.attr('target', 'nyroModalIframe'); jFrom.attr('action', url); jFrom.prepend('<input type="hidden" name="' + currentSettings.formIndicator + '" value="1" />'); if (currentSettings.selector) jFrom.prepend('<input type="hidden" name="' + currentSettings.selIndicator + '" value="' + currentSettings.selector.substring(1) + '" />'); modal.tmp.html('<iframe frameborder="0" hspace="0" name="nyroModalIframe" src="javascript:\'\';"></iframe>'); $('iframe', modal.tmp).css({ width: currentSettings.width, height: currentSettings.height }).error(loadingError).load(formDataLoaded); debug('Form Data Load: ' + jFrom.attr('action')); showModal(); showContentOrLoading() } else if (currentSettings.type == 'image') { debug('Image Load: ' + url); var title = jFrom.attr('title') || currentSettings.defaultImgAlt; initModal(); modal.tmp.html('<img id="nyroModalImg" />').find('img').attr('alt', title); modal.tmp.css({ lineHeight: 0 }); $('img', modal.tmp).error(loadingError).load(function() { debug('Image Loaded: ' + this.src); $(this).unbind('load'); var w = modal.tmp.width(); var h = modal.tmp.height(); modal.tmp.css({ lineHeight: '' }); resized.width = w; resized.height = h; setCurrentSettings({ width: w, height: h, imgWidth: w, imgHeight: h }); initSettingsSize.width = w; initSettingsSize.height = h; setCurrentSettings({ overflow: 'visible' }, 'cssOpt', 'content'); modal.dataReady = true; if (modal.loadingShown || modal.transition) showContentOrLoading() }).attr('src', url); showModal() } else if (currentSettings.type == 'iframeForm') { initModal(); modal.tmp.html('<iframe frameborder="0" hspace="0" src="javascript:\'\';" name="nyroModalIframe" id="nyroModalIframe"></iframe>'); debug('Iframe Form Load: ' + url); $('iframe', modal.tmp).eq(0).css({ width: '100%', height: $.support.boxModel ? '99%' : '100%' }).load(iframeLoaded); modal.dataReady = true; showModal() } else if (currentSettings.type == 'iframe') { initModal(); modal.tmp.html('<iframe frameborder="0" hspace="0" src="javascript:\'\';" name="nyroModalIframe" id="nyroModalIframe"></iframe>'); debug('Iframe Load: ' + url); $('iframe', modal.tmp).eq(0).css({ width: '100%', height: $.support.boxModel ? '99%' : '100%' }).load(iframeLoaded); modal.dataReady = true; showModal() } else if (currentSettings.type) { debug('Content: ' + currentSettings.type); initModal(); modal.tmp.html(currentSettings.content); var w = modal.tmp.width(); var h = modal.tmp.height(); var div = $(currentSettings.type); if (div.length) { setCurrentSettings({ type: 'div' }); w = div.width(); h = div.height(); if (contentElt) contentEltLast = contentElt; contentElt = div; modal.tmp.append(div.contents()) } initSettingsSize.width = w; initSettingsSize.height = h; setCurrentSettings({ width: w, height: h }); if (modal.tmp.html()) modal.dataReady = true; else loadingError(); if (!modal.ready) showModal(); else endHideContent() } else { debug('Ajax Load: ' + url); setCurrentSettings({ type: 'ajax' }); var data = currentSettings.ajax.data || {}; if (currentSettings.selector) { if (typeof data == "string") { data += '&' + currentSettings.selIndicator + '=' + currentSettings.selector.substring(1) } else { data[currentSettings.selIndicator] = currentSettings.selector.substring(1) } } showModal(); $.ajax($.extend(true, currentSettings.ajax, { url: url, success: ajaxLoaded, error: loadingError, data: data })) } } else if (currentSettings.content) { debug('Content: ' + currentSettings.type); setCurrentSettings({ type: 'manual' }); initModal(); modal.tmp.html($('<div/>').html(currentSettings.content).contents()); if (modal.tmp.html()) modal.dataReady = true; else loadingError(); showModal() } else { } } function setDefaultCurrentSettings(settings) { debug('setDefaultCurrentSettings'); currentSettings = $.extend(true, {}, $.fn.nyroModal.settings, settings); setMargin() } function setCurrentSettings(settings, deep1, deep2) { if (modal.started) { if (deep1 && deep2) { $.extend(true, currentSettings[deep1][deep2], settings) } else if (deep1) { $.extend(true, currentSettings[deep1], settings) } else { if (modal.animContent) { if ('width' in settings) { if (!modal.resizing) { settings.setWidth = settings.width; shouldResize = true } delete settings['width'] } if ('height' in settings) { if (!modal.resizing) { settings.setHeight = settings.height; shouldResize = true } delete settings['height'] } } $.extend(true, currentSettings, settings) } } else { if (deep1 && deep2) { $.extend(true, $.fn.nyroModal.settings[deep1][deep2], settings) } else if (deep1) { $.extend(true, $.fn.nyroModal.settings[deep1], settings) } else { $.extend(true, $.fn.nyroModal.settings, settings) } } } function setMarginScroll() { if (isIE6 && !modal.blocker) { if (document.documentElement) { currentSettings.marginScrollLeft = document.documentElement.scrollLeft; currentSettings.marginScrollTop = document.documentElement.scrollTop } else { currentSettings.marginScrollLeft = document.body.scrollLeft; currentSettings.marginScrollTop = document.body.scrollTop } } else { currentSettings.marginScrollLeft = 0; currentSettings.marginScrollTop = 0 } } function setMargin() { setMarginScroll(); currentSettings.marginLeft = -(currentSettings.width + currentSettings.borderW) / 2; currentSettings.marginTop = -(currentSettings.height + currentSettings.borderH) / 2; if (!modal.blocker) { currentSettings.marginLeft += currentSettings.marginScrollLeft; currentSettings.marginTop += currentSettings.marginScrollTop } } function setMarginLoading() { setMarginScroll(); var outer = getOuter(modal.loading); currentSettings.marginTopLoading = -(modal.loading.height() + outer.h.border + outer.h.padding) / 2; currentSettings.marginLeftLoading = -(modal.loading.width() + outer.w.border + outer.w.padding) / 2; if (!modal.blocker) { currentSettings.marginLeftLoading += currentSettings.marginScrollLeft; currentSettings.marginTopLoading += currentSettings.marginScrollTop } } function setTitle() { var title = $('h1#nyroModalTitle', modal.contentWrapper); if (title.length) title.text(currentSettings.title); else modal.contentWrapper.prepend('<h1 id="nyroModalTitle">' + currentSettings.title + '</h1>') } function initModal() { debug('initModal'); if (!modal.full) { if (currentSettings.debug) setCurrentSettings({ color: 'white' }, 'cssOpt', 'bg'); var full = { zIndex: currentSettings.zIndexStart, position: 'fixed', top: 0, left: 0, width: '100%', height: '100%' }; var contain = body; var iframeHideIE = ''; if (currentSettings.blocker) { modal.blocker = contain = $(currentSettings.blocker); var pos = modal.blocker.offset(); var w = modal.blocker.outerWidth(); var h = modal.blocker.outerHeight(); if (isIE6) { setCurrentSettings({ height: '100%', width: '100%', top: 0, left: 0 }, 'cssOpt', 'bg') } modal.blockerVars = { top: pos.top, left: pos.left, width: w, height: h }; var plusTop = (/msie/.test(userAgent) ? 0 : getCurCSS(body.get(0), 'borderTopWidth')); var plusLeft = (/msie/.test(userAgent) ? 0 : getCurCSS(body.get(0), 'borderLeftWidth')); full = { position: 'absolute', top: pos.top + plusTop, left: pos.left + plusLeft, width: w, height: h} } else if (isIE6) { body.css({ marginLeft: 0, marginRight: 0 }); var w = body.width(); var h = $(window).height() + 'px'; if ($(window).height() >= body.outerHeight()) { h = body.outerHeight() + 'px' } else w += 20; w += 'px'; body.css({ width: w, height: h, position: 'static', overflow: 'hidden' }); $('html').css({ overflow: 'hidden' }); setCurrentSettings({ cssOpt: { bg: { position: 'absolute', zIndex: currentSettings.zIndexStart + 1, height: '110%', width: '110%', top: currentSettings.marginScrollTop + 'px', left: currentSettings.marginScrollLeft + 'px' }, wrapper: { zIndex: currentSettings.zIndexStart + 2 }, loading: { zIndex: currentSettings.zIndexStart + 3}} }); iframeHideIE = $('<iframe id="nyroModalIframeHideIe" src="javascript:\'\';"></iframe>').css($.extend({}, currentSettings.cssOpt.bg, { opacity: 0, zIndex: 50, border: 'none' })) } contain.append($('<div id="nyroModalFull"><div id="nyroModalBg"></div><div id="nyroModalWrapper"><div id="nyroModalContent"></div></div><div id="nyrModalTmp"></div><div id="nyroModalLoading"></div></div>').hide()); modal.full = $('#nyroModalFull').css(full).show(); modal.bg = $('#nyroModalBg').css($.extend({ backgroundColor: currentSettings.bgColor }, currentSettings.cssOpt.bg)).before(iframeHideIE); modal.bg.bind('click.nyroModal', clickBg); modal.loading = $('#nyroModalLoading').css(currentSettings.cssOpt.loading).hide(); modal.contentWrapper = $('#nyroModalWrapper').css(currentSettings.cssOpt.wrapper).hide(); modal.content = $('#nyroModalContent'); modal.tmp = $('#nyrModalTmp').hide(); if ($.isFunction($.fn.mousewheel)) { modal.content.mousewheel(function(e, d) { var elt = modal.content.get(0); if ((d > 0 && elt.scrollTop == 0) || (d < 0 && elt.scrollHeight - elt.scrollTop == elt.clientHeight)) { e.preventDefault(); e.stopPropagation() } }) } $(document).bind('keydown.nyroModal', keyHandler); modal.content.css({ width: 'auto', height: 'auto' }); modal.contentWrapper.css({ width: 'auto', height: 'auto' }); if (!currentSettings.blocker && currentSettings.windowResize) { $(window).bind('resize.nyroModal', function() { window.clearTimeout(windowResizeTimeout); windowResizeTimeout = window.setTimeout(windowResizeHandler, 200) }) } } } function windowResizeHandler() { $.nyroModalSettings(initSettingsSize) } function showModal() { debug('showModal'); if (!modal.ready) { initModal(); modal.anim = true; currentSettings.showBackground(modal, currentSettings, endBackground) } else { modal.anim = true; modal.transition = true; currentSettings.showTransition(modal, currentSettings, function() { endHideContent(); modal.anim = false; showContentOrLoading() }) } } function clickBg(e) { if (!currentSettings.modal) removeModal() } function keyHandler(e) { if (e.keyCode == 27) { if (!currentSettings.modal) removeModal() } else if (currentSettings.gallery && modal.ready && modal.dataReady && !modal.anim && !modal.transition) { if (e.keyCode == 39 || e.keyCode == 40) { e.preventDefault(); $.nyroModalNext(); return false } else if (e.keyCode == 37 || e.keyCode == 38) { e.preventDefault(); $.nyroModalPrev(); return false } } } function fileType() { var from = currentSettings.from; var url; if (from && from.nodeName) { var jFrom = $(from); url = jFrom.attr(from.nodeName.toLowerCase() == 'form' ? 'action' : 'href'); if (!url) url = location.href.substring(window.location.host.length + 7); currentSettings.url = url; if (jFrom.attr('rev') == 'modal') currentSettings.modal = true; currentSettings.title = jFrom.attr('title'); if (from && from.rel && from.rel.toLowerCase() != 'nofollow') { var indexSpace = from.rel.indexOf(' '); currentSettings.gallery = indexSpace > 0 ? from.rel.substr(0, indexSpace) : from.rel } var imgType = imageType(url, from); if (imgType) return imgType; if (isSwf(url)) return 'swf'; var iframe = false; if (from.target && from.target.toLowerCase() == '_blank' || (from.hostname && from.hostname.replace(/:\d*$/, '') != window.location.hostname.replace(/:\d*$/, ''))) { iframe = true } if (from.nodeName.toLowerCase() == 'form') { if (iframe) return 'iframeForm'; setCurrentSettings(extractUrlSel(url)); if (jFrom.attr('enctype') == 'multipart/form-data') return 'formData'; return 'form' } if (iframe) return 'iframe' } else { url = currentSettings.url; if (!currentSettings.content) currentSettings.from = true; if (!url) return null; if (isSwf(url)) return 'swf'; var reg1 = new RegExp("^http://|https://", "g"); if (url.match(reg1)) return 'iframe' } var imgType = imageType(url, from); if (imgType) return imgType; var tmp = extractUrlSel(url); setCurrentSettings(tmp); if (!tmp.url) return tmp.selector } function imageType(url, from) { var image = new RegExp(currentSettings.regexImg, 'i'); if (image.test(url)) { return 'image' } } function isSwf(url) { var swf = new RegExp('[^\.]\.(swf)\s*$', 'i'); return swf.test(url) } function extractUrlSel(url) { var ret = { url: null, selector: null }; if (url) { var hash = getHash(url); var hashLoc = getHash(window.location.href); var curLoc = window.location.href.substring(0, window.location.href.length - hashLoc.length); var req = url.substring(0, url.length - hash.length); if (req == curLoc || req == $('base').attr('href')) { ret.selector = hash } else { ret.url = req; ret.selector = hash } } return ret } function loadingError() { debug('loadingError'); modal.error = true; if (!modal.ready) return; if ($.isFunction(currentSettings.handleError)) currentSettings.handleError(modal, currentSettings); modal.loading.addClass(currentSettings.errorClass).html(currentSettings.contentError); $(currentSettings.closeSelector, modal.loading).unbind('click.nyroModal').bind('click.nyroModal', removeModal); setMarginLoading(); modal.loading.css({ marginTop: currentSettings.marginTopLoading + 'px', marginLeft: currentSettings.marginLeftLoading + 'px' }) } function fillContent() { debug('fillContent'); if (!modal.tmp.html()) return; modal.content.html(modal.tmp.contents()); modal.tmp.empty(); wrapContent(); if (currentSettings.type == 'iframeForm') { $(currentSettings.from).attr('target', 'nyroModalIframe').data('nyroModalprocessing', 1).submit().attr('target', '_blank').removeData('nyroModalprocessing') } if (!currentSettings.modal) modal.wrapper.prepend(currentSettings.closeButton); if ($.isFunction(currentSettings.endFillContent)) currentSettings.endFillContent(modal, currentSettings); modal.content.append(modal.scripts); $(currentSettings.closeSelector, modal.contentWrapper).unbind('click.nyroModal').bind('click.nyroModal', removeModal); $(currentSettings.openSelector, modal.contentWrapper).nyroModal(getCurrentSettingsNew()) } function getCurrentSettingsNew() { return callingSettings; var currentSettingsNew = $.extend(true, {}, currentSettings); if (resized.width) currentSettingsNew.width = null; else currentSettingsNew.width = initSettingsSize.width; if (resized.height) currentSettingsNew.height = null; else currentSettingsNew.height = initSettingsSize.height; currentSettingsNew.cssOpt.content.overflow = 'auto'; return currentSettingsNew } function wrapContent() { debug('wrapContent'); var wrap = $(currentSettings.wrap[currentSettings.type]); modal.content.append(wrap.children().remove()); modal.contentWrapper.wrapInner(wrap); if (currentSettings.gallery) { modal.content.append(currentSettings.galleryLinks); gallery.links = $('[rel="' + currentSettings.gallery + '"], [rel^="' + currentSettings.gallery + ' "]'); gallery.index = gallery.links.index(currentSettings.from); if (currentSettings.galleryCounts && $.isFunction(currentSettings.galleryCounts)) currentSettings.galleryCounts(gallery.index + 1, gallery.links.length, modal, currentSettings); var currentSettingsNew = getCurrentSettingsNew(); var linkPrev = getGalleryLink(-1); if (linkPrev) { var prev = $('.nyroModalPrev', modal.contentWrapper).attr('href', linkPrev.attr('href')).click(function(e) { e.preventDefault(); $.nyroModalPrev(); return false }); if (isIE6 && currentSettings.type == 'swf') { prev.before($('<iframe id="nyroModalIframeHideIeGalleryPrev" src="javascript:\'\';"></iframe>').css({ position: prev.css('position'), top: prev.css('top'), left: prev.css('left'), width: prev.width(), height: prev.height(), opacity: 0, border: 'none' })) } } else { $('.nyroModalPrev', modal.contentWrapper).remove() } var linkNext = getGalleryLink(1); if (linkNext) { var next = $('.nyroModalNext', modal.contentWrapper).attr('href', linkNext.attr('href')).click(function(e) { e.preventDefault(); $.nyroModalNext(); return false }); if (isIE6 && currentSettings.type == 'swf') { next.before($('<iframe id="nyroModalIframeHideIeGalleryNext" src="javascript:\'\';"></iframe>').css($.extend({}, { position: next.css('position'), top: next.css('top'), left: next.css('left'), width: next.width(), height: next.height(), opacity: 0, border: 'none' }))) } } else { $('.nyroModalNext', modal.contentWrapper).remove() } } calculateSize() } function getGalleryLink(dir) { if (currentSettings.gallery) { if (!currentSettings.ltr) dir *= -1; var index = gallery.index + dir; if (index >= 0 && index < gallery.links.length) return gallery.links.eq(index); else if (currentSettings.galleryLoop) { if (index < 0) return gallery.links.eq(gallery.links.length - 1); else return gallery.links.eq(0) } } return false } function calculateSize(resizing) { debug('calculateSize'); modal.wrapper = modal.contentWrapper.children('div:first'); resized.width = false; resized.height = false; if (false && !currentSettings.windowResizing) { initSettingsSize.width = currentSettings.width; initSettingsSize.height = currentSettings.height } if (currentSettings.autoSizable && (!currentSettings.width || !currentSettings.height)) { modal.contentWrapper.css({ opacity: 0, width: 'auto', height: 'auto' }).show(); var tmp = { width: 'auto', height: 'auto' }; if (currentSettings.width) { tmp.width = currentSettings.width } else if (currentSettings.type == 'iframe') { tmp.width = currentSettings.minWidth } if (currentSettings.height) { tmp.height = currentSettings.height } else if (currentSettings.type == 'iframe') { tmp.height = currentSettings.minHeight } modal.content.css(tmp); if (!currentSettings.width) { currentSettings.width = modal.content.outerWidth(true); resized.width = true } if (!currentSettings.height) { currentSettings.height = modal.content.outerHeight(true); resized.height = true } modal.contentWrapper.css({ opacity: 1 }); if (!resizing) modal.contentWrapper.hide() } if (currentSettings.type != 'image' && currentSettings.type != 'swf') { currentSettings.width = Math.max(currentSettings.width, currentSettings.minWidth); currentSettings.height = Math.max(currentSettings.height, currentSettings.minHeight) } var outerWrapper = getOuter(modal.contentWrapper); var outerWrapper2 = getOuter(modal.wrapper); var outerContent = getOuter(modal.content); var tmp = { content: { width: currentSettings.width, height: currentSettings.height }, wrapper2: { width: currentSettings.width + outerContent.w.total, height: currentSettings.height + outerContent.h.total }, wrapper: { width: currentSettings.width + outerContent.w.total + outerWrapper2.w.total, height: currentSettings.height + outerContent.h.total + outerWrapper2.h.total} }; if (currentSettings.resizable) { var maxHeight = modal.blockerVars ? modal.blockerVars.height : $(window).height() - outerWrapper.h.border - (tmp.wrapper.height - currentSettings.height); var maxWidth = modal.blockerVars ? modal.blockerVars.width : $(window).width() - outerWrapper.w.border - (tmp.wrapper.width - currentSettings.width); maxHeight -= currentSettings.padding * 2; maxWidth -= currentSettings.padding * 2; if (tmp.content.height > maxHeight || tmp.content.width > maxWidth) { if (currentSettings.type == 'image' || currentSettings.type == 'swf') { var useW = currentSettings.imgWidth ? currentSettings.imgWidth : currentSettings.width; var useH = currentSettings.imgHeight ? currentSettings.imgHeight : currentSettings.height; var diffW = tmp.content.width - useW; var diffH = tmp.content.height - useH; if (diffH < 0) diffH = 0; if (diffW < 0) diffW = 0; var calcH = maxHeight - diffH; var calcW = maxWidth - diffW; var ratio = Math.min(calcH / useH, calcW / useW); calcW = Math.floor(useW * ratio); calcH = Math.floor(useH * ratio); tmp.content.height = calcH + diffH; tmp.content.width = calcW + diffW } else { tmp.content.height = Math.min(tmp.content.height, maxHeight); tmp.content.width = Math.min(tmp.content.width, maxWidth) } tmp.wrapper2 = { width: tmp.content.width + outerContent.w.total, height: tmp.content.height + outerContent.h.total }; tmp.wrapper = { width: tmp.content.width + outerContent.w.total + outerWrapper2.w.total, height: tmp.content.height + outerContent.h.total + outerWrapper2.h.total} } } if (currentSettings.type == 'swf') { $('object, embed', modal.content).attr('width', tmp.content.width).attr('height', tmp.content.height) } else if (currentSettings.type == 'image') { $('img', modal.content).css({ width: tmp.content.width, height: tmp.content.height }) } modal.content.css($.extend({}, tmp.content, currentSettings.cssOpt.content)); modal.wrapper.css($.extend({}, tmp.wrapper2, currentSettings.cssOpt.wrapper2)); if (!resizing) modal.contentWrapper.css($.extend({}, tmp.wrapper, currentSettings.cssOpt.wrapper)); if (currentSettings.type == 'image' && currentSettings.addImageDivTitle) { $('img', modal.content).removeAttr('alt'); var divTitle = $('div', modal.content); if (currentSettings.title != currentSettings.defaultImgAlt && currentSettings.title) { if (divTitle.length == 0) { divTitle = $('<div>' + currentSettings.title + '</div>'); modal.content.append(divTitle) } if (currentSettings.setWidthImgTitle) { var outerDivTitle = getOuter(divTitle); divTitle.css({ width: (tmp.content.width + outerContent.w.padding - outerDivTitle.w.total) + 'px' }) } } else if (divTitle.length = 0) { divTitle.remove() } } if (currentSettings.title) setTitle(); tmp.wrapper.borderW = outerWrapper.w.border; tmp.wrapper.borderH = outerWrapper.h.border; setCurrentSettings(tmp.wrapper); setMargin() } function removeModal(e) { debug('removeModal'); if (e) e.preventDefault(); if (modal.full && modal.ready) { $(document).unbind('keydown.nyroModal'); if (!currentSettings.blocker) $(window).unbind('resize.nyroModal'); modal.ready = false; modal.anim = true; modal.closing = true; if (modal.loadingShown || modal.transition) { currentSettings.hideLoading(modal, currentSettings, function() { modal.loading.hide(); modal.loadingShown = false; modal.transition = false; currentSettings.hideBackground(modal, currentSettings, endRemove) }) } else { if (fixFF) modal.content.css({ position: '' }); modal.wrapper.css({ overflow: 'hidden' }); modal.content.css({ overflow: 'hidden' }); $('iframe', modal.content).hide(); if ($.isFunction(currentSettings.beforeHideContent)) { currentSettings.beforeHideContent(modal, currentSettings, function() { currentSettings.hideContent(modal, currentSettings, function() { endHideContent(); currentSettings.hideBackground(modal, currentSettings, endRemove) }) }) } else { currentSettings.hideContent(modal, currentSettings, function() { endHideContent(); currentSettings.hideBackground(modal, currentSettings, endRemove) }) } } } if (e) return false } function showContentOrLoading() { debug('showContentOrLoading'); if (modal.ready && !modal.anim) { if (modal.dataReady) { if (modal.tmp.html()) { modal.anim = true; if (modal.transition) { fillContent(); modal.animContent = true; currentSettings.hideTransition(modal, currentSettings, function() { modal.loading.hide(); modal.transition = false; modal.loadingShown = false; endShowContent() }) } else { currentSettings.hideLoading(modal, currentSettings, function() { modal.loading.hide(); modal.loadingShown = false; fillContent(); setMarginLoading(); setMargin(); modal.animContent = true; currentSettings.showContent(modal, currentSettings, endShowContent) }) } } } else if (!modal.loadingShown && !modal.transition) { modal.anim = true; modal.loadingShown = true; if (modal.error) loadingError(); else modal.loading.html(currentSettings.contentLoading); $(currentSettings.closeSelector, modal.loading).unbind('click.nyroModal').bind('click.nyroModal', removeModal); setMarginLoading(); currentSettings.showLoading(modal, currentSettings, function() { modal.anim = false; showContentOrLoading() }) } } } function ajaxLoaded(data) { debug('AjaxLoaded: ' + this.url); if (currentSettings.selector) { var tmp = {}; var i = 0; data = data.replace(/\r\n/gi, 'nyroModalLN').replace(/<script(.|\s)*?\/script>/gi, function(x) { tmp[i] = x; return '<pre style="display: none" class=nyroModalScript rel="' + (i++) + '"></pre>' }); data = $('<div>' + data + '</div>').find(currentSettings.selector).html().replace(/<pre style="display: none;?" class="?nyroModalScript"? rel="(.?)"><\/pre>/gi, function(x, y, z) { return tmp[y] }).replace(/nyroModalLN/gi, "\r\n") } modal.tmp.html(filterScripts(data)); if (modal.tmp.html()) { modal.dataReady = true; showContentOrLoading() } else loadingError() } function formDataLoaded() { debug('formDataLoaded'); var jFrom = $(currentSettings.from); jFrom.attr('action', jFrom.attr('action') + currentSettings.selector); jFrom.attr('target', ''); $('input[name=' + currentSettings.formIndicator + ']', currentSettings.from).remove(); var iframe = modal.tmp.children('iframe'); var iframeContent = iframe.unbind('load').contents().find(currentSettings.selector || 'body').not('script[src]'); iframe.attr('src', 'about:blank'); modal.tmp.html(iframeContent.html()); if (modal.tmp.html()) { modal.dataReady = true; showContentOrLoading() } else loadingError() } function iframeLoaded() { if ((window.location.hostname && currentSettings.url.indexOf(window.location.hostname) > -1) || currentSettings.url.indexOf('http://')) { var iframe = $('iframe', modal.full).contents(); var tmp = {}; if (currentSettings.titleFromIframe) { tmp.title = iframe.find('title').text(); if (!tmp.title) { try { tmp.title = iframe.find('title').html() } catch (err) { } } } var body = iframe.find('body'); if (!currentSettings.height && body.height()) tmp.height = body.height(); if (!currentSettings.width && body.width()) tmp.width = body.width(); $.extend(initSettingsSize, tmp); $.nyroModalSettings(tmp) } } function galleryCounts(nb, total, elts, settings) { if (total > 1) settings.title += (settings.title ? ' - ' : '') + nb + '/' + total } function endHideContent() { debug('endHideContent'); modal.anim = false; if (contentEltLast) { contentEltLast.append(modal.content.contents()); contentEltLast = null } else if (contentElt) { contentElt.append(modal.content.contents()); contentElt = null } modal.content.empty(); gallery = {}; modal.contentWrapper.hide().children().remove().empty().attr('style', '').hide(); if (modal.closing || modal.transition) modal.contentWrapper.hide(); modal.contentWrapper.css(currentSettings.cssOpt.wrapper).append(modal.content); showContentOrLoading() } function endRemove() { debug('endRemove'); $(document).unbind('keydown', keyHandler); modal.anim = false; modal.full.remove(); modal.full = null; if (isIE6) { body.css({ height: '', width: '', position: '', overflow: '', marginLeft: '', marginRight: '' }); $('html').css({ overflow: '' }) } if ($.isFunction(currentSettings.endRemove)) currentSettings.endRemove(modal, currentSettings) } function endBackground() { debug('endBackground'); modal.ready = true; modal.anim = false; showContentOrLoading() } function endShowContent() { debug('endShowContent'); modal.anim = false; modal.animContent = false; modal.contentWrapper.css({ opacity: '' }); fixFF = /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent) && parseFloat(browserVersion) < 1.9 && currentSettings.type != 'image'; if (fixFF) modal.content.css({ position: 'fixed' }); modal.content.append(modal.scriptsShown); if (currentSettings.type == 'iframe') modal.content.find('iframe').attr('src', currentSettings.url); if ($.isFunction(currentSettings.endShowContent)) currentSettings.endShowContent(modal, currentSettings); if (shouldResize) { shouldResize = false; $.nyroModalSettings({ width: currentSettings.setWidth, height: currentSettings.setHeight }); delete currentSettings['setWidth']; delete currentSettings['setHeight'] } if (resized.width) setCurrentSettings({ width: null }); if (resized.height) setCurrentSettings({ height: null }) } function getHash(url) { if (typeof url == 'string') { var hashPos = url.indexOf('#'); if (hashPos > -1) return url.substring(hashPos) } return '' } function filterScripts(data) { if (typeof data == 'string') data = data.replace(/<\/?(html|head|body)([^>]*)>/gi, ''); var tmp = new Array(); $.each($.clean({ 0: data }, this.ownerDocument), function() { if ($.nodeName(this, "script")) { if (!this.src || $(this).attr('rel') == 'forceLoad') { if ($(this).attr('rev') == 'shown') modal.scriptsShown.push(this); else modal.scripts.push(this) } } else tmp.push(this) }); return tmp } function getOuter(elm) { elm = elm.get(0); var ret = { h: { margin: getCurCSS(elm, 'marginTop') + getCurCSS(elm, 'marginBottom'), border: getCurCSS(elm, 'borderTopWidth') + getCurCSS(elm, 'borderBottomWidth'), padding: getCurCSS(elm, 'paddingTop') + getCurCSS(elm, 'paddingBottom') }, w: { margin: getCurCSS(elm, 'marginLeft') + getCurCSS(elm, 'marginRight'), border: getCurCSS(elm, 'borderLeftWidth') + getCurCSS(elm, 'borderRightWidth'), padding: getCurCSS(elm, 'paddingLeft') + getCurCSS(elm, 'paddingRight')} }; ret.h.outer = ret.h.margin + ret.h.border; ret.w.outer = ret.w.margin + ret.w.border; ret.h.inner = ret.h.padding + ret.h.border; ret.w.inner = ret.w.padding + ret.w.border; ret.h.total = ret.h.outer + ret.h.padding; ret.w.total = ret.w.outer + ret.w.padding; return ret } function getCurCSS(elm, name) { var ret = parseInt($.curCSS(elm, name, true)); if (isNaN(ret)) ret = 0; return ret } function debug(msg) { if ($.fn.nyroModal.settings.debug || currentSettings && currentSettings.debug) nyroModalDebug(msg, modal, currentSettings || {}) } function showBackground(elts, settings, callback) { elts.bg.css({ opacity: 0 }).fadeTo(500, 0.75, callback) } function hideBackground(elts, settings, callback) { elts.bg.fadeOut(300, callback) } function showLoading(elts, settings, callback) { elts.loading.css({ marginTop: settings.marginTopLoading + 'px', marginLeft: settings.marginLeftLoading + 'px', opacity: 0 }).show().animate({ opacity: 1 }, { complete: callback, duration: 400 }) } function hideLoading(elts, settings, callback) { callback() } function showContent(elts, settings, callback) { elts.loading.css({ marginTop: settings.marginTopLoading + 'px', marginLeft: settings.marginLeftLoading + 'px' }).show().animate({ width: settings.width + 'px', height: settings.height + 'px', marginTop: settings.marginTop + 'px', marginLeft: settings.marginLeft + 'px' }, { duration: 350, complete: function() { elts.contentWrapper.css({ width: settings.width + 'px', height: settings.height + 'px', marginTop: settings.marginTop + 'px', marginLeft: settings.marginLeft + 'px' }).show(); elts.loading.fadeOut(200, callback) } }) } function hideContent(elts, settings, callback) { elts.contentWrapper.animate({ height: '50px', width: '50px', marginTop: (-(25 + settings.borderH) / 2 + settings.marginScrollTop) + 'px', marginLeft: (-(25 + settings.borderW) / 2 + settings.marginScrollLeft) + 'px' }, { duration: 350, complete: function() { elts.contentWrapper.hide(); callback() } }) } function showTransition(elts, settings, callback) { elts.loading.css({ marginTop: elts.contentWrapper.css('marginTop'), marginLeft: elts.contentWrapper.css('marginLeft'), height: elts.contentWrapper.css('height'), width: elts.contentWrapper.css('width'), opacity: 0 }).show().fadeTo(400, 1, function() { elts.contentWrapper.hide(); callback() }) } function hideTransition(elts, settings, callback) { elts.contentWrapper.hide().css({ width: settings.width + 'px', height: settings.height + 'px', marginLeft: settings.marginLeft + 'px', marginTop: settings.marginTop + 'px', opacity: 1 }); elts.loading.animate({ width: settings.width + 'px', height: settings.height + 'px', marginLeft: settings.marginLeft + 'px', marginTop: settings.marginTop + 'px' }, { complete: function() { elts.contentWrapper.show(); elts.loading.fadeOut(400, function() { elts.loading.hide(); callback() }) }, duration: 350 }) } function resize(elts, settings, callback) { elts.contentWrapper.animate({ width: settings.width + 'px', height: settings.height + 'px', marginLeft: settings.marginLeft + 'px', marginTop: settings.marginTop + 'px' }, { complete: callback, duration: 400 }) } function updateBgColor(elts, settings, callback) { if (!$.fx.step.backgroundColor) { elts.bg.css({ backgroundColor: settings.bgColor }); callback() } else elts.bg.animate({ backgroundColor: settings.bgColor }, { complete: callback, duration: 400 }) } $($.fn.nyroModal.settings.openSelector).nyroModal() }); var tmpDebug = ''; function nyroModalDebug(msg, elts, settings) { if (elts.full && elts.bg) { elts.bg.prepend(msg + '<br />' + tmpDebug); tmpDebug = '' } else tmpDebug += msg + '<br />' };

/******************************/
/*jcarousellite_1.0.1.min.js  */
/******************************/
(function($) { $.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() { var b = false, animCss = o.vertical ? "top" : "left", sizeCss = o.vertical ? "height" : "width"; var c = $(this), ul = $("ul", c), 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 f = $("li", ul), itemLength = f.size(), curr = o.start; c.css("visibility", "visible"); f.css({ overflow: "hidden", float: o.vertical ? "none" : "left" }); ul.css({ margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1" }); c.css({ overflow: "hidden", position: "relative", "z-index": "2", left: "0px" }); var g = o.vertical ? height(f) : width(f); var h = g * itemLength; var j = g * v; f.css({ width: f.width(), height: f.height() }); ul.css(sizeCss, h + "px").css(animCss, -(curr * g)); c.css(sizeCss, j + "px"); 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, a) { $(a).click(function() { return go(o.circular ? o.visible + i : i) }) }); if (o.mouseWheel && c.mousewheel) c.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 f.slice(curr).slice(0, v) }; function go(a) { if (!b) { if (o.beforeStart) o.beforeStart.call(this, vis()); if (o.circular) { if (a <= o.start - v - 1) { ul.css(animCss, -((itemLength - (v * 2)) * g) + "px"); curr = a == o.start - v - 1 ? itemLength - (v * 2) - 1 : itemLength - (v * 2) - o.scroll } else if (a >= itemLength - v + 1) { ul.css(animCss, -((v) * g) + "px"); curr = a == itemLength - v + 1 ? v + 1 : v + o.scroll } else curr = a } else { if (a < 0 || a > itemLength - v) return; else curr = a } b = true; ul.animate(animCss == "left" ? { left: -(curr * g)} : { top: -(curr * g) }, o.speed, o.easing, function() { if (o.afterEnd) o.afterEnd.call(this, vis()); b = false }); 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(a, b) { return parseInt($.css(a[0], b)) || 0 }; function width(a) { return a[0].offsetWidth + css(a, 'marginLeft') + css(a, 'marginRight') }; function height(a) { return a[0].offsetHeight + css(a, 'marginTop') + css(a, 'marginBottom') } })(jQuery);

