johnbacon

Untitled

Jan 23rd, 2013
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 165.18 KB | None | 0 0
  1. /** PLUGIN DIRECTORY
  2. What you can find in this file [listed in order they appear]
  3.  
  4.              1.) FlexSlider Responsive Slider 2.1 - http://flexslider.woothemes.com/
  5.              2.) bxSlider v4.0 - http://bxslider.com
  6.              3.) jQuery imagesLoaded plugin 2.1.0 - http://github.com/desandro/imagesloaded
  7.              4.) fancyBox 2.0.5 - http://fancyapps.com/fancybox/
  8.              5.) jquery-placeholder 2.0.3 - https://github.com/mathiasbynens/jquery-placeholder
  9.              6.) Isotope Leak Free - https://github.com/khiltd/isotope-leak-free
  10.              7.) jquery.pjax.js - https://github.com/defunkt/jquery-pjax
  11.              8.) RefineSlide
  12.              X.) Init scripts
  13. */
  14.  
  15. /*
  16.  * 1.) jQuery FlexSlider v2.1
  17.  * @author: Muffin Man
  18.  * Contributing author: Tyler Smith (@mbmufffin)
  19.  */
  20.  
  21. ;(function ($) {
  22.  
  23.     //FlexSlider: Object Instance
  24.     $.flexslider = function(el, options) {
  25.         var slider = $(el),
  26.                 vars = $.extend({}, $.flexslider.defaults, options),
  27.                 namespace = vars.namespace,
  28.                 touch = ("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch,
  29.                 eventType = (touch) ? "touchend" : "click",
  30.                 vertical = vars.direction === "vertical",
  31.                 reverse = vars.reverse,
  32.                 carousel = (vars.itemWidth > 0),
  33.                 fade = vars.animation === "fade",
  34.                 asNav = vars.asNavFor !== "",
  35.                 methods = {};
  36.  
  37.         // Store a reference to the slider object
  38.         $.data(el, "flexslider", slider);
  39.  
  40.         // Privat slider methods
  41.         methods = {
  42.             init: function() {
  43.                 slider.animating = false;
  44.                 slider.currentSlide = vars.startAt;
  45.                 slider.animatingTo = slider.currentSlide;
  46.                 slider.atEnd = (slider.currentSlide === 0 || slider.currentSlide === slider.last);
  47.                 slider.containerSelector = vars.selector.substr(0,vars.selector.search(' '));
  48.                 slider.slides = $(vars.selector, slider);
  49.                 slider.container = $(slider.containerSelector, slider);
  50.                 slider.count = slider.slides.length;
  51.                 // SYNC:
  52.                 slider.syncExists = $(vars.sync).length > 0;
  53.                 // SLIDE:
  54.                 if (vars.animation === "slide") vars.animation = "swing";
  55.                 slider.prop = (vertical) ? "top" : "marginLeft";
  56.                 slider.args = {};
  57.                 // SLIDESHOW:
  58.                 slider.manualPause = false;
  59.                 // TOUCH/USECSS:
  60.                 slider.transitions = !vars.video && !fade && vars.useCSS && (function() {
  61.                     var obj = document.createElement('div'),
  62.                             props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
  63.                     for (var i in props) {
  64.                         if ( obj.style[ props[i] ] !== undefined ) {
  65.                             slider.pfx = props[i].replace('Perspective','').toLowerCase();
  66.                             slider.prop = "-" + slider.pfx + "-transform";
  67.                             return true;
  68.                         }
  69.                     }
  70.                     return false;
  71.                 }());
  72.                 // CONTROLSCONTAINER:
  73.                 if (vars.controlsContainer !== "") slider.controlsContainer = $(vars.controlsContainer).length > 0 && $(vars.controlsContainer);
  74.                 // MANUAL:
  75.                 if (vars.manualControls !== "") slider.manualControls = $(vars.manualControls).length > 0 && $(vars.manualControls);
  76.  
  77.                 // RANDOMIZE:
  78.                 if (vars.randomize) {
  79.                     slider.slides.sort(function() { return (Math.round(Math.random())-0.5); });
  80.                     slider.container.empty().append(slider.slides);
  81.                 }
  82.  
  83.                 slider.doMath();
  84.  
  85.                 // ASNAV:
  86.                 if (asNav) methods.asNav.setup();
  87.  
  88.                 // INIT
  89.                 slider.setup("init");
  90.  
  91.                 // CONTROLNAV:
  92.                 if (vars.controlNav) methods.controlNav.setup();
  93.  
  94.                 // DIRECTIONNAV:
  95.                 if (vars.directionNav) methods.directionNav.setup();
  96.  
  97.                 // KEYBOARD:
  98.                 if (vars.keyboard && ($(slider.containerSelector).length === 1 || vars.multipleKeyboard)) {
  99.                     $(document).bind('keyup', function(event) {
  100.                         var keycode = event.keyCode;
  101.                         if (!slider.animating && (keycode === 39 || keycode === 37)) {
  102.                             var target = (keycode === 39) ? slider.getTarget('next') :
  103.                                                      (keycode === 37) ? slider.getTarget('prev') : false;
  104.                             slider.flexAnimate(target, vars.pauseOnAction);
  105.                         }
  106.                     });
  107.                 }
  108.                 // MOUSEWHEEL:
  109.                 if (vars.mousewheel) {
  110.                     slider.bind('mousewheel', function(event, delta, deltaX, deltaY) {
  111.                         event.preventDefault();
  112.                         var target = (delta < 0) ? slider.getTarget('next') : slider.getTarget('prev');
  113.                         slider.flexAnimate(target, vars.pauseOnAction);
  114.                     });
  115.                 }
  116.  
  117.                 // PAUSEPLAY
  118.                 if (vars.pausePlay) methods.pausePlay.setup();
  119.  
  120.                 // SLIDSESHOW
  121.                 if (vars.slideshow) {
  122.                     if (vars.pauseOnHover) {
  123.                         slider.hover(function() {
  124.                             if (!slider.manualPlay && !slider.manualPause) slider.pause();
  125.                         }, function() {
  126.                             if (!slider.manualPause && !slider.manualPlay) slider.play();
  127.                         });
  128.                     }
  129.                     // initialize animation
  130.                     (vars.initDelay > 0) ? setTimeout(slider.play, vars.initDelay) : slider.play();
  131.                 }
  132.  
  133.                 // TOUCH
  134.                 if (touch && vars.touch) methods.touch();
  135.  
  136.                 // FADE&&SMOOTHHEIGHT || SLIDE:
  137.                 if (!fade || (fade && vars.smoothHeight)) $(window).bind("resize focus", methods.resize);
  138.  
  139.  
  140.                 // API: start() Callback
  141.                 setTimeout(function(){
  142.                     vars.start(slider);
  143.                 }, 200);
  144.             },
  145.             asNav: {
  146.                 setup: function() {
  147.                     slider.asNav = true;
  148.                     slider.animatingTo = Math.floor(slider.currentSlide/slider.move);
  149.                     slider.currentItem = slider.currentSlide;
  150.                     slider.slides.removeClass(namespace + "active-slide").eq(slider.currentItem).addClass(namespace + "active-slide");
  151.                     slider.slides.click(function(e){
  152.                         e.preventDefault();
  153.                         var $slide = $(this),
  154.                                 target = $slide.index();
  155.                         if (!$(vars.asNavFor).data('flexslider').animating && !$slide.hasClass('active')) {
  156.                             slider.direction = (slider.currentItem < target) ? "next" : "prev";
  157.                             slider.flexAnimate(target, vars.pauseOnAction, false, true, true);
  158.                         }
  159.                     });
  160.                 }
  161.             },
  162.             controlNav: {
  163.                 setup: function() {
  164.                     if (!slider.manualControls) {
  165.                         methods.controlNav.setupPaging();
  166.                     } else { // MANUALCONTROLS:
  167.                         methods.controlNav.setupManual();
  168.                     }
  169.                 },
  170.                 setupPaging: function() {
  171.                     var type = (vars.controlNav === "thumbnails") ? 'control-thumbs' : 'control-paging',
  172.                             j = 1,
  173.                             item;
  174.  
  175.                     slider.controlNavScaffold = $('<ol class="'+ namespace + 'control-nav ' + namespace + type + '"></ol>');
  176.  
  177.                     if (slider.pagingCount > 1) {
  178.                         for (var i = 0; i < slider.pagingCount; i++) {
  179.                             item = (vars.controlNav === "thumbnails") ? '<img src="' + slider.slides.eq(i).attr("data-thumb") + '"/>' : '<a>' + j + '</a>';
  180.                             slider.controlNavScaffold.append('<li>' + item + '</li>');
  181.                             j++;
  182.                         }
  183.                     }
  184.  
  185.                     // CONTROLSCONTAINER:
  186.                     (slider.controlsContainer) ? $(slider.controlsContainer).append(slider.controlNavScaffold) : slider.append(slider.controlNavScaffold);
  187.                     methods.controlNav.set();
  188.  
  189.                     methods.controlNav.active();
  190.  
  191.                     slider.controlNavScaffold.delegate('a, img', eventType, function(event) {
  192.                         event.preventDefault();
  193.                         var $this = $(this),
  194.                                 target = slider.controlNav.index($this);
  195.  
  196.                         if (!$this.hasClass(namespace + 'active')) {
  197.                             slider.direction = (target > slider.currentSlide) ? "next" : "prev";
  198.                             slider.flexAnimate(target, vars.pauseOnAction);
  199.                         }
  200.                     });
  201.                     // Prevent iOS click event bug
  202.                     if (touch) {
  203.                         slider.controlNavScaffold.delegate('a', "click touchstart", function(event) {
  204.                             event.preventDefault();
  205.                         });
  206.                     }
  207.                 },
  208.                 setupManual: function() {
  209.                     slider.controlNav = slider.manualControls;
  210.                     methods.controlNav.active();
  211.  
  212.                     slider.controlNav.live(eventType, function(event) {
  213.                         event.preventDefault();
  214.                         var $this = $(this),
  215.                                 target = slider.controlNav.index($this);
  216.  
  217.                         if (!$this.hasClass(namespace + 'active')) {
  218.                             (target > slider.currentSlide) ? slider.direction = "next" : slider.direction = "prev";
  219.                             slider.flexAnimate(target, vars.pauseOnAction);
  220.                         }
  221.                     });
  222.                     // Prevent iOS click event bug
  223.                     if (touch) {
  224.                         slider.controlNav.live("click touchstart", function(event) {
  225.                             event.preventDefault();
  226.                         });
  227.                     }
  228.                 },
  229.                 set: function() {
  230.                     var selector = (vars.controlNav === "thumbnails") ? 'img' : 'a';
  231.                     slider.controlNav = $('.' + namespace + 'control-nav li ' + selector, (slider.controlsContainer) ? slider.controlsContainer : slider);
  232.                 },
  233.                 active: function() {
  234.                     slider.controlNav.removeClass(namespace + "active").eq(slider.animatingTo).addClass(namespace + "active");
  235.                 },
  236.                 update: function(action, pos) {
  237.                     if (slider.pagingCount > 1 && action === "add") {
  238.                         slider.controlNavScaffold.append($('<li><a>' + slider.count + '</a></li>'));
  239.                     } else if (slider.pagingCount === 1) {
  240.                         slider.controlNavScaffold.find('li').remove();
  241.                     } else {
  242.                         slider.controlNav.eq(pos).closest('li').remove();
  243.                     }
  244.                     methods.controlNav.set();
  245.                     (slider.pagingCount > 1 && slider.pagingCount !== slider.controlNav.length) ? slider.update(pos, action) : methods.controlNav.active();
  246.                 }
  247.             },
  248.             directionNav: {
  249.                 setup: function() {
  250.                     var directionNavScaffold = $('<ul class="' + namespace + 'direction-nav"><li><a class="' + namespace + 'prev" href="#">' + vars.prevText + '</a></li><li><a class="' + namespace + 'next" href="#">' + vars.nextText + '</a></li></ul>');
  251.  
  252.                     // CONTROLSCONTAINER:
  253.                     if (slider.controlsContainer) {
  254.                         $(slider.controlsContainer).append(directionNavScaffold);
  255.                         slider.directionNav = $('.' + namespace + 'direction-nav li a', slider.controlsContainer);
  256.                     } else {
  257.                         slider.append(directionNavScaffold);
  258.                         slider.directionNav = $('.' + namespace + 'direction-nav li a', slider);
  259.                     }
  260.  
  261.                     methods.directionNav.update();
  262.  
  263.                     slider.directionNav.bind(eventType, function(event) {
  264.                         event.preventDefault();
  265.                         var target = ($(this).hasClass(namespace + 'next')) ? slider.getTarget('next') : slider.getTarget('prev');
  266.                         slider.flexAnimate(target, vars.pauseOnAction);
  267.                     });
  268.                     // Prevent iOS click event bug
  269.                     if (touch) {
  270.                         slider.directionNav.bind("click touchstart", function(event) {
  271.                             event.preventDefault();
  272.                         });
  273.                     }
  274.                 },
  275.                 update: function() {
  276.                     var disabledClass = namespace + 'disabled';
  277.                     if (slider.pagingCount === 1) {
  278.                         slider.directionNav.addClass(disabledClass);
  279.                     } else if (!vars.animationLoop) {
  280.                         if (slider.animatingTo === 0) {
  281.                             slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "prev").addClass(disabledClass);
  282.                         } else if (slider.animatingTo === slider.last) {
  283.                             slider.directionNav.removeClass(disabledClass).filter('.' + namespace + "next").addClass(disabledClass);
  284.                         } else {
  285.                             slider.directionNav.removeClass(disabledClass);
  286.                         }
  287.                     } else {
  288.                         slider.directionNav.removeClass(disabledClass);
  289.                     }
  290.                 }
  291.             },
  292.             pausePlay: {
  293.                 setup: function() {
  294.                     var pausePlayScaffold = $('<div class="' + namespace + 'pauseplay"><a></a></div>');
  295.  
  296.                     // CONTROLSCONTAINER:
  297.                     if (slider.controlsContainer) {
  298.                         slider.controlsContainer.append(pausePlayScaffold);
  299.                         slider.pausePlay = $('.' + namespace + 'pauseplay a', slider.controlsContainer);
  300.                     } else {
  301.                         slider.append(pausePlayScaffold);
  302.                         slider.pausePlay = $('.' + namespace + 'pauseplay a', slider);
  303.                     }
  304.  
  305.                     methods.pausePlay.update((vars.slideshow) ? namespace + 'pause' : namespace + 'play');
  306.  
  307.                     slider.pausePlay.bind(eventType, function(event) {
  308.                         event.preventDefault();
  309.                         if ($(this).hasClass(namespace + 'pause')) {
  310.                             slider.manualPause = true;
  311.                             slider.manualPlay = false;
  312.                             slider.pause();
  313.                         } else {
  314.                             slider.manualPause = false;
  315.                             slider.manualPlay = true;
  316.                             slider.play();
  317.                         }
  318.                     });
  319.                     // Prevent iOS click event bug
  320.                     if (touch) {
  321.                         slider.pausePlay.bind("click touchstart", function(event) {
  322.                             event.preventDefault();
  323.                         });
  324.                     }
  325.                 },
  326.                 update: function(state) {
  327.                     (state === "play") ? slider.pausePlay.removeClass(namespace + 'pause').addClass(namespace + 'play').text(vars.playText) : slider.pausePlay.removeClass(namespace + 'play').addClass(namespace + 'pause').text(vars.pauseText);
  328.                 }
  329.             },
  330.             touch: function() {
  331.                 var startX,
  332.                     startY,
  333.                     offset,
  334.                     cwidth,
  335.                     dx,
  336.                     startT,
  337.                     scrolling = false;
  338.  
  339.                 el.addEventListener('touchstart', onTouchStart, false);
  340.                 function onTouchStart(e) {
  341.                     if (slider.animating) {
  342.                         e.preventDefault();
  343.                     } else if (e.touches.length === 1) {
  344.                         slider.pause();
  345.                         // CAROUSEL:
  346.                         cwidth = (vertical) ? slider.h : slider. w;
  347.                         startT = Number(new Date());
  348.                         // CAROUSEL:
  349.                         offset = (carousel && reverse && slider.animatingTo === slider.last) ? 0 :
  350.                                          (carousel && reverse) ? slider.limit - (((slider.itemW + vars.itemMargin) * slider.move) * slider.animatingTo) :
  351.                                          (carousel && slider.currentSlide === slider.last) ? slider.limit :
  352.                                          (carousel) ? ((slider.itemW + vars.itemMargin) * slider.move) * slider.currentSlide :
  353.                                          (reverse) ? (slider.last - slider.currentSlide + slider.cloneOffset) * cwidth : (slider.currentSlide + slider.cloneOffset) * cwidth;
  354.                         startX = (vertical) ? e.touches[0].pageY : e.touches[0].pageX;
  355.                         startY = (vertical) ? e.touches[0].pageX : e.touches[0].pageY;
  356.  
  357.                         el.addEventListener('touchmove', onTouchMove, false);
  358.                         el.addEventListener('touchend', onTouchEnd, false);
  359.                     }
  360.                 }
  361.  
  362.                 function onTouchMove(e) {
  363.                     dx = (vertical) ? startX - e.touches[0].pageY : startX - e.touches[0].pageX;
  364.                     scrolling = (vertical) ? (Math.abs(dx) < Math.abs(e.touches[0].pageX - startY)) : (Math.abs(dx) < Math.abs(e.touches[0].pageY - startY));
  365.  
  366.                     if (!scrolling || Number(new Date()) - startT > 500) {
  367.                         e.preventDefault();
  368.                         if (!fade && slider.transitions) {
  369.                             if (!vars.animationLoop) {
  370.                                 dx = dx/((slider.currentSlide === 0 && dx < 0 || slider.currentSlide === slider.last && dx > 0) ? (Math.abs(dx)/cwidth+2) : 1);
  371.                             }
  372.                             slider.setProps(offset + dx, "setTouch");
  373.                         }
  374.                     }
  375.                 }
  376.  
  377.                 function onTouchEnd(e) {
  378.                     if (slider.animatingTo === slider.currentSlide && !scrolling && !(dx === null)) {
  379.                         var updateDx = (reverse) ? -dx : dx,
  380.                                 target = (updateDx > 0) ? slider.getTarget('next') : slider.getTarget('prev');
  381.  
  382.                         if (slider.canAdvance(target) && (Number(new Date()) - startT < 550 && Math.abs(updateDx) > 50 || Math.abs(updateDx) > cwidth/2)) {
  383.                             slider.flexAnimate(target, vars.pauseOnAction);
  384.                         } else {
  385.                             slider.flexAnimate(slider.currentSlide, vars.pauseOnAction, true);
  386.                         }
  387.                     }
  388.                     // finish the touch by undoing the touch session
  389.                     el.removeEventListener('touchmove', onTouchMove, false);
  390.                     el.removeEventListener('touchend', onTouchEnd, false);
  391.                     startX = null;
  392.                     startY = null;
  393.                     dx = null;
  394.                     offset = null;
  395.                 }
  396.             },
  397.             resize: function() {
  398.                 if (!slider.animating && slider.is(':visible')) {
  399.                     if (!carousel) slider.doMath();
  400.  
  401.                     if (fade) {
  402.                         // SMOOTH HEIGHT:
  403.                         methods.smoothHeight();
  404.                     } else if (carousel) { //CAROUSEL:
  405.                         slider.slides.width(slider.computedW);
  406.                         slider.update(slider.pagingCount);
  407.                         slider.setProps();
  408.                     }
  409.                     else if (vertical) { //VERTICAL:
  410.                         slider.viewport.height(slider.h);
  411.                         slider.setProps(slider.h, "setTotal");
  412.                     } else {
  413.                         // SMOOTH HEIGHT:
  414.                         if (vars.smoothHeight) methods.smoothHeight();
  415.                         slider.newSlides.width(slider.computedW);
  416.                         slider.setProps(slider.computedW, "setTotal");
  417.                     }
  418.                 }
  419.             },
  420.             smoothHeight: function(dur) {
  421.                 if (!vertical || fade) {
  422.                     var $obj = (fade) ? slider : slider.viewport;
  423.                     (dur) ? $obj.animate({"height": slider.slides.eq(slider.animatingTo).height()}, dur) : $obj.height(slider.slides.eq(slider.animatingTo).height());
  424.                 }
  425.             },
  426.             sync: function(action) {
  427.                 var $obj = $(vars.sync).data("flexslider"),
  428.                         target = slider.animatingTo;
  429.  
  430.                 switch (action) {
  431.                     case "animate": $obj.flexAnimate(target, vars.pauseOnAction, false, true); break;
  432.                     case "play": if (!$obj.playing && !$obj.asNav) { $obj.play(); } break;
  433.                     case "pause": $obj.pause(); break;
  434.                 }
  435.             }
  436.         };
  437.  
  438.         // public methods
  439.         slider.flexAnimate = function(target, pause, override, withSync, fromNav) {
  440.             if (asNav && slider.pagingCount === 1) slider.direction = (slider.currentItem < target) ? "next" : "prev";
  441.  
  442.             if (!slider.animating && (slider.canAdvance(target, fromNav) || override) && slider.is(":visible")) {
  443.                 if (asNav && withSync) {
  444.                     var master = $(vars.asNavFor).data('flexslider');
  445.                     slider.atEnd = target === 0 || target === slider.count - 1;
  446.                     master.flexAnimate(target, true, false, true, fromNav);
  447.                     slider.direction = (slider.currentItem < target) ? "next" : "prev";
  448.                     master.direction = slider.direction;
  449.  
  450.                     if (Math.ceil((target + 1)/slider.visible) - 1 !== slider.currentSlide && target !== 0) {
  451.                         slider.currentItem = target;
  452.                         slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
  453.                         target = Math.floor(target/slider.visible);
  454.                     } else {
  455.                         slider.currentItem = target;
  456.                         slider.slides.removeClass(namespace + "active-slide").eq(target).addClass(namespace + "active-slide");
  457.                         return false;
  458.                     }
  459.                 }
  460.  
  461.                 slider.animating = true;
  462.                 slider.animatingTo = target;
  463.                 // API: before() animation Callback
  464.                 vars.before(slider);
  465.  
  466.                 // SLIDESHOW:
  467.                 if (pause) slider.pause();
  468.  
  469.                 // SYNC:
  470.                 if (slider.syncExists && !fromNav) methods.sync("animate");
  471.  
  472.                 // CONTROLNAV
  473.                 if (vars.controlNav) methods.controlNav.active();
  474.  
  475.                 // !CAROUSEL:
  476.                 // CANDIDATE: slide active class (for add/remove slide)
  477.                 if (!carousel) slider.slides.removeClass(namespace + 'active-slide').eq(target).addClass(namespace + 'active-slide');
  478.  
  479.                 // INFINITE LOOP:
  480.                 // CANDIDATE: atEnd
  481.                 slider.atEnd = target === 0 || target === slider.last;
  482.  
  483.                 // DIRECTIONNAV:
  484.                 if (vars.directionNav) methods.directionNav.update();
  485.  
  486.                 if (target === slider.last) {
  487.                     // API: end() of cycle Callback
  488.                     vars.end(slider);
  489.                     // SLIDESHOW && !INFINITE LOOP:
  490.                     if (!vars.animationLoop) slider.pause();
  491.                 }
  492.  
  493.                 // SLIDE:
  494.                 if (!fade) {
  495.                     var dimension = (vertical) ? slider.slides.filter(':first').height() : slider.computedW,
  496.                             margin, slideString, calcNext;
  497.  
  498.                     // INFINITE LOOP / REVERSE:
  499.                     if (carousel) {
  500.                         margin = (vars.itemWidth > slider.w) ? vars.itemMargin * 2 : vars.itemMargin;
  501.                         calcNext = ((slider.itemW + margin) * slider.move) * slider.animatingTo;
  502.                         slideString = (calcNext > slider.limit && slider.visible !== 1) ? slider.limit : calcNext;
  503.                     } else if (slider.currentSlide === 0 && target === slider.count - 1 && vars.animationLoop && slider.direction !== "next") {
  504.                         slideString = (reverse) ? (slider.count + slider.cloneOffset) * dimension : 0;
  505.                     } else if (slider.currentSlide === slider.last && target === 0 && vars.animationLoop && slider.direction !== "prev") {
  506.                         slideString = (reverse) ? 0 : (slider.count + 1) * dimension;
  507.                     } else {
  508.                         slideString = (reverse) ? ((slider.count - 1) - target + slider.cloneOffset) * dimension : (target + slider.cloneOffset) * dimension;
  509.                     }
  510.                     slider.setProps(slideString, "", vars.animationSpeed);
  511.                     if (slider.transitions) {
  512.                         if (!vars.animationLoop || !slider.atEnd) {
  513.                             slider.animating = false;
  514.                             slider.currentSlide = slider.animatingTo;
  515.                         }
  516.                         slider.container.unbind("webkitTransitionEnd transitionend");
  517.                         slider.container.bind("webkitTransitionEnd transitionend", function() {
  518.                             slider.wrapup(dimension);
  519.                         });
  520.                     } else {
  521.                         slider.container.animate(slider.args, vars.animationSpeed, vars.easing, function(){
  522.                             slider.wrapup(dimension);
  523.                         });
  524.                     }
  525.                 } else { // FADE:
  526.                     slider.slides.eq(slider.currentSlide).fadeOut(vars.animationSpeed, vars.easing);
  527.                     slider.slides.eq(target).fadeIn(vars.animationSpeed, vars.easing, slider.wrapup);
  528.                 }
  529.                 // SMOOTH HEIGHT:
  530.                 if (vars.smoothHeight) methods.smoothHeight(vars.animationSpeed);
  531.             }
  532.         };
  533.         slider.wrapup = function(dimension) {
  534.             // SLIDE:
  535.             if (!fade && !carousel) {
  536.                 if (slider.currentSlide === 0 && slider.animatingTo === slider.last && vars.animationLoop) {
  537.                     slider.setProps(dimension, "jumpEnd");
  538.                 } else if (slider.currentSlide === slider.last && slider.animatingTo === 0 && vars.animationLoop) {
  539.                     slider.setProps(dimension, "jumpStart");
  540.                 }
  541.             }
  542.             slider.animating = false;
  543.             slider.currentSlide = slider.animatingTo;
  544.             // API: after() animation Callback
  545.             vars.after(slider);
  546.         };
  547.  
  548.         // SLIDESHOW:
  549.         slider.animateSlides = function() {
  550.             if (!slider.animating) slider.flexAnimate(slider.getTarget("next"));
  551.         };
  552.         // SLIDESHOW:
  553.         slider.pause = function() {
  554.             clearInterval(slider.animatedSlides);
  555.             slider.playing = false;
  556.             // PAUSEPLAY:
  557.             if (vars.pausePlay) methods.pausePlay.update("play");
  558.             // SYNC:
  559.             if (slider.syncExists) methods.sync("pause");
  560.         };
  561.         // SLIDESHOW:
  562.         slider.play = function() {
  563.             slider.animatedSlides = setInterval(slider.animateSlides, vars.slideshowSpeed);
  564.             slider.playing = true;
  565.             // PAUSEPLAY:
  566.             if (vars.pausePlay) methods.pausePlay.update("pause");
  567.             // SYNC:
  568.             if (slider.syncExists) methods.sync("play");
  569.         };
  570.         slider.canAdvance = function(target, fromNav) {
  571.             // ASNAV:
  572.             var last = (asNav) ? slider.pagingCount - 1 : slider.last;
  573.             return (fromNav) ? true :
  574.                          (asNav && slider.currentItem === slider.count - 1 && target === 0 && slider.direction === "prev") ? true :
  575.                          (asNav && slider.currentItem === 0 && target === slider.pagingCount - 1 && slider.direction !== "next") ? false :
  576.                          (target === slider.currentSlide && !asNav) ? false :
  577.                          (vars.animationLoop) ? true :
  578.                          (slider.atEnd && slider.currentSlide === 0 && target === last && slider.direction !== "next") ? false :
  579.                          (slider.atEnd && slider.currentSlide === last && target === 0 && slider.direction === "next") ? false :
  580.                          true;
  581.         };
  582.         slider.getTarget = function(dir) {
  583.             slider.direction = dir;
  584.             if (dir === "next") {
  585.                 return (slider.currentSlide === slider.last) ? 0 : slider.currentSlide + 1;
  586.             } else {
  587.                 return (slider.currentSlide === 0) ? slider.last : slider.currentSlide - 1;
  588.             }
  589.         };
  590.  
  591.         // SLIDE:
  592.         slider.setProps = function(pos, special, dur) {
  593.             var target = (function() {
  594.                 var posCheck = (pos) ? pos : ((slider.itemW + vars.itemMargin) * slider.move) * slider.animatingTo,
  595.                         posCalc = (function() {
  596.                             if (carousel) {
  597.                                 return (special === "setTouch") ? pos :
  598.                                              (reverse && slider.animatingTo === slider.last) ? 0 :
  599.                                              (reverse) ? slider.limit - (((slider.itemW + vars.itemMargin) * slider.move) * slider.animatingTo) :
  600.                                              (slider.animatingTo === slider.last) ? slider.limit : posCheck;
  601.                             } else {
  602.                                 switch (special) {
  603.                                     case "setTotal": return (reverse) ? ((slider.count - 1) - slider.currentSlide + slider.cloneOffset) * pos : (slider.currentSlide + slider.cloneOffset) * pos;
  604.                                     case "setTouch": return (reverse) ? pos : pos;
  605.                                     case "jumpEnd": return (reverse) ? pos : slider.count * pos;
  606.                                     case "jumpStart": return (reverse) ? slider.count * pos : pos;
  607.                                     default: return pos;
  608.                                 }
  609.                             }
  610.                         }());
  611.                         return (posCalc * -1) + "px";
  612.                     }());
  613.  
  614.             if (slider.transitions) {
  615.                 target = (vertical) ? "translate3d(0," + target + ",0)" : "translate3d(" + target + ",0,0)";
  616.                 dur = (dur !== undefined) ? (dur/1000) + "s" : "0s";
  617.                 slider.container.css("-" + slider.pfx + "-transition-duration", dur);
  618.             }
  619.  
  620.             slider.args[slider.prop] = target;
  621.             if (slider.transitions || dur === undefined) slider.container.css(slider.args);
  622.         };
  623.  
  624.         slider.setup = function(type) {
  625.             // SLIDE:
  626.             if (!fade) {
  627.                 var sliderOffset, arr;
  628.  
  629.                 if (type === "init") {
  630.                     slider.viewport = $('<div class="' + namespace + 'viewport"></div>').css({"overflow": "hidden", "position": "relative"}).appendTo(slider).append(slider.container);
  631.                     // INFINITE LOOP:
  632.                     slider.cloneCount = 0;
  633.                     slider.cloneOffset = 0;
  634.                     // REVERSE:
  635.                     if (reverse) {
  636.                         arr = $.makeArray(slider.slides).reverse();
  637.                         slider.slides = $(arr);
  638.                         slider.container.empty().append(slider.slides);
  639.                     }
  640.                 }
  641.                 // INFINITE LOOP && !CAROUSEL:
  642.                 if (vars.animationLoop && !carousel) {
  643.                     slider.cloneCount = 2;
  644.                     slider.cloneOffset = 1;
  645.                     // clear out old clones
  646.                     if (type !== "init") slider.container.find('.clone').remove();
  647.                     slider.container.append(slider.slides.first().clone().addClass('clone')).prepend(slider.slides.last().clone().addClass('clone'));
  648.                 }
  649.                 slider.newSlides = $(vars.selector, slider);
  650.  
  651.                 sliderOffset = (reverse) ? slider.count - 1 - slider.currentSlide + slider.cloneOffset : slider.currentSlide + slider.cloneOffset;
  652.                 // VERTICAL:
  653.                 if (vertical && !carousel) {
  654.                     slider.container.height((slider.count + slider.cloneCount) * 200 + "%").css("position", "absolute").width("100%");
  655.                     setTimeout(function(){
  656.                         slider.newSlides.css({"display": "block"});
  657.                         slider.doMath();
  658.                         slider.viewport.height(slider.h);
  659.                         slider.setProps(sliderOffset * slider.h, "init");
  660.                     }, (type === "init") ? 100 : 0);
  661.                 } else {
  662.                     slider.container.width((slider.count + slider.cloneCount) * 200 + "%");
  663.                     slider.setProps(sliderOffset * slider.computedW, "init");
  664.                     setTimeout(function(){
  665.                         slider.doMath();
  666.                         slider.newSlides.css({"width": slider.computedW, "float": "left", "display": "block"});
  667.                         // SMOOTH HEIGHT:
  668.                         if (vars.smoothHeight) methods.smoothHeight();
  669.                     }, (type === "init") ? 100 : 0);
  670.                 }
  671.             } else { // FADE:
  672.                 slider.slides.css({"width": "100%", "float": "left", "marginRight": "-100%", "position": "relative"});
  673.                 if (type === "init") slider.slides.eq(slider.currentSlide).fadeIn(vars.animationSpeed, vars.easing);
  674.                 // SMOOTH HEIGHT:
  675.                 if (vars.smoothHeight) methods.smoothHeight();
  676.             }
  677.             // !CAROUSEL:
  678.             // CANDIDATE: active slide
  679.             if (!carousel) slider.slides.removeClass(namespace + "active-slide").eq(slider.currentSlide).addClass(namespace + "active-slide");
  680.         };
  681.  
  682.         slider.doMath = function() {
  683.             var slide = slider.slides.first(),
  684.                     slideMargin = vars.itemMargin,
  685.                     minItems = vars.minItems,
  686.                     maxItems = vars.maxItems;
  687.  
  688.             slider.w = slider.width();
  689.             slider.h = slide.height();
  690.             slider.boxPadding = slide.outerWidth() - slide.width();
  691.  
  692.             // CAROUSEL:
  693.             if (carousel) {
  694.                 slider.itemT = vars.itemWidth + slideMargin;
  695.                 slider.minW = (minItems) ? minItems * slider.itemT : slider.w;
  696.                 slider.maxW = (maxItems) ? maxItems * slider.itemT : slider.w;
  697.                 slider.itemW = (slider.minW > slider.w) ? (slider.w - (slideMargin * minItems))/minItems :
  698.                                              (slider.maxW < slider.w) ? (slider.w - (slideMargin * maxItems))/maxItems :
  699.                                              (vars.itemWidth > slider.w) ? slider.w : vars.itemWidth;
  700.                 slider.visible = Math.floor(slider.w/(slider.itemW + slideMargin));
  701.                 slider.move = (vars.move > 0 && vars.move < slider.visible ) ? vars.move : slider.visible;
  702.                 slider.pagingCount = Math.ceil(((slider.count - slider.visible)/slider.move) + 1);
  703.                 slider.last =   slider.pagingCount - 1;
  704.                 slider.limit = (slider.pagingCount === 1) ? 0 :
  705.                                              (vars.itemWidth > slider.w) ? ((slider.itemW + (slideMargin * 2)) * slider.count) - slider.w - slideMargin : ((slider.itemW + slideMargin) * slider.count) - slider.w - slideMargin;
  706.             } else {
  707.                 slider.itemW = slider.w;
  708.                 slider.pagingCount = slider.count;
  709.                 slider.last = slider.count - 1;
  710.             }
  711.             slider.computedW = slider.itemW - slider.boxPadding;
  712.         };
  713.  
  714.         slider.update = function(pos, action) {
  715.             slider.doMath();
  716.  
  717.             // update currentSlide and slider.animatingTo if necessary
  718.             if (!carousel) {
  719.                 if (pos < slider.currentSlide) {
  720.                     slider.currentSlide += 1;
  721.                 } else if (pos <= slider.currentSlide && pos !== 0) {
  722.                     slider.currentSlide -= 1;
  723.                 }
  724.                 slider.animatingTo = slider.currentSlide;
  725.             }
  726.  
  727.             // update controlNav
  728.             if (vars.controlNav && !slider.manualControls) {
  729.                 if ((action === "add" && !carousel) || slider.pagingCount > slider.controlNav.length) {
  730.                     methods.controlNav.update("add");
  731.                 } else if ((action === "remove" && !carousel) || slider.pagingCount < slider.controlNav.length) {
  732.                     if (carousel && slider.currentSlide > slider.last) {
  733.                         slider.currentSlide -= 1;
  734.                         slider.animatingTo -= 1;
  735.                     }
  736.                     methods.controlNav.update("remove", slider.last);
  737.                 }
  738.             }
  739.             // update directionNav
  740.             if (vars.directionNav) methods.directionNav.update();
  741.  
  742.         };
  743.  
  744.         slider.addSlide = function(obj, pos) {
  745.             var $obj = $(obj);
  746.  
  747.             slider.count += 1;
  748.             slider.last = slider.count - 1;
  749.  
  750.             // append new slide
  751.             if (vertical && reverse) {
  752.                 (pos !== undefined) ? slider.slides.eq(slider.count - pos).after($obj) : slider.container.prepend($obj);
  753.             } else {
  754.                 (pos !== undefined) ? slider.slides.eq(pos).before($obj) : slider.container.append($obj);
  755.             }
  756.  
  757.             // update currentSlide, animatingTo, controlNav, and directionNav
  758.             slider.update(pos, "add");
  759.  
  760.             // update slider.slides
  761.             slider.slides = $(vars.selector + ':not(.clone)', slider);
  762.             // re-setup the slider to accomdate new slide
  763.             slider.setup();
  764.  
  765.             //FlexSlider: added() Callback
  766.             vars.added(slider);
  767.         };
  768.         slider.removeSlide = function(obj) {
  769.             var pos = (isNaN(obj)) ? slider.slides.index($(obj)) : obj;
  770.  
  771.             // update count
  772.             slider.count -= 1;
  773.             slider.last = slider.count - 1;
  774.  
  775.             // remove slide
  776.             if (isNaN(obj)) {
  777.                 $(obj, slider.slides).remove();
  778.             } else {
  779.                 (vertical && reverse) ? slider.slides.eq(slider.last).remove() : slider.slides.eq(obj).remove();
  780.             }
  781.  
  782.             // update currentSlide, animatingTo, controlNav, and directionNav
  783.             slider.doMath();
  784.             slider.update(pos, "remove");
  785.  
  786.             // update slider.slides
  787.             slider.slides = $(vars.selector + ':not(.clone)', slider);
  788.             // re-setup the slider to accomdate new slide
  789.             slider.setup();
  790.  
  791.             // FlexSlider: removed() Callback
  792.             vars.removed(slider);
  793.         };
  794.  
  795.         //FlexSlider: Initialize
  796.         methods.init();
  797.     };
  798.  
  799.     //FlexSlider: Default Settings
  800.     $.flexslider.defaults = {
  801.         namespace: "flex-",                      //{NEW} String: Prefix string attached to the class of every element generated by the plugin
  802.         selector: ".slides > li",            //{NEW} Selector: Must match a simple pattern. '{container} > {slide}' -- Ignore pattern at your own peril
  803.         animation: "fade",                          //String: Select your animation type, "fade" or "slide"
  804.         easing: "swing",                             //{NEW} String: Determines the easing method used in jQuery transitions. jQuery easing plugin is supported!
  805.         direction: "horizontal",                //String: Select the sliding direction, "horizontal" or "vertical"
  806.         reverse: false,                              //{NEW} Boolean: Reverse the animation direction
  807.         animationLoop: true,                         //Boolean: Should the animation loop? If false, directionNav will received "disable" classes at either end
  808.         smoothHeight: false,                        //{NEW} Boolean: Allow height of the slider to animate smoothly in horizontal mode
  809.         startAt: 0,                                      //Integer: The slide that the slider should start on. Array notation (0 = first slide)
  810.         slideshow: true,                                //Boolean: Animate slider automatically
  811.         slideshowSpeed: 7000,                    //Integer: Set the speed of the slideshow cycling, in milliseconds
  812.         animationSpeed: 600,                        //Integer: Set the speed of animations, in milliseconds
  813.         initDelay: 0,                                    //{NEW} Integer: Set an initialization delay, in milliseconds
  814.         randomize: false,                            //Boolean: Randomize slide order
  815.  
  816.         // Usability features
  817.         pauseOnAction: true,                        //Boolean: Pause the slideshow when interacting with control elements, highly recommended.
  818.         pauseOnHover: false,                        //Boolean: Pause the slideshow when hovering over slider, then resume when no longer hovering
  819.         useCSS: true,                                    //{NEW} Boolean: Slider will use CSS3 transitions if available
  820.         touch: true,                                        //{NEW} Boolean: Allow touch swipe navigation of the slider on touch-enabled devices
  821.         video: false,                                    //{NEW} Boolean: If using video in the slider, will prevent CSS3 3D Transforms to avoid graphical glitches
  822.  
  823.         // Primary Controls
  824.         controlNav: true,                            //Boolean: Create navigation for paging control of each clide? Note: Leave true for manualControls usage
  825.         directionNav: true,                      //Boolean: Create navigation for previous/next navigation? (true/false)
  826.         prevText: "Previous",                    //String: Set the text for the "previous" directionNav item
  827.         nextText: "Next",                            //String: Set the text for the "next" directionNav item
  828.  
  829.         // Secondary Navigation
  830.         keyboard: true,                              //Boolean: Allow slider navigating via keyboard left/right keys
  831.         multipleKeyboard: true,             //{NEW} Boolean: Allow keyboard navigation to affect multiple sliders. Default behavior cuts out keyboard navigation with more than one slider present.
  832.         mousewheel: false,                          //{UPDATED} Boolean: Requires jquery.mousewheel.js (https://github.com/brandonaaron/jquery-mousewheel) - Allows slider navigating via mousewheel
  833.         pausePlay: false,                            //Boolean: Create pause/play dynamic element
  834.         pauseText: "Pause",                      //String: Set the text for the "pause" pausePlay item
  835.         playText: "Play",                            //String: Set the text for the "play" pausePlay item
  836.  
  837.         // Special properties
  838.         controlsContainer: "",                  //{UPDATED} jQuery Object/Selector: Declare which container the navigation elements should be appended too. Default container is the FlexSlider element. Example use would be $(".flexslider-container"). Property is ignored if given element is not found.
  839.         manualControls: "",                      //{UPDATED} jQuery Object/Selector: Declare custom control navigation. Examples would be $(".flex-control-nav li") or "#tabs-nav li img", etc. The number of elements in your controlNav should match the number of slides/tabs.
  840.         sync: "",                                            //{NEW} Selector: Mirror the actions performed on this slider with another slider. Use with care.
  841.         asNavFor: "",                                    //{NEW} Selector: Internal property exposed for turning the slider into a thumbnail navigation for another slider
  842.  
  843.         // Carousel Options
  844.         itemWidth: 0,                                    //{NEW} Integer: Box-model width of individual carousel items, including horizontal borders and padding.
  845.         itemMargin: 0,                                  //{NEW} Integer: Margin between carousel items.
  846.         minItems: 0,                                        //{NEW} Integer: Minimum number of carousel items that should be visible. Items will resize fluidly when below this.
  847.         maxItems: 0,                                        //{NEW} Integer: Maxmimum number of carousel items that should be visible. Items will resize fluidly when above this limit.
  848.         move: 0,                                                //{NEW} Integer: Number of carousel items that should move on animation. If 0, slider will move all visible items.
  849.  
  850.         // Callback API
  851.         start: function(){},                        //Callback: function(slider) - Fires when the slider loads the first slide
  852.         before: function(){},                    //Callback: function(slider) - Fires asynchronously with each slider animation
  853.         after: function(){},                        //Callback: function(slider) - Fires after each slider animation completes
  854.         end: function(){},                          //Callback: function(slider) - Fires when the slider reaches the last slide (asynchronous)
  855.         added: function(){},                        //{NEW} Callback: function(slider) - Fires after a slide is added
  856.         removed: function(){}                    //{NEW} Callback: function(slider) - Fires after a slide is removed
  857.     };
  858.  
  859.  
  860.     //FlexSlider: Plugin Function
  861.     $.fn.flexslider = function(options) {
  862.         if (options === undefined) options = {};
  863.  
  864.         if (typeof options === "object") {
  865.             return this.each(function() {
  866.                 var $this = $(this),
  867.                         selector = (options.selector) ? options.selector : ".slides > li",
  868.                         $slides = $this.find(selector);
  869.  
  870.                 if ($slides.length === 1) {
  871.                     $slides.fadeIn(400);
  872.                     if (options.start) options.start($this);
  873.                 } else if ($this.data('flexslider') === undefined) {
  874.                     new $.flexslider(this, options);
  875.                 }
  876.             });
  877.         } else {
  878.             // Helper strings to quickly perform functions on the slider
  879.             var $slider = $(this).data('flexslider');
  880.             switch (options) {
  881.                 case "play": $slider.play(); break;
  882.                 case "pause": $slider.pause(); break;
  883.                 case "next": $slider.flexAnimate($slider.getTarget("next"), true); break;
  884.                 case "prev":
  885.                 case "previous": $slider.flexAnimate($slider.getTarget("prev"), true); break;
  886.                 default: if (typeof options === "number") $slider.flexAnimate(options, true);
  887.             }
  888.         }
  889.     };
  890.  
  891. })(jQuery);
  892.  
  893.  
  894. /**
  895. * 2.) bxSlider v.4.0 - http://bxslider.com
  896. */
  897.  
  898. /**
  899.  * BxSlider v4.0 - Fully loaded, responsive content slider
  900.  * http://bxslider.com
  901.  *
  902.  * Copyright 2012, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com
  903.  * Written while drinking Belgian ales and listening to jazz
  904.  *
  905.  * Released under the WTFPL license - http://sam.zoy.org/wtfpl/
  906.  */
  907.  
  908. ;(function($){
  909.  
  910.     var plugin = {};
  911.  
  912.     var defaults = {
  913.  
  914.         // GENERAL
  915.         mode: 'horizontal',
  916.         slideSelector: '',
  917.         infiniteLoop: true,
  918.         hideControlOnEnd: false,
  919.         speed: 500,
  920.         easing: null,
  921.         slideMargin: 0,
  922.         startSlide: 0,
  923.         randomStart: false,
  924.         captions: false,
  925.         ticker: false,
  926.         tickerHover: false,
  927.         adaptiveHeight: false,
  928.         adaptiveHeightSpeed: 500,
  929.         touchEnabled: true,
  930.         swipeThreshold: 50,
  931.         video: false,
  932.         useCSS: true,
  933.  
  934.         // PAGER
  935.         pager: true,
  936.         pagerType: 'full',
  937.         pagerShortSeparator: ' / ',
  938.         pagerSelector: null,
  939.         buildPager: null,
  940.         pagerCustom: null,
  941.  
  942.         // CONTROLS
  943.         controls: true,
  944.         nextText: '',
  945.         prevText: '',
  946.         nextSelector: null,
  947.         prevSelector: null,
  948.         autoControls: false,
  949.         startText: 'Start',
  950.         stopText: 'Stop',
  951.         autoControlsCombine: false,
  952.         autoControlsSelector: null,
  953.  
  954.         // AUTO
  955.         auto: false,
  956.         pause: 4000,
  957.         autoStart: true,
  958.         autoDirection: 'next',
  959.         autoHover: false,
  960.         autoDelay: 0,
  961.  
  962.         // CAROUSEL
  963.         minSlides: 1,
  964.         maxSlides: 1,
  965.         moveSlides: 0,
  966.         slideWidth: 0,
  967.  
  968.         // CALLBACKS
  969.         onSliderLoad: function() {},
  970.         onSlideBefore: function() {},
  971.         onSlideAfter: function() {},
  972.         onSlideNext: function() {},
  973.         onSlidePrev: function() {}
  974.     }
  975.  
  976.     $.fn.bxSlider = function(options){
  977.  
  978.         if(this.length == 0) return;
  979.  
  980.         // support mutltiple elements
  981.         if(this.length > 1){
  982.             this.each(function(){$(this).bxSlider(options)});
  983.             return this;
  984.         }
  985.  
  986.         // create a namespace to be used throughout the plugin
  987.         var slider = {};
  988.         // set a reference to our slider element
  989.         var el = this;
  990.         plugin.el = this;
  991.  
  992.         /**
  993.          * ===================================================================================
  994.          * = PRIVATE FUNCTIONS
  995.          * ===================================================================================
  996.          */
  997.  
  998.         /**
  999.          * Initializes namespace settings to be used throughout plugin
  1000.          */
  1001.         var init = function(){
  1002.             // merge user-supplied options with the defaults
  1003.             slider.settings = $.extend({}, defaults, options);
  1004.             // store the original children
  1005.             slider.children = el.children(slider.settings.slideSelector);
  1006.             // if random start, set the startSlide setting to random number
  1007.             if(slider.settings.randomStart) slider.settings.startSlide = Math.floor(Math.random() * slider.children.length);
  1008.             // store active slide information
  1009.             slider.active = { index: slider.settings.startSlide }
  1010.             // store if the slider is in carousel mode (displaying / moving multiple slides)
  1011.             slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1;
  1012.             // calculate the min / max width thresholds based on min / max number of slides
  1013.             // used to setup and update carousel slides dimensions
  1014.             slider.minThreshold = (slider.settings.minSlides * slider.settings.slideWidth) + ((slider.settings.minSlides - 1) * slider.settings.slideMargin);
  1015.             slider.maxThreshold = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin);
  1016.             // store the current state of the slider (if currently animating, working is true)
  1017.             slider.working = false;
  1018.             // initialize the controls object
  1019.             slider.controls = {};
  1020.             // determine which property to use for transitions
  1021.             slider.animProp = slider.settings.mode == 'vertical' ? 'top' : 'left';
  1022.             // determine if hardware acceleration can be used
  1023.             slider.usingCSS = slider.settings.useCSS && slider.settings.mode != 'fade' && (function(){
  1024.                 // create our test div element
  1025.                 var div = document.createElement('div');
  1026.                 // css transition properties
  1027.                 var props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
  1028.                 // test for each property
  1029.                 for(var i in props){
  1030.                     if(div.style[props[i]] !== undefined){
  1031.                         slider.cssPrefix = props[i].replace('Perspective', '').toLowerCase();
  1032.                         slider.animProp = '-' + slider.cssPrefix + '-transform';
  1033.                         return true;
  1034.                     }
  1035.                 }
  1036.                 return false;
  1037.             }());
  1038.             // if vertical mode always make maxSlides and minSlides equal
  1039.             if(slider.settings.mode == 'vertical') slider.settings.maxSlides = slider.settings.minSlides;
  1040.             // perform all DOM / CSS modifications
  1041.             setup();
  1042.         }
  1043.  
  1044.         /**
  1045.          * Performs all DOM and CSS modifications
  1046.          */
  1047.         var setup = function(){
  1048.             // wrap el in a wrapper
  1049.             el.wrap('<div class="bx-wrapper"><div class="bx-viewport"></div></div>');
  1050.             // store a namspace reference to .bx-viewport
  1051.             slider.viewport = el.parent();
  1052.             // add a loading div to display while images are loading
  1053.             slider.loader = $('<div class="bx-loading" />');
  1054.             slider.viewport.prepend(slider.loader);
  1055.             // set el to a massive width, to hold any needed slides
  1056.             // also strip any margin and padding from el
  1057.             el.css({
  1058.                 width: slider.settings.mode == 'horizontal' ? slider.children.length * 215 + '%' : 'auto',
  1059.                 position: 'relative',
  1060.             });
  1061.             // if using CSS, add the easing property
  1062.             if(slider.usingCSS && slider.settings.easing){
  1063.                 el.css('-' + slider.cssPrefix + '-transition-timing-function', slider.settings.easing);
  1064.             // if not using CSS and no easing value was supplied, use the default JS animation easing (swing)
  1065.             }else if(!slider.settings.easing){
  1066.                 slider.settings.easing = 'swing';
  1067.             }
  1068.             // make modifications to the viewport (.bx-viewport)
  1069.             slider.viewport.css({
  1070.                 width: '100%',
  1071.                 overflow: 'hidden',
  1072.                 position: 'relative'
  1073.             });
  1074.             // apply css to all slider children
  1075.             slider.children.css({
  1076.                 float: slider.settings.mode == 'horizontal' ? 'left' : 'none',
  1077.                 listStyle: 'none',
  1078.             });
  1079.             // apply the calculated width after the float is applied to prevent scrollbar interference
  1080.             slider.children.width(getSlideWidth());
  1081.             // if slideMargin is supplied, add the css
  1082.             if(slider.settings.mode == 'horizontal' && slider.settings.slideMargin > 0) slider.children.css('marginRight', slider.settings.slideMargin);
  1083.             if(slider.settings.mode == 'vertical' && slider.settings.slideMargin > 0) slider.children.css('marginBottom', slider.settings.slideMargin);
  1084.             // if "fade" mode, add positioning and z-index CSS
  1085.             if(slider.settings.mode == 'fade'){
  1086.                 slider.children.css({
  1087.                     position: 'absolute',
  1088.                     zIndex: 0,
  1089.                     display: 'none'
  1090.                 });
  1091.                 // prepare the z-index on the showing element
  1092.                 slider.children.eq(slider.settings.startSlide).css({zIndex: 50, display: 'block'});
  1093.             }
  1094.             // create an element to contain all slider controls (pager, start / stop, etc)
  1095.             slider.controls.el = $('<div class="bx-controls" />');
  1096.             // if captions are requested, add them
  1097.             if(slider.settings.captions) appendCaptions();
  1098.             // if infinite loop, prepare additional slides
  1099.             if(slider.settings.infiniteLoop && slider.settings.mode != 'fade' && !slider.settings.ticker){
  1100.                 var slice = slider.settings.mode == 'vertical' ? slider.settings.minSlides : slider.settings.maxSlides;
  1101.                 var sliceAppend = slider.children.slice(0, slice).clone().addClass('bx-clone');
  1102.                 var slicePrepend = slider.children.slice(-slice).clone().addClass('bx-clone');
  1103.                 el.append(sliceAppend).prepend(slicePrepend);
  1104.             }
  1105.             // check if startSlide is last slide
  1106.             slider.active.last = slider.settings.startSlide == getPagerQty() - 1;
  1107.             // if video is true, set up the fitVids plugin
  1108.             if(slider.settings.video) el.fitVids();
  1109.             // only check for control addition if not in "ticker" mode
  1110.             if(!slider.settings.ticker){
  1111.                 // if pager is requested, add it
  1112.                 if(slider.settings.pager) appendPager();
  1113.                 // if controls are requested, add them
  1114.                 if(slider.settings.controls) appendControls();
  1115.                 // if auto is true, and auto controls are requested, add them
  1116.                 if(slider.settings.auto && slider.settings.autoControls) appendControlsAuto();
  1117.                 // if any control option is requested, add the controls wrapper
  1118.                 if(slider.settings.controls || slider.settings.autoControls || slider.settings.pager) slider.viewport.after(slider.controls.el);
  1119.             }
  1120.             // preload all images, then perform final DOM / CSS modifications that depend on images being loaded
  1121.             el.children().imagesLoaded(function(){
  1122.                 // remove the loading DOM element
  1123.                 slider.loader.remove();
  1124.                 // set the left / top position of "el"
  1125.                 setSlidePosition();
  1126.                 // if "vertical" mode, always use adaptiveHeight to prevent odd behavior
  1127.                 if (slider.settings.mode == 'vertical') slider.settings.adaptiveHeight = true;
  1128.                 // set the viewport height
  1129.                 slider.viewport.height(getViewportHeight());
  1130.                 // onSliderLoad callback
  1131.                 slider.settings.onSliderLoad(slider.active.index);
  1132.                 // if auto is true, start the show
  1133.                 if (slider.settings.auto && slider.settings.autoStart) initAuto();
  1134.                 // if ticker is true, start the ticker
  1135.                 if (slider.settings.ticker) initTicker();
  1136.                 // if pager is requested, make the appropriate pager link active
  1137.                 if (slider.settings.pager) updatePagerActive(slider.settings.startSlide);
  1138.                 // check for any updates to the controls (like hideControlOnEnd updates)
  1139.                 if (slider.settings.controls) updateDirectionControls();
  1140.                 // if touchEnabled is true, setup the touch events
  1141.                 if (slider.settings.touchEnabled && !slider.settings.ticker) initTouch();
  1142.             });
  1143.         }
  1144.  
  1145.         /**
  1146.          * Returns the calculated height of the viewport, used to determine either adaptiveHeight or the maxHeight value
  1147.          */
  1148.         var getViewportHeight = function(){
  1149.             var height = 0;
  1150.             // first determine which children (slides) should be used in our height calculation
  1151.             var children = $();
  1152.             // if mode is not "vertical", adaptiveHeight is always false, so return all children
  1153.             if(slider.settings.mode != 'vertical' && !slider.settings.adaptiveHeight){
  1154.                 children = slider.children;
  1155.             }else{
  1156.                 // if not carousel, return the single active child
  1157.                 if(!slider.carousel){
  1158.                     children = slider.children.eq(slider.active.index);
  1159.                 // if carousel, return a slice of children
  1160.                 }else{
  1161.                     // get the individual slide index
  1162.                     var currentIndex = slider.settings.moveSlides == 1 ? slider.active.index : slider.active.index * getMoveBy();
  1163.                     // add the current slide to the children
  1164.                     children = slider.children.eq(currentIndex);
  1165.                     // cycle through the remaining "showing" slides
  1166.                     for (i = 1; i <= slider.settings.maxSlides - 1; i++){
  1167.                         // if looped back to the start
  1168.                         if(currentIndex + i >= slider.children.length){
  1169.                             children = children.add(slider.children.eq(i - 1));
  1170.                         }else{
  1171.                             children = children.add(slider.children.eq(currentIndex + i));
  1172.                         }
  1173.                     }
  1174.                 }
  1175.             }
  1176.             // if "vertical" mode, calculate the sum of the heights of the children
  1177.             if(slider.settings.mode == 'vertical'){
  1178.                 children.each(function(index) {
  1179.                   height += $(this).outerHeight();
  1180.                 });
  1181.                 // add user-supplied margins
  1182.                 if(slider.settings.slideMargin > 0){
  1183.                     height += slider.settings.slideMargin * (slider.settings.minSlides - 1);
  1184.                 }
  1185.             // if not "vertical" mode, calculate the max height of the children
  1186.             }else{
  1187.                 height = Math.max.apply(Math, children.map(function(){
  1188.                     return $(this).outerHeight(false);
  1189.                 }).get());
  1190.             }
  1191.             return height;
  1192.         }
  1193.  
  1194.         /**
  1195.          * Returns the calculated width to be applied to each slide
  1196.          */
  1197.         var getSlideWidth = function(){
  1198.             // start with any user-supplied slide width
  1199.             var newElWidth = slider.settings.slideWidth;
  1200.             // get the current viewport width
  1201.             var wrapWidth = slider.viewport.width();
  1202.             // if slide width was not supplied, use the viewport width (means not carousel)
  1203.             if(slider.settings.slideWidth == 0){
  1204.                 newElWidth = wrapWidth;
  1205.             // if carousel, use the thresholds to determine the width
  1206.             }else{
  1207.                 if(wrapWidth > slider.maxThreshold){
  1208.                     newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.maxSlides - 1))) / slider.settings.maxSlides;
  1209.                 }else if(wrapWidth < slider.minThreshold){
  1210.                     newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.minSlides - 1))) / slider.settings.minSlides;
  1211.                 }
  1212.             }
  1213.             return newElWidth;
  1214.         }
  1215.  
  1216.         /**
  1217.          * Returns the number of slides currently visible in the viewport (includes partially visible slides)
  1218.          */
  1219.         var getNumberSlidesShowing = function(){
  1220.             var slidesShowing = 1;
  1221.             if(slider.settings.mode == 'horizontal'){
  1222.                 // if viewport is smaller than minThreshold, return minSlides
  1223.                 if(slider.viewport.width() < slider.minThreshold){
  1224.                     slidesShowing = slider.settings.minSlides;
  1225.                 // if viewport is larger than minThreshold, return maxSlides
  1226.                 }else if(slider.viewport.width() > slider.maxThreshold){
  1227.                     slidesShowing = slider.settings.maxSlides;
  1228.                 // if viewport is between min / max thresholds, divide viewport width by first child width
  1229.                 }else{
  1230.                     var childWidth = slider.children.first().width();
  1231.                     slidesShowing = Math.floor(slider.viewport.width() / childWidth);
  1232.                 }
  1233.             // if "vertical" mode, slides showing will always be minSlides
  1234.             }else if(slider.settings.mode == 'vertical'){
  1235.                 slidesShowing = slider.settings.minSlides;
  1236.             }
  1237.             return slidesShowing;
  1238.         }
  1239.  
  1240.         /**
  1241.          * Returns the number of pages (one full viewport of slides is one "page")
  1242.          */
  1243.         var getPagerQty = function(){
  1244.             var pagerQty = 0;
  1245.             // if moveSlides is specified by the user
  1246.             if(slider.settings.moveSlides > 0){
  1247.                 if(slider.settings.infiniteLoop){
  1248.                     pagerQty = slider.children.length / getMoveBy();
  1249.                 }else{
  1250.                     // use a while loop to determine pages
  1251.                     var breakPoint = 0;
  1252.                     var counter = 0
  1253.                     // when breakpoint goes above children length, counter is the number of pages
  1254.                     while (breakPoint < slider.children.length){
  1255.                         ++pagerQty;
  1256.                         breakPoint = counter + getNumberSlidesShowing();
  1257.                         counter += slider.settings.moveSlides <= getNumberSlidesShowing() ? slider.settings.moveSlides : getNumberSlidesShowing();
  1258.                     }
  1259.                 }
  1260.             // if moveSlides is 0 (auto) divide children length by sides showing, then round up
  1261.             }else{
  1262.                 pagerQty = Math.ceil(slider.children.length / getNumberSlidesShowing());
  1263.             }
  1264.             return pagerQty;
  1265.         }
  1266.  
  1267.         /**
  1268.          * Returns the number of indivual slides by which to shift the slider
  1269.          */
  1270.         var getMoveBy = function(){
  1271.             // if moveSlides was set by the user and moveSlides is less than number of slides showing
  1272.             if(slider.settings.moveSlides > 0 && slider.settings.moveSlides <= getNumberSlidesShowing()){
  1273.                 return slider.settings.moveSlides;
  1274.             }
  1275.             // if moveSlides is 0 (auto)
  1276.             return getNumberSlidesShowing();
  1277.         }
  1278.  
  1279.         /**
  1280.          * Sets the slider's (el) left or top position
  1281.          */
  1282.         var setSlidePosition = function(){
  1283.             // if last slide
  1284.             if(slider.active.last){
  1285.                 if (slider.settings.mode == 'horizontal'){
  1286.                     // get the last child's position
  1287.                     var lastChild = slider.children.last();
  1288.                     var position = lastChild.position();
  1289.                     // set the left position
  1290.                     setPositionProperty(-(position.left - (slider.viewport.width() - lastChild.width())), 'reset', 0);
  1291.                 }else if(slider.settings.mode == 'vertical'){
  1292.                     // get the last showing index's position
  1293.                     var lastShowingIndex = slider.children.length - slider.settings.minSlides;
  1294.                     var position = slider.children.eq(lastShowingIndex).position();
  1295.                     // set the top position
  1296.                     setPositionProperty(-position.top, 'reset', 0);
  1297.                 }
  1298.             // if not last slide
  1299.             }else{
  1300.                 // get the position of the first showing slide
  1301.                 var position = slider.children.eq(slider.active.index * getMoveBy()).position();
  1302.                 // check for last slide
  1303.                 if (slider.active.index == getPagerQty() - 1) slider.active.last = true;
  1304.                 // set the repective position
  1305.                 if (position != undefined){
  1306.                     if (slider.settings.mode == 'horizontal') setPositionProperty(-position.left, 'reset', 0);
  1307.                     else if (slider.settings.mode == 'vertical') setPositionProperty(-position.top, 'reset', 0);
  1308.                 }
  1309.             }
  1310.         }
  1311.  
  1312.         /**
  1313.          * Sets the el's animating property position (which in turn will sometimes animate el).
  1314.          * If using CSS, sets the transform property. If not using CSS, sets the top / left property.
  1315.          *
  1316.          * @param value (int)
  1317.          *  - the animating property's value
  1318.          *
  1319.          * @param type (string) 'slider', 'reset', 'ticker'
  1320.          *  - the type of instance for which the function is being
  1321.          *
  1322.          * @param duration (int)
  1323.          *  - the amount of time (in ms) the transition should occupy
  1324.          *
  1325.          * @param params (array) optional
  1326.          *  - an optional parameter containing any variables that need to be passed in
  1327.          */
  1328.         var setPositionProperty = function(value, type, duration, params){
  1329.             // use CSS transform
  1330.             if(slider.usingCSS){
  1331.                 // determine the translate3d value
  1332.                 var propValue = slider.settings.mode == 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)';
  1333.                 // add the CSS transition-duration
  1334.                 el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's');
  1335.                 if(type == 'slide'){
  1336.                     // set the property value
  1337.                     el.css(slider.animProp, propValue);
  1338.                     // bind a callback method - executes when CSS transition completes
  1339.                     el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
  1340.                         // unbind the callback
  1341.                         el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
  1342.                         updateAfterSlideTransition();
  1343.                     });
  1344.                 }else if(type == 'reset'){
  1345.                     el.css(slider.animProp, propValue);
  1346.                 }else if(type == 'ticker'){
  1347.                     // make the transition use 'linear'
  1348.                     el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear');
  1349.                     el.css(slider.animProp, propValue);
  1350.                     // bind a callback method - executes when CSS transition completes
  1351.                     el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
  1352.                         // unbind the callback
  1353.                         el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
  1354.                         // reset the position
  1355.                         setPositionProperty(params['resetValue'], 'reset', 0);
  1356.                         // start the loop again
  1357.                         tickerLoop();
  1358.                     });
  1359.                 }
  1360.             // use JS animate
  1361.             }else{
  1362.                 var animateObj = {};
  1363.                 animateObj[slider.animProp] = value;
  1364.                 if(type == 'slide'){
  1365.                     el.animate(animateObj, duration, slider.settings.easing, function(){
  1366.                         updateAfterSlideTransition();
  1367.                     });
  1368.                 }else if(type == 'reset'){
  1369.                     el.css(slider.animProp, value)
  1370.                 }else if(type == 'ticker'){
  1371.                     el.animate(animateObj, speed, 'linear', function(){
  1372.                         setPositionProperty(params['resetValue'], 'reset', 0);
  1373.                         // run the recursive loop after animation
  1374.                         tickerLoop();
  1375.                     });
  1376.                 }
  1377.             }
  1378.         }
  1379.  
  1380.         /**
  1381.          * Populates the pager with proper amount of pages
  1382.          */
  1383.         var populatePager = function(){
  1384.             var pagerHtml = '';
  1385.             pagerQty = getPagerQty();
  1386.             // loop through each pager item
  1387.             for(var i=0; i < pagerQty; i++){
  1388.                 var linkContent = '';
  1389.                 // if a buildPager function is supplied, use it to get pager link value, else use index + 1
  1390.                 if(slider.settings.buildPager && $.isFunction(slider.settings.buildPager)){
  1391.                     linkContent = slider.settings.buildPager(i);
  1392.                     slider.pagerEl.addClass('bx-custom-pager');
  1393.                 }else{
  1394.                     linkContent = i + 1;
  1395.                     slider.pagerEl.addClass('bx-default-pager');
  1396.                 }
  1397.                 // var linkContent = slider.settings.buildPager && $.isFunction(slider.settings.buildPager) ? slider.settings.buildPager(i) : i + 1;
  1398.                 // add the markup to the string
  1399.                 pagerHtml += '<div class="bx-pager-item"><a href="" data-slide-index="' + i + '" class="bx-pager-link">' + linkContent + '</a></div>';
  1400.             };
  1401.             // populate the pager element with pager links
  1402.             slider.pagerEl.html(pagerHtml);
  1403.         }
  1404.  
  1405.         /**
  1406.          * Appends the pager to the controls element
  1407.          */
  1408.         var appendPager = function(){
  1409.             if(!slider.settings.pagerCustom){
  1410.                 // create the pager DOM element
  1411.                 slider.pagerEl = $('<div class="bx-pager" />');
  1412.                 // if a pager selector was supplied, populate it with the pager
  1413.                 if(slider.settings.pagerSelector){
  1414.                     $(slider.settings.pagerSelector).html(slider.pagerEl);
  1415.                 // if no pager selector was supplied, add it after the wrapper
  1416.                 }else{
  1417.                     slider.controls.el.addClass('bx-has-pager').append(slider.pagerEl);
  1418.                 }
  1419.                 // populate the pager
  1420.                 populatePager();
  1421.             }else{
  1422.                 slider.pagerEl = $(slider.settings.pagerCustom);
  1423.             }
  1424.             // assign the pager click binding
  1425.             slider.pagerEl.delegate('a', 'click', clickPagerBind);
  1426.         }
  1427.  
  1428.         /**
  1429.          * Appends prev / next controls to the controls element
  1430.          */
  1431.         var appendControls = function(){
  1432.             slider.controls.next = $('<span class="bx-next link">' + slider.settings.nextText + '</span>');
  1433.             slider.controls.prev = $('<span class="bx-prev link disabled">' + slider.settings.prevText + '</span>');
  1434.             // bind click actions to the controls
  1435.             slider.controls.next.bind('click', clickNextBind);
  1436.             slider.controls.prev.bind('click', clickPrevBind);
  1437.             // if nextSlector was supplied, populate it
  1438.             if(slider.settings.nextSelector){
  1439.                 $(slider.settings.nextSelector).append(slider.controls.next);
  1440.             }
  1441.             // if prevSlector was supplied, populate it
  1442.             if(slider.settings.prevSelector){
  1443.                 $(slider.settings.prevSelector).append(slider.controls.prev);
  1444.             }
  1445.             // if no custom selectors were supplied
  1446.             if(!slider.settings.nextSelector && !slider.settings.prevSelector){
  1447.                 // add the controls to the DOM
  1448.                 slider.controls.directionEl = $('<div class="bx-controls-direction" />');
  1449.                 // add the control elements to the directionEl
  1450.                 slider.controls.directionEl.append(slider.controls.prev).append(slider.controls.next);
  1451.                 // slider.viewport.append(slider.controls.directionEl);
  1452.                 slider.controls.el.addClass('bx-has-controls-direction').append(slider.controls.directionEl);
  1453.             }
  1454.         }
  1455.  
  1456.         /**
  1457.          * Appends start / stop auto controls to the controls element
  1458.          */
  1459.         var appendControlsAuto = function(){
  1460.             slider.controls.start = $('<div class="bx-controls-auto-item"><a class="bx-start" href="">' + slider.settings.startText + '</a></div>');
  1461.             slider.controls.stop = $('<div class="bx-controls-auto-item"><a class="bx-stop" href="">' + slider.settings.stopText + '</a></div>');
  1462.             // add the controls to the DOM
  1463.             slider.controls.autoEl = $('<div class="bx-controls-auto" />');
  1464.             // bind click actions to the controls
  1465.             slider.controls.autoEl.delegate('.bx-start', 'click', clickStartBind);
  1466.             slider.controls.autoEl.delegate('.bx-stop', 'click', clickStopBind);
  1467.             // if autoControlsCombine, insert only the "start" control
  1468.             if(slider.settings.autoControlsCombine){
  1469.                 slider.controls.autoEl.append(slider.controls.start);
  1470.             // if autoControlsCombine is false, insert both controls
  1471.             }else{
  1472.                 slider.controls.autoEl.append(slider.controls.start).append(slider.controls.stop);
  1473.             }
  1474.             // if auto controls selector was supplied, populate it with the controls
  1475.             if(slider.settings.autoControlsSelector){
  1476.                 $(slider.settings.autoControlsSelector).html(slider.controls.autoEl);
  1477.             // if auto controls selector was not supplied, add it after the wrapper
  1478.             }else{
  1479.                 slider.controls.el.addClass('bx-has-controls-auto').append(slider.controls.autoEl);
  1480.             }
  1481.             // update the auto controls
  1482.             updateAutoControls(slider.settings.autoStart ? 'stop' : 'start');
  1483.         }
  1484.  
  1485.         /**
  1486.          * Appends image captions to the DOM
  1487.          */
  1488.         var appendCaptions = function(){
  1489.             // cycle through each child
  1490.             slider.children.each(function(index){
  1491.                 // get the image title attribute
  1492.                 var title = $(this).find('img:first').attr('title');
  1493.                 // append the caption
  1494.                 if (title != undefined) $(this).append('<div class="bx-caption"><span>' + title + '</span></div>');
  1495.             });
  1496.         }
  1497.  
  1498.         /**
  1499.          * Click next binding
  1500.          *
  1501.          * @param e (event)
  1502.          *  - DOM event object
  1503.          */
  1504.         var clickNextBind = function(e){
  1505.             // if auto show is running, stop it
  1506.             if (slider.settings.auto) el.stopAuto();
  1507.             el.goToNextSlide();
  1508.             e.preventDefault();
  1509.         }
  1510.  
  1511.         /**
  1512.          * Click prev binding
  1513.          *
  1514.          * @param e (event)
  1515.          *  - DOM event object
  1516.          */
  1517.         var clickPrevBind = function(e){
  1518.             // if auto show is running, stop it
  1519.             if (slider.settings.auto) el.stopAuto();
  1520.             el.goToPrevSlide();
  1521.             e.preventDefault();
  1522.         }
  1523.  
  1524.         /**
  1525.          * Click start binding
  1526.          *
  1527.          * @param e (event)
  1528.          *  - DOM event object
  1529.          */
  1530.         var clickStartBind = function(e){
  1531.             el.startAuto();
  1532.             e.preventDefault();
  1533.         }
  1534.  
  1535.         /**
  1536.          * Click stop binding
  1537.          *
  1538.          * @param e (event)
  1539.          *  - DOM event object
  1540.          */
  1541.         var clickStopBind = function(e){
  1542.             el.stopAuto();
  1543.             e.preventDefault();
  1544.         }
  1545.  
  1546.         /**
  1547.          * Click pager binding
  1548.          *
  1549.          * @param e (event)
  1550.          *  - DOM event object
  1551.          */
  1552.         var clickPagerBind = function(e){
  1553.             // if auto show is running, stop it
  1554.             if (slider.settings.auto) el.stopAuto();
  1555.             var pagerLink = $(e.currentTarget);
  1556.             var pagerIndex = parseInt(pagerLink.attr('data-slide-index'));
  1557.             // if clicked pager link is not active, continue with the goToSlide call
  1558.             if(pagerIndex != slider.active.index) el.goToSlide(pagerIndex);
  1559.             e.preventDefault();
  1560.         }
  1561.  
  1562.         /**
  1563.          * Updates the pager links with an active class
  1564.          *
  1565.          * @param slideIndex (int)
  1566.          *  - index of slide to make active
  1567.          */
  1568.         var updatePagerActive = function(slideIndex){
  1569.             // if "short" pager type
  1570.             if(slider.settings.pagerType == 'short'){
  1571.                 slider.pagerEl.html((slideIndex + 1) + slider.settings.pagerShortSeparator + slider.children.length);
  1572.                 return;
  1573.             }
  1574.             // remove all pager active classes
  1575.             slider.pagerEl.find('a').removeClass('active');
  1576.             // apply the active class
  1577.             slider.pagerEl.find('a').eq(slideIndex).addClass('active');
  1578.         }
  1579.  
  1580.         /**
  1581.          * Performs needed actions after a slide transition
  1582.          */
  1583.         var updateAfterSlideTransition = function(){
  1584.             // if infinte loop is true
  1585.             if(slider.settings.infiniteLoop){
  1586.                 var position = '';
  1587.                 // first slide
  1588.                 if(slider.active.index == 0){
  1589.                     // set the new position
  1590.                     position = slider.children.eq(0).position();
  1591.                 // carousel, last slide
  1592.                 }else if(slider.active.index == getPagerQty() - 1 && slider.carousel){
  1593.                     position = slider.children.eq((getPagerQty() - 1) * getMoveBy()).position();
  1594.                 // last slide
  1595.                 }else if(slider.active.index == slider.children.length - 1){
  1596.                     position = slider.children.eq(slider.children.length - 1).position();
  1597.                 }
  1598.                 if (slider.settings.mode == 'horizontal') { setPositionProperty(-position.left, 'reset', 0);; }
  1599.                 else if (slider.settings.mode == 'vertical') { setPositionProperty(-position.top, 'reset', 0);; }
  1600.             }
  1601.             // declare that the transition is complete
  1602.             slider.working = false;
  1603.             // onSlideAfter callback
  1604.             slider.settings.onSlideAfter(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
  1605.         }
  1606.  
  1607.         /**
  1608.          * Updates the auto controls state (either active, or combined switch)
  1609.          *
  1610.          * @param state (string) "start", "stop"
  1611.          *  - the new state of the auto show
  1612.          */
  1613.         var updateAutoControls = function(state){
  1614.             // if autoControlsCombine is true, replace the current control with the new state
  1615.             if(slider.settings.autoControlsCombine){
  1616.                 slider.controls.autoEl.html(slider.controls[state]);
  1617.             // if autoControlsCombine is false, apply the "active" class to the appropriate control
  1618.             }else{
  1619.                 slider.controls.autoEl.find('a').removeClass('active');
  1620.                 slider.controls.autoEl.find('a:not(.bx-' + state + ')').addClass('active');
  1621.             }
  1622.         }
  1623.  
  1624.         /**
  1625.          * Updates the direction controls (checks if either should be hidden)
  1626.          */
  1627.         var updateDirectionControls = function(){
  1628.             // if infiniteLoop is false and hideControlOnEnd is true
  1629.             if(!slider.settings.infiniteLoop && slider.settings.hideControlOnEnd){
  1630.                 // if first slide
  1631.                 if (slider.active.index == 0){
  1632.                     slider.controls.prev.addClass('disabled');
  1633.                     slider.controls.next.removeClass('disabled');
  1634.                 // if last slide
  1635.                 }else if(slider.active.index == getPagerQty() - 1){
  1636.                     slider.controls.next.addClass('disabled');
  1637.                     slider.controls.prev.removeClass('disabled');
  1638.                 // if any slide in the middle
  1639.                 }else{
  1640.                     slider.controls.prev.removeClass('disabled');
  1641.                     slider.controls.next.removeClass('disabled');
  1642.                 }
  1643.             }
  1644.         }
  1645.  
  1646.         /**
  1647.          * Initialzes the auto process
  1648.          */
  1649.         var initAuto = function(){
  1650.             // if autoDelay was supplied, launch the auto show using a setTimeout() call
  1651.             if(slider.settings.autoDelay > 0){
  1652.                 var timeout = setTimeout(el.startAuto, slider.settings.autoDelay);
  1653.             // if autoDelay was not supplied, start the auto show normally
  1654.             }else{
  1655.                 el.startAuto();
  1656.             }
  1657.             // if autoHover is requested
  1658.             if(slider.settings.autoHover){
  1659.                 // on el hover
  1660.                 el.hover(function(){
  1661.                     // if the auto show is currently playing (has an active interval)
  1662.                     if(slider.interval){
  1663.                         // stop the auto show and pass true agument which will prevent control update
  1664.                         el.stopAuto(true);
  1665.                         // create a new autoPaused value which will be used by the relative "mouseout" event
  1666.                         slider.autoPaused = true;
  1667.                     }
  1668.                 }, function(){
  1669.                     // if the autoPaused value was created be the prior "mouseover" event
  1670.                     if(slider.autoPaused){
  1671.                         // start the auto show and pass true agument which will prevent control update
  1672.                         el.startAuto(true);
  1673.                         // reset the autoPaused value
  1674.                         slider.autoPaused = null;
  1675.                     }
  1676.                 });
  1677.             }
  1678.         }
  1679.  
  1680.         /**
  1681.          * Initialzes the ticker process
  1682.          */
  1683.         var initTicker = function(){
  1684.             var startPosition = 0;
  1685.             // if autoDirection is "next", append a clone of the entire slider
  1686.             if(slider.settings.autoDirection == 'next'){
  1687.                 el.append(slider.children.clone().addClass('bx-clone'));
  1688.             // if autoDirection is "prev", prepend a clone of the entire slider, and set the left position
  1689.             }else{
  1690.                 el.prepend(slider.children.clone().addClass('bx-clone'));
  1691.                 var position = slider.children.first().position();
  1692.                 startPosition = slider.settings.mode == 'horizontal' ? -position.left : -position.top;
  1693.             }
  1694.             setPositionProperty(startPosition, 'reset', 0);
  1695.             // do not allow controls in ticker mode
  1696.             slider.settings.pager = false;
  1697.             slider.settings.controls = false;
  1698.             slider.settings.autoControls = false;
  1699.             // if autoHover is requested
  1700.             if(slider.settings.tickerHover && !slider.usingCSS){
  1701.                 // on el hover
  1702.                 slider.viewport.hover(function(){
  1703.                     el.stop();
  1704.                 }, function(){
  1705.                     // calculate the total width of children (used to calculate the speed ratio)
  1706.                     var totalDimens = 0;
  1707.                     slider.children.each(function(index){
  1708.                       totalDimens += slider.settings.mode == 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
  1709.                     });
  1710.                     // calculate the speed ratio (used to determine the new speed to finish the paused animation)
  1711.                     var ratio = slider.settings.speed / totalDimens;
  1712.                     // determine which property to use
  1713.                     var property = slider.settings.mode == 'horizontal' ? 'left' : 'top';
  1714.                     // calculate the new speed
  1715.                     var newSpeed = ratio * (totalDimens - (Math.abs(parseInt(el.css(property)))));
  1716.                     tickerLoop(newSpeed);
  1717.                 });
  1718.             }
  1719.             // start the ticker loop
  1720.             tickerLoop();
  1721.         }
  1722.  
  1723.         /**
  1724.          * Runs a continuous loop, news ticker-style
  1725.          */
  1726.         var tickerLoop = function(resumeSpeed){
  1727.             speed = resumeSpeed ? resumeSpeed : slider.settings.speed;
  1728.             var position = {left: 0, top: 0};
  1729.             var reset = {left: 0, top: 0};
  1730.             // if "next" animate left position to last child, then reset left to 0
  1731.             if(slider.settings.autoDirection == 'next'){
  1732.                 position = el.find('.bx-clone').first().position();
  1733.             // if "prev" animate left position to 0, then reset left to first non-clone child
  1734.             }else{
  1735.                 reset = slider.children.first().position();
  1736.             }
  1737.             var animateProperty = slider.settings.mode == 'horizontal' ? -position.left : -position.top;
  1738.             var resetValue = slider.settings.mode == 'horizontal' ? -reset.left : -reset.top;
  1739.             var params = {resetValue: resetValue};
  1740.             setPositionProperty(animateProperty, 'ticker', speed, params);
  1741.         }
  1742.  
  1743.         /**
  1744.          * Initializes touch events
  1745.          */
  1746.         var initTouch = function(){
  1747.             // initialize object to contain all touch values
  1748.             slider.touch = {
  1749.                 start: {x: 0, y: 0},
  1750.                 end: {x: 0, y: 0}
  1751.             }
  1752.             slider.viewport.bind('touchstart', onTouchStart);
  1753.         }
  1754.  
  1755.         /**
  1756.          * Event handler for "touchstart"
  1757.          *
  1758.          * @param e (event)
  1759.          *  - DOM event object
  1760.          */
  1761.         var onTouchStart = function(e){
  1762.             if(slider.working){
  1763.                 e.preventDefault();
  1764.             }else{
  1765.                 // record the original position when touch starts
  1766.                 slider.touch.originalPos = el.position();
  1767.                 var orig = e.originalEvent;
  1768.                 // record the starting touch x, y coordinates
  1769.                 slider.touch.start.x = orig.changedTouches[0].pageX;
  1770.                 slider.touch.start.y = orig.changedTouches[0].pageY;
  1771.                 // bind a "touchmove" event to the viewport
  1772.                 slider.viewport.bind('touchmove', onTouchMove);
  1773.                 // bind a "touchend" event to the viewport
  1774.                 slider.viewport.bind('touchend', onTouchEnd);
  1775.             }
  1776.         }
  1777.  
  1778.         /**
  1779.          * Event handler for "touchmove"
  1780.          *
  1781.          * @param e (event)
  1782.          *  - DOM event object
  1783.          */
  1784.         var onTouchMove = function(e){
  1785.             e.preventDefault();
  1786.             if(slider.settings.mode != 'fade'){
  1787.                 var orig = e.originalEvent;
  1788.                 var value = 0;
  1789.                 // if horizontal, drag along x axis
  1790.                 if(slider.settings.mode == 'horizontal'){
  1791.                     var change = orig.changedTouches[0].pageX - slider.touch.start.x;
  1792.                     value = slider.touch.originalPos.left + change;
  1793.                 // if vertical, drag along y axis
  1794.                 }else{
  1795.                     var change = orig.changedTouches[0].pageY - slider.touch.start.y;
  1796.                     value = slider.touch.originalPos.top + change;
  1797.                 }
  1798.                 setPositionProperty(value, 'reset', 0);
  1799.             }
  1800.         }
  1801.  
  1802.         /**
  1803.          * Event handler for "touchend"
  1804.          *
  1805.          * @param e (event)
  1806.          *  - DOM event object
  1807.          */
  1808.         var onTouchEnd = function(e){
  1809.             slider.viewport.unbind('touchmove', onTouchMove);
  1810.             var orig = e.originalEvent;
  1811.             var value = 0;
  1812.             // record end x, y positions
  1813.             slider.touch.end.x = orig.changedTouches[0].pageX;
  1814.             slider.touch.end.y = orig.changedTouches[0].pageY;
  1815.             // if fade mode, check if absolute x distance clears the threshold
  1816.             if(slider.settings.mode == 'fade'){
  1817.                 var distance = Math.abs(slider.touch.start.x - slider.touch.end.x);
  1818.                 if(distance >= slider.settings.swipeThreshold){
  1819.                     slider.touch.start.x > slider.touch.end.x ? el.goToNextSlide() : el.goToPrevSlide();
  1820.                     el.stopAuto();
  1821.                 }
  1822.             // not fade mode
  1823.             }else{
  1824.                 var distance = 0;
  1825.                 // calculate distance and el's animate property
  1826.                 if(slider.settings.mode == 'horizontal'){
  1827.                     distance = slider.touch.end.x - slider.touch.start.x;
  1828.                     value = slider.touch.originalPos.left;
  1829.                 }else{
  1830.                     distance = slider.touch.end.y - slider.touch.start.y;
  1831.                     value = slider.touch.originalPos.top;
  1832.                 }
  1833.                 // if not infinite loop and first / last slide, do not attempt a slide transition
  1834.                 if(!slider.settings.infiniteLoop && ((slider.active.index == 0 && distance > 0) || (slider.active.last && distance < 0))){
  1835.                     setPositionProperty(value, 'reset', 200);
  1836.                 }else{
  1837.                     // check if distance clears threshold
  1838.                     if(Math.abs(distance) >= slider.settings.swipeThreshold){
  1839.                         distance < 0 ? el.goToNextSlide() : el.goToPrevSlide();
  1840.                         el.stopAuto();
  1841.                     }else{
  1842.                         // el.animate(property, 200);
  1843.                         setPositionProperty(value, 'reset', 200);
  1844.                     }
  1845.                 }
  1846.             }
  1847.             slider.viewport.unbind('touchend', onTouchEnd);
  1848.         }
  1849.  
  1850.         /**
  1851.          * ===================================================================================
  1852.          * = PUBLIC FUNCTIONS
  1853.          * ===================================================================================
  1854.          */
  1855.  
  1856.         /**
  1857.          * Performs slide transition to the specified slide
  1858.          *
  1859.          * @param slideIndex (int)
  1860.          *  - the destination slide's index (zero-based)
  1861.          *
  1862.          * @param direction (string)
  1863.          *  - INTERNAL USE ONLY - the direction of travel ("prev" / "next")
  1864.          */
  1865.         el.goToSlide = function(slideIndex, direction){
  1866.             // if plugin is currently in motion, ignore request
  1867.             if(slider.working || slider.active.index == slideIndex) return;
  1868.             // declare that plugin is in motion
  1869.             slider.working = true;
  1870.             // store the old index
  1871.             slider.oldIndex = slider.active.index;
  1872.             // if slideIndex is less than zero, set active index to last child (this happens during infinite loop)
  1873.             if(slideIndex < 0){
  1874.                 slider.active.index = getPagerQty() - 1;
  1875.             // if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop)
  1876.             }else if(slideIndex >= getPagerQty()){
  1877.                 slider.active.index = 0;
  1878.             // set active index to requested slide
  1879.             }else{
  1880.                 slider.active.index = slideIndex;
  1881.             }
  1882.             // onSlideBefore, onSlideNext, onSlidePrev callbacks
  1883.             slider.settings.onSlideBefore(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
  1884.             if(direction == 'next'){
  1885.                 slider.settings.onSlideNext(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
  1886.             }else if(direction == 'prev'){
  1887.                 slider.settings.onSlidePrev(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
  1888.             }
  1889.             // check if last slide
  1890.             slider.active.last = slider.active.index >= getPagerQty() - 1;
  1891.             // update the pager with active class
  1892.             if(slider.settings.pager) updatePagerActive(slider.active.index);
  1893.             // // check for direction control update
  1894.             if(slider.settings.controls) updateDirectionControls();
  1895.             // if slider is set to mode: "fade"
  1896.             if(slider.settings.mode == 'fade'){
  1897.                 // if adaptiveHeight is true and next height is different from current height, animate to the new height
  1898.                 if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHeight()){
  1899.                     slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
  1900.                 }
  1901.                 // fade out the visible child and reset its z-index value
  1902.                 slider.children.filter(':visible').fadeOut(slider.settings.speed).css({zIndex: 0});
  1903.                 // fade in the newly requested slide
  1904.                 slider.children.eq(slider.active.index).css('zIndex', 51).fadeIn(slider.settings.speed, function(){
  1905.                     $(this).css('zIndex', 50);
  1906.                     updateAfterSlideTransition();
  1907.                 });
  1908.             // slider mode is not "fade"
  1909.             }else{
  1910.                 // if adaptiveHeight is true and next height is different from current height, animate to the new height
  1911.                 if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHeight()){
  1912.                     slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
  1913.                 }
  1914.                 var moveBy = 0;
  1915.                 var position = {left: 0, top: 0};
  1916.                 // if carousel and not infinite loop
  1917.                 if(!slider.settings.infiniteLoop && slider.carousel && slider.active.last){
  1918.                     if(slider.settings.mode == 'horizontal'){
  1919.                         // get the last child position
  1920.                         var lastChild = slider.children.eq(slider.children.length - 1);
  1921.                         position = lastChild.position();
  1922.                         // calculate the position of the last slide
  1923.                         moveBy = slider.viewport.width() - lastChild.width();
  1924.                     }else{
  1925.                         // get last showing index position
  1926.                         var lastShowingIndex = slider.children.length - slider.settings.minSlides;
  1927.                         position = slider.children.eq(lastShowingIndex).position();
  1928.                     }
  1929.                     // horizontal carousel, going previous while on first slide (infiniteLoop mode)
  1930.                 }else if(slider.carousel && slider.active.last && direction == 'prev'){
  1931.                     // get the last child position
  1932.                     var eq = slider.settings.moveSlides == 1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) * getMoveBy()) - (slider.children.length - slider.settings.maxSlides);
  1933.                     var lastChild = el.children('.bx-clone').eq(eq);
  1934.                     position = lastChild.position();
  1935.                 // if infinite loop and "Next" is clicked on the last slide
  1936.                 }else if(direction == 'next' && slider.active.index == 0){
  1937.                     // get the last clone position
  1938.                     position = el.find('.bx-clone').eq(slider.settings.maxSlides).position();
  1939.                     slider.active.last = false;
  1940.                 // normal non-zero requests
  1941.                 }else if(slideIndex >= 0){
  1942.                     var requestEl = slideIndex * getMoveBy();
  1943.                     position = slider.children.eq(requestEl).position();
  1944.                 }
  1945.                 // plugin values to be animated
  1946.                 var value = slider.settings.mode == 'horizontal' ? -(position.left - moveBy) : -position.top;
  1947.                 setPositionProperty(value, 'slide', slider.settings.speed);
  1948.             }
  1949.         }
  1950.  
  1951.         /**
  1952.          * Transitions to the next slide in the show
  1953.          */
  1954.         el.goToNextSlide = function(){
  1955.             // if infiniteLoop is false and last page is showing, disregard call
  1956.             if (!slider.settings.infiniteLoop && slider.active.last) return;
  1957.             var pagerIndex = slider.active.index + 1;
  1958.             el.goToSlide(pagerIndex, 'next');
  1959.         }
  1960.  
  1961.         /**
  1962.          * Transitions to the prev slide in the show
  1963.          */
  1964.         el.goToPrevSlide = function(){
  1965.             // if infiniteLoop is false and last page is showing, disregard call
  1966.             if (!slider.settings.infiniteLoop && slider.active.index == 0) return;
  1967.             var pagerIndex = slider.active.index - 1;
  1968.             el.goToSlide(pagerIndex, 'prev');
  1969.         }
  1970.  
  1971.         /**
  1972.          * Starts the auto show
  1973.          *
  1974.          * @param preventControlUpdate (boolean)
  1975.          *  - if true, auto controls state will not be updated
  1976.          */
  1977.         el.startAuto = function(preventControlUpdate){
  1978.             // if an interval already exists, disregard call
  1979.             if(slider.interval) return;
  1980.             // create an interval
  1981.             slider.interval = setInterval(function(){
  1982.                 slider.settings.autoDirection == 'next' ? el.goToNextSlide() : el.goToPrevSlide();
  1983.             }, slider.settings.pause);
  1984.             // if auto controls are displayed and preventControlUpdate is not true
  1985.             if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('stop');
  1986.         }
  1987.  
  1988.         /**
  1989.          * Stops the auto show
  1990.          *
  1991.          * @param preventControlUpdate (boolean)
  1992.          *  - if true, auto controls state will not be updated
  1993.          */
  1994.         el.stopAuto = function(preventControlUpdate){
  1995.             // if no interval exists, disregard call
  1996.             if(!slider.interval) return;
  1997.             // clear the interval
  1998.             clearInterval(slider.interval);
  1999.             slider.interval = null;
  2000.             // if auto controls are displayed and preventControlUpdate is not true
  2001.             if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('start');
  2002.         }
  2003.  
  2004.         /**
  2005.          * Returns current slide index (zero-based)
  2006.          */
  2007.         el.getCurrentSlide = function(){
  2008.             return slider.active.index;
  2009.         }
  2010.  
  2011.         /**
  2012.          * Returns number of slides in show
  2013.          */
  2014.         el.getSlideCount = function(){
  2015.             return slider.children.length;
  2016.         }
  2017.  
  2018.         /**
  2019.          * Makes slideshow responsive
  2020.          */
  2021.         // first get the original window dimens (thanks alot IE)
  2022.         var windowWidth = $(window).width();
  2023.         var windowHeight = $(window).height();
  2024.         $(window).resize(function(){
  2025.             // get the new window dimens (again, thank you IE)
  2026.             var windowWidthNew = $(window).width();
  2027.             var windowHeightNew = $(window).height();
  2028.             // make sure that it is a true window resize
  2029.             // *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements
  2030.             // are resized. Can you just die already?*
  2031.             if(windowWidth != windowWidthNew || windowHeight != windowHeightNew){
  2032.                 // set the new window dimens
  2033.                 windowWidth = windowWidthNew;
  2034.                 windowHeight = windowHeightNew;
  2035.                 // resize all children in ratio to new screen size
  2036.                 slider.children.add(el.find('.bx-clone')).width(getSlideWidth());
  2037.                 // adjust the height
  2038.                 slider.viewport.css('height', getViewportHeight());
  2039.                 // if active.last was true before the screen resize, we want
  2040.                 // to keep it last no matter what screen size we end on
  2041.                 if (slider.active.last) slider.active.index = getPagerQty() - 1;
  2042.                 // if the active index (page) no longer exists due to the resize, simply set the index as last
  2043.                 if (slider.active.index >= getPagerQty()) slider.active.last = true;
  2044.                 // if a pager is being displayed and a custom pager is not being used, update it
  2045.                 if(slider.settings.pager && !slider.settings.pagerCustom){
  2046.                     populatePager();
  2047.                     updatePagerActive(slider.active.index);
  2048.                 }
  2049.                 // update the slide position
  2050.                 if(!slider.settings.ticker) setSlidePosition();
  2051.             }
  2052.         });
  2053.  
  2054.         init();
  2055.  
  2056.         // returns the current jQuery object
  2057.         return this;
  2058.     }
  2059.  
  2060. })(jQuery);
  2061.  
  2062. /**
  2063. * 3.) jQuery imagesLoaded plugin 2.1.0 - http://github.com/desandro/imagesloaded
  2064. */
  2065.  
  2066. /*!
  2067.  * jQuery imagesLoaded plugin v2.1.0
  2068.  * http://github.com/desandro/imagesloaded
  2069.  *
  2070.  * MIT License. by Paul Irish et al.
  2071.  */
  2072.  
  2073. /*jshint curly: true, eqeqeq: true, noempty: true, strict: true, undef: true, browser: true */
  2074. /*global jQuery: false */
  2075.  
  2076.  
  2077. (function(c,n){var l="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";c.fn.imagesLoaded=function(f){function m(){var b=c(i),a=c(h);d&&(h.length?d.reject(e,b,a):d.resolve(e));c.isFunction(f)&&f.call(g,e,b,a)}function j(b,a){b.src===l||-1!==c.inArray(b,k)||(k.push(b),a?h.push(b):i.push(b),c.data(b,"imagesLoaded",{isBroken:a,src:b.src}),o&&d.notifyWith(c(b),[a,e,c(i),c(h)]),e.length===k.length&&(setTimeout(m),e.unbind(".imagesLoaded")))}var g=this,d=c.isFunction(c.Deferred)?c.Deferred():
  2078. 0,o=c.isFunction(d.notify),e=g.find("img").add(g.filter("img")),k=[],i=[],h=[];c.isPlainObject(f)&&c.each(f,function(b,a){if("callback"===b)f=a;else if(d)d[b](a)});e.length?e.bind("load.imagesLoaded error.imagesLoaded",function(b){j(b.target,"error"===b.type)}).each(function(b,a){var d=a.src,e=c.data(a,"imagesLoaded");if(e&&e.src===d)j(a,e.isBroken);else if(a.complete&&a.naturalWidth!==n)j(a,0===a.naturalWidth||0===a.naturalHeight);else if(a.readyState||a.complete)a.src=l,a.src=d}):m();return d?d.promise(g):
  2079. g}})(jQuery);
  2080.  
  2081.  
  2082. /**
  2083. * 4.) fancyBox 2.0.5 - http://fancyapps.com/fancybox/
  2084. */
  2085.  
  2086.     /*!
  2087.  * fancyBox - jQuery Plugin
  2088.  * version: 2.0.5 (02/03/2012)
  2089.  * @requires jQuery v1.6 or later
  2090.  *
  2091.  * Examples at http://fancyapps.com/fancybox/
  2092.  * License: www.fancyapps.com/fancybox/#license
  2093.  *
  2094.  * Copyright 2012 Janis Skarnelis - [email protected]
  2095.  *
  2096.  */
  2097. (function (window, document, undefined) {
  2098.     "use strict";
  2099.  
  2100.     var $ = window.jQuery,
  2101.         W = $(window),
  2102.         D = $(document),
  2103.         F = $.fancybox = function () {
  2104.             F.open.apply( this, arguments );
  2105.         },
  2106.         didResize = false,
  2107.         resizeTimer = null,
  2108.         isMobile = document.createTouch !== undefined,
  2109.         isString = function(str) {
  2110.             return $.type(str) === "string";
  2111.         };
  2112.  
  2113.     $.extend(F, {
  2114.         // The current version of fancyBox
  2115.         version: '2.0.5',
  2116.  
  2117.         defaults: {
  2118.             padding: 15,
  2119.             margin: 20,
  2120.  
  2121.             width: 800,
  2122.             height: 600,
  2123.             minWidth: 100,
  2124.             minHeight: 100,
  2125.             maxWidth: 9999,
  2126.             maxHeight: 9999,
  2127.  
  2128.             autoSize: true,
  2129.             autoResize: !isMobile,
  2130.             autoCenter : !isMobile,
  2131.             fitToView: true,
  2132.             aspectRatio: false,
  2133.             topRatio: 0.5,
  2134.  
  2135.             fixed: !($.browser.msie && $.browser.version <= 6) && !isMobile,
  2136.             scrolling: 'auto', // 'auto', 'yes' or 'no'
  2137.             wrapCSS: 'fancybox-default',
  2138.  
  2139.             arrows: true,
  2140.             closeBtn: true,
  2141.             closeClick: false,
  2142.             nextClick : false,
  2143.             mouseWheel: true,
  2144.             autoPlay: false,
  2145.             playSpeed: 3000,
  2146.             preload : 3,
  2147.  
  2148.             modal: false,
  2149.             loop: true,
  2150.             ajax: { dataType: 'html', headers: { 'X-fancyBox': true } },
  2151.             keys: {
  2152.                 next: [13, 32, 34, 39, 40], // enter, space, page down, right arrow, down arrow
  2153.                 prev: [8, 33, 37, 38], // backspace, page up, left arrow, up arrow
  2154.                 close: [27] // escape key
  2155.             },
  2156.  
  2157.             // Override some properties
  2158.             index: 0,
  2159.             type: null,
  2160.             href: null,
  2161.             content: null,
  2162.             title: null,
  2163.  
  2164.             // HTML templates
  2165.             tpl: {
  2166.                 wrap: '<div class="fancybox-wrap"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div>',
  2167.                 image: '<img class="fancybox-image" src="{href}" alt="" />',
  2168.                 iframe: '<iframe class="fancybox-iframe" name="fancybox-frame{rnd}" frameborder="0" hspace="0"' + ($.browser.msie ? ' allowtransparency="true"' : '') + '></iframe>',
  2169.                 swf: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{href}" /><embed src="{href}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="100%" height="100%" wmode="transparent"></embed></object>',
  2170.                 error: '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
  2171.                 closeBtn: '<div title="Close" class="fancybox-item fancybox-close"></div>',
  2172.                 next: '<a title="Next" class="fancybox-nav fancybox-next"><span></span></a>',
  2173.                 prev: '<a title="Previous" class="fancybox-nav fancybox-prev"><span></span></a>'
  2174.             },
  2175.  
  2176.             // Properties for each animation type
  2177.             // Opening fancyBox
  2178.             openEffect: 'fade', // 'elastic', 'fade' or 'none'
  2179.             openSpeed: 250,
  2180.             openEasing: 'swing',
  2181.             openOpacity: true,
  2182.             openMethod: 'zoomIn',
  2183.  
  2184.             // Closing fancyBox
  2185.             closeEffect: 'fade', // 'elastic', 'fade' or 'none'
  2186.             closeSpeed: 250,
  2187.             closeEasing: 'swing',
  2188.             closeOpacity: true,
  2189.             closeMethod: 'zoomOut',
  2190.  
  2191.             // Changing next gallery item
  2192.             nextEffect: 'elastic', // 'elastic', 'fade' or 'none'
  2193.             nextSpeed: 300,
  2194.             nextEasing: 'swing',
  2195.             nextMethod: 'changeIn',
  2196.  
  2197.             // Changing previous gallery item
  2198.             prevEffect: 'elastic', // 'elastic', 'fade' or 'none'
  2199.             prevSpeed: 300,
  2200.             prevEasing: 'swing',
  2201.             prevMethod: 'changeOut',
  2202.  
  2203.             // Enabled helpers
  2204.             helpers: {
  2205.                 overlay: {
  2206.                     speedIn: 0,
  2207.                     speedOut: 300,
  2208.                     opacity: 0.8,
  2209.                     css: {
  2210.                         cursor: 'pointer'
  2211.                     },
  2212.                     closeClick: true
  2213.                 },
  2214.                 title: {
  2215.                     type: 'float' // 'float', 'inside', 'outside' or 'over'
  2216.                 }
  2217.             },
  2218.  
  2219.             // Callbacks
  2220.             onCancel: $.noop, // If canceling
  2221.             beforeLoad: $.noop, // Before loading
  2222.             afterLoad: $.noop, // After loading
  2223.             beforeShow: $.noop, // Before changing in current item
  2224.             afterShow: $.noop, // After opening
  2225.             beforeClose: $.noop, // Before closing
  2226.             afterClose: $.noop // After closing
  2227.         },
  2228.  
  2229.         //Current state
  2230.         group: {}, // Selected group
  2231.         opts: {}, // Group options
  2232.         coming: null, // Element being loaded
  2233.         current: null, // Currently loaded element
  2234.         isOpen: false, // Is currently open
  2235.         isOpened: false, // Have been fully opened at least once
  2236.         wrap: null,
  2237.         outer: null,
  2238.         inner: null,
  2239.  
  2240.         player: {
  2241.             timer: null,
  2242.             isActive: false
  2243.         },
  2244.  
  2245.         // Loaders
  2246.         ajaxLoad: null,
  2247.         imgPreload: null,
  2248.  
  2249.         // Some collections
  2250.         transitions: {},
  2251.         helpers: {},
  2252.  
  2253.         /*
  2254.         *   Static methods
  2255.         */
  2256.  
  2257.         open: function (group, opts) {
  2258.             //Kill existing instances
  2259.             F.close(true);
  2260.  
  2261.             //Normalize group
  2262.             if (group && !$.isArray(group)) {
  2263.                 group = group instanceof $ ? $(group).get() : [group];
  2264.             }
  2265.  
  2266.             F.isActive = true;
  2267.  
  2268.             //Extend the defaults
  2269.             F.opts = $.extend(true, {}, F.defaults, opts);
  2270.  
  2271.             //All options are merged recursive except keys
  2272.             if ($.isPlainObject(opts) && opts.keys !== undefined) {
  2273.                 F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
  2274.             }
  2275.  
  2276.             F.group = group;
  2277.  
  2278.             F._start(F.opts.index || 0);
  2279.         },
  2280.  
  2281.         cancel: function () {
  2282.             if (F.coming && false === F.trigger('onCancel')) {
  2283.                 return;
  2284.             }
  2285.  
  2286.             F.coming = null;
  2287.  
  2288.             F.hideLoading();
  2289.  
  2290.             if (F.ajaxLoad) {
  2291.                 F.ajaxLoad.abort();
  2292.             }
  2293.  
  2294.             F.ajaxLoad = null;
  2295.  
  2296.             if (F.imgPreload) {
  2297.                 F.imgPreload.onload = F.imgPreload.onabort = F.imgPreload.onerror = null;
  2298.             }
  2299.         },
  2300.  
  2301.         close: function (a) {
  2302.             F.cancel();
  2303.  
  2304.             if (!F.current || false === F.trigger('beforeClose')) {
  2305.                 return;
  2306.             }
  2307.  
  2308.             F.unbindEvents();
  2309.  
  2310.             //If forced or is still opening then remove immediately
  2311.             if (!F.isOpen || (a && a[0] === true)) {
  2312.                 $(".fancybox-wrap").stop().trigger('onReset').remove();
  2313.  
  2314.                 F._afterZoomOut();
  2315.  
  2316.             } else {
  2317.                 F.isOpen = F.isOpened = false;
  2318.  
  2319.                 $(".fancybox-item, .fancybox-nav").remove();
  2320.  
  2321.                 F.wrap.stop(true).removeClass('fancybox-opened');
  2322.                 F.inner.css('overflow', 'hidden');
  2323.  
  2324.                 F.transitions[F.current.closeMethod]();
  2325.             }
  2326.         },
  2327.  
  2328.         // Start/stop slideshow
  2329.         play: function (a) {
  2330.             var clear = function () {
  2331.                     clearTimeout(F.player.timer);
  2332.                 },
  2333.                 set = function () {
  2334.                     clear();
  2335.  
  2336.                     if (F.current && F.player.isActive) {
  2337.                         F.player.timer = setTimeout(F.next, F.current.playSpeed);
  2338.                     }
  2339.                 },
  2340.                 stop = function () {
  2341.                     clear();
  2342.  
  2343.                     $('body').unbind('.player');
  2344.  
  2345.                     F.player.isActive = false;
  2346.  
  2347.                     F.trigger('onPlayEnd');
  2348.                 },
  2349.                 start = function () {
  2350.                     if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
  2351.                         F.player.isActive = true;
  2352.  
  2353.                         $('body').bind({
  2354.                             'afterShow.player onUpdate.player': set,
  2355.                             'onCancel.player beforeClose.player': stop,
  2356.                             'beforeLoad.player': clear
  2357.                         });
  2358.  
  2359.                         set();
  2360.  
  2361.                         F.trigger('onPlayStart');
  2362.                     }
  2363.                 };
  2364.  
  2365.             if (F.player.isActive || (a && a[0] === false)) {
  2366.                 stop();
  2367.             } else {
  2368.                 start();
  2369.             }
  2370.         },
  2371.  
  2372.         next: function () {
  2373.             if (F.current) {
  2374.                 F.jumpto(F.current.index + 1);
  2375.             }
  2376.         },
  2377.  
  2378.         prev: function () {
  2379.             if (F.current) {
  2380.                 F.jumpto(F.current.index - 1);
  2381.             }
  2382.         },
  2383.  
  2384.         jumpto: function (index) {
  2385.             if (!F.current) {
  2386.                 return;
  2387.             }
  2388.  
  2389.             index = parseInt(index, 10);
  2390.  
  2391.             if (F.group.length > 1 && F.current.loop) {
  2392.                 if (index >= F.group.length) {
  2393.                     index = 0;
  2394.  
  2395.                 } else if (index < 0) {
  2396.                     index = F.group.length - 1;
  2397.                 }
  2398.             }
  2399.  
  2400.             if (F.group[index] !== undefined) {
  2401.                 F.cancel();
  2402.  
  2403.                 F._start(index);
  2404.             }
  2405.         },
  2406.  
  2407.         reposition: function (a, b) {
  2408.             if (F.isOpen) {
  2409.                 if (b && b.type === 'scroll') {
  2410.                     F.wrap.stop().animate(F._getPosition(a), 200);
  2411.                 } else {
  2412.                     F.wrap.css(F._getPosition(a));
  2413.                 }
  2414.             }
  2415.         },
  2416.  
  2417.         update: function (e) {
  2418.             if (F.isOpen) {
  2419.                 // It's a very bad idea to attach handlers to the window scroll event, run this code after a delay
  2420.                 if (!didResize) {
  2421.                     resizeTimer = setTimeout(function () {
  2422.                         var current = F.current;
  2423.  
  2424.                         if (didResize) {
  2425.                             didResize = false;
  2426.  
  2427.                             if (current) {
  2428.                                 if (!e || (e && (e.type === 'orientationchange' || (current.autoResize && e.type === 'resize')))) {
  2429.                                     if (current.autoSize) {
  2430.                                         F.inner.height('auto');
  2431.                                         current.height = F.inner.height();
  2432.                                     }
  2433.  
  2434.                                     F._setDimension();
  2435.  
  2436.                                     if (current.canGrow) {
  2437.                                         F.inner.height('auto');
  2438.                                     }
  2439.                                 }
  2440.  
  2441.                                 if (current.autoCenter) {
  2442.                                     F.reposition(null, e);
  2443.                                 }
  2444.  
  2445.                                 F.trigger('onUpdate');
  2446.                             }
  2447.                         }
  2448.                     }, 100);
  2449.                 }
  2450.  
  2451.                 didResize = true;
  2452.             }
  2453.         },
  2454.  
  2455.         toggle: function () {
  2456.             if (F.isOpen) {
  2457.                 F.current.fitToView = !F.current.fitToView;
  2458.  
  2459.                 F.update();
  2460.             }
  2461.         },
  2462.  
  2463.         hideLoading: function () {
  2464.             D.unbind('keypress.fb');
  2465.  
  2466.             $("#fancybox-loading").remove();
  2467.         },
  2468.  
  2469.         showLoading: function () {
  2470.             F.hideLoading();
  2471.  
  2472.             //If user will press the escape-button, the request will be canceled
  2473.             D.bind('keypress.fb', function(e) {
  2474.                 if (e.keyCode == 27) {
  2475.                     e.preventDefault();
  2476.                     F.cancel();
  2477.                 }
  2478.             });
  2479.  
  2480.             $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
  2481.         },
  2482.  
  2483.         getViewport: function () {
  2484.             return {
  2485.                 x: W.scrollLeft(),
  2486.                 y: W.scrollTop(),
  2487.                 w: W.width(),
  2488.                 h: W.height()
  2489.             };
  2490.         },
  2491.  
  2492.         // Unbind the keyboard / clicking actions
  2493.         unbindEvents: function () {
  2494.             if (F.wrap) {
  2495.                 F.wrap.unbind('.fb');
  2496.             }
  2497.  
  2498.             D.unbind('.fb');
  2499.             W.unbind('.fb');
  2500.         },
  2501.  
  2502.         bindEvents: function () {
  2503.             var current = F.current,
  2504.                 keys = current.keys;
  2505.  
  2506.             if (!current) {
  2507.                 return;
  2508.             }
  2509.  
  2510.             W.bind('resize.fb, orientationchange.fb', F.update);
  2511.  
  2512.             if (!current.fixed && current.autoCenter) {
  2513.                 W.bind("scroll.fb", F.update);
  2514.             }
  2515.  
  2516.             if (keys) {
  2517.                 D.bind('keydown.fb', function (e) {
  2518.                     var code;
  2519.  
  2520.                     // Ignore key combinations and key events within form elements
  2521.                     if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && $.inArray(e.target.tagName.toLowerCase(), ['input', 'textarea', 'select', 'button']) < 0) {
  2522.                         code = e.keyCode;
  2523.  
  2524.                         if ($.inArray(code, keys.close) > -1) {
  2525.                             F.close();
  2526.                             e.preventDefault();
  2527.  
  2528.                         } else if ($.inArray(code, keys.next) > -1) {
  2529.                             F.next();
  2530.                             e.preventDefault();
  2531.  
  2532.                         } else if ($.inArray(code, keys.prev) > -1) {
  2533.                             F.prev();
  2534.                             e.preventDefault();
  2535.                         }
  2536.                     }
  2537.                 });
  2538.             }
  2539.  
  2540.             if ($.fn.mousewheel && current.mouseWheel && F.group.length > 1) {
  2541.                 F.wrap.bind('mousewheel.fb', function (e, delta) {
  2542.                     var target = e.target || null;
  2543.  
  2544.                     if (delta !== 0 && (!target || target.clientHeight === 0 || (target.scrollHeight === target.clientHeight && target.scrollWidth === target.clientWidth))) {
  2545.                         e.preventDefault();
  2546.  
  2547.                         F[delta > 0 ? 'prev' : 'next']();
  2548.                     }
  2549.                 });
  2550.             }
  2551.         },
  2552.  
  2553.         trigger: function (event) {
  2554.             var ret, obj = F[ $.inArray(event, ['onCancel', 'beforeLoad', 'afterLoad']) > -1 ? 'coming' : 'current' ];
  2555.  
  2556.             if (!obj) {
  2557.                 return;
  2558.             }
  2559.  
  2560.             if ($.isFunction( obj[event] )) {
  2561.                 ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
  2562.             }
  2563.  
  2564.             if (ret === false) {
  2565.                 return false;
  2566.             }
  2567.  
  2568.             if (obj.helpers) {
  2569.                 $.each(obj.helpers, function (helper, opts) {
  2570.                     if (opts && $.isPlainObject(F.helpers[helper]) && $.isFunction(F.helpers[helper][event])) {
  2571.                         F.helpers[helper][event](opts, obj);
  2572.                     }
  2573.                 });
  2574.             }
  2575.  
  2576.             $.event.trigger(event + '.fb');
  2577.         },
  2578.  
  2579.         isImage: function (str) {
  2580.             return str && str.toString().match(/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i);
  2581.         },
  2582.  
  2583.         isSWF: function (str) {
  2584.             return str && str.toString().match(/\.(swf)(.*)?$/i);
  2585.         },
  2586.  
  2587.         _start: function (index) {
  2588.             var coming = {},
  2589.                 element = F.group[index] || null,
  2590.                 isDom,
  2591.                 href,
  2592.                 type,
  2593.                 rez,
  2594.                 hrefParts;
  2595.  
  2596.             if (element && (element.nodeType || element instanceof $)) {
  2597.                 isDom = true;
  2598.  
  2599.                 if ($.metadata) {
  2600.                     coming = $(element).metadata();
  2601.                 }
  2602.             }
  2603.  
  2604.             coming = $.extend(true, {}, F.opts, {index : index, element : element}, ($.isPlainObject(element) ? element : coming));
  2605.  
  2606.             // Re-check overridable options
  2607.             $.each(['href', 'title', 'content', 'type'], function(i,v) {
  2608.                 coming[v] = F.opts[ v ] || (isDom && $(element).attr( v )) || coming[ v ] || null;
  2609.             });
  2610.  
  2611.             // Convert margin property to array - top, right, bottom, left
  2612.             if (typeof coming.margin === 'number') {
  2613.                 coming.margin = [coming.margin, coming.margin, coming.margin, coming.margin];
  2614.             }
  2615.  
  2616.             // 'modal' propery is just a shortcut
  2617.             if (coming.modal) {
  2618.                 $.extend(true, coming, {
  2619.                     closeBtn : false,
  2620.                     closeClick: false,
  2621.                     nextClick : false,
  2622.                     arrows : false,
  2623.                     mouseWheel : false,
  2624.                     keys : null,
  2625.                     helpers: {
  2626.                         overlay : {
  2627.                             css: {
  2628.                                 cursor : 'auto'
  2629.                             },
  2630.                             closeClick : false
  2631.                         }
  2632.                     }
  2633.                 });
  2634.             }
  2635.  
  2636.             //Give a chance for callback or helpers to update coming item (type, title, etc)
  2637.             F.coming = coming;
  2638.  
  2639.             if (false === F.trigger('beforeLoad')) {
  2640.                 F.coming = null;
  2641.                 return;
  2642.             }
  2643.  
  2644.             type = coming.type;
  2645.             href = coming.href || element;
  2646.  
  2647.             ///Check if content type is set, if not, try to get
  2648.             if (!type) {
  2649.                 if (isDom) {
  2650.                     rez = $(element).data('fancybox-type');
  2651.  
  2652.                     if (!rez && element.className) {
  2653.                         rez = element.className.match(/fancybox\.(\w+)/);
  2654.                         type = rez ? rez[1] : null;
  2655.                     }
  2656.                 }
  2657.  
  2658.                 if (!type && isString(href)) {
  2659.                     if (F.isImage(href)) {
  2660.                         type = 'image';
  2661.  
  2662.                     } else if (F.isSWF(href)) {
  2663.                         type = 'swf';
  2664.  
  2665.                     } else if (href.match(/^#/)) {
  2666.                         type = 'inline';
  2667.                     }
  2668.                 }
  2669.  
  2670.                 // ...if not - display element itself
  2671.                 if (!type) {
  2672.                     type = isDom ? 'inline' : 'html';
  2673.                 }
  2674.  
  2675.                 coming.type = type;
  2676.             }
  2677.  
  2678.             // Check before try to load; 'inline' and 'html' types need content, others - href
  2679.             if (type === 'inline' || type === 'html') {
  2680.                 if (!coming.content) {
  2681.                     if (type === 'inline') {
  2682.                         coming.content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
  2683.  
  2684.                     } else {
  2685.                         coming.content = element;
  2686.                     }
  2687.                 }
  2688.  
  2689.                 if (!coming.content || !coming.content.length) {
  2690.                     type = null;
  2691.                 }
  2692.  
  2693.             } else if (!href) {
  2694.                 type = null;
  2695.             }
  2696.  
  2697.             /*
  2698.                 Add reference to the group, so it`s possible to access from callbacks, example:
  2699.  
  2700.                 afterLoad : function() {
  2701.                     this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
  2702.                 }
  2703.  
  2704.             */
  2705.  
  2706.             hrefParts = href.split(/\s+/, 2);
  2707.  
  2708.             coming.group = F.group;
  2709.             coming.isDom = isDom;
  2710.             coming.href = hrefParts.shift();
  2711.             coming.selector = hrefParts.shift();
  2712.  
  2713.             if (type === 'image') {
  2714.                 F._loadImage();
  2715.  
  2716.             } else if (type === 'ajax') {
  2717.                 F._loadAjax();
  2718.  
  2719.             } else if (type) {
  2720.                 F._afterLoad();
  2721.  
  2722.             } else {
  2723.                 F._error( 'type' );
  2724.             }
  2725.         },
  2726.  
  2727.         _error: function ( type ) {
  2728.             F.hideLoading();
  2729.  
  2730.             $.extend(F.coming, {
  2731.                 type : 'html',
  2732.                 autoSize : true,
  2733.                 minHeight : 0,
  2734.                 hasError : type,
  2735.                 content : F.coming.tpl.error
  2736.             });
  2737.  
  2738.             F._afterLoad();
  2739.         },
  2740.  
  2741.         _loadImage: function () {
  2742.             // Reset preload image so it is later possible to check "complete" property
  2743.             F.imgPreload = new Image();
  2744.  
  2745.             F.imgPreload.onload = function () {
  2746.                 this.onload = this.onerror = null;
  2747.  
  2748.                 F.coming.width = this.width;
  2749.                 F.coming.height = this.height;
  2750.  
  2751.                 F._afterLoad();
  2752.             };
  2753.  
  2754.             F.imgPreload.onerror = function () {
  2755.                 this.onload = this.onerror = null;
  2756.  
  2757.                 F._error( 'image' );
  2758.             };
  2759.  
  2760.             F.imgPreload.src = F.coming.href;
  2761.  
  2762.             if (!F.imgPreload.width) {
  2763.                 F.showLoading();
  2764.             }
  2765.         },
  2766.  
  2767.         _loadAjax: function () {
  2768.             F.showLoading();
  2769.  
  2770.             F.ajaxLoad = $.ajax($.extend({}, F.coming.ajax, {
  2771.                 url: F.coming.href,
  2772.                 error: function (jqXHR, textStatus) {
  2773.                     if (F.coming && textStatus !== 'abort') {
  2774.                         F._error( 'ajax', jqXHR );
  2775.  
  2776.                     } else {
  2777.                         F.hideLoading();
  2778.                     }
  2779.                 },
  2780.                 success: function (data, textStatus) {
  2781.                     if (textStatus === 'success') {
  2782.                         F.coming.content = data;
  2783.  
  2784.                         F._afterLoad();
  2785.                     }
  2786.                 }
  2787.             }));
  2788.         },
  2789.  
  2790.         _preloadImages: function() {
  2791.             var group = F.group,
  2792.                 current = F.current,
  2793.                 len = group.length,
  2794.                 item,
  2795.                 href,
  2796.                 i,
  2797.                 cnt = Math.min(current.preload, len - 1);
  2798.  
  2799.             if (!current.preload || group.length < 2) {
  2800.                 return;
  2801.             }
  2802.  
  2803.             for (i = 1; i <= cnt; i += 1) {
  2804.                 item = group[ (current.index + i ) % len ];
  2805.                 href = $( item ).attr('href') || item;
  2806.  
  2807.                 if (item.type === 'image' || F.isImage(href)) {
  2808.                     new Image().src = href;
  2809.                 }
  2810.             }
  2811.         },
  2812.  
  2813.         _afterLoad: function () {
  2814.             F.hideLoading();
  2815.  
  2816.             if (!F.coming || false === F.trigger('afterLoad', F.current)) {
  2817.                 F.coming = false;
  2818.  
  2819.                 return;
  2820.             }
  2821.  
  2822.             if (F.isOpened) {
  2823.                 $(".fancybox-item").remove();
  2824.  
  2825.                 F.wrap.stop(true).removeClass('fancybox-opened');
  2826.                 F.inner.css('overflow', 'hidden');
  2827.  
  2828.                 F.transitions[F.current.prevMethod]();
  2829.  
  2830.             } else {
  2831.                 $(".fancybox-wrap").stop().trigger('onReset').remove();
  2832.  
  2833.                 F.trigger('afterClose');
  2834.             }
  2835.  
  2836.             F.unbindEvents();
  2837.  
  2838.             F.isOpen = false;
  2839.             F.current = F.coming;
  2840.  
  2841.             //Build the neccessary markup
  2842.             F.wrap = $(F.current.tpl.wrap).addClass('fancybox-' + (isMobile ? 'mobile' : 'desktop') + ' fancybox-tmp ' + F.current.wrapCSS).appendTo('body');
  2843.             F.outer = $('.fancybox-outer', F.wrap).css('padding', F.current.padding + 'px');
  2844.             F.inner = $('.fancybox-inner', F.wrap);
  2845.  
  2846.             F._setContent();
  2847.         },
  2848.  
  2849.         _setContent: function () {
  2850.             var current = F.current, content = current.content, type = current.type, loadingBay;
  2851.  
  2852.             switch (type) {
  2853.                 case 'inline':
  2854.                 case 'ajax':
  2855.                 case 'html':
  2856.                     if (current.selector) {
  2857.                         content = $("<div>").html(content).find(current.selector);
  2858.  
  2859.                     } else if (content instanceof $) {
  2860.                         content = content.show().detach();
  2861.  
  2862.                         if (content.parent().hasClass('fancybox-inner')) {
  2863.                             content.parents('.fancybox-wrap').trigger('onReset').remove();
  2864.                         }
  2865.  
  2866.                         $(F.wrap).bind('onReset', function () {
  2867.                             content.appendTo('body').hide();
  2868.                         });
  2869.                     }
  2870.  
  2871.                     if (current.autoSize) {
  2872.                         loadingBay = $('<div class="fancybox-tmp ' + F.current.wrapCSS + '"></div>').appendTo('body').append(content);
  2873.                         current.width = loadingBay.width();
  2874.                         current.height = loadingBay.height();
  2875.  
  2876.                         // Re-check to fix 1px bug in some browsers
  2877.                         loadingBay.width( F.current.width );
  2878.  
  2879.                         if (loadingBay.height() > current.height) {
  2880.                             loadingBay.width(current.width + 1);
  2881.  
  2882.                             current.width = loadingBay.width();
  2883.                             current.height = loadingBay.height();
  2884.                         }
  2885.  
  2886.                         content = loadingBay.contents().detach();
  2887.  
  2888.                         loadingBay.remove();
  2889.                     }
  2890.  
  2891.                 break;
  2892.  
  2893.                 case 'image':
  2894.                     content = current.tpl.image.replace('{href}', current.href);
  2895.  
  2896.                     current.aspectRatio = true;
  2897.                 break;
  2898.  
  2899.                 case 'swf':
  2900.                     content = current.tpl.swf.replace(/\{width\}/g, current.width).replace(/\{height\}/g, current.height).replace(/\{href\}/g, current.href);
  2901.                 break;
  2902.             }
  2903.  
  2904.             if (type === 'iframe') {
  2905.                 content = $(current.tpl.iframe.replace('{rnd}', new Date().getTime()) ).attr('scrolling', current.scrolling);
  2906.  
  2907.                 current.scrolling = 'auto';
  2908.  
  2909.                 // Set auto height for iframes
  2910.                 if (current.autoSize) {
  2911.                     content.width( current.width );
  2912.  
  2913.                     F.showLoading();
  2914.  
  2915.                     content.data('ready', false).appendTo(F.inner).bind({
  2916.                         onCancel : function() {
  2917.                             $(this).unbind();
  2918.  
  2919.                             F._afterZoomOut();
  2920.                         },
  2921.                         load : function() {
  2922.                             var iframe = $(this), height;
  2923.  
  2924.                             try {
  2925.                                 if (this.contentWindow.document.location) {
  2926.                                     height = iframe.contents().find('body').height() + 12;
  2927.  
  2928.                                     iframe.height( height );
  2929.                                 }
  2930.  
  2931.                             } catch (e) {
  2932.                                 current.autoSize = false;
  2933.                             }
  2934.  
  2935.                             if (iframe.data('ready') === false) {
  2936.                                 F.hideLoading();
  2937.  
  2938.                                 if (height) {
  2939.                                     F.current.height = height;
  2940.                                 }
  2941.  
  2942.                                 F._beforeShow();
  2943.  
  2944.                                 iframe.data('ready', true);
  2945.  
  2946.                             } else if (height) {
  2947.                                 F.update();
  2948.                             }
  2949.                         }
  2950.  
  2951.                     }).attr('src', current.href);
  2952.  
  2953.                     return;
  2954.                 }
  2955.  
  2956.                 content.attr('src', current.href);
  2957.  
  2958.             } else if (type === 'image' || type === 'swf') {
  2959.                 current.autoSize = false;
  2960.                 current.scrolling = 'visible';
  2961.             }
  2962.  
  2963.             F.inner.append(content);
  2964.  
  2965.             F._beforeShow();
  2966.         },
  2967.  
  2968.         _beforeShow : function() {
  2969.             F.coming = null;
  2970.  
  2971.             //Give a chance for helpers or callbacks to update elements
  2972.             F.trigger('beforeShow');
  2973.  
  2974.             //Set initial dimensions and hide
  2975.             F._setDimension();
  2976.  
  2977.             F.wrap.hide().removeClass('fancybox-tmp');
  2978.  
  2979.             F.bindEvents();
  2980.             F._preloadImages();
  2981.  
  2982.             F.transitions[ F.isOpened ? F.current.nextMethod : F.current.openMethod ]();
  2983.         },
  2984.  
  2985.         _setDimension: function () {
  2986.             var wrap = F.wrap,
  2987.                 outer = F.outer,
  2988.                 inner = F.inner,
  2989.                 current = F.current,
  2990.                 viewport = F.getViewport(),
  2991.                 margin = current.margin,
  2992.                 padding2 = current.padding * 2,
  2993.                 width = current.width,
  2994.                 height = current.height,
  2995.                 maxWidth = current.maxWidth,
  2996.                 maxHeight = current.maxHeight,
  2997.                 minWidth = current.minWidth,
  2998.                 minHeight = current.minHeight,
  2999.                 ratio,
  3000.                 height_,
  3001.                 space;
  3002.  
  3003.             viewport.w -= (margin[1] + margin[3]);
  3004.             viewport.h -= (margin[0] + margin[2]);
  3005.  
  3006.             if (width.toString().indexOf('%') > -1) {
  3007.                 width = (((viewport.w - padding2) * parseFloat(width)) / 100);
  3008.             }
  3009.  
  3010.             if (height.toString().indexOf('%') > -1) {
  3011.                 height = (((viewport.h - padding2) * parseFloat(height)) / 100);
  3012.             }
  3013.  
  3014.             ratio = width / height;
  3015.  
  3016.             width += padding2;
  3017.             height += padding2;
  3018.  
  3019.             if (current.fitToView) {
  3020.                 maxWidth = Math.min(viewport.w, maxWidth);
  3021.                 maxHeight = Math.min(viewport.h, maxHeight);
  3022.             }
  3023.  
  3024.             if (current.aspectRatio) {
  3025.                 if (width > maxWidth) {
  3026.                     width = maxWidth;
  3027.                     height = ((width - padding2) / ratio) + padding2;
  3028.                 }
  3029.  
  3030.                 if (height > maxHeight) {
  3031.                     height = maxHeight;
  3032.                     width = ((height - padding2) * ratio) + padding2;
  3033.                 }
  3034.  
  3035.                 if (width < minWidth) {
  3036.                     width = minWidth;
  3037.                     height = ((width - padding2) / ratio) + padding2;
  3038.                 }
  3039.  
  3040.                 if (height < minHeight) {
  3041.                     height = minHeight;
  3042.                     width = ((height - padding2) * ratio) + padding2;
  3043.                 }
  3044.  
  3045.             } else {
  3046.                 width = Math.max(minWidth, Math.min(width, maxWidth));
  3047.                 height = Math.max(minHeight, Math.min(height, maxHeight));
  3048.             }
  3049.  
  3050.             width = Math.round(width);
  3051.             height = Math.round(height);
  3052.  
  3053.             //Reset dimensions
  3054.             $(wrap.add(outer).add(inner)).width('auto').height('auto');
  3055.  
  3056.             inner.width(width - padding2).height(height - padding2);
  3057.             wrap.width(width);
  3058.  
  3059.             height_ = wrap.height(); // Real wrap height
  3060.  
  3061.             //Fit wrapper inside
  3062.             if (width > maxWidth || height_ > maxHeight) {
  3063.                 while ((width > maxWidth || height_ > maxHeight) && width > minWidth && height_ > minHeight) {
  3064.                     height = height - 10;
  3065.  
  3066.                     if (current.aspectRatio) {
  3067.                         width = Math.round(((height - padding2) * ratio) + padding2);
  3068.  
  3069.                         if (width < minWidth) {
  3070.                             width = minWidth;
  3071.                             height = ((width - padding2) / ratio) + padding2;
  3072.                         }
  3073.  
  3074.                     } else {
  3075.                         width = width - 10;
  3076.                     }
  3077.  
  3078.                     inner.width(width - padding2).height(height - padding2);
  3079.                     wrap.width(width);
  3080.  
  3081.                     height_ = wrap.height();
  3082.                 }
  3083.             }
  3084.  
  3085.             current.dim = {
  3086.                 width: width,
  3087.                 height: height_
  3088.             };
  3089.  
  3090.             current.canGrow = current.autoSize && height > minHeight && height < maxHeight;
  3091.             current.canShrink = false;
  3092.             current.canExpand = false;
  3093.  
  3094.             if ((width - padding2) < current.width || (height - padding2) < current.height) {
  3095.                 current.canExpand = true;
  3096.  
  3097.             } else if ((width > viewport.w || height_ > viewport.h) && width > minWidth && height > minHeight) {
  3098.                 current.canShrink = true;
  3099.             }
  3100.  
  3101.             space = height_ - padding2;
  3102.  
  3103.             F.innerSpace = space - inner.height();
  3104.             F.outerSpace = space - outer.height();
  3105.         },
  3106.  
  3107.         _getPosition: function (a) {
  3108.             var current = F.current,
  3109.                 viewport = F.getViewport(),
  3110.                 margin = current.margin,
  3111.                 width = F.wrap.width() + margin[1] + margin[3],
  3112.                 height = F.wrap.height() + margin[0] + margin[2],
  3113.                 rez = {
  3114.                     position: 'absolute',
  3115.                     top: margin[0] + viewport.y,
  3116.                     left: margin[3] + viewport.x
  3117.                 };
  3118.  
  3119.             if (current.autoCenter && current.fixed && (!a || a[0] === false) && height <= viewport.h && width <= viewport.w) {
  3120.                 rez = {
  3121.                     position: 'fixed',
  3122.                     top: margin[0],
  3123.                     left: margin[3]
  3124.                 };
  3125.             }
  3126.  
  3127.             rez.top = Math.ceil(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio))) + 'px';
  3128.             rez.left = Math.ceil(Math.max(rez.left, rez.left + ((viewport.w - width) * 0.5))) + 'px';
  3129.  
  3130.             return rez;
  3131.         },
  3132.  
  3133.         _afterZoomIn: function () {
  3134.             var current = F.current, scrolling = current ? current.scrolling : 'no';
  3135.  
  3136.             if (!current) {
  3137.                 return;
  3138.             }
  3139.  
  3140.             F.isOpen = F.isOpened = true;
  3141.  
  3142.             F.wrap.addClass('fancybox-opened').css('overflow', 'visible');
  3143.  
  3144.             F.update();
  3145.  
  3146.             F.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
  3147.  
  3148.             //Assign a click event
  3149.             if (current.closeClick || current.nextClick) {
  3150.                 //This is not the perfect solution but arrows have to be next to content so their height will match
  3151.                 // and I do not want another wrapper around content
  3152.                 F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
  3153.                     if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
  3154.                         F[ current.closeClick ? 'close' : 'next' ]();
  3155.                     }
  3156.                 });
  3157.             }
  3158.  
  3159.             //Create a close button
  3160.             if (current.closeBtn) {
  3161.                 $(current.tpl.closeBtn).appendTo(F.outer).bind('click.fb', F.close);
  3162.             }
  3163.  
  3164.             //Create navigation arrows
  3165.             if (current.arrows && F.group.length > 1) {
  3166.                 if (current.loop || current.index > 0) {
  3167.                     $(current.tpl.prev).appendTo(F.inner).bind('click.fb', F.prev);
  3168.                 }
  3169.  
  3170.                 if (current.loop || current.index < F.group.length - 1) {
  3171.                     $(current.tpl.next).appendTo(F.inner).bind('click.fb', F.next);
  3172.                 }
  3173.             }
  3174.  
  3175.             F.trigger('afterShow');
  3176.  
  3177.             if (F.opts.autoPlay && !F.player.isActive) {
  3178.                 F.opts.autoPlay = false;
  3179.  
  3180.                 F.play();
  3181.             }
  3182.         },
  3183.  
  3184.         _afterZoomOut: function () {
  3185.             F.trigger('afterClose');
  3186.  
  3187.             F.wrap.trigger('onReset').remove();
  3188.  
  3189.             $.extend(F, {
  3190.                 group: {},
  3191.                 opts: {},
  3192.                 current: null,
  3193.                 isActive: false,
  3194.                 isOpened: false,
  3195.                 isOpen: false,
  3196.                 wrap: null,
  3197.                 outer: null,
  3198.                 inner: null
  3199.             });
  3200.         }
  3201.     });
  3202.  
  3203.     /*
  3204.     *   Default transitions
  3205.     */
  3206.  
  3207.     F.transitions = {
  3208.         getOrigPosition: function () {
  3209.             var current = F.current,
  3210.                 element = current.element,
  3211.                 padding = current.padding,
  3212.                 orig = $(current.orig),
  3213.                 pos = {},
  3214.                 width = 50,
  3215.                 height = 50,
  3216.                 viewport;
  3217.  
  3218.             if (!orig.length && current.isDom && $(element).is(':visible')) {
  3219.                 orig = $(element).find('img:first');
  3220.  
  3221.                 if (!orig.length) {
  3222.                     orig = $(element);
  3223.                 }
  3224.             }
  3225.  
  3226.             if (orig.length) {
  3227.                 pos = orig.offset();
  3228.  
  3229.                 if (orig.is('img')) {
  3230.                     width = orig.outerWidth();
  3231.                     height = orig.outerHeight();
  3232.                 }
  3233.  
  3234.             } else {
  3235.                 viewport = F.getViewport();
  3236.  
  3237.                 pos.top = viewport.y + (viewport.h - height) * 0.5;
  3238.                 pos.left = viewport.x + (viewport.w - width) * 0.5;
  3239.             }
  3240.  
  3241.             pos = {
  3242.                 top: Math.ceil(pos.top - padding) + 'px',
  3243.                 left: Math.ceil(pos.left - padding) + 'px',
  3244.                 width: Math.ceil(width + padding * 2) + 'px',
  3245.                 height: Math.ceil(height + padding * 2) + 'px'
  3246.             };
  3247.  
  3248.             return pos;
  3249.         },
  3250.  
  3251.         step: function (now, fx) {
  3252.             var ratio, innerValue, outerValue;
  3253.  
  3254.             if (fx.prop === 'width' || fx.prop === 'height') {
  3255.                 innerValue = outerValue = Math.ceil(now - (F.current.padding * 2));
  3256.  
  3257.                 if (fx.prop === 'height') {
  3258.                     ratio = (now - fx.start) / (fx.end - fx.start);
  3259.  
  3260.                     if (fx.start > fx.end) {
  3261.                         ratio = 1 - ratio;
  3262.                     }
  3263.  
  3264.                     innerValue -= F.innerSpace * ratio;
  3265.                     outerValue -= F.outerSpace * ratio;
  3266.                 }
  3267.  
  3268.                 F.inner[fx.prop](innerValue);
  3269.                 F.outer[fx.prop](outerValue);
  3270.             }
  3271.         },
  3272.  
  3273.         zoomIn: function () {
  3274.             var wrap = F.wrap,
  3275.                 current = F.current,
  3276.                 startPos,
  3277.                 endPos,
  3278.                 dim = current.dim;
  3279.  
  3280.             if (current.openEffect === 'elastic') {
  3281.                 endPos = $.extend({}, dim, F._getPosition(true));
  3282.  
  3283.                 //Remove "position" property
  3284.                 delete endPos.position;
  3285.  
  3286.                 startPos = this.getOrigPosition();
  3287.  
  3288.                 if (current.openOpacity) {
  3289.                     startPos.opacity = 0;
  3290.                     endPos.opacity = 1;
  3291.                 }
  3292.  
  3293.                 F.outer.add(F.inner).width('auto').height('auto');
  3294.  
  3295.                 wrap.css(startPos).show();
  3296.  
  3297.                 wrap.animate(endPos, {
  3298.                     duration: current.openSpeed,
  3299.                     easing: current.openEasing,
  3300.                     step: this.step,
  3301.                     complete: F._afterZoomIn
  3302.                 });
  3303.  
  3304.             } else {
  3305.                 wrap.css($.extend({}, dim, F._getPosition()));
  3306.  
  3307.                 if (current.openEffect === 'fade') {
  3308.                     wrap.fadeIn(current.openSpeed, F._afterZoomIn);
  3309.  
  3310.                 } else {
  3311.                     wrap.show();
  3312.                     F._afterZoomIn();
  3313.                 }
  3314.             }
  3315.         },
  3316.  
  3317.         zoomOut: function () {
  3318.             var wrap = F.wrap,
  3319.                 current = F.current,
  3320.                 endPos;
  3321.  
  3322.             if (current.closeEffect === 'elastic') {
  3323.                 if (wrap.css('position') === 'fixed') {
  3324.                     wrap.css(F._getPosition(true));
  3325.                 }
  3326.  
  3327.                 endPos = this.getOrigPosition();
  3328.  
  3329.                 if (current.closeOpacity) {
  3330.                     endPos.opacity = 0;
  3331.                 }
  3332.  
  3333.                 wrap.animate(endPos, {
  3334.                     duration: current.closeSpeed,
  3335.                     easing: current.closeEasing,
  3336.                     step: this.step,
  3337.                     complete: F._afterZoomOut
  3338.                 });
  3339.  
  3340.             } else {
  3341.                 wrap.fadeOut(current.closeEffect === 'fade' ? current.closeSpeed : 0, F._afterZoomOut);
  3342.             }
  3343.         },
  3344.  
  3345.         changeIn: function () {
  3346.             var wrap = F.wrap,
  3347.                 current = F.current,
  3348.                 startPos;
  3349.  
  3350.             if (current.nextEffect === 'elastic') {
  3351.                 startPos = F._getPosition(true);
  3352.                 startPos.opacity = 0;
  3353.                 startPos.top = (parseInt(startPos.top, 10) - 200) + 'px';
  3354.  
  3355.                 wrap.css(startPos).show().animate({
  3356.                     opacity: 1,
  3357.                     top: '+=200px'
  3358.                 }, {
  3359.                     duration: current.nextSpeed,
  3360.                     easing: current.nextEasing,
  3361.                     complete: F._afterZoomIn
  3362.                 });
  3363.  
  3364.             } else {
  3365.                 wrap.css(F._getPosition());
  3366.  
  3367.                 if (current.nextEffect === 'fade') {
  3368.                     wrap.hide().fadeIn(current.nextSpeed, F._afterZoomIn);
  3369.  
  3370.                 } else {
  3371.                     wrap.show();
  3372.                     F._afterZoomIn();
  3373.                 }
  3374.             }
  3375.         },
  3376.  
  3377.         changeOut: function () {
  3378.             var wrap = F.wrap,
  3379.                 current = F.current,
  3380.                 cleanUp = function () {
  3381.                     $(this).trigger('onReset').remove();
  3382.                 };
  3383.  
  3384.             wrap.removeClass('fancybox-opened');
  3385.  
  3386.             if (current.prevEffect === 'elastic') {
  3387.                 wrap.animate({
  3388.                     'opacity': 0,
  3389.                     top: '+=200px'
  3390.                 }, {
  3391.                     duration: current.prevSpeed,
  3392.                     easing: current.prevEasing,
  3393.                     complete: cleanUp
  3394.                 });
  3395.  
  3396.             } else {
  3397.                 wrap.fadeOut(current.prevEffect === 'fade' ? current.prevSpeed : 0, cleanUp);
  3398.             }
  3399.         }
  3400.     };
  3401.  
  3402.     /*
  3403.     *   Overlay helper
  3404.     */
  3405.  
  3406.     F.helpers.overlay = {
  3407.         overlay: null,
  3408.  
  3409.         update: function () {
  3410.             var width, scrollWidth, offsetWidth;
  3411.  
  3412.             //Reset width/height so it will not mess
  3413.             this.overlay.width(0).height(0);
  3414.  
  3415.             if ($.browser.msie) {
  3416.                 scrollWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
  3417.                 offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
  3418.  
  3419.                 width = scrollWidth < offsetWidth ? W.width() : scrollWidth;
  3420.  
  3421.             } else {
  3422.                 width = D.width();
  3423.             }
  3424.  
  3425.             this.overlay.width(width).height(D.height());
  3426.         },
  3427.  
  3428.         beforeShow: function (opts) {
  3429.             if (this.overlay) {
  3430.                 return;
  3431.             }
  3432.  
  3433.             opts = $.extend(true, {
  3434.                 speedIn : 'fast',
  3435.                 closeClick : true,
  3436.                 opacity : 1,
  3437.                 css : {
  3438.                     background: 'black'
  3439.                 }
  3440.             }, opts);
  3441.  
  3442.             this.overlay = $('<div id="fancybox-overlay"></div>').css(opts.css).appendTo('body');
  3443.  
  3444.             this.update();
  3445.  
  3446.             if (opts.closeClick) {
  3447.                 this.overlay.bind('click.fb', F.close);
  3448.             }
  3449.  
  3450.             W.bind("resize.fb", $.proxy(this.update, this));
  3451.  
  3452.             this.overlay.fadeTo(opts.speedIn, opts.opacity);
  3453.         },
  3454.  
  3455.         onUpdate: function () {
  3456.             //Update as content may change document dimensions
  3457.             this.update();
  3458.         },
  3459.  
  3460.         afterClose: function (opts) {
  3461.             if (this.overlay) {
  3462.                 this.overlay.fadeOut(opts.speedOut || 0, function () {
  3463.                     $(this).remove();
  3464.                 });
  3465.             }
  3466.  
  3467.             this.overlay = null;
  3468.         }
  3469.     };
  3470.  
  3471.     /*
  3472.     *   Title helper
  3473.     */
  3474.  
  3475.     F.helpers.title = {
  3476.         beforeShow: function (opts) {
  3477.             var title, text = F.current.title;
  3478.  
  3479.             if (text) {
  3480.                 title = $('<div class="fancybox-title fancybox-title-' + opts.type + '-wrap">' + text + '</div>').appendTo('body');
  3481.  
  3482.                 if (opts.type === 'float') {
  3483.                     //This helps for some browsers
  3484.                     title.width(title.width());
  3485.  
  3486.                     title.wrapInner('<span class="child"></span>');
  3487.  
  3488.                     //Increase bottom margin so this title will also fit into viewport
  3489.                     F.current.margin[2] += Math.abs(parseInt(title.css('margin-bottom'), 10));
  3490.                 }
  3491.  
  3492.                 title.appendTo(opts.type === 'over' ? F.inner : (opts.type === 'outside' ? F.wrap : F.outer));
  3493.             }
  3494.         }
  3495.     };
  3496.  
  3497.     // jQuery plugin initialization
  3498.     $.fn.fancybox = function (options) {
  3499.         var that = $(this),
  3500.             selector = this.selector || '',
  3501.             index,
  3502.             run = function(e) {
  3503.                 var what = this, idx = index, relType, relVal;
  3504.  
  3505.                 if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
  3506.                     e.preventDefault();
  3507.  
  3508.                     relType = options.groupAttr || 'data-fancybox-group';
  3509.                     relVal = $(what).attr(relType);
  3510.  
  3511.                     if (!relVal) {
  3512.                         relType = 'rel';
  3513.                         relVal = what[ relType ];
  3514.                     }
  3515.  
  3516.                     if (relVal && relVal !== '' && relVal !== 'nofollow') {
  3517.                         what = selector.length ? $(selector) : that;
  3518.                         what = what.filter('[' + relType + '="' + relVal + '"]');
  3519.                         idx = what.index(this);
  3520.                     }
  3521.  
  3522.                     options.index = idx;
  3523.  
  3524.                     F.open(what, options);
  3525.                 }
  3526.             };
  3527.  
  3528.         options = options || {};
  3529.         index = options.index || 0;
  3530.  
  3531.         if (selector) {
  3532.             D.undelegate(selector, 'click.fb-start').delegate(selector, 'click.fb-start', run);
  3533.  
  3534.         } else {
  3535.             that.unbind('click.fb-start').bind('click.fb-start', run);
  3536.         }
  3537.  
  3538.         return this;
  3539.     };
  3540.  
  3541. }(window, document));
  3542.  
  3543.  
  3544. /**
  3545. * 5.) jquery placeholder 2.0.3 - https://github.com/mathiasbynens/jquery-placeholder
  3546. * @author Mathias Bynens
  3547. */
  3548.  
  3549. (function (window, document, $) {
  3550.  
  3551.         var isInputSupported = 'placeholder' in document.createElement('input'),
  3552.                 isTextareaSupported = 'placeholder' in document.createElement('textarea'),
  3553.                 prototype = $.fn,
  3554.                 valHooks = $.valHooks,
  3555.                 hooks,
  3556.                 placeholder;
  3557.  
  3558.         if (isInputSupported && isTextareaSupported) {
  3559.  
  3560.                 placeholder = prototype.placeholder = function() {
  3561.                         return this;
  3562.                 };
  3563.  
  3564.                 placeholder.input = placeholder.textarea = true;
  3565.  
  3566.         } else {
  3567.  
  3568.                 placeholder = prototype.placeholder = function() {
  3569.                         return this
  3570.                                 .filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
  3571.                                 .not('.placeholder')
  3572.                                 .bind({
  3573.                                         'focus.placeholder': clearPlaceholder,
  3574.                                         'blur.placeholder': setPlaceholder
  3575.                                 })
  3576.                                 .data('placeholder-enabled', true)
  3577.                                 .trigger('blur.placeholder').end();
  3578.                 };
  3579.  
  3580.                 placeholder.input = isInputSupported;
  3581.                 placeholder.textarea = isTextareaSupported;
  3582.  
  3583.                 hooks = {
  3584.                         'get': function(element) {
  3585.                                 var $element = $(element);
  3586.                                 return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
  3587.                         },
  3588.                         'set': function(element, value) {
  3589.                                 var $element = $(element);
  3590.                                 if (!$element.data('placeholder-enabled')) {
  3591.                                         return element.value = value;
  3592.                                 }
  3593.                                 if (value == '') {
  3594.                                         element.value = value;
  3595.                                         // We can’t use `triggerHandler` here because of dummy text/password inputs :(
  3596.                                         setPlaceholder.call(element);
  3597.                                 } else if ($element.hasClass('placeholder')) {
  3598.                                         clearPlaceholder.call(element, true, value) || (element.value = value);
  3599.                                 } else {
  3600.                                         element.value = value;
  3601.                                 }
  3602.                                 // `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
  3603.                                 return $element;
  3604.                         }
  3605.                 };
  3606.  
  3607.                 isInputSupported || (valHooks.input = hooks);
  3608.                 isTextareaSupported || (valHooks.textarea = hooks);
  3609.  
  3610.                 $(function() {
  3611.                         // Look for forms
  3612.                         $(document).delegate('form', 'submit.placeholder', function() {
  3613.                                 // Clear the placeholder values so they don’t get submitted
  3614.                                 var $inputs = $('.placeholder', this).each(clearPlaceholder);
  3615.                                 setTimeout(function() {
  3616.                                         $inputs.each(setPlaceholder);
  3617.                                 }, 10);
  3618.                         });
  3619.                 });
  3620.  
  3621.                 // Clear placeholder values upon page reload
  3622.                 $(window).bind('beforeunload.placeholder', function() {
  3623.                         $('.placeholder').each(function() {
  3624.                                 this.value = '';
  3625.                         });
  3626.                 });
  3627.  
  3628.         }
  3629.  
  3630.         function args(elem) {
  3631.                 // Return an object of element attributes
  3632.                 var newAttrs = {},
  3633.                         rinlinejQuery = /^jQuery\d+$/;
  3634.                 $.each(elem.attributes, function(i, attr) {
  3635.                         if (attr.specified && !rinlinejQuery.test(attr.name)) {
  3636.                                 newAttrs[attr.name] = attr.value;
  3637.                         }
  3638.                 });
  3639.                 return newAttrs;
  3640.         }
  3641.  
  3642.         function clearPlaceholder(event, value) {
  3643.                 var input = this,
  3644.                         $input = $(input);
  3645.                 if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
  3646.                         if ($input.data('placeholder-password')) {
  3647.                                 $input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
  3648.                                 // If `clearPlaceholder` was called from `$.valHooks.input.set`
  3649.                                 if (event === true) {
  3650.                                         return $input[0].value = value;
  3651.                                 }
  3652.                                 $input.focus();
  3653.                         } else {
  3654.                                 input.value = '';
  3655.                                 $input.removeClass('placeholder');
  3656.                         }
  3657.                 }
  3658.         }
  3659.  
  3660.         function setPlaceholder() {
  3661.                 var $replacement,
  3662.                         input = this,
  3663.                         $input = $(input),
  3664.                         $origInput = $input,
  3665.                         id = this.id;
  3666.                 if (input.value === '') {
  3667.                         if (input.type == 'password') {
  3668.                                 if (!$input.data('placeholder-textinput')) {
  3669.                                         try {
  3670.                                                 $replacement = $input.clone().attr({ 'type': 'text' });
  3671.                                         } catch(e) {
  3672.                                                 $replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
  3673.                                         }
  3674.                                         $replacement
  3675.                                                 .removeAttr('name')
  3676.                                                 .data({
  3677.                                                         'placeholder-password': true,
  3678.                                                         'placeholder-id': id
  3679.                                                 })
  3680.                                                 .bind('focus.placeholder', clearPlaceholder);
  3681.                                         $input
  3682.                                                 .data({
  3683.                                                         'placeholder-textinput': $replacement,
  3684.                                                         'placeholder-id': id
  3685.                                                 })
  3686.                                                 .before($replacement);
  3687.                                 }
  3688.                                 $input = $input.removeAttr('id').hide().prev().attr('id', id).show();
  3689.                                 // Note: `$input[0] != input` now!
  3690.                         }
  3691.                         $input.addClass('placeholder');
  3692.                         $input[0].value = $input.attr('placeholder');
  3693.                 } else {
  3694.                         $input.removeClass('placeholder');
  3695.                 }
  3696.         }
  3697.  
  3698. }(this, document, jQuery));
  3699.  
  3700.  
  3701. /**
  3702. * 6.) Isotope Leak Free - https://github.com/khiltd/isotope-leak-free
  3703. */
  3704.  
  3705. /**
  3706.  * Isotope Leak Free
  3707.  *
  3708.  * https://github.com/khiltd/isotope-leak-free
  3709.  *
  3710.  * Forked from Isotope v1.5.21 to stop crashing browsers.
  3711.  *
  3712.  * Original, crashy version by:
  3713.  *
  3714.  * http://isotope.metafizzy.co
  3715.  *
  3716.  * Commercial use requires one-time license fee
  3717.  * http://metafizzy.co/#licenses
  3718.  *
  3719.  * Copyright 2012 David DeSandro / Metafizzy
  3720.  */
  3721. (function(a,b,c){"use strict";var d=a.document,e=a.Modernizr,f=function(a){return a.charAt(0).toUpperCase()+a.slice(1)},g="Moz Webkit O Ms".split(" "),h=function(a){var b=d.documentElement.style,c;if(typeof b[a]=="string")return a;a=f(a);for(var e=0,h=g.length;e<h;e++){c=g[e]+a;if(typeof b[c]=="string")return c}},i=h("transform"),j=h("transitionProperty"),k={csstransforms:function(){return!!i},csstransforms3d:function(){var a=!!h("perspective");if(a){var c=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),d="@media ("+c.join("transform-3d),(")+"modernizr)",e=b("<style>"+d+"{#modernizr{height:3px}}"+"</style>").appendTo("head"),f=b('<div id="modernizr" />').appendTo("html");a=f.height()===3,f.remove(),e.remove()}return a},csstransitions:function(){return!!j}},l;if(e)for(l in k)e.hasOwnProperty(l)||e.addTest(l,k[l]);else{e=a.Modernizr={_version:"1.6ish: miniModernizr for Isotope"};var m=" ",n;for(l in k)n=k[l](),e[l]=n,m+=" "+(n?"":"no-")+l;b("html").addClass(m)}if(e.csstransforms){var o=e.csstransforms3d?{translate:function(a){return"translate3d("+a[0]+"px, "+a[1]+"px, 0) "},scale:function(a){return"scale3d("+a+", "+a+", 1) "}}:{translate:function(a){return"translate("+a[0]+"px, "+a[1]+"px) "},scale:function(a){return"scale("+a+") "}},p=function(a,c,d){var e=b.data(a,"isoTransform")||{},f={},g,h={},j;f[c]=d,b.extend(e,f);for(g in e)j=e[g],h[g]=o[g](j);var k=h.translate||"",l=h.scale||"",m=k+l;b.data(a,"isoTransform",e),a.style[i]=m};b.cssNumber.scale=!0,b.cssHooks.scale={set:function(a,b){p(a,"scale",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.scale?d.scale:1}},b.fx.step.scale=function(a){b.cssHooks.scale.set(a.elem,a.now+a.unit)},b.cssNumber.translate=!0,b.cssHooks.translate={set:function(a,b){p(a,"translate",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.translate?d.translate:[0,0]}}}var q,r;e.csstransitions&&(q={WebkitTransitionProperty:"webkitTransitionEnd",MozTransitionProperty:"transitionend",OTransitionProperty:"oTransitionEnd otransitionend",transitionProperty:"transitionend"}[j],r=h("transitionDuration"));var s=b.event,t;s.special.smartresize={setup:function(){b(this).bind("resize",s.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",s.special.smartresize.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartresize",t&&clearTimeout(t),t=setTimeout(function(){jQuery.event.handle.apply(c,d)},b==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Isotope=function(a,c,d){this.element=b(c),this._create(a),this._init(d)};var u=["width","height"],v=b(a);b.Isotope.settings={resizable:!0,layoutMode:"masonry",containerClass:"isotope",itemClass:"isotope-item",hiddenClass:"isotope-hidden",hiddenStyle:{opacity:0,scale:.001},visibleStyle:{opacity:1,scale:1},containerStyle:{position:"relative",overflow:"hidden"},animationEngine:"best-available",animationOptions:{queue:!1,duration:800},sortBy:"original-order",sortAscending:!0,resizesContainer:!0,transformsEnabled:!0,itemPositionDataEnabled:!1},b.Isotope.prototype={_create:function(a){this.options=b.extend({},b.Isotope.settings,a),this.styleQueue=[],this.elemCount=0;var c=this.element[0].style;this.originalStyle={};var d=u.slice(0);for(var e in this.options.containerStyle)d.push(e);for(var f=0,g=d.length;f<g;f++)e=d[f],this.originalStyle[e]=c[e]||"";this.element.css(this.options.containerStyle),this._updateAnimationEngine(),this._updateUsingTransforms();var h={"original-order":function(a,b){return b.elemCount++,b.elemCount},random:function(){return Math.random()}};this.options.getSortData=b.extend(this.options.getSortData,h),this.reloadItems(),this.offset={left:parseInt(this.element.css("padding-left")||0,10),top:parseInt(this.element.css("padding-top")||0,10)};var i=this;setTimeout(function(){i.element.addClass(i.options.containerClass)},0),this.options.resizable&&v.bind("smartresize.isotope",function(){i.resize()}),this.element.delegate("."+this.options.hiddenClass,"click",function(){return!1})},_expandoSafe:function(a){return delete a.prevObject,a},_getAtoms:function(a){var b=this.options.itemSelector,c=b?a.filter(b).add(a.find(b)):a,d={position:"absolute"};return this.usingTransforms&&(d.left=0,d.top=0),c.css(d).addClass(this.options.itemClass),this.updateSortData(c,!0),c},_init:function(a){this.$filteredAtoms=this._expandoSafe(this._filter(this.$allAtoms)),this._sort(),this.reLayout(a)},option:function(a){if(b.isPlainObject(a)){this.options=b.extend(!0,this.options,a);var c;for(var d in a)c="_update"+f(d),this[c]&&this[c]()}},_updateAnimationEngine:function(){var a=this.options.animationEngine.toLowerCase().replace(/[ _\-]/g,""),b;switch(a){case"css":case"none":b=!1;break;case"jquery":b=!0;break;default:b=!e.csstransitions}this.isUsingJQueryAnimation=b,this._updateUsingTransforms()},_updateTransformsEnabled:function(){this._updateUsingTransforms()},_updateUsingTransforms:function(){var a=this.usingTransforms=this.options.transformsEnabled&&e.csstransforms&&e.csstransitions&&!this.isUsingJQueryAnimation;a||(delete this.options.hiddenStyle.scale,delete this.options.visibleStyle.scale),this.getPositionStyles=a?this._translate:this._positionAbs},_filter:function(a){var b=this.options.filter===""?"*":this.options.filter;if(!b)return a;var c=this.options.hiddenClass,d="."+c,e=a.filter(d),f=e;if(b!=="*"){f=e.filter(b);var g=a.not(d).not(b).addClass(c);this.styleQueue.push({$el:g,style:this.options.hiddenStyle})}return this.styleQueue.push({$el:f,style:this.options.visibleStyle}),f.removeClass(c),a.filter(b)},updateSortData:function(a,c){var d=this,e=this.options.getSortData,f,g;a.each(function(){f=b(this),g={};for(var a in e)!c&&a==="original-order"?g[a]=b.data(this,"isotope-sort-data")[a]:g[a]=e[a](f,d);b.data(this,"isotope-sort-data",g)})},_sort:function(){var a=this.options.sortBy,b=this._getSorter,c=this.options.sortAscending?1:-1,d=function(d,e){var f=b(d,a),g=b(e,a);return f===g&&a!=="original-order"&&(f=b(d,"original-order"),g=b(e,"original-order")),(f>g?1:f<g?-1:0)*c};this.$filteredAtoms.sort(d)},_getSorter:function(a,c){return b.data(a,"isotope-sort-data")[c]},_translate:function(a,b){return{translate:[a,b]}},_positionAbs:function(a,b){return{left:a,top:b}},_pushPosition:function(a,b,c){b=Math.round(b+this.offset.left),c=Math.round(c+this.offset.top);var d=this.getPositionStyles(b,c);this.styleQueue.push({$el:a,style:d}),this.options.itemPositionDataEnabled&&a.data("isotope-item-position",{x:b,y:c})},layout:function(a,b){var c=this.options.layoutMode;this["_"+c+"Layout"](a);if(this.options.resizesContainer){var d=this["_"+c+"GetContainerSize"]();this.styleQueue.push({$el:this.element,style:d})}this._processStyleQueue(a,b),this.isLaidOut=!0},_processStyleQueue:function(a,c){var d=this.isLaidOut?this.isUsingJQueryAnimation?"animate":"css":"css",f=this.options.animationOptions,g=this.options.onLayout,h,i,j,k;i=function(a,b){b.$el[d](b.style,f)};if(this._isInserting&&this.isUsingJQueryAnimation)i=function(a,b){h=b.$el.hasClass("no-transition")?"css":d,b.$el[h](b.style,f)};else if(c||g||f.complete){var l=!1,m=[c,g,f.complete],n=this;j=!0,k=function(){if(l)return;var b;for(var c=0,d=m.length;c<d;c++)b=m[c],typeof b=="function"&&b.call(n.element,a,n);l=!0};if(this.isUsingJQueryAnimation&&d==="animate")f.complete=k,j=!1;else if(e.csstransitions){var o=0,p=this.styleQueue[0],s=p&&p.$el,t;while(!s||!s.length){t=this.styleQueue[o++];if(!t)return;s=t.$el}var u=parseFloat(getComputedStyle(s[0])[r]);u>0&&(i=function(a,b){b.$el[d](b.style,f).one(q,k)},j=!1)}}b.each(this.styleQueue,i),j&&k(),this.styleQueue=[]},resize:function(){this["_"+this.options.layoutMode+"ResizeChanged"]()&&this.reLayout()},reLayout:function(a){this["_"+this.options.layoutMode+"Reset"](),this.layout(this.$filteredAtoms,a)},addItems:function(a,b){var c=this._getAtoms(a);this.$allAtoms=this._expandoSafe(this.$allAtoms.add(c)),b&&b(c)},insert:function(a,b){this.element.append(a);var c=this;this.addItems(a,function(a){var d=c._filter(a);c._addHideAppended(d),c._sort(),c.reLayout(),c._revealAppended(d,b)})},appended:function(a,b){var c=this;this.addItems(a,function(a){c._addHideAppended(a),c.layout(a),c._revealAppended(a,b)})},_addHideAppended:function(a){this.$filteredAtoms=this._expandoSafe(this.$filteredAtoms.add(a)),a.addClass("no-transition"),this._isInserting=!0,this.styleQueue.push({$el:a,style:this.options.hiddenStyle})},_revealAppended:function(a,b){var c=this;setTimeout(function(){a.removeClass("no-transition"),c.styleQueue.push({$el:a,style:c.options.visibleStyle}),c._isInserting=!1,c._processStyleQueue(a,b)},10)},reloadItems:function(){this.$allAtoms=this._expandoSafe(this._getAtoms(this.element.children()))},remove:function(a,b){this.$allAtoms=this._expandoSafe(this.$allAtoms.not(a)),this.$filteredAtoms=this._expandoSafe(this.$filteredAtoms.not(a));var c=this,d=function(){a.remove(),b&&b.call(c.element)};a.filter(":not(."+this.options.hiddenClass+")").length?(this.styleQueue.push({$el:a,style:this.options.hiddenStyle}),this._sort(),this.reLayout(d)):d()},shuffle:function(a){this.updateSortData(this.$allAtoms),this.options.sortBy="random",this._sort(),this.reLayout(a)},destroy:function(){var a=this.usingTransforms,b=this.options;this.$allAtoms.removeClass(b.hiddenClass+" "+b.itemClass).each(function(){var b=this.style;b.position="",b.top="",b.left="",b.opacity="",a&&(b[i]="")});var c=this.element[0].style;for(var d in this.originalStyle)c[d]=this.originalStyle[d];this.element.unbind(".isotope").undelegate("."+b.hiddenClass,"click").removeClass(b.containerClass).removeData("isotope"),v.unbind(".isotope")},_getSegments:function(a){var b=this.options.layoutMode,c=a?"rowHeight":"columnWidth",d=a?"height":"width",e=a?"rows":"cols",g=this.element[d](),h,i=this.options[b]&&this.options[b][c]||this.$filteredAtoms["outer"+f(d)](!0)||g;h=Math.floor(g/i),h=Math.max(h,1),this[b][e]=h,this[b][c]=i},_checkIfSegmentsChanged:function(a){var b=this.options.layoutMode,c=a?"rows":"cols",d=this[b][c];return this._getSegments(a),this[b][c]!==d},_masonryReset:function(){this.masonry={},this._getSegments();var a=this.masonry.cols;this.masonry.colYs=[];while(a--)this.masonry.colYs.push(0)},_masonryLayout:function(a){var c=this,d=c.masonry;a.each(function(){var a=b(this),e=Math.ceil(a.outerWidth(!0)/d.columnWidth);e=Math.min(e,d.cols);if(e===1)c._masonryPlaceBrick(a,d.colYs);else{var f=d.cols+1-e,g=[],h,i;for(i=0;i<f;i++)h=d.colYs.slice(i,i+e),g[i]=Math.max.apply(Math,h);c._masonryPlaceBrick(a,g)}})},_masonryPlaceBrick:function(a,b){var c=Math.min.apply(Math,b),d=0;for(var e=0,f=b.length;e<f;e++)if(b[e]===c){d=e;break}var g=this.masonry.columnWidth*d,h=c;this._pushPosition(a,g,h);var i=c+a.outerHeight(!0),j=this.masonry.cols+1-f;for(e=0;e<j;e++)this.masonry.colYs[d+e]=i},_masonryGetContainerSize:function(){var a=Math.max.apply(Math,this.masonry.colYs);return{height:a}},_masonryResizeChanged:function(){return this._checkIfSegmentsChanged()},_fitRowsReset:function(){this.fitRows={x:0,y:0,height:0}},_fitRowsLayout:function(a){var c=this,d=this.element.width(),e=this.fitRows;a.each(function(){var a=b(this),f=a.outerWidth(!0),g=a.outerHeight(!0);e.x!==0&&f+e.x>d&&(e.x=0,e.y=e.height),c._pushPosition(a,e.x,e.y),e.height=Math.max(e.y+g,e.height),e.x+=f})},_fitRowsGetContainerSize:function(){return{height:this.fitRows.height}},_fitRowsResizeChanged:function(){return!0},_cellsByRowReset:function(){this.cellsByRow={index:0},this._getSegments(),this._getSegments(!0)},_cellsByRowLayout:function(a){var c=this,d=this.cellsByRow;a.each(function(){var a=b(this),e=d.index%d.cols,f=Math.floor(d.index/d.cols),g=(e+.5)*d.columnWidth-a.outerWidth(!0)/2,h=(f+.5)*d.rowHeight-a.outerHeight(!0)/2;c._pushPosition(a,g,h),d.index++})},_cellsByRowGetContainerSize:function(){return{height:Math.ceil(this.$filteredAtoms.length/this.cellsByRow.cols)*this.cellsByRow.rowHeight+this.offset.top}},_cellsByRowResizeChanged:function(){return this._checkIfSegmentsChanged()},_straightDownReset:function(){this.straightDown={y:0}},_straightDownLayout:function(a){var c=this;a.each(function(a){var d=b(this);c._pushPosition(d,0,c.straightDown.y),c.straightDown.y+=d.outerHeight(!0)})},_straightDownGetContainerSize:function(){return{height:this.straightDown.y}},_straightDownResizeChanged:function(){return!0},_masonryHorizontalReset:function(){this.masonryHorizontal={},this._getSegments(!0);var a=this.masonryHorizontal.rows;this.masonryHorizontal.rowXs=[];while(a--)this.masonryHorizontal.rowXs.push(0)},_masonryHorizontalLayout:function(a){var c=this,d=c.masonryHorizontal;a.each(function(){var a=b(this),e=Math.ceil(a.outerHeight(!0)/d.rowHeight);e=Math.min(e,d.rows);if(e===1)c._masonryHorizontalPlaceBrick(a,d.rowXs);else{var f=d.rows+1-e,g=[],h,i;for(i=0;i<f;i++)h=d.rowXs.slice(i,i+e),g[i]=Math.max.apply(Math,h);c._masonryHorizontalPlaceBrick(a,g)}})},_masonryHorizontalPlaceBrick:function(a,b){var c=Math.min.apply(Math,b),d=0;for(var e=0,f=b.length;e<f;e++)if(b[e]===c){d=e;break}var g=c,h=this.masonryHorizontal.rowHeight*d;this._pushPosition(a,g,h);var i=c+a.outerWidth(!0),j=this.masonryHorizontal.rows+1-f;for(e=0;e<j;e++)this.masonryHorizontal.rowXs[d+e]=i},_masonryHorizontalGetContainerSize:function(){var a=Math.max.apply(Math,this.masonryHorizontal.rowXs);return{width:a}},_masonryHorizontalResizeChanged:function(){return this._checkIfSegmentsChanged(!0)},_fitColumnsReset:function(){this.fitColumns={x:0,y:0,width:0}},_fitColumnsLayout:function(a){var c=this,d=this.element.height(),e=this.fitColumns;a.each(function(){var a=b(this),f=a.outerWidth(!0),g=a.outerHeight(!0);e.y!==0&&g+e.y>d&&(e.x=e.width,e.y=0),c._pushPosition(a,e.x,e.y),e.width=Math.max(e.x+f,e.width),e.y+=g})},_fitColumnsGetContainerSize:function(){return{width:this.fitColumns.width}},_fitColumnsResizeChanged:function(){return!0},_cellsByColumnReset:function(){this.cellsByColumn={index:0},this._getSegments(),this._getSegments(!0)},_cellsByColumnLayout:function(a){var c=this,d=this.cellsByColumn;a.each(function(){var a=b(this),e=Math.floor(d.index/d.rows),f=d.index%d.rows,g=(e+.5)*d.columnWidth-a.outerWidth(!0)/2,h=(f+.5)*d.rowHeight-a.outerHeight(!0)/2;c._pushPosition(a,g,h),d.index++})},_cellsByColumnGetContainerSize:function(){return{width:Math.ceil(this.$filteredAtoms.length/this.cellsByColumn.rows)*this.cellsByColumn.columnWidth}},_cellsByColumnResizeChanged:function(){return this._checkIfSegmentsChanged(!0)},_straightAcrossReset:function(){this.straightAcross={x:0}},_straightAcrossLayout:function(a){var c=this;a.each(function(a){var d=b(this);c._pushPosition(d,c.straightAcross.x,0),c.straightAcross.x+=d.outerWidth(!0)})},_straightAcrossGetContainerSize:function(){return{width:this.straightAcross.x}},_straightAcrossResizeChanged:function(){return!0}},b.fn.imagesLoaded=function(a){function h(){a.call(c,d)}function i(a){var c=a.target;c.src!==f&&b.inArray(c,g)===-1&&(g.push(c),--e<=0&&(setTimeout(h),d.unbind(".imagesLoaded",i)))}var c=this,d=c.find("img").add(c.filter("img")),e=d.length,f="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",g=[];return e||h(),d.bind("load.imagesLoaded error.imagesLoaded",i).each(function(){var a=this.src;this.src=f,this.src=a}),c};var w=function(b){a.console&&a.console.error(b)};b.fn.isotope=function(a,c){if(typeof a=="string"){var d=Array.prototype.slice.call(arguments,1);this.each(function(){var c=b.data(this,"isotope");if(!c){w("cannot call methods on isotope prior to initialization; attempted to call method '"+a+"'");return}if(!b.isFunction(c[a])||a.charAt(0)==="_"){w("no such method '"+a+"' for isotope instance");return}c[a].apply(c,d)})}else this.each(function(){var d=b.data(this,"isotope");d?(d.option(a),d._init(c)):b.data(this,"isotope",new b.Isotope(a,this,c))});return this}})(window,jQuery);
  3722.  
  3723.  
  3724. // Isotope init
  3725. // ------------------
  3726.  
  3727. $(document).on('ready pjax:success', function() {
  3728.  
  3729.     $(function () {
  3730.  
  3731.         var $isotopeContainer = $('#isotope-team');
  3732.  
  3733.         $isotopeContainer.isotope({
  3734.             // options
  3735.             //filter: '.metal',
  3736.             itemSelector : '.item'
  3737.         });
  3738.  
  3739.         var $optionSets = $('#filters'),
  3740.                 $optionLinks = $optionSets.find('a');
  3741.  
  3742.         // filter Meet the Team items when filter link is clicked
  3743.         $optionLinks.click(function(){
  3744.             var $this = $(this);
  3745.             // don't proceed if already selected
  3746.             if ( $this.hasClass('selected') ) {
  3747.                 return false;
  3748.             }
  3749.             $optionSets.find('.selected').removeClass('selected');
  3750.             $this.addClass('selected');
  3751.             var selector = $this.attr('data-filter');
  3752.             $isotopeContainer.isotope({ filter: selector });
  3753.             return false;
  3754.         });
  3755.  
  3756.     });
  3757.  
  3758. });
  3759.  
  3760. /**
  3761. * 7.) jquery.pjax.js - https://github.com/defunkt/jquery-pjax
  3762. */
  3763.  
  3764. // jquery.pjax.js
  3765. // copyright chris wanstrath
  3766. // https://github.com/defunkt/jquery-pjax
  3767.  
  3768. (function($){
  3769.  
  3770. // When called on a container with a selector, fetches the href with
  3771. // ajax into the container or with the data-pjax attribute on the link
  3772. // itself.
  3773. //
  3774. // Tries to make sure the back button and ctrl+click work the way
  3775. // you'd expect.
  3776. //
  3777. // Exported as $.fn.pjax
  3778. //
  3779. // Accepts a jQuery ajax options object that may include these
  3780. // pjax specific options:
  3781. //
  3782. //
  3783. // container - Where to stick the response body. Usually a String selector.
  3784. //                       $(container).html(xhr.responseBody)
  3785. //                       (default: current jquery context)
  3786. //          push - Whether to pushState the URL. Defaults to true (of course).
  3787. //   replace - Want to use replaceState instead? That's cool.
  3788. //
  3789. // For convenience the second parameter can be either the container or
  3790. // the options object.
  3791. //
  3792. // Returns the jQuery object
  3793. function fnPjax(selector, container, options) {
  3794.     var context = this
  3795.     return this.on('click.pjax', selector, function(event) {
  3796.         var opts = $.extend({}, optionsFor(container, options))
  3797.         if (!opts.container)
  3798.             opts.container = $(this).attr('data-pjax') || context
  3799.         handleClick(event, opts)
  3800.     })
  3801. }
  3802.  
  3803. // Public: pjax on click handler
  3804. //
  3805. // Exported as $.pjax.click.
  3806. //
  3807. // event     - "click" jQuery.Event
  3808. // options - pjax options
  3809. //
  3810. // Examples
  3811. //
  3812. //   $(document).on('click', 'a', $.pjax.click)
  3813. //   // is the same as
  3814. //   $(document).pjax('a')
  3815. //
  3816. //  $(document).on('click', 'a', function(event) {
  3817. //      var container = $(this).closest('[data-pjax-container]')
  3818. //      $.pjax.click(event, container)
  3819. //  })
  3820. //
  3821. // Returns nothing.
  3822. function handleClick(event, container, options) {
  3823.     options = optionsFor(container, options)
  3824.  
  3825.     var link = event.currentTarget
  3826.  
  3827.     if (link.tagName.toUpperCase() !== 'A')
  3828.         throw "$.fn.pjax or $.pjax.click requires an anchor element"
  3829.  
  3830.     // Middle click, cmd click, and ctrl click should open
  3831.     // links in a new tab as normal.
  3832.     if ( event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey )
  3833.         return
  3834.  
  3835.     // Ignore cross origin links
  3836.     if ( location.protocol !== link.protocol || location.host !== link.host )
  3837.         return
  3838.  
  3839.     // Ignore anchors on the same page
  3840.     if (link.hash && link.href.replace(link.hash, '') ===
  3841.              location.href.replace(location.hash, ''))
  3842.         return
  3843.  
  3844.     // Ignore empty anchor "foo.html#"
  3845.     if (link.href === location.href + '#')
  3846.         return
  3847.  
  3848.     var defaults = {
  3849.         url: link.href,
  3850.         container: $(link).attr('data-pjax'),
  3851.         target: link,
  3852.         fragment: null
  3853.     }
  3854.  
  3855.     pjax($.extend({}, defaults, options))
  3856.  
  3857.     event.preventDefault()
  3858. }
  3859.  
  3860. // Public: pjax on form submit handler
  3861. //
  3862. // Exported as $.pjax.submit
  3863. //
  3864. // event     - "click" jQuery.Event
  3865. // options - pjax options
  3866. //
  3867. // Examples
  3868. //
  3869. //  $(document).on('submit', 'form', function(event) {
  3870. //      var container = $(this).closest('[data-pjax-container]')
  3871. //      $.pjax.submit(event, container)
  3872. //  })
  3873. //
  3874. // Returns nothing.
  3875. function handleSubmit(event, container, options) {
  3876.     options = optionsFor(container, options)
  3877.  
  3878.     var form = event.currentTarget
  3879.  
  3880.     if (form.tagName.toUpperCase() !== 'FORM')
  3881.         throw "$.pjax.submit requires a form element"
  3882.  
  3883.     var defaults = {
  3884.         type: form.method,
  3885.         url: form.action,
  3886.         data: $(form).serializeArray(),
  3887.         container: $(form).attr('data-pjax'),
  3888.         target: form,
  3889.         fragment: null
  3890.     }
  3891.  
  3892.     pjax($.extend({}, defaults, options))
  3893.  
  3894.     event.preventDefault()
  3895. }
  3896.  
  3897. // Loads a URL with ajax, puts the response body inside a container,
  3898. // then pushState()'s the loaded URL.
  3899. //
  3900. // Works just like $.ajax in that it accepts a jQuery ajax
  3901. // settings object (with keys like url, type, data, etc).
  3902. //
  3903. // Accepts these extra keys:
  3904. //
  3905. // container - Where to stick the response body.
  3906. //                       $(container).html(xhr.responseBody)
  3907. //          push - Whether to pushState the URL. Defaults to true (of course).
  3908. //   replace - Want to use replaceState instead? That's cool.
  3909. //
  3910. // Use it just like $.ajax:
  3911. //
  3912. //   var xhr = $.pjax({ url: this.href, container: '#main' })
  3913. //   console.log( xhr.readyState )
  3914. //
  3915. // Returns whatever $.ajax returns.
  3916. function pjax(options) {
  3917.     options = $.extend(true, {}, $.ajaxSettings, pjax.defaults, options)
  3918.  
  3919.     if ($.isFunction(options.url)) {
  3920.         options.url = options.url()
  3921.     }
  3922.  
  3923.     var target = options.target
  3924.  
  3925.     var hash = parseURL(options.url).hash
  3926.  
  3927.     var context = options.context = findContainerFor(options.container)
  3928.  
  3929.     // We want the browser to maintain two separate internal caches: one
  3930.     // for pjax'd partial page loads and one for normal page loads.
  3931.     // Without adding this secret parameter, some browsers will often
  3932.     // confuse the two.
  3933.     if (!options.data) options.data = {}
  3934.     options.data._pjax = context.selector
  3935.  
  3936.     function fire(type, args) {
  3937.         var event = $.Event(type, { relatedTarget: target })
  3938.         context.trigger(event, args)
  3939.         return !event.isDefaultPrevented()
  3940.     }
  3941.  
  3942.     var timeoutTimer
  3943.  
  3944.     options.beforeSend = function(xhr, settings) {
  3945.         // No timeout for non-GET requests
  3946.         // Its not safe to request the resource again with a fallback method.
  3947.         if (settings.type !== 'GET') {
  3948.             settings.timeout = 0
  3949.         }
  3950.  
  3951.         xhr.setRequestHeader('X-PJAX', 'true')
  3952.         xhr.setRequestHeader('X-PJAX-Container', context.selector)
  3953.  
  3954.         var result
  3955.  
  3956.         if (!fire('pjax:beforeSend', [xhr, settings]))
  3957.             return false
  3958.  
  3959.         if (settings.timeout > 0) {
  3960.             timeoutTimer = setTimeout(function() {
  3961.                 if (fire('pjax:timeout', [xhr, options]))
  3962.                     xhr.abort('timeout')
  3963.             }, settings.timeout)
  3964.  
  3965.             // Clear timeout setting so jquerys internal timeout isn't invoked
  3966.             settings.timeout = 0
  3967.         }
  3968.  
  3969.         options.requestUrl = parseURL(settings.url).href
  3970.     }
  3971.  
  3972.     options.complete = function(xhr, textStatus) {
  3973.         if (timeoutTimer)
  3974.             clearTimeout(timeoutTimer)
  3975.  
  3976.         fire('pjax:complete', [xhr, textStatus, options])
  3977.  
  3978.         fire('pjax:end', [xhr, options])
  3979.     }
  3980.  
  3981.     options.error = function(xhr, textStatus, errorThrown) {
  3982.         var container = extractContainer("", xhr, options)
  3983.  
  3984.         var allowed = fire('pjax:error', [xhr, textStatus, errorThrown, options])
  3985.         if (options.type == 'GET' && textStatus !== 'abort' && allowed) {
  3986.             locationReplace(container.url)
  3987.         }
  3988.     }
  3989.  
  3990.     options.success = function(data, status, xhr) {
  3991.         var container = extractContainer(data, xhr, options)
  3992.  
  3993.         if (!container.contents) {
  3994.             locationReplace(container.url)
  3995.             return
  3996.         }
  3997.  
  3998.         pjax.state = {
  3999.             id: options.id || uniqueId(),
  4000.             url: container.url,
  4001.             title: container.title,
  4002.             container: context.selector,
  4003.             fragment: options.fragment,
  4004.             timeout: options.timeout
  4005.         }
  4006.  
  4007.         if (options.push || options.replace) {
  4008.             window.history.replaceState(pjax.state, container.title, container.url)
  4009.         }
  4010.  
  4011.         if (container.title) document.title = container.title
  4012.         context.html(container.contents)
  4013.  
  4014.         // Scroll to top by default
  4015.         if (typeof options.scrollTo === 'number')
  4016.             $(window).scrollTop(options.scrollTo)
  4017.  
  4018.         // Google Analytics support
  4019.         if ( (options.replace || options.push) && window._gaq )
  4020.             _gaq.push(['_trackPageview'])
  4021.  
  4022.         // If the URL has a hash in it, make sure the browser
  4023.         // knows to navigate to the hash.
  4024.         if ( hash !== '' ) {
  4025.             // Avoid using simple hash set here. Will add another history
  4026.             // entry. Replace the url with replaceState and scroll to target
  4027.             // by hand.
  4028.             //
  4029.             //   window.location.hash = hash
  4030.             var url = parseURL(container.url)
  4031.             url.hash = hash
  4032.  
  4033.             pjax.state.url = url.href
  4034.             window.history.replaceState(pjax.state, container.title, url.href)
  4035.  
  4036.             var target = $(url.hash)
  4037.             if (target.length) $(window).scrollTop(target.offset().top)
  4038.         }
  4039.  
  4040.         fire('pjax:success', [data, status, xhr, options])
  4041.     }
  4042.  
  4043.  
  4044.     // Initialize pjax.state for the initial page load. Assume we're
  4045.     // using the container and options of the link we're loading for the
  4046.     // back button to the initial page. This ensures good back button
  4047.     // behavior.
  4048.     if (!pjax.state) {
  4049.         pjax.state = {
  4050.             id: uniqueId(),
  4051.             url: window.location.href,
  4052.             title: document.title,
  4053.             container: context.selector,
  4054.             fragment: options.fragment,
  4055.             timeout: options.timeout
  4056.         }
  4057.         window.history.replaceState(pjax.state, document.title)
  4058.     }
  4059.  
  4060.     // Cancel the current request if we're already pjaxing
  4061.     var xhr = pjax.xhr
  4062.     if ( xhr && xhr.readyState < 4) {
  4063.         xhr.onreadystatechange = $.noop
  4064.         xhr.abort()
  4065.     }
  4066.  
  4067.     pjax.options = options
  4068.     var xhr = pjax.xhr = $.ajax(options)
  4069.  
  4070.     if (xhr.readyState > 0) {
  4071.         if (options.push && !options.replace) {
  4072.             // Cache current container element before replacing it
  4073.             cachePush(pjax.state.id, context.clone().contents())
  4074.  
  4075.             window.history.pushState(null, "", stripPjaxParam(options.requestUrl))
  4076.         }
  4077.  
  4078.         fire('pjax:start', [xhr, options])
  4079.         fire('pjax:send', [xhr, options])
  4080.     }
  4081.  
  4082.     return pjax.xhr
  4083. }
  4084.  
  4085. // Public: Reload current page with pjax.
  4086. //
  4087. // Returns whatever $.pjax returns.
  4088. function pjaxReload(container, options) {
  4089.     var defaults = {
  4090.         url: window.location.href,
  4091.         push: false,
  4092.         replace: true,
  4093.         scrollTo: false
  4094.     }
  4095.  
  4096.     return pjax($.extend(defaults, optionsFor(container, options)))
  4097. }
  4098.  
  4099. // Internal: Hard replace current state with url.
  4100. //
  4101. // Work for around WebKit
  4102. //   https://bugs.webkit.org/show_bug.cgi?id=93506
  4103. //
  4104. // Returns nothing.
  4105. function locationReplace(url) {
  4106.     window.history.replaceState(null, "", "#")
  4107.     window.location.replace(url)
  4108. }
  4109.  
  4110. // popstate handler takes care of the back and forward buttons
  4111. //
  4112. // You probably shouldn't use pjax on pages with other pushState
  4113. // stuff yet.
  4114. function onPjaxPopstate(event) {
  4115.     var state = event.state
  4116.  
  4117.     if (state && state.container) {
  4118.         var container = $(state.container)
  4119.         if (container.length) {
  4120.             var contents = cacheMapping[state.id]
  4121.  
  4122.             if (pjax.state) {
  4123.                 // Since state ids always increase, we can deduce the history
  4124.                 // direction from the previous state.
  4125.                 var direction = pjax.state.id < state.id ? 'forward' : 'back'
  4126.  
  4127.                 // Cache current container before replacement and inform the
  4128.                 // cache which direction the history shifted.
  4129.                 cachePop(direction, pjax.state.id, container.clone().contents())
  4130.             } else {
  4131.                 // Page was reloaded but we have an existing history entry.
  4132.                 // Set it to our initial state.
  4133.                 pjax.state = state;
  4134.                 return;
  4135.             }
  4136.  
  4137.             var popstateEvent = $.Event('pjax:popstate', {
  4138.                 state: state,
  4139.                 direction: direction
  4140.             })
  4141.             container.trigger(popstateEvent)
  4142.  
  4143.             var options = {
  4144.                 id: state.id,
  4145.                 url: state.url,
  4146.                 container: container,
  4147.                 push: false,
  4148.                 fragment: state.fragment,
  4149.                 timeout: state.timeout,
  4150.                 scrollTo: false
  4151.             }
  4152.  
  4153.             if (contents) {
  4154.                 container.trigger('pjax:start', [null, options])
  4155.  
  4156.                 if (state.title) document.title = state.title
  4157.                 container.html(contents)
  4158.                 pjax.state = state
  4159.  
  4160.                 container.trigger('pjax:end', [null, options])
  4161.             } else {
  4162.                 pjax(options)
  4163.             }
  4164.  
  4165.             // Force reflow/relayout before the browser tries to restore the
  4166.             // scroll position.
  4167.             container[0].offsetHeight
  4168.         } else {
  4169.             locationReplace(location.href)
  4170.         }
  4171.     }
  4172. }
  4173.  
  4174. // Fallback version of main pjax function for browsers that don't
  4175. // support pushState.
  4176. //
  4177. // Returns nothing since it retriggers a hard form submission.
  4178. function fallbackPjax(options) {
  4179.     var url = $.isFunction(options.url) ? options.url() : options.url,
  4180.             method = options.type ? options.type.toUpperCase() : 'GET'
  4181.  
  4182.     var form = $('<form>', {
  4183.         method: method === 'GET' ? 'GET' : 'POST',
  4184.         action: url,
  4185.         style: 'display:none'
  4186.     })
  4187.  
  4188.     if (method !== 'GET' && method !== 'POST') {
  4189.         form.append($('<input>', {
  4190.             type: 'hidden',
  4191.             name: '_method',
  4192.             value: method.toLowerCase()
  4193.         }))
  4194.     }
  4195.  
  4196.     var data = options.data
  4197.     if (typeof data === 'string') {
  4198.         $.each(data.split('&'), function(index, value) {
  4199.             var pair = value.split('=')
  4200.             form.append($('<input>', {type: 'hidden', name: pair[0], value: pair[1]}))
  4201.         })
  4202.     } else if (typeof data === 'object') {
  4203.         for (key in data)
  4204.             form.append($('<input>', {type: 'hidden', name: key, value: data[key]}))
  4205.     }
  4206.  
  4207.     $(document.body).append(form)
  4208.     form.submit()
  4209. }
  4210.  
  4211. // Internal: Generate unique id for state object.
  4212. //
  4213. // Use a timestamp instead of a counter since ids should still be
  4214. // unique across page loads.
  4215. //
  4216. // Returns Number.
  4217. function uniqueId() {
  4218.     return (new Date).getTime()
  4219. }
  4220.  
  4221. // Internal: Strips _pjax param from url
  4222. //
  4223. // url - String
  4224. //
  4225. // Returns String.
  4226. function stripPjaxParam(url) {
  4227.     return url
  4228.         .replace(/\?_pjax=[^&]+&?/, '?')
  4229.         .replace(/_pjax=[^&]+&?/, '')
  4230.         .replace(/[\?&]$/, '')
  4231. }
  4232.  
  4233. // Internal: Parse URL components and returns a Locationish object.
  4234. //
  4235. // url - String URL
  4236. //
  4237. // Returns HTMLAnchorElement that acts like Location.
  4238. function parseURL(url) {
  4239.     var a = document.createElement('a')
  4240.     a.href = url
  4241.     return a
  4242. }
  4243.  
  4244. // Internal: Build options Object for arguments.
  4245. //
  4246. // For convenience the first parameter can be either the container or
  4247. // the options object.
  4248. //
  4249. // Examples
  4250. //
  4251. //   optionsFor('#container')
  4252. //   // => {container: '#container'}
  4253. //
  4254. //   optionsFor('#container', {push: true})
  4255. //   // => {container: '#container', push: true}
  4256. //
  4257. //   optionsFor({container: '#container', push: true})
  4258. //   // => {container: '#container', push: true}
  4259. //
  4260. // Returns options Object.
  4261. function optionsFor(container, options) {
  4262.     // Both container and options
  4263.     if ( container && options )
  4264.         options.container = container
  4265.  
  4266.     // First argument is options Object
  4267.     else if ( $.isPlainObject(container) )
  4268.         options = container
  4269.  
  4270.     // Only container
  4271.     else
  4272.         options = {container: container}
  4273.  
  4274.     // Find and validate container
  4275.     if (options.container)
  4276.         options.container = findContainerFor(options.container)
  4277.  
  4278.     return options
  4279. }
  4280.  
  4281. // Internal: Find container element for a variety of inputs.
  4282. //
  4283. // Because we can't persist elements using the history API, we must be
  4284. // able to find a String selector that will consistently find the Element.
  4285. //
  4286. // container - A selector String, jQuery object, or DOM Element.
  4287. //
  4288. // Returns a jQuery object whose context is `document` and has a selector.
  4289. function findContainerFor(container) {
  4290.     container = $(container)
  4291.  
  4292.     if ( !container.length ) {
  4293.         throw "no pjax container for " + container.selector
  4294.     } else if ( container.selector !== '' && container.context === document ) {
  4295.         return container
  4296.     } else if ( container.attr('id') ) {
  4297.         return $('#' + container.attr('id'))
  4298.     } else {
  4299.         throw "cant get selector for pjax container!"
  4300.     }
  4301. }
  4302.  
  4303. // Internal: Filter and find all elements matching the selector.
  4304. //
  4305. // Where $.fn.find only matches descendants, findAll will test all the
  4306. // top level elements in the jQuery object as well.
  4307. //
  4308. // elems        - jQuery object of Elements
  4309. // selector - String selector to match
  4310. //
  4311. // Returns a jQuery object.
  4312. function findAll(elems, selector) {
  4313.     return elems.filter(selector).add(elems.find(selector));
  4314. }
  4315.  
  4316. // Internal: Extracts container and metadata from response.
  4317. //
  4318. // 1. Extracts X-PJAX-URL header if set
  4319. // 2. Extracts inline <title> tags
  4320. // 3. Builds response Element and extracts fragment if set
  4321. //
  4322. // data     - String response data
  4323. // xhr       - XHR response
  4324. // options - pjax options Object
  4325. //
  4326. // Returns an Object with url, title, and contents keys.
  4327. function extractContainer(data, xhr, options) {
  4328.     var obj = {}
  4329.  
  4330.     // Prefer X-PJAX-URL header if it was set, otherwise fallback to
  4331.     // using the original requested url.
  4332.     obj.url = stripPjaxParam(xhr.getResponseHeader('X-PJAX-URL') || options.requestUrl)
  4333.  
  4334.     // Attempt to parse response html into elements
  4335.     if (/<html/i.test(data)) {
  4336.         var $head = $(data.match(/<head[^>]*>([\s\S.]*)<\/head>/i)[0])
  4337.         var $body = $(data.match(/<body[^>]*>([\s\S.]*)<\/body>/i)[0])
  4338.     } else {
  4339.         var $head = $body = $(data)
  4340.     }
  4341.  
  4342.     // If response data is empty, return fast
  4343.     if ($body.length === 0)
  4344.         return obj
  4345.  
  4346.     // If there's a <title> tag in the header, use it as
  4347.     // the page's title.
  4348.     obj.title = findAll($head, 'title').last().text()
  4349.  
  4350.     if (options.fragment) {
  4351.         // If they specified a fragment, look for it in the response
  4352.         // and pull it out.
  4353.         if (options.fragment === 'body') {
  4354.             var $fragment = $body
  4355.         } else {
  4356.             var $fragment = findAll($body, options.fragment).first()
  4357.         }
  4358.  
  4359.         if ($fragment.length) {
  4360.             obj.contents = $fragment.contents()
  4361.  
  4362.             // If there's no title, look for data-title and title attributes
  4363.             // on the fragment
  4364.             if (!obj.title)
  4365.                 obj.title = $fragment.attr('title') || $fragment.data('title')
  4366.         }
  4367.  
  4368.     } else if (!/<html/i.test(data)) {
  4369.         obj.contents = $body
  4370.     }
  4371.  
  4372.     // Clean up any <title> tags
  4373.     if (obj.contents) {
  4374.         // Remove any parent title elements
  4375.         obj.contents = obj.contents.not('title')
  4376.  
  4377.         // Then scrub any titles from their descendents
  4378.         obj.contents.find('title').remove()
  4379.     }
  4380.  
  4381.     // Trim any whitespace off the title
  4382.     if (obj.title) obj.title = $.trim(obj.title)
  4383.  
  4384.     return obj
  4385. }
  4386.  
  4387. // Internal: History DOM caching class.
  4388. var cacheMapping            = {}
  4389. var cacheForwardStack = []
  4390. var cacheBackStack      = []
  4391.  
  4392. // Push previous state id and container contents into the history
  4393. // cache. Should be called in conjunction with `pushState` to save the
  4394. // previous container contents.
  4395. //
  4396. // id       - State ID Number
  4397. // value - DOM Element to cache
  4398. //
  4399. // Returns nothing.
  4400. function cachePush(id, value) {
  4401.     cacheMapping[id] = value
  4402.     cacheBackStack.push(id)
  4403.  
  4404.     // Remove all entires in forward history stack after pushing
  4405.     // a new page.
  4406.     while (cacheForwardStack.length)
  4407.         delete cacheMapping[cacheForwardStack.shift()]
  4408.  
  4409.     // Trim back history stack to max cache length.
  4410.     while (cacheBackStack.length > pjax.defaults.maxCacheLength)
  4411.         delete cacheMapping[cacheBackStack.shift()]
  4412. }
  4413.  
  4414. // Shifts cache from directional history cache. Should be
  4415. // called on `popstate` with the previous state id and container
  4416. // contents.
  4417. //
  4418. // direction - "forward" or "back" String
  4419. // id               - State ID Number
  4420. // value         - DOM Element to cache
  4421. //
  4422. // Returns nothing.
  4423. function cachePop(direction, id, value) {
  4424.     var pushStack, popStack
  4425.     cacheMapping[id] = value
  4426.  
  4427.     if (direction === 'forward') {
  4428.         pushStack = cacheBackStack
  4429.         popStack    = cacheForwardStack
  4430.     } else {
  4431.         pushStack = cacheForwardStack
  4432.         popStack    = cacheBackStack
  4433.     }
  4434.  
  4435.     pushStack.push(id)
  4436.     if (id = popStack.pop())
  4437.         delete cacheMapping[id]
  4438. }
  4439.  
  4440. // Install pjax functions on $.pjax to enable pushState behavior.
  4441. //
  4442. // Does nothing if already enabled.
  4443. //
  4444. // Examples
  4445. //
  4446. //       $.pjax.enable()
  4447. //
  4448. // Returns nothing.
  4449. function enable() {
  4450.     $.fn.pjax = fnPjax
  4451.     $.pjax = pjax
  4452.     $.pjax.enable = $.noop
  4453.     $.pjax.disable = disable
  4454.     $.pjax.click = handleClick
  4455.     $.pjax.submit = handleSubmit
  4456.     $.pjax.reload = pjaxReload
  4457.     $.pjax.defaults = {
  4458.         timeout: 2000,
  4459.         push: true,
  4460.         replace: false,
  4461.         type: 'GET',
  4462.         dataType: 'html',
  4463.         scrollTo: 0,
  4464.         maxCacheLength: 20
  4465.     }
  4466.     $(window).bind('popstate.pjax', onPjaxPopstate)
  4467. }
  4468.  
  4469. // Disable pushState behavior.
  4470. //
  4471. // This is the case when a browser doesn't support pushState. It is
  4472. // sometimes useful to disable pushState for debugging on a modern
  4473. // browser.
  4474. //
  4475. // Examples
  4476. //
  4477. //       $.pjax.disable()
  4478. //
  4479. // Returns nothing.
  4480. function disable() {
  4481.     $.fn.pjax = function() { return this }
  4482.     $.pjax = fallbackPjax
  4483.     $.pjax.enable = enable
  4484.     $.pjax.disable = $.noop
  4485.     $.pjax.click = $.noop
  4486.     $.pjax.submit = $.noop
  4487.     $.pjax.reload = function() { window.location.reload() }
  4488.  
  4489.     $(window).unbind('popstate.pjax', onPjaxPopstate)
  4490. }
  4491.  
  4492.  
  4493. // Add the state property to jQuery's event object so we can use it in
  4494. // $(window).bind('popstate')
  4495. if ( $.inArray('state', $.event.props) < 0 )
  4496.     $.event.props.push('state')
  4497.  
  4498.  // Is pjax supported by this browser?
  4499. $.support.pjax =
  4500.     window.history && window.history.pushState && window.history.replaceState &&
  4501.     // pushState isn't reliable on iOS until 5.
  4502.     !navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]|WebApps\/.+CFNetwork)/)
  4503.  
  4504. $.support.pjax ? enable() : disable()
  4505.  
  4506. })(jQuery);
  4507.  
  4508. // LOAD DISQUS FUNCTION
  4509. function loadDisqus() {
  4510.     var disqus_shortname = 'redstormentertainment';
  4511.     $.ajax({
  4512.         url: 'http://redstormentertainment.disqus.com/embed.js',
  4513.         dataType: 'script',
  4514.         cache: true // otherwise will get fresh copy every page load
  4515.     });
  4516. }
  4517.  
  4518. // LOAD SOCIALITE FUNCTION
  4519. function loadSocialite() {
  4520.     $.ajax({
  4521.         url: '//www.redstorm.com/js/libs/socialite.custom.min.js?v=1.0.1',
  4522.         dataType: 'script',
  4523.         async: true,
  4524.         cache: true, // otherwise will get fresh copy every page load
  4525.         success: function() {
  4526.                 // script loaded, do stuff!
  4527.             /* * * LOAD SOCIAL MEDIA SHARING BUTTONS * * */
  4528.             Socialite.load('#socialite');
  4529.             /* * * INITIATE FACEBOOK RECENT ACTIVITY WIDGET * * */
  4530.             if (typeof(FB) != 'undefined'
  4531.                  && FB != null ) {
  4532.                 FB.XFBML.parse(document.getElementById('news'));
  4533.             }
  4534.         }
  4535.     });
  4536. }
  4537.  
  4538. // LOAD ONLY FACEBOOK SDK
  4539. function loadFacebookSDK() {
  4540.     $.ajax({
  4541.         url: 'http://connect.facebook.net/en_US/all.js',
  4542.         dataType: 'script',
  4543.         cache: true, // otherwise will get fresh copy every page load
  4544.         success: function () {
  4545.             /* * * INITIATE FACEBOOK RECENT ACTIVITY WIDGET * * */
  4546.             if (typeof(FB) != 'undefined'
  4547.                  && FB != null ) {
  4548.                 FB.XFBML.parse(document.getElementById('fb-activity'));
  4549.             }
  4550.         }
  4551.     });
  4552. }
  4553.  
  4554.  
  4555. /**
  4556. * X.) Plugin Initialization Code
  4557. * Author: John Bacon, Red Storm Entertainment
  4558. */
  4559.  
  4560.  
  4561. /*============================================================*/
  4562. /* PJAX
  4563. /*============================================================*/
  4564. var pjaxSelection = ':not([data-skip-pjax])a';
  4565. $(document).pjax(pjaxSelection, { container: '#pjax-container', fragment: '#pjax-container', timeout: 2000, maxCacheLength: 2});
  4566.  
  4567. $(document).on('pjax:send', function() {
  4568.     $('#loading').show()
  4569. })
  4570. $(document).on('pjax:complete', function() {
  4571.     $('#loading').hide()
  4572. })
  4573.  
  4574. $(document).on('pjax:timeout', function(event) {
  4575.     // Prevent default timeout redirection behavior
  4576.     event.preventDefault()
  4577. })
  4578.  
  4579. // Temporary fix (duplicate code) until we figure out what is causing issues in IE8
  4580. $(document).ready(function() {
  4581.  
  4582.         // FlexSlider
  4583.         // ----------
  4584.         $('#slider-main').flexslider({
  4585.                 directionNav: false,
  4586.                 animation: 'fade',
  4587.                 animationDuration: 600,
  4588.                 manualControls: '.flex-control-nav li',
  4589.                 // Removes spin.gif from background
  4590.                 start: function () {
  4591.                         $('.slides').css('background', 'none');
  4592.                 }
  4593.         });
  4594.  
  4595.         $('#slider').flexslider({
  4596.             animation: "slide",
  4597.             controlNav: true,
  4598.             animationLoop: false,
  4599.             slideshow: false,
  4600.             sync: "#carousel",
  4601.                 start: function () {
  4602.                         $('#slider .flex-viewport').css('opacity', '100');
  4603.                         $('#slider').css('background-image', 'none');
  4604.                 }
  4605.         });
  4606.  
  4607.         // The slider being synced must be initialized first
  4608.         $('#carousel').flexslider({
  4609.             animation: "slide",
  4610.             controlNav: false,
  4611.             animationLoop: false,
  4612.             slideshow: false,
  4613.             itemWidth: 210,
  4614.             itemMargin: 5,
  4615.             asNavFor: '#slider',
  4616.                 start: function () {
  4617.                         $('#carousel .flex-viewport').css('opacity', '100');
  4618.                         $('#carousel').css('background-image', 'none');
  4619.                 }
  4620.         });
  4621.  
  4622.  
  4623.         // bxSlider
  4624.         // --------
  4625.         $('#gallery').removeClass('is-hidden').bxSlider({
  4626.                 mode: 'horizontal',
  4627.                 minSlides: 2,
  4628.                 maxSlides: 2,
  4629.                 slideWidth: 305,
  4630.                 slideMargin: 0,
  4631.                 infiniteLoop: false,
  4632.                 hideControlOnEnd: true,
  4633.                 nextText: '',
  4634.                 prevText: '',
  4635.                 pager: false,
  4636.                 displaySlideQty: 2,
  4637.                 moveSlideQty: 1,
  4638.                 speed: 250
  4639.         });
  4640.         $('#four-gallery').removeClass('is-hidden').bxSlider({
  4641.                 mode: 'horizontal',
  4642.                 minSlides: 4,
  4643.                 maxSlides: 4,
  4644.                 slideWidth: 180,
  4645.                 slideMargin: 0,
  4646.                 infiniteLoop: false,
  4647.                 hideControlOnEnd: true,
  4648.                 nextText: '',
  4649.                 prevText: '',
  4650.                 pager: false,
  4651.                 displaySlideQty: 4,
  4652.                 moveSlideQty: 2,
  4653.                 speed: 250
  4654.         });
  4655.         $('#archive-list').removeClass('is-hidden').bxSlider({
  4656.                 mode: 'horizontal',
  4657.                 infiniteLoop: false,
  4658.                 hideControlOnEnd: true,
  4659.                 nextText: '',
  4660.                 prevText: '',
  4661.                 pager: false,
  4662.                 speed: 500
  4663.         });
  4664.  
  4665.  
  4666.         // Accordion script
  4667.         // ----------------
  4668.         var $accordion = $('.accordion-heading');
  4669.         $accordion.click(function () {
  4670.                 if( $(this).next().is(':hidden') ) {
  4671.                         $accordion.removeClass('active').next().slideUp();
  4672.                         $(this).addClass('active').next().slideDown();
  4673.                 }
  4674.                 return false;
  4675.         });
  4676.  
  4677.  
  4678.         // FancyBox
  4679.         // --------
  4680.         var $thumb = $('.thumb');
  4681.         $thumb.fancybox({
  4682.                 loop: true,
  4683.                 helpers      : {
  4684.                         title    : { type : 'over' }
  4685.                 }
  4686.         });
  4687.  
  4688.  
  4689.         // jQuery Placeholder
  4690.         // ------------------
  4691.         $('input, textarea').placeholder();
  4692.  
  4693.  
  4694.         // Asteroids link-up
  4695.         // -----------------
  4696.         $('#logo-link').click(function() {
  4697.                 $.getScript('/js/mylibs/asteroids.min.js?v=1.0.1');
  4698.                 return false;
  4699.         });
  4700.  
  4701.  
  4702.         // // Facebook
  4703.         // if ( $('#twitter-news').length > 0 ) {
  4704.         //   // run the app
  4705.         //  FB.XFBML.parse();
  4706.         // };
  4707.  
  4708.  
  4709.         $(function loadAJAX() {
  4710.         var disqus_shortname = 'redstormentertainment'; // required: replace example with your forum shortname
  4711.  
  4712.             if ( $("#news").length > 0 ) {
  4713.                 if ( $("#socialite").length > 0 ) {
  4714.                         var initSocialite = loadSocialite();
  4715.                         var initDisqus = loadDisqus();
  4716.                     } else {
  4717.                         var initFacebookSDK = loadFacebookSDK();
  4718.                 }
  4719.             }
  4720.         });
  4721.  
  4722. });
  4723.  
  4724. // will fire on initial page load (document.ready), and subsequent PJAX page loads
  4725. $(document).on('pjax:success', function() {
  4726.  
  4727.  
  4728.         // FlexSlider
  4729.         // ----------
  4730.         $('#slider-main').flexslider({
  4731.                 directionNav: false,
  4732.                 animation: 'fade',
  4733.                 animationDuration: 600,
  4734.                 manualControls: '.flex-control-nav li',
  4735.                 // Removes spin.gif from background
  4736.                 start: function () {
  4737.                         $('.slides').css('background', 'none');
  4738.                 }
  4739.         });
  4740.  
  4741.         $('#slider').flexslider({
  4742.             animation: "slide",
  4743.             controlNav: true,
  4744.             animationLoop: false,
  4745.             slideshow: false,
  4746.             sync: "#carousel",
  4747.                 start: function () {
  4748.                         $('#slider .flex-viewport').css('opacity', '100');
  4749.                         $('#slider').css('background-image', 'none');
  4750.                 }
  4751.         });
  4752.  
  4753.         // The slider being synced must be initialized first
  4754.         $('#carousel').flexslider({
  4755.             animation: "slide",
  4756.             controlNav: false,
  4757.             animationLoop: false,
  4758.             slideshow: false,
  4759.             itemWidth: 210,
  4760.             itemMargin: 5,
  4761.             asNavFor: '#slider',
  4762.                 start: function () {
  4763.                         $('#carousel .flex-viewport').css('opacity', '100');
  4764.                         $('#carousel').css('background-image', 'none');
  4765.                 }
  4766.         });
  4767.  
  4768.  
  4769.         // bxSlider
  4770.         // --------
  4771.         $('#gallery').removeClass('is-hidden').bxSlider({
  4772.                 mode: 'horizontal',
  4773.                 minSlides: 2,
  4774.                 maxSlides: 2,
  4775.                 slideWidth: 305,
  4776.                 slideMargin: 0,
  4777.                 infiniteLoop: false,
  4778.                 hideControlOnEnd: true,
  4779.                 nextText: '',
  4780.                 prevText: '',
  4781.                 pager: false,
  4782.                 displaySlideQty: 2,
  4783.                 moveSlideQty: 1,
  4784.                 speed: 250
  4785.         });
  4786.         $('#four-gallery').removeClass('is-hidden').bxSlider({
  4787.                 mode: 'horizontal',
  4788.                 minSlides: 4,
  4789.                 maxSlides: 4,
  4790.                 slideWidth: 180,
  4791.                 slideMargin: 0,
  4792.                 infiniteLoop: false,
  4793.                 hideControlOnEnd: true,
  4794.                 nextText: '',
  4795.                 prevText: '',
  4796.                 pager: false,
  4797.                 displaySlideQty: 4,
  4798.                 moveSlideQty: 2,
  4799.                 speed: 250
  4800.         });
  4801.         $('#archive-list').removeClass('is-hidden').bxSlider({
  4802.                 mode: 'horizontal',
  4803.                 infiniteLoop: false,
  4804.                 hideControlOnEnd: true,
  4805.                 nextText: '',
  4806.                 prevText: '',
  4807.                 pager: false,
  4808.                 speed: 500
  4809.         });
  4810.  
  4811.  
  4812.         // Accordion script
  4813.         // ----------------
  4814.         var $accordion = $('.accordion-heading');
  4815.         $accordion.click(function () {
  4816.                 if( $(this).next().is(':hidden') ) {
  4817.                         $accordion.removeClass('active').next().slideUp();
  4818.                         $(this).addClass('active').next().slideDown();
  4819.                 }
  4820.                 return false;
  4821.         });
  4822.  
  4823.  
  4824.         // FancyBox
  4825.         // --------
  4826.         var $thumb = $('.thumb');
  4827.         $thumb.fancybox({
  4828.                 loop: true,
  4829.                 helpers      : {
  4830.                         title    : { type : 'over' }
  4831.                 }
  4832.         });
  4833.  
  4834.  
  4835.         // jQuery Placeholder
  4836.         // ------------------
  4837.         $('input, textarea').placeholder();
  4838.  
  4839.  
  4840.         // Asteroids link-up
  4841.         // -----------------
  4842.         $('#logo-link').click(function() {
  4843.                 $.getScript('/js/mylibs/asteroids.min.js?v=1.0.1');
  4844.                 return false;
  4845.         });
  4846.  
  4847.  
  4848.         // // Facebook
  4849.         // if ( $('#twitter-news').length > 0 ) {
  4850.         //   // run the app
  4851.         //  FB.XFBML.parse();
  4852.         // };
  4853.  
  4854.  
  4855.         $(function loadAJAX() {
  4856.         var disqus_shortname = 'redstormentertainment'; // required: replace example with your forum shortname
  4857.  
  4858.             if ( $("#news").length > 0 ) {
  4859.                 if ( $("#socialite").length > 0 ) {
  4860.                         var initSocialite = loadSocialite();
  4861.                         var initDisqus = loadDisqus();
  4862.                     } else {
  4863.                         var initFacebookSDK = loadFacebookSDK();
  4864.                 }
  4865.             }
  4866.         });
  4867.  
  4868.  
  4869. });
Add Comment
Please, Sign In to add comment