﻿/*
* String.Format Function
*/
var format = function (str, col) {
    col = typeof col === 'object' ? col : Array.prototype.slice.call(arguments, 1);

    return str.replace(/\{([^}]+)\}/gm, function () {
    return col[arguments[1]];
    });
};

/*
* Random Number Function
*/
function randomFromTo(from, to) {
    return Math.floor(Math.random() * (to - from + 1) + from);
}

/*
* jQuery Nivo Slider v2.5
* http://nivo.dev7studios.com
*
* Copyright 2011, Gilbert Pellegrom
* Free to use and abuse under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 
* March 2010
*/

(function ($) {
    var NivoSlider = function (element, options) {
        var settings = $.extend({}, $.fn.nivoSlider.defaults, options); var vars = { currentSlide: 0, currentImage: '', totalSlides: 0, randAnim: '', running: false, paused: false, stop: false }; var slider = $(element); slider.data('nivo:vars', vars); slider.css('position', 'relative'); slider.addClass('nivoSlider'); var kids = slider.children(); kids.each(function () {
            var child = $(this); var link = ''; if (!child.is('img')) {
                if (child.is('a')) { child.addClass('nivo-imageLink'); link = child; }
                child = child.find('img:first');
            }
            var childWidth = child.width(); if (childWidth == 0) childWidth = child.attr('width'); var childHeight = child.height(); if (childHeight == 0) childHeight = child.attr('height'); if (childWidth > slider.width()) { slider.width(childWidth); }
            if (childHeight > slider.height()) { slider.height(childHeight); }
            if (link != '') { link.css('display', 'none'); }
            child.css('display', 'none'); vars.totalSlides++;
        }); if (settings.startSlide > 0) { if (settings.startSlide >= vars.totalSlides) settings.startSlide = vars.totalSlides - 1; vars.currentSlide = settings.startSlide; }
        if ($(kids[vars.currentSlide]).is('img')) { vars.currentImage = $(kids[vars.currentSlide]); } else { vars.currentImage = $(kids[vars.currentSlide]).find('img:first'); }
        if ($(kids[vars.currentSlide]).is('a')) { $(kids[vars.currentSlide]).css('display', 'block'); }
        slider.css('background', 'url("' + vars.currentImage.attr('src') + '") no-repeat'); slider.append($('<div class="nivo-caption"><p></p></div>').css({ display: 'none', opacity: settings.captionOpacity })); var processCaption = function (settings) {
            var nivoCaption = $('.nivo-caption', slider); if (vars.currentImage.attr('title') != '') {
                var title = vars.currentImage.attr('title'); if (title.substr(0, 1) == '#') title = $(title).html(); if (nivoCaption.css('display') == 'block') { nivoCaption.find('p').fadeOut(settings.animSpeed, function () { $(this).html(title); $(this).fadeIn(settings.animSpeed); }); } else { nivoCaption.find('p').html(title); }
                nivoCaption.fadeIn(settings.animSpeed);
            } else { nivoCaption.fadeOut(settings.animSpeed); } 
        }
        processCaption(settings); var timer = 0; if (!settings.manualAdvance && kids.length > 1) { timer = setInterval(function () { nivoRun(slider, kids, settings, false); }, settings.pauseTime); }
        if (settings.directionNav) {
            slider.append('<div class="nivo-directionNav"><a class="nivo-prevNav">' + settings.prevText + '</a><a class="nivo-nextNav">' + settings.nextText + '</a></div>'); if (settings.directionNavHide) { $('.nivo-directionNav', slider).hide(); slider.hover(function () { $('.nivo-directionNav', slider).show(); }, function () { $('.nivo-directionNav', slider).hide(); }); }
            $('a.nivo-prevNav', slider).live('click', function () { if (vars.running) return false; clearInterval(timer); timer = ''; vars.currentSlide -= 2; nivoRun(slider, kids, settings, 'prev'); }); $('a.nivo-nextNav', slider).live('click', function () { if (vars.running) return false; clearInterval(timer); timer = ''; nivoRun(slider, kids, settings, 'next'); });
        }
        if (settings.controlNav) {
            var nivoControl = $('<div class="nivo-controlNav"></div>'); slider.append(nivoControl); for (var i = 0; i < kids.length; i++) {
                if (settings.controlNavThumbs) {
                    var child = kids.eq(i); if (!child.is('img')) { child = child.find('img:first'); }
                    if (settings.controlNavThumbsFromRel) { nivoControl.append('<a class="nivo-control" rel="' + i + '"><img src="' + child.attr('rel') + '" alt="" /></a>'); } else { nivoControl.append('<a class="nivo-control" rel="' + i + '"><img src="' + child.attr('src').replace(settings.controlNavThumbsSearch, settings.controlNavThumbsReplace) + '" alt="" /></a>'); } 
                } else { nivoControl.append('<a class="nivo-control" rel="' + i + '">' + (i + 1) + '</a>'); } 
            }
            $('.nivo-controlNav a:eq(' + vars.currentSlide + ')', slider).addClass('active'); $('.nivo-controlNav a', slider).live('click', function () { if (vars.running) return false; if ($(this).hasClass('active')) return false; clearInterval(timer); timer = ''; slider.css('background', 'url("' + vars.currentImage.attr('src') + '") no-repeat'); vars.currentSlide = $(this).attr('rel') - 1; nivoRun(slider, kids, settings, 'control'); });
        }
        if (settings.keyboardNav) {
            $(window).keypress(function (event) {
                if (event.keyCode == '37') { if (vars.running) return false; clearInterval(timer); timer = ''; vars.currentSlide -= 2; nivoRun(slider, kids, settings, 'prev'); }
                if (event.keyCode == '39') { if (vars.running) return false; clearInterval(timer); timer = ''; nivoRun(slider, kids, settings, 'next'); } 
            });
        }
        if (settings.pauseOnHover) { slider.hover(function () { vars.paused = true; clearInterval(timer); timer = ''; }, function () { vars.paused = false; if (timer == '' && !settings.manualAdvance) { timer = setInterval(function () { nivoRun(slider, kids, settings, false); }, settings.pauseTime); } }); }
        slider.bind('nivo:animFinished', function () {
            vars.running = false; $(kids).each(function () { if ($(this).is('a')) { $(this).css('display', 'none'); } }); if ($(kids[vars.currentSlide]).is('a')) { $(kids[vars.currentSlide]).css('display', 'block'); }
            if (timer == '' && !vars.paused && !settings.manualAdvance) { timer = setInterval(function () { nivoRun(slider, kids, settings, false); }, settings.pauseTime); }
            settings.afterChange.call(this);
        }); var createSlices = function (slider, settings, vars) { for (var i = 0; i < settings.slices; i++) { var sliceWidth = Math.round(slider.width() / settings.slices); if (i == settings.slices - 1) { slider.append($('<div class="nivo-slice"></div>').css({ left: (sliceWidth * i) + 'px', width: (slider.width() - (sliceWidth * i)) + 'px', height: '0px', opacity: '0', background: 'url("' + vars.currentImage.attr('src') + '") no-repeat -' + ((sliceWidth + (i * sliceWidth)) - sliceWidth) + 'px 0%' })); } else { slider.append($('<div class="nivo-slice"></div>').css({ left: (sliceWidth * i) + 'px', width: sliceWidth + 'px', height: '0px', opacity: '0', background: 'url("' + vars.currentImage.attr('src') + '") no-repeat -' + ((sliceWidth + (i * sliceWidth)) - sliceWidth) + 'px 0%' })); } } }
        var createBoxes = function (slider, settings, vars) { var boxWidth = Math.round(slider.width() / settings.boxCols); var boxHeight = Math.round(slider.height() / settings.boxRows); for (var rows = 0; rows < settings.boxRows; rows++) { for (var cols = 0; cols < settings.boxCols; cols++) { if (cols == settings.boxCols - 1) { slider.append($('<div class="nivo-box"></div>').css({ opacity: 0, left: (boxWidth * cols) + 'px', top: (boxHeight * rows) + 'px', width: (slider.width() - (boxWidth * cols)) + 'px', height: boxHeight + 'px', background: 'url("' + vars.currentImage.attr('src') + '") no-repeat -' + ((boxWidth + (cols * boxWidth)) - boxWidth) + 'px -' + ((boxHeight + (rows * boxHeight)) - boxHeight) + 'px' })); } else { slider.append($('<div class="nivo-box"></div>').css({ opacity: 0, left: (boxWidth * cols) + 'px', top: (boxHeight * rows) + 'px', width: boxWidth + 'px', height: boxHeight + 'px', background: 'url("' + vars.currentImage.attr('src') + '") no-repeat -' + ((boxWidth + (cols * boxWidth)) - boxWidth) + 'px -' + ((boxHeight + (rows * boxHeight)) - boxHeight) + 'px' })); } } } }
        var nivoRun = function (slider, kids, settings, nudge) {
            var vars = slider.data('nivo:vars'); if (vars && (vars.currentSlide == vars.totalSlides - 1)) { settings.lastSlide.call(this); }
            if ((!vars || vars.stop) && !nudge) return false; settings.beforeChange.call(this); if (!nudge) { slider.css('background', 'url("' + vars.currentImage.attr('src') + '") no-repeat'); } else {
                if (nudge == 'prev') { slider.css('background', 'url("' + vars.currentImage.attr('src') + '") no-repeat'); }
                if (nudge == 'next') { slider.css('background', 'url("' + vars.currentImage.attr('src') + '") no-repeat'); } 
            }
            vars.currentSlide++; if (vars.currentSlide == vars.totalSlides) { vars.currentSlide = 0; settings.slideshowEnd.call(this); }
            if (vars.currentSlide < 0) vars.currentSlide = (vars.totalSlides - 1); if ($(kids[vars.currentSlide]).is('img')) { vars.currentImage = $(kids[vars.currentSlide]); } else { vars.currentImage = $(kids[vars.currentSlide]).find('img:first'); }
            if (settings.controlNav) { $('.nivo-controlNav a', slider).removeClass('active'); $('.nivo-controlNav a:eq(' + vars.currentSlide + ')', slider).addClass('active'); }
            processCaption(settings); $('.nivo-slice', slider).remove(); $('.nivo-box', slider).remove(); if (settings.effect == 'random') { var anims = new Array('sliceDownRight', 'sliceDownLeft', 'sliceUpRight', 'sliceUpLeft', 'sliceUpDown', 'sliceUpDownLeft', 'fold', 'fade', 'boxRandom', 'boxRain', 'boxRainReverse'); vars.randAnim = anims[Math.floor(Math.random() * (anims.length + 1))]; if (vars.randAnim == undefined) vars.randAnim = 'fade'; }
            if (settings.effect.indexOf(',') != -1) { var anims = settings.effect.split(','); vars.randAnim = anims[Math.floor(Math.random() * (anims.length))]; if (vars.randAnim == undefined) vars.randAnim = 'fade'; }
            vars.running = true; if (settings.effect == 'sliceDown' || settings.effect == 'sliceDownRight' || vars.randAnim == 'sliceDownRight' || settings.effect == 'sliceDownLeft' || vars.randAnim == 'sliceDownLeft') {
                createSlices(slider, settings, vars); var timeBuff = 0; var i = 0; var slices = $('.nivo-slice', slider); if (settings.effect == 'sliceDownLeft' || vars.randAnim == 'sliceDownLeft') slices = $('.nivo-slice', slider)._reverse(); slices.each(function () {
                    var slice = $(this); slice.css({ 'top': '0px' }); if (i == settings.slices - 1) { setTimeout(function () { slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed, '', function () { slider.trigger('nivo:animFinished'); }); }, (100 + timeBuff)); } else { setTimeout(function () { slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed); }, (100 + timeBuff)); }
                    timeBuff += 50; i++;
                });
            }
            else if (settings.effect == 'sliceUp' || settings.effect == 'sliceUpRight' || vars.randAnim == 'sliceUpRight' || settings.effect == 'sliceUpLeft' || vars.randAnim == 'sliceUpLeft') {
                createSlices(slider, settings, vars); var timeBuff = 0; var i = 0; var slices = $('.nivo-slice', slider); if (settings.effect == 'sliceUpLeft' || vars.randAnim == 'sliceUpLeft') slices = $('.nivo-slice', slider)._reverse(); slices.each(function () {
                    var slice = $(this); slice.css({ 'bottom': '0px' }); if (i == settings.slices - 1) { setTimeout(function () { slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed, '', function () { slider.trigger('nivo:animFinished'); }); }, (100 + timeBuff)); } else { setTimeout(function () { slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed); }, (100 + timeBuff)); }
                    timeBuff += 50; i++;
                });
            }
            else if (settings.effect == 'sliceUpDown' || settings.effect == 'sliceUpDownRight' || vars.randAnim == 'sliceUpDown' || settings.effect == 'sliceUpDownLeft' || vars.randAnim == 'sliceUpDownLeft') {
                createSlices(slider, settings, vars); var timeBuff = 0; var i = 0; var v = 0; var slices = $('.nivo-slice', slider); if (settings.effect == 'sliceUpDownLeft' || vars.randAnim == 'sliceUpDownLeft') slices = $('.nivo-slice', slider)._reverse(); slices.each(function () {
                    var slice = $(this); if (i == 0) { slice.css('top', '0px'); i++; } else { slice.css('bottom', '0px'); i = 0; }
                    if (v == settings.slices - 1) { setTimeout(function () { slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed, '', function () { slider.trigger('nivo:animFinished'); }); }, (100 + timeBuff)); } else { setTimeout(function () { slice.animate({ height: '100%', opacity: '1.0' }, settings.animSpeed); }, (100 + timeBuff)); }
                    timeBuff += 50; v++;
                });
            }
            else if (settings.effect == 'fold' || vars.randAnim == 'fold') {
                createSlices(slider, settings, vars); var timeBuff = 0; var i = 0; $('.nivo-slice', slider).each(function () {
                    var slice = $(this); var origWidth = slice.width(); slice.css({ top: '0px', height: '100%', width: '0px' }); if (i == settings.slices - 1) { setTimeout(function () { slice.animate({ width: origWidth, opacity: '1.0' }, settings.animSpeed, '', function () { slider.trigger('nivo:animFinished'); }); }, (100 + timeBuff)); } else { setTimeout(function () { slice.animate({ width: origWidth, opacity: '1.0' }, settings.animSpeed); }, (100 + timeBuff)); }
                    timeBuff += 50; i++;
                });
            }
            else if (settings.effect == 'fade' || vars.randAnim == 'fade') { createSlices(slider, settings, vars); var firstSlice = $('.nivo-slice:first', slider); firstSlice.css({ 'height': '100%', 'width': slider.width() + 'px' }); firstSlice.animate({ opacity: '1.0' }, (settings.animSpeed * 2), '', function () { slider.trigger('nivo:animFinished'); }); }
            else if (settings.effect == 'slideInRight' || vars.randAnim == 'slideInRight') { createSlices(slider, settings, vars); var firstSlice = $('.nivo-slice:first', slider); firstSlice.css({ 'height': '100%', 'width': '0px', 'opacity': '1' }); firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed * 2), '', function () { slider.trigger('nivo:animFinished'); }); }
            else if (settings.effect == 'slideInLeft' || vars.randAnim == 'slideInLeft') { createSlices(slider, settings, vars); var firstSlice = $('.nivo-slice:first', slider); firstSlice.css({ 'height': '100%', 'width': '0px', 'opacity': '1', 'left': '', 'right': '0px' }); firstSlice.animate({ width: slider.width() + 'px' }, (settings.animSpeed * 2), '', function () { firstSlice.css({ 'left': '0px', 'right': '' }); slider.trigger('nivo:animFinished'); }); }
            else if (settings.effect == 'boxRandom' || vars.randAnim == 'boxRandom') {
                createBoxes(slider, settings, vars); var totalBoxes = settings.boxCols * settings.boxRows; var i = 0; var timeBuff = 0; var boxes = shuffle($('.nivo-box', slider)); boxes.each(function () {
                    var box = $(this); if (i == totalBoxes - 1) { setTimeout(function () { box.animate({ opacity: '1' }, settings.animSpeed, '', function () { slider.trigger('nivo:animFinished'); }); }, (100 + timeBuff)); } else { setTimeout(function () { box.animate({ opacity: '1' }, settings.animSpeed); }, (100 + timeBuff)); }
                    timeBuff += 20; i++;
                });
            }
            else if (settings.effect == 'boxRain' || vars.randAnim == 'boxRain' || settings.effect == 'boxRainReverse' || vars.randAnim == 'boxRainReverse') {
                createBoxes(slider, settings, vars); var totalBoxes = settings.boxCols * settings.boxRows; var i = 0; var timeBuff = 0; var rowIndex = 0; var colIndex = 0; var box2Darr = new Array(); box2Darr[rowIndex] = new Array(); var boxes = $('.nivo-box', slider); if (settings.effect == 'boxRainReverse' || vars.randAnim == 'boxRainReverse') { boxes = $('.nivo-box', slider)._reverse(); }
                boxes.each(function () { box2Darr[rowIndex][colIndex] = $(this); colIndex++; if (colIndex == settings.boxCols) { rowIndex++; colIndex = 0; box2Darr[rowIndex] = new Array(); } }); for (var cols = 0; cols < (settings.boxCols * 2); cols++) {
                    var prevCol = cols; for (var rows = 0; rows < settings.boxRows; rows++) {
                        if (prevCol >= 0 && prevCol < settings.boxCols) { (function (row, col, time, i, totalBoxes) { var box = $(box2Darr[row][col]); if (i == totalBoxes - 1) { setTimeout(function () { box.animate({ opacity: '1' }, settings.animSpeed / 1.3, '', function () { slider.trigger('nivo:animFinished'); }); }, (100 + time)); } else { setTimeout(function () { box.animate({ opacity: '1' }, settings.animSpeed / 1.3); }, (100 + time)); } })(rows, prevCol, timeBuff, i, totalBoxes); i++; }
                        prevCol--;
                    }
                    timeBuff += 100;
                } 
            } 
        }
        var shuffle = function (arr) { for (var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x); return arr; }
        var trace = function (msg) {
            if (this.console && typeof console.log != "undefined")
                console.log(msg);
        }
        this.stop = function () { if (!$(element).data('nivo:vars').stop) { $(element).data('nivo:vars').stop = true; trace('Stop Slider'); } }
        this.start = function () { if ($(element).data('nivo:vars').stop) { $(element).data('nivo:vars').stop = false; trace('Start Slider'); } }
        settings.afterLoad.call(this); return this;
    }; $.fn.nivoSlider = function (options) { return this.each(function (key, value) { var element = $(this); if (element.data('nivoslider')) return element.data('nivoslider'); var nivoslider = new NivoSlider(this, options); element.data('nivoslider', nivoslider); }); }; $.fn.nivoSlider.defaults = { effect: 'random', slices: 15, boxCols: 8, boxRows: 4, animSpeed: 500, pauseTime: 3000, startSlide: 0, directionNav: true, directionNavHide: true, controlNav: true, controlNavThumbs: false, controlNavThumbsFromRel: false, controlNavThumbsSearch: '.jpg', controlNavThumbsReplace: '_thumb.jpg', keyboardNav: true, pauseOnHover: true, manualAdvance: false, captionOpacity: 0.8, prevText: 'Prev', nextText: 'Next', beforeChange: function () { }, afterChange: function () { }, slideshowEnd: function () { }, lastSlide: function () { }, afterLoad: function () { } }; $.fn._reverse = [].reverse;
})(jQuery);


/**
* Isotope v1.4.110808
* An exquisite jQuery plugin for magical layouts
* http://isotope.metafizzy.co
*
* Commercial use requires one-time license fee
* http://metafizzy.co/#licenses
*
* Copyright 2011 David DeSandro / Metafizzy
*/
/*jshint curly: true, eqeqeq: true, forin: false, immed: false, newcap: true, noempty: true, undef: true */
/*global Modernizr: true */
(function (a, b, c) { function f(a) { var b = document.documentElement.style, c; if (typeof b[a] == "string") return a; a = d(a); for (var f = 0, g = e.length; f < g; f++) { c = e[f] + a; if (typeof b[c] == "string") return c } } function d(a) { return a.charAt(0).toUpperCase() + a.slice(1) } var e = "Moz Webkit Khtml O Ms".split(" "), g = f("transform"), h = { csstransforms: function () { return !!g }, csstransforms3d: function () { var a = !!f("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"), g = b('<div id="modernizr" />').appendTo("html"); a = g.height() === 3, g.remove(), e.remove() } return a }, csstransitions: function () { return !!f("transitionProperty") } }; if (a.Modernizr) for (var i in h) Modernizr.hasOwnProperty(i) || Modernizr.addTest(i, h[i]); else a.Modernizr = function () { var a = { _version: "1.6ish: miniModernizr for Isotope" }, c = " ", d, e; for (e in h) d = h[e](), a[e] = d, c += " " + (d ? "" : "no-") + e; b("html").addClass(c); return a } (); if (Modernizr.csstransforms) { var j = Modernizr.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 + ") " } }, k = function (a, c, d) { var e = b.data(a, "isoTransform") || {}, f = {}, h, i = {}, k; f[c] = d, b.extend(e, f); for (h in e) k = e[h], i[h] = j[h](k); var l = i.translate || "", m = i.scale || "", n = l + m; b.data(a, "isoTransform", e), a.style[g] = n }; b.cssNumber.scale = !0, b.cssHooks.scale = { set: function (a, b) { k(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) { k(a, "translate", b) }, get: function (a, c) { var d = b.data(a, "isoTransform"); return d && d.translate ? d.translate : [0, 0] } } } var l = b.event, m; l.special.smartresize = { setup: function () { b(this).bind("resize", l.special.smartresize.handler) }, teardown: function () { b(this).unbind("resize", l.special.smartresize.handler) }, handler: function (a, b) { var c = this, d = arguments; a.type = "smartresize", m && clearTimeout(m), m = 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) { this.element = b(c), this._create(a), this._init() }; var n = ["overflow", "position", "width", "height"]; b.Isotope.settings = { resizable: !0, layoutMode: "masonry", containerClass: "isotope", itemClass: "isotope-item", hiddenClass: "isotope-hidden", hiddenStyle: Modernizr.csstransforms && !b.browser.opera ? { opacity: 0, scale: .001} : { opacity: 0 }, visibleStyle: Modernizr.csstransforms && !b.browser.opera ? { opacity: 1, scale: 1} : { opacity: 1 }, animationEngine: b.browser.opera ? "jquery" : "best-available", animationOptions: { queue: !1, duration: 800 }, sortBy: "original-order", sortAscending: !0, resizesContainer: !0, transformsEnabled: !0, itemPositionDataEnabled: !1 }, b.Isotope.prototype = { _create: function (c) { this.options = b.extend({}, b.Isotope.settings, c), this.styleQueue = [], this.elemCount = 0; var d = this.element[0].style; this.originalStyle = {}; for (var e = 0, f = n.length; e < f; e++) { var g = n[e]; this.originalStyle[g] = d[g] || "" } this.element.css({ overflow: "hidden", position: "relative" }), this._updateAnimationEngine(), this._updateUsingTransforms(); var h = { "original-order": function (a, b) { return b.elemCount }, random: function () { return Math.random() } }; this.options.getSortData = b.extend(this.options.getSortData, h), this.reloadItems(); var i = b(document.createElement("div")).prependTo(this.element); this.offset = i.position(), i.remove(); var j = this; setTimeout(function () { j.element.addClass(j.options.containerClass) }, 0), this.options.resizable && b(a).bind("smartresize.isotope", function () { j.resize() }) }, _getAtoms: function (a) { var b = this.options.itemSelector, c = b ? a.filter(b).add(a.find(b)) : a, d = { position: "absolute" }; this.usingTransforms && (d.left = 0, d.top = 0), c.css(d).addClass(this.options.itemClass), this.updateSortData(c, !0); return c }, _init: function (a) { this.$filteredAtoms = 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 e in a) c = "_update" + d(e), this[c] && this[c]() } }, _updateAnimationEngine: function () { var a = this.options.animationEngine.toLowerCase().replace(/[ _\-]/g, ""); switch (a) { case "css": case "none": this.isUsingJQueryAnimation = !1; break; case "jquery": this.isUsingJQueryAnimation = !0; break; default: this.isUsingJQueryAnimation = !Modernizr.csstransitions } this._updateUsingTransforms() }, _updateTransformsEnabled: function () { this._updateUsingTransforms() }, _updateUsingTransforms: function () { this.usingTransforms = this.options.transformsEnabled && Modernizr.csstransforms && Modernizr.csstransitions && !this.isUsingJQueryAnimation, this.getPositionStyles = this.usingTransforms ? 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 }) } this.styleQueue.push({ $el: f, style: this.options.visibleStyle }), f.removeClass(c); return 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) g[a] = e[a](f, d); b.data(this, "isotope-sort-data", g), c && d.elemCount++ }) }, _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); f === g && a !== "original-order" && (f = b(d, "original-order"), g = b(e, "original-order")); return (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 += this.offset.left, 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(), b && b.call(a), this.isLaidOut = !0 }, _processStyleQueue: function () { var a = this.isLaidOut ? this.isUsingJQueryAnimation ? "animate" : "css" : "css", c = this.options.animationOptions, d = this._isInserting && this.isUsingJQueryAnimation, e; b.each(this.styleQueue, function (b, f) { e = d && f.$el.hasClass("no-transition") ? "css" : a, f.$el[e](f.style, c) }), 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.$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, !0); 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.$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._processStyleQueue(), delete c._isInserting, b && b(a) }, 10) }, reloadItems: function () { this.$allAtoms = this._getAtoms(this.element.children()) }, remove: function (a) { this.$allAtoms = this.$allAtoms.not(a), this.$filteredAtoms = this.$filteredAtoms.not(a), a.remove() }, shuffle: function () { this.updateSortData(this.$allAtoms), this.options.sortBy = "random", this._sort(), this.reLayout() }, destroy: function () { var c = this.usingTransforms; this.$allAtoms.removeClass(this.options.hiddenClass + " " + this.options.itemClass).each(function () { this.style.position = "", this.style.top = "", this.style.left = "", this.style.opacity = "", c && (this.style[g] = "") }); var d = this.element[0].style; for (var e = 0, f = n.length; e < f; e++) { var h = n[e]; d[h] = this.originalStyle[h] } this.element.unbind(".isotope").removeClass(this.options.containerClass).removeData("isotope"), b(a).unbind(".isotope") }, _getSegments: function (a) { var b = this.options.layoutMode, c = a ? "rowHeight" : "columnWidth", e = a ? "height" : "width", f = a ? "rows" : "cols", g = this.element[e](), h, i = this.options[b] && this.options[b][c] || this.$filteredAtoms["outer" + d(e)](!0) || g; h = Math.floor(g / i), h = Math.max(h, 1), this[b][f] = h, this[b][c] = i }, _checkIfSegmentsChanged: function (a) { var b = this.options.layoutMode, c = a ? "rows" : "cols", d = this[b][c]; this._getSegments(a); return 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 = ~ ~(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 = ~ ~(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) { var b = this.find("img"), c = [], d = this, e = b.length; if (!b.length) { a.call(this); return this } b.one("load error", function () { --e === 0 && (e = b.length, b.one("load error", function () { --e === 0 && a.call(d) }).each(function () { this.src = c.shift() })) }).each(function () { c.push(this.src), this.src = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==" }); return this }; var o = function (a) { this.console && console.error(a) }; b.fn.isotope = function (a) { if (typeof a == "string") { var c = Array.prototype.slice.call(arguments, 1); this.each(function () { var d = b.data(this, "isotope"); if (!d) o("cannot call methods on isotope prior to initialization; attempted to call method '" + a + "'"); else { if (!b.isFunction(d[a]) || a.charAt(0) === "_") { o("no such method '" + a + "' for isotope instance"); return } d[a].apply(d, c) } }) } else this.each(function () { var c = b.data(this, "isotope"); c ? (c.option(a), c._init()) : b.data(this, "isotope", new b.Isotope(a, this)) }); return this } })(window, jQuery);

$.Isotope.prototype.flush = function () {
    this.$allAtoms = $();
    this.$filteredAtoms = $();
    this.element.children().remove();
    this.reLayout();
};

/*
News ticker plugin (BBC news style)
Bryan Gullan,2007-2011
version 2.3.6
updated 2011-03-16
Documentation at http://www.makemineatriple.com/news-ticker-documentation/
Demo at http://www.makemineatriple.com/jquery/?newsTicker
Use and distrubute freely with this header intact.
*/

(function ($) {

    var name = 'newsTicker';
    var debugMode = false; // enabling this turns on console logging for interactions

    function runTicker(settings) {

        tickerData = $(settings.newsList).data('newsTicker');

        if (tickerData.currentItem > tickerData.newsItemCounter) {
            // if we've looped to beyond the last item in the list, start over
            tickerData.currentItem = 0;
        }
        else if (tickerData.currentItem < 0) {
            // if we've looped back before the first item, move to the last one
            tickerData.currentItem = tickerData.newsItemCounter;
        }

        if (tickerData.currentPosition == 0) {
            if (tickerData.newsLinks[tickerData.currentItem].length > 0) {
                $(tickerData.newsList).empty().append('<li><a ' + tickerData.newsAttributes[tickerData.currentItem] + '></a></li>');
            }
            else {
                $(tickerData.newsList).empty().append('<li></li>');
            }
        }

        //only start the ticker itself if it's defined as animating: otherwise it's paused or under manual advance
        if (tickerData.animating) {

            if (tickerData.currentPosition % 2 == 0) {
                var placeHolder = tickerData.placeHolder1;
            }
            else {
                var placeHolder = tickerData.placeHolder2;
            }

            if (tickerData.currentPosition < tickerData.newsItems[tickerData.currentItem].length) {
                // we haven't completed ticking out the current item

                var tickerText = tickerData.newsItems[tickerData.currentItem].substring(0, tickerData.currentPosition);
                if (tickerData.newsLinks[tickerData.currentItem].length > 0) {
                    $(tickerData.newsList + ' li a').text(tickerText + placeHolder);
                }
                else {
                    $(tickerData.newsList + ' li').text(tickerText + placeHolder);
                }
                tickerData.currentPosition++;
                setTimeout(function () { runTicker(settings); settings = null; }, tickerData.tickerRate);
            }

            else {
                // we're on the last letter of the current item

                if (tickerData.newsLinks[tickerData.currentItem].length > 0) {
                    $(tickerData.newsList + ' li a').text(tickerData.newsItems[tickerData.currentItem]);
                }
                else {
                    $(tickerData.newsList + ' li').text(tickerData.newsItems[tickerData.currentItem]);
                }

                setTimeout(function () {
                    if (tickerData.animating) {
                        tickerData.currentPosition = 0;
                        tickerData.currentItem++;
                        runTicker(settings); settings = null;
                    }
                }, tickerData.loopDelay);

            }
        }

        else {// settings.animating == false 

            // display the full text of the current item
            var tickerText = tickerData.newsItems[tickerData.currentItem];

            if (tickerData.newsLinks[tickerData.currentItem].length > 0) {
                $(tickerData.newsList + ' li a').text(tickerText);
            }
            else {
                $(tickerData.newsList + ' li').text(tickerText);
            }

        }

    }


    // Core plugin setup and config
    jQuery.fn[name] = function (options) {

        // Add or overwrite options onto defaults
        var settings = jQuery.extend({}, jQuery.fn.newsTicker.defaults, options);

        var newsItems = new Array();
        var newsLinks = new Array();
        var newsAttributes = new Array();
        var newsItemCounter = 0;

        // Hide the static list items
        $(settings.newsList + ' li').hide();

        // Store the items and links in arrays for output
        $(settings.newsList + ' li').each(function () {
            if ($(this).children('a').length) {
                newsItems[newsItemCounter] = $(this).children('a').text();
                newsLinks[newsItemCounter] = $(this).children('a').attr('href');

                var linkAttributes = new Object();
                var attrs = $(this).children('a')[0].attributes;
                for (var i = 0; i < attrs.length; i++) {
                    linkAttributes[attrs[i].nodeName] = attrs[i].nodeValue;
                }
                if (debugMode) {
                    console.log(linkAttributes);
                }

                var linkAttributesProcessed = '';
                for (var prop in linkAttributes) {
                    // print out the attributes as a string ready for output within the anchor tag
                    linkAttributesProcessed = linkAttributesProcessed + prop + '="' + linkAttributes[prop] + '" ';
                }
                if (debugMode) {
                    console.log(linkAttributesProcessed);
                }

                newsAttributes[newsItemCounter] = linkAttributesProcessed;

            }
            else {
                newsItems[newsItemCounter] = $(this).text();
                newsLinks[newsItemCounter] = '';
                newsAttributes[newsItemCounter] = '';
            }
            newsItemCounter++;
        });

        var tickerElement = $(settings.newsList); // for quick reference below

        tickerElement.data(name, {
            newsList: settings.newsList,
            tickerRate: settings.tickerRate,
            startDelay: settings.startDelay,
            loopDelay: settings.loopDelay,
            placeHolder1: settings.placeHolder1,
            placeHolder2: settings.placeHolder2,
            controls: settings.controls,
            ownControls: settings.ownControls,
            stopOnHover: settings.stopOnHover,
            resumeOffHover: settings.resumeOffHover,
            newsItems: newsItems,
            newsLinks: newsLinks,
            newsAttributes: newsAttributes,
            newsItemCounter: newsItemCounter - 1, // -1 because we've incremented even after the last item (above)
            currentItem: 0,
            currentPosition: 0,
            firstRun: 1
        })
        .bind({
            stop: function (event) {
                // show remainder of the current item immediately
                tickerData = tickerElement.data(name);
                if (tickerData.animating) { // only stop if not already stopped
                    tickerData.animating = false;
                    if (debugMode) {
                        console.log('stop' + tickerData.currentItem + ' ' + tickerData.animating);
                    }
                }
            },
            play: function (event) {
                // show 1st item with startdelay
                tickerData = tickerElement.data(name);
                if (!tickerData.animating) { // if already animating, don't start animating again
                    tickerData.animating = true;
                    if (debugMode) {
                        console.log('play' + tickerData.currentItem + ' ' + tickerData.animating);
                    }
                    setTimeout(function () { runTicker(tickerData); tickerData = null; }, tickerData.startDelay);
                }
            },
            resume: function (event) {
                // start from next item, with no delay
                tickerData = tickerElement.data(name);
                if (!tickerData.animating) { // if already animating, don't start animating again
                    tickerData.animating = true;
                    // set the character position as 0 to ensure on resume we start at the right point
                    tickerData.currentPosition = 0;
                    tickerData.currentItem++;
                    if (debugMode) {
                        console.log('resume' + tickerData.currentItem + ' ' + tickerData.animating);
                    }
                    runTicker(tickerData); // no delay when resuming.
                }
            },
            next: function (event) {
                // show whole of next item
                tickerData = tickerElement.data(name);
                // stop (which sets as non-animating), and call runticker
                $(tickerData.newsList).trigger("stop");
                // set the character position as 0 to ensure on resume we start at the right point
                tickerData.currentPosition = 0;
                tickerData.currentItem++;
                if (debugMode) {
                    console.log('next' + tickerData.currentItem + ' ' + tickerData.animating);
                }
                runTicker(tickerData);
            },
            previous: function (event) {
                // show whole of previous item
                tickerData = tickerElement.data(name);
                // stop (which sets as non-animating), and call runticker
                $(tickerData.newsList).trigger("stop");
                // set the character position as 0 to ensure on resume we start at the right point
                tickerData.currentPosition = 0;
                tickerData.currentItem--;
                if (debugMode) {
                    console.log('previous' + tickerData.currentItem + ' ' + tickerData.animating);
                }
                runTicker(tickerData);
            }
        });
        if (settings.stopOnHover) {
            tickerElement.bind({
                mouseover: function (event) {
                    tickerData = tickerElement.data(name);
                    if (tickerData.animating) { // stop if not already stopped
                        $(tickerData.newsList).trigger("stop");
                        if (tickerData.controls) { // ensure that the ticker can be resumed if controls are enabled
                            $('.stop').hide();
                            $('.resume').show();
                        }
                    }
                }
            });
            if (settings.resumeOffHover) { // only allowed if stopOnHover enabled
                tickerElement.bind({
                    mouseout: function (event) {
                        tickerData = tickerElement.data(name);
                        if (!tickerData.animating) { // if already animating, don't start animating again
                            $(tickerData.newsList).trigger("resume");
                            if (debugMode) {
                                console.log('resumeoffhover' + tickerData.currentItem + ' ' + tickerData.animating);
                            }
                        }
                    }
                });
            }
        }

        tickerData = tickerElement.data(name);

        // set up control buttons if the option is on
        if (tickerData.controls || tickerData.ownControls) {
            if (!tickerData.ownControls) {
                $('<ul class="ticker-controls"><li class="play"><a href="#play">Play</a></li><li class="resume"><a href="#resume">Resume</a></li><li class="stop"><a href="#stop">Stop</a></li><li class="previous"><a href="#previous">Previous</a></li><li class="next"><a href="#next">Next</a></li></ul>').insertAfter($(tickerData.newsList));
            }
            $('.play').hide();
            $('.resume').hide();

            $('.play').click(function (event) {
                $(tickerData.newsList).trigger("play");
                $('.play').hide();
                $('.resume').hide();
                $('.stop').show();
                event.preventDefault();
            });
            $('.resume').click(function (event) {
                $(tickerData.newsList).trigger("resume");
                $('.play').hide();
                $('.resume').hide();
                $('.stop').show();
                event.preventDefault();
            });
            $('.stop').click(function (event) {
                $(tickerData.newsList).trigger("stop");
                $('.stop').hide();
                $('.resume').show();
                event.preventDefault();
            });
            $('.previous').click(function (event) {
                $(tickerData.newsList).trigger("previous");
                $('.stop').hide();
                $('.resume').show();
                event.preventDefault();
            });
            $('.next').click(function (event) {
                $(tickerData.newsList).trigger("next");
                $('.stop').hide();
                $('.resume').show();
                event.preventDefault();
            });

        };

        // tell it to play
        $(tickerData.newsList).trigger("play");
    };

    // News ticker defaults 
    jQuery.fn[name].defaults = {
        newsList: "#news",
        tickerRate: 80,
        startDelay: 100,
        loopDelay: 3000,
        placeHolder1: " |",
        placeHolder2: "_",
        controls: true,
        ownControls: false,
        stopOnHover: true,
        resumeOffHover: false
    }

})(jQuery);


/**
* jQuery.ScrollTo
* Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
* Dual licensed under MIT and GPL.
* Date: 5/25/2009
*
* @projectDescription Easy element scrolling using jQuery.
* http://flesler.blogspot.com/2007/10/jqueryscrollto.html
* Works with jQuery +1.2.6. Tested on FF 2/3, IE 6/7/8, Opera 9.5/6, Safari 3, Chrome 1 on WinXP.
*
* @author Ariel Flesler
* @version 1.4.2
*
* @id jQuery.scrollTo
* @id jQuery.fn.scrollTo
* @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements.
*	  The different options for target are:
*		- A number position (will be applied to all axes).
*		- A string position ('44', '100px', '+=90', etc ) will be applied to all axes
*		- A jQuery/DOM element ( logically, child of the element to scroll )
*		- A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc )
*		- A hash { top:x, left:y }, x and y can be any kind of number/string like above.
*		- A percentage of the container's dimension/s, for example: 50% to go to the middle.
*		- The string 'max' for go-to-end. 
* @param {Number} duration The OVERALL length of the animation, this argument can be the settings object instead.
* @param {Object,Function} settings Optional set of settings or the onAfter callback.
*	 @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
*	 @option {Number} duration The OVERALL length of the animation.
*	 @option {String} easing The easing method for the animation.
*	 @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
*	 @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }.
*	 @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes.
*	 @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
*	 @option {Function} onAfter Function to be called after the scrolling ends. 
*	 @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.
* @return {jQuery} Returns the same jQuery object, for chaining.
*
* @desc Scroll to a fixed position
* @example $('div').scrollTo( 340 );
*
* @desc Scroll relatively to the actual position
* @example $('div').scrollTo( '+=340px', { axis:'y' } );
*
* @dec Scroll using a selector (relative to the scrolled element)
* @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } );
*
* @ Scroll to a DOM element (same for jQuery object)
* @example var second_child = document.getElementById('container').firstChild.nextSibling;
*			$('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){
*				alert('scrolled!!');																   
*			}});
*
* @desc Scroll on both axes, to different values
* @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } );
*/
; (function ($) {

    var $scrollTo = $.scrollTo = function (target, duration, settings) {
        $(window).scrollTo(target, duration, settings);
    };

    $scrollTo.defaults = {
        axis: 'xy',
        duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1
    };

    // Returns the element that needs to be animated to scroll the window.
    // Kept for backwards compatibility (specially for localScroll & serialScroll)
    $scrollTo.window = function (scope) {
        return $(window)._scrollable();
    };

    // Hack, hack, hack :)
    // Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
    $.fn._scrollable = function () {
        return this.map(function () {
            var elem = this,
				isWin = !elem.nodeName || $.inArray(elem.nodeName.toLowerCase(), ['iframe', '#document', 'html', 'body']) != -1;

            if (!isWin)
                return elem;

            var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;

            return $.browser.safari || doc.compatMode == 'BackCompat' ?
				doc.body :
				doc.documentElement;
        });
    };

    $.fn.scrollTo = function (target, duration, settings) {
        if (typeof duration == 'object') {
            settings = duration;
            duration = 0;
        }
        if (typeof settings == 'function')
            settings = { onAfter: settings };

        if (target == 'max')
            target = 9e9;

        settings = $.extend({}, $scrollTo.defaults, settings);
        // Speed is still recognized for backwards compatibility
        duration = duration || settings.speed || settings.duration;
        // Make sure the settings are given right
        settings.queue = settings.queue && settings.axis.length > 1;

        if (settings.queue)
        // Let's keep the overall duration
            duration /= 2;
        settings.offset = both(settings.offset);
        settings.over = both(settings.over);

        return this._scrollable().each(function () {
            var elem = this,
				$elem = $(elem),
				targ = target, toff, attr = {},
				win = $elem.is('html,body');

            switch (typeof targ) {
                // A number will pass the regex 
                case 'number':
                case 'string':
                    if (/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)) {
                        targ = both(targ);
                        // We are done
                        break;
                    }
                    // Relative selector, no break!
                    targ = $(targ, this);
                case 'object':
                    // DOMElement / jQuery
                    if (targ.is || targ.style)
                    // Get the real position of the target 
                        toff = (targ = $(targ)).offset();
            }
            $.each(settings.axis.split(''), function (i, axis) {
                var Pos = axis == 'x' ? 'Left' : 'Top',
					pos = Pos.toLowerCase(),
					key = 'scroll' + Pos,
					old = elem[key],
					max = $scrollTo.max(elem, axis);

                if (toff) {// jQuery / DOMElement
                    attr[key] = toff[pos] + (win ? 0 : old - $elem.offset()[pos]);

                    // If it's a dom element, reduce the margin
                    if (settings.margin) {
                        attr[key] -= parseInt(targ.css('margin' + Pos)) || 0;
                        attr[key] -= parseInt(targ.css('border' + Pos + 'Width')) || 0;
                    }

                    attr[key] += settings.offset[pos] || 0;

                    if (settings.over[pos])
                    // Scroll to a fraction of its width/height
                        attr[key] += targ[axis == 'x' ? 'width' : 'height']() * settings.over[pos];
                } else {
                    var val = targ[pos];
                    // Handle percentage values
                    attr[key] = val.slice && val.slice(-1) == '%' ?
						parseFloat(val) / 100 * max
						: val;
                }

                // Number or 'number'
                if (/^\d+$/.test(attr[key]))
                // Check the limits
                    attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max);

                // Queueing axes
                if (!i && settings.queue) {
                    // Don't waste time animating, if there's no need.
                    if (old != attr[key])
                    // Intermediate animation
                        animate(settings.onAfterFirst);
                    // Don't animate this axis again in the next iteration.
                    delete attr[key];
                }
            });

            animate(settings.onAfter);

            function animate(callback) {
                $elem.animate(attr, duration, settings.easing, callback && function () {
                    callback.call(this, target, settings);
                });
            };

        }).end();
    };

    // Max scrolling position, works on quirks mode
    // It only fails (not too badly) on IE, quirks mode.
    $scrollTo.max = function (elem, axis) {
        var Dim = axis == 'x' ? 'Width' : 'Height',
			scroll = 'scroll' + Dim;

        if (!$(elem).is('html,body'))
            return elem[scroll] - $(elem)[Dim.toLowerCase()]();

        var size = 'client' + Dim,
			html = elem.ownerDocument.documentElement,
			body = elem.ownerDocument.body;

        return Math.max(html[scroll], body[scroll])
			 - Math.min(html[size], body[size]);

    };

    function both(val) {
        return typeof val == 'object' ? val : { top: val, left: val };
    };

})(jQuery);

/**
 * jquery.simpletip 1.3.1. A simple tooltip plugin
 * 
 * Copyright (c) 2009 Craig Thompson
 * http://craigsworks.com
 *
 * Licensed under GPLv3
 * http://www.opensource.org/licenses/gpl-3.0.html
 *
 * Launch  : February 2009
 * Version : 1.3.1
 * Released: February 5, 2009 - 11:04am
 */
(function($){function Simpletip(elem,conf){var self=this;elem=jQuery(elem);var tooltip=jQuery(document.createElement('div')).addClass(conf.baseClass).addClass((conf.fixed)?conf.fixedClass:'').addClass((conf.persistent)?conf.persistentClass:'').html(conf.content).appendTo(elem);if(!conf.hidden)tooltip.show();else tooltip.hide();if(!conf.persistent){elem.hover(function(event){self.show(event)},function(){self.hide()});if(!conf.fixed){elem.mousemove(function(event){if(tooltip.css('display')!=='none')self.updatePos(event);});};}else
{elem.click(function(event){if(event.target===elem.get(0)){if(tooltip.css('display')!=='none')self.hide();else
self.show();};});jQuery(window).mousedown(function(event){if(tooltip.css('display')!=='none'){var check=(conf.focus)?jQuery(event.target).parents('.tooltip').andSelf().filter(function(){return this===tooltip.get(0)}).length:0;if(check===0)self.hide();};});};jQuery.extend(self,{getVersion:function(){return[1,2,0];},getParent:function(){return elem;},getTooltip:function(){return tooltip;},getPos:function(){return tooltip.offset();},setPos:function(posX,posY){var elemPos=elem.offset();if(typeof posX=='string')posX=parseInt(posX)+elemPos.left;if(typeof posY=='string')posY=parseInt(posY)+elemPos.top;tooltip.css({left:posX,top:posY});return self;},show:function(event){conf.onBeforeShow.call(self);self.updatePos((conf.fixed)?null:event);switch(conf.showEffect){case'fade':tooltip.fadeIn(conf.showTime);break;case'slide':tooltip.slideDown(conf.showTime,self.updatePos);break;case'custom':conf.showCustom.call(tooltip,conf.showTime);break;default:case'none':tooltip.show();break;};tooltip.addClass(conf.activeClass);conf.onShow.call(self);return self;},hide:function(){conf.onBeforeHide.call(self);switch(conf.hideEffect){case'fade':tooltip.fadeOut(conf.hideTime);break;case'slide':tooltip.slideUp(conf.hideTime);break;case'custom':conf.hideCustom.call(tooltip,conf.hideTime);break;default:case'none':tooltip.hide();break;};tooltip.removeClass(conf.activeClass);conf.onHide.call(self);return self;},update:function(content){tooltip.html(content);conf.content=content;return self;},load:function(uri,data){conf.beforeContentLoad.call(self);tooltip.load(uri,data,function(){conf.onContentLoad.call(self);});return self;},boundryCheck:function(posX,posY){var newX=posX+tooltip.outerWidth();var newY=posY+tooltip.outerHeight();var windowWidth=jQuery(window).width()+jQuery(window).scrollLeft();var windowHeight=jQuery(window).height()+jQuery(window).scrollTop();return[(newX>=windowWidth),(newY>=windowHeight)];},updatePos:function(event){var tooltipWidth=tooltip.outerWidth();var tooltipHeight=tooltip.outerHeight();if(!event&&conf.fixed){if(conf.position.constructor==Array){posX=parseInt(conf.position[0]);posY=parseInt(conf.position[1]);}else if(jQuery(conf.position).attr('nodeType')===1){var offset=jQuery(conf.position).offset();posX=offset.left;posY=offset.top;}else
{var elemPos=elem.offset();var elemWidth=elem.outerWidth();var elemHeight=elem.outerHeight();switch(conf.position){case'top':var posX=elemPos.left-(tooltipWidth/2)+(elemWidth/2);var posY=elemPos.top-tooltipHeight;break;case'bottom':var posX=elemPos.left-(tooltipWidth/2)+(elemWidth/2);var posY=elemPos.top+elemHeight;break;case'left':var posX=elemPos.left-tooltipWidth;var posY=elemPos.top-(tooltipHeight/2)+(elemHeight/2);break;case'right':var posX=elemPos.left+elemWidth;var posY=elemPos.top-(tooltipHeight/2)+(elemHeight/2);break;default:case'default':var posX=(elemWidth/2)+elemPos.left+20;var posY=elemPos.top;break;};};}else
{var posX=event.pageX;var posY=event.pageY;};if(typeof conf.position!='object'){posX=posX+conf.offset[0];posY=posY+conf.offset[1];if(conf.boundryCheck){var overflow=self.boundryCheck(posX,posY);if(overflow[0])posX=posX-(tooltipWidth/2)-(2*conf.offset[0]);if(overflow[1])posY=posY-(tooltipHeight/2)-(2*conf.offset[1]);}}else
{if(typeof conf.position[0]=="string")posX=String(posX);if(typeof conf.position[1]=="string")posY=String(posY);};self.setPos(posX,posY);return self;}});};jQuery.fn.simpletip=function(conf){var api=jQuery(this).eq(typeof conf=='number'?conf:0).data("simpletip");if(api)return api;var defaultConf={content:'A simple tooltip',persistent:false,focus:false,hidden:true,position:'default',offset:[0,0],boundryCheck:true,fixed:true,showEffect:'fade',showTime:150,showCustom:null,hideEffect:'fade',hideTime:150,hideCustom:null,baseClass:'tooltip',activeClass:'active',fixedClass:'fixed',persistentClass:'persistent',focusClass:'focus',onBeforeShow:function(){},onShow:function(){},onBeforeHide:function(){},onHide:function(){},beforeContentLoad:function(){},onContentLoad:function(){}};jQuery.extend(defaultConf,conf);this.each(function(){var el=new Simpletip(jQuery(this),defaultConf);jQuery(this).data("simpletip",el);});return this;};})();
