// document.ready
$(function () {

    // IE6 Fail
    if (typeof (console) === 'undefined') {
        $('body').append('<div id="consoleLog" style="display: none;"></div>');
        console = { log: function (msg) { /* $('#consoleLog').append(msg); */ } };
    }
    $('.ie6 .leftNav li:first-child').addClass('first-child'); // Fix IE6 first-child selectors on leftnav
    if ($('.ie6 .workPreview,.ie6 .emailThis').length) {
        //IE6 bgiframe fix for Work page dropdown behing .workPreview popups
        $('.ie6 .workPreview, .ie6 .emailThis').bgiframe();
    }

    // Initialise homepage feature pane
    FeaturePane.init();

    // Initialise work showcase
    WorkShowcase.init();

    // Anything with class tooltip has it's title text styled
    var isiPad = navigator.userAgent.match(/iPad/i) != null;
    if (!Modernizr.touch) {
        attachTooltips();
    }

    // Highlight current section of the site in main nav
    $('#mainNav a, #topRightNav a').each(function (i) {
        if (window.location.pathname.indexOf($(this).attr('href')) >= 0) {
            $(this).addClass('selected');
        }
        if (window.location.pathname.indexOf($(this).attr('rel')) >= 0) {
            // Work pages should highlight Clients link
            $(this).addClass('selected');
        }
        if ($(this).attr('href').indexOf(window.location.pathname.substr(1).split('-')[0]) >= 0 && window.location.pathname.substr(1).split('-')[0]) {
            $(this).addClass('selected');
        }
    });

    // Print current page link
    $('.printLink').live('click', function (e) {
        e.preventDefault();
        window.print();
    });

    // Custom Share link
    var shareTimeout;
    $('.shareText, .shareThis .plusIcon').live('click', function (e) {
        if (!$('.shareThis').hasClass('active')) {
            if ($('.ie6 .shareButtons, .ie7 .shareButtons').length) {
                $('.ie6 .shareButtons, .ie7 .shareButtons').show();
            }
            else {
                $('.shareButtons').animate({
                    left: '0',
                    opacity: '1'
                }, 1000);
            }
            $('.shareThis').addClass('active');
            $('.shareThis .plusIcon').html('-');
            shareTimeout = setTimeout(function () {
                $('.shareText').click();
            }, 5000);
        }
        else {
            clearTimeout(shareTimeout);
            if ($('.ie6 .shareButtons, .ie7 .shareButtons').length) {
                $('.ie6 .shareButtons, .ie7 .shareButtons').hide();
            }
            else {
                $('.shareButtons').animate({
                    left: '120px',
                    opacity: '0'
                }, 1000);
            }
            $('.shareThis').removeClass('active');
            $('.shareThis .plusIcon').html('+');
        }
    });
    $('.shareButton').live('click', function (e) {
        clearTimeout(shareTimeout);
    });
    /*
    $('.shareButton.email').live('click', function (e) {
			e.preventDefault();
			var position = $(this).offset();
			position.top += 20;
			position.left -= 430;
			$('.emailThis').css(position).slideDown(500);
			$('.transparentOverlay').show();
    });
    */
    $('.transparentOverlay').live('click', function (e) {
        $('.emailThis,.transparentOverlay').fadeOut();
        $('.shareText').click();
    });
    //$('.emailThis textarea').val($('.emailThis textarea').val().replace('http://www.openplatform.co.uk/', window.location.href));
    $('.shareButton.facebook').attr('href', 'http://www.facebook.com/sharer.php?u=' + encodeURI(window.location.href) + '&t=' + encodeURI(document.title));
    $('.shareButton.email').attr('href', $('.shareButton.email').attr('href') + encodeURI(window.location.href));


    // Attach the URL pagename as a class on the body, so we can target specific pages in CSS
    var pageName = window.location.pathname.replace('.aspx', '').replace('/', '');
    if (!pageName) {
        pageName = 'Home';
    }
    $('body').addClass(pageName);

    // Initialise lightbox images
    $('a.lightBox').lightBox({ fixedNavigation: true });

    // Form validation hack to get thanks message fading in nicely.
    if ($('.formSubmittedSuccessfullyPane input:eq(0)').val() == 'true') {
        $('.thankYouMessage').fadeIn(800);
    }

    // Hack to vertically align clientSpotlight logo with it's (variable-length) description
    if ($('.clientSpotlight').length) {
        var $clientImagePane = $('.clientSpotlight').find('div:eq(0)');
        var $clientDescription = $clientImagePane.next('div');
        $clientImagePane.css('line-height', $clientDescription.height() + 'px');
    }

    // Custom style for recaptcha (contact page)
    // Note custom styling proper way: http://code.google.com/apis/recaptcha/docs/customization.html
    if ($('#recaptcha_logo').length) {
        $('#recaptcha_logo').remove();
        $('#recaptcha_tagline').remove();
        $('.recaptchatable').css('border', 'none !important');
        $('.recaptchatable td').css('padding-left', '0 !important');
        $('.recaptchatable #recaptcha_response_field').css('width', '285px');
        $('.recaptchatable #recaptcha_response_field').css('border-color', '#CCC');
        $('img#recaptcha_reload').attr('src', '/images/recaptcha/refresh.png');
        $('img#recaptcha_switch_audio').attr('src', '/images/recaptcha/audio.png');
        $('img#recaptcha_whatsthis').attr('src', '/images/recaptcha/help.png');
    }

});


/*
FeaturePane object encapsulates all functionality for homepage feature
panel. Note there are both CTA "Feature" panes. And the slideshow "Slides".

The "slides" property is an array of "slide" objects
    
If a slide object has a source property, this is a URL that will be
loaded with Ajax. It must then also have an onLoad property which
is a function that should initialise that slide.

Each slide also has an unLoad property which is a function that is
executed once another slide is loaded.

init method attaches event handlers to CTAs and slide navigation.
*/
var FeaturePane = {

    paneNumber: null,   // Currently loaded feature pane. One based.

    slideIndex: 0,      // For slideshow panels. Zero based.

    slides: [
        {
            id: 'slide1',
            background: '../images/features/heroBanner1.jpg',
            slideInterval: 6000
        },
        {
            id: 'slide2',
            background: '../images/features/heroBanner2.jpg',
            slideInterval: 6000
        },
        {
            id: 'slide3',
            background: '../images/features/heroBanner3.jpg',
            slideInterval: 6000
        },
        {
            id: 'slide4',
            background: '../images/features/heroBanner4.jpg',
            slideInterval: 6000
        }
    /*
    {
    id: 'slide3',
    background: '../images/features/heroBanner3.jpg',
    slideInterval: 18000,
    source: '/slides/slide3.html',
    onLoad: function () {
    // DEMO: HTML5 Video
    if ($('.no-video').length == 0) {
    //document.getElementById('slide3Video').play();    // temporarily disabled (it's annoying during dev)
    }
    // TODO: Flash video play (? - I think it does by default)
    },
    isLoaded: false,
    onUnload: function () {
    // DEMO: HTML5 Video
    if ($('.no-video').length == 0) {
    document.getElementById('slide3Video').pause();
    }
    // TODO: Flash video pause
    }
    },
    {
    id: 'slide4',
    background: '../images/features/heroBanner4.jpg',
    slideInterval: 8000,
    source: '/slides/slide4.html',
    onLoad: function () {
    // DEMO: Simple JS "perspective" based landscape
    // https://github.com/stephband/jparallax
    $('.parallax-layer').parallax({
    mouseport: jQuery(".port")
    });
    }
    },
    {
    id: 'slide5',
    slideInterval: 40000,
    source: '/slides/slide5.html',
    onLoad: function () {
    // DEMO: Simple canvas functionality
    var canvas = document.getElementById('canvas');
    var context = null;
    var x = 920;
    var y = 292;
    var dx = 5;
    var dy = 5;
    var img = new Image();
    img.src = '/images/features/html5CanvasImage.png';

    if (Modernizr.canvas) {
    // Draw a circle on the canvas every 10 milliseconds
    img.onload = function () {
    context = canvas.getContext('2d');
    setInterval(drawCanvasCircle, 10);
    context.drawImage(img, 0, 0, 920, 292);
    }
    }
    else {
    // Canvas not available. embed flash
    var flashvars = {};
    var params = { 'wmode': 'transparent' };
    var attributes = {};
    swfobject.embedSWF("/swfs/bannerTest.swf", "slide5FlashContainer", "920", "292", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
    }

    function drawCanvasCircle() {
    //context.clearRect(0, 0, 920, 292);    //purpose?
    context.drawImage(img, 0, 0, 920, 292);
    context.beginPath();
    context.fillStyle = "#FFFFFF";
    // Draws a circle of radius 20 at the coordinates 100,100 on the canvas
    context.arc(x, y, 10, 0, Math.PI * 2, true);
    context.closePath();
    context.fill();
    // Boundary Logic
    if (x < 0 || x > 920) dx = -dx;
    if (y < 0 || y > 292) dy = -dy;
    x += dx;
    y += dy;
    }
    },
    isLoaded: false
    }
    */
    ],

    getCurrentSlide: function () {
        return this.slides[this.slideIndex];
    },

    // Loads the CURRENT slide. Can provide parameter to switch to any given slide
    loadSlide: function (slideIndex) {

        if (this.getCurrentSlide().onUnload) {
            this.getCurrentSlide().onUnload();
        }

        if (slideIndex !== 'undefined' && parseInt(slideIndex) >= 0 && parseInt(slideIndex) < this.slides.length) {
            this.slideIndex = parseInt(slideIndex)
        }

        if (FeaturePane.slideTimer) {
            clearTimeout(FeaturePane.slideTimer);
        }
        FeaturePane.slideTimer = setTimeout(FeaturePane.nextSlide, this.getCurrentSlide().slideInterval);

        // Grab the slide's div
        var $getCurrentSlidePane = $('#' + this.getCurrentSlide().id);
        // Set the slide's background if it has been specified
        if (this.getCurrentSlide().background) {
            $('#' + this.getCurrentSlide().id).css('background', 'url(' + this.getCurrentSlide().background + ')');
        }
        // Check if the slide requires an external source (Lazy Loading)
        if (this.getCurrentSlide().source && !this.getCurrentSlide().isLoaded) {
            this.getCurrentSlide().isLoaded = true;    // Mark slide as loaded so we don't make request on next load
            var getCurrentSlideCallback = this.getCurrentSlide().onLoad;
            $('.loadingPane').fadeIn();
            // Fetch the external content for the slide
            $getCurrentSlidePane.load(this.getCurrentSlide().source, function (d) {
                // getCurrentSlideCallback is for rendering Canvas or other in-slide content
                getCurrentSlideCallback();
                // Hide visible slide
                $('.slide').fadeOut();
                $getCurrentSlidePane.fadeIn(function () {
                    // Hide any loading icons
                    $('.loadingPane').fadeOut();
                    $('.slide:hidden .loadingPane').css('display', 'none'); // fadeOut does not hide non-visible element
                });
            });
        }
        else {
            // Hide any visible slides (check is required for INITIAL page load)
            if ($('.slide:visible').length) {
                $('.slide').fadeOut();
            }
            // Fade in the current slide
            $getCurrentSlidePane.fadeIn(function () {
                // Hide any loading icons
                $('.loadingPane').fadeOut();
                $('.slide:hidden .loadingPane').css('display', 'none'); // fadeOut does not hide non-visible element
            });
        }
    },

    previousSlide: function () {
        var slideIndex = FeaturePane.slideIndex - 1;
        if (slideIndex < 0) {
            slideIndex = FeaturePane.slides.length - 1; // back to end
        }
        FeaturePane.loadSlide(slideIndex);
    },

    nextSlide: function () {
        var slideIndex = FeaturePane.slideIndex + 1;
        if (slideIndex >= FeaturePane.slides.length) {
            slideIndex = 0; // back to start
        }
        FeaturePane.loadSlide(slideIndex);
    },

    switchFeatureOn: function (paneNumber) {

        $('.featureShadow>div').first().removeClass('cta' + this.paneNumber);
        $('#ctas article').removeClass('active');

        this.paneNumber = paneNumber;
        $('#featureContainer').addClass('cta' + paneNumber);
        $('.featureShadow>div').first().addClass('cta' + paneNumber);
        $('#featureContainer .feature').slideUp();

        var marginLeft = (paneNumber - 1) * 235;    // 215 box plus 20 margin
        $('.featureShadow div.cta' + paneNumber).css('margin-left', marginLeft + 'px');

        $thisCtaPane = $('#cta' + paneNumber).addClass('active');

        // Note down and up are inverted:
        //  http://www.learningjquery.com/2009/02/slide-elements-in-different-directions
        $('#feature' + paneNumber).slideDown(300);

    },

    switchFeaturesOff: function () {
        $('#featureContainer').removeClass('cta' + this.paneNumber);
        $('.featureShadow>div').first().removeClass('cta' + this.paneNumber);
        $('#ctas article').removeClass('active');

        // Note down and up are inverted:
        //  http://www.learningjquery.com/2009/02/slide-elements-in-different-directions
        $('#featureContainer .feature').slideUp(300);
    },

    init: function () {

        // Return if there is no feature container on a given page (homepage only)
        if ($('#featureContainer').length === 0) {
            //console.log('No feature panel available. Skipping FeaturePane.init()');
            return;
        }

        // Load first slide
        console.log(Math.floor(Math.random() * FeaturePane.slides.length));
        FeaturePane.loadSlide(Math.floor(Math.random() * FeaturePane.slides.length));

        // Event handles for next and previous slide links
        $('.nextSlide').live('click', function (e) {
            e.preventDefault();
            FeaturePane.nextSlide();
        });
        $('.previousSlide').live('click', function (e) {
            e.preventDefault();
            FeaturePane.previousSlide();
        });

        // The circles in the bottom right of slides allow jumping to any slide
        $('.slideNavigation a').live('click', function (e) {
            e.preventDefault();
            // 2nd slide has slideIndex 1. 2nd link has 1 previous sibling. Therefore...
            var slideIndex = $(this).prevAll('a').length;
            FeaturePane.loadSlide(slideIndex);
        });

        // Features slide up over the carousel on click
        $('#ctas article').live('click', function (e) {
            e.preventDefault();
            if ($(this).hasClass('active')) {
                FeaturePane.switchFeaturesOff();
            }
            else {
                FeaturePane.switchFeatureOn($(this).attr('rel'));
            }
        });

        $('.closeThisFeature').live('click', function (e) {
            e.preventDefault();
            FeaturePane.switchFeaturesOff();
        });
    }
}

/*
WorkShowcase object encapsulates all functionality for work/portfolio screen
This mostly consists of isotope plugin to provide animated filtering
http://isotope.metafizzy.co/   (License purchased on 2011.09.27)
*/
var WorkShowcase = {

    init: function () {

        // Return if there are no work items on a given page
        if ($('.workShowcaseItem').length === 0) {
            //console.log('No work showcase available. Skipping WorkShowcase.init()');
            return;
        }

        // Number the workShowcaseItem tiles and workPreview tiles.
        // They must be in the same order to be related
        $('.workShowcaseItem').each(function (i) {
            $(this).attr('rel', i);
        });
        $('.workPreview').each(function (i) {
            $(this).attr('rel', i);
        });

        // Tooltip preview of jobs
        $('.workShowcaseItem').hoverIntent(function (e) {
            // Position the tooltip next to the thumbnail
            var position = $(this).offset();
						
            // Shift panel horizontally if close to the edge of the screen
            var cursorInRightHalf = ((($(window).width() / 2) - e.clientX - 4) < 0);
            if (cursorInRightHalf) {
                position.left -= 490;
            }
            else {
                position.left += 140;
            }

            // Shift panel vertically if close to the edge of the screen
            if ($(window).height() - e.clientY < 400) {
                position.top -= 300;    // too close to the bottom
            }
            else if (e.clientY < 300) {
                // too close to the top
            }
            else {
                position.top -= 200;    // right in the center
            }
						
						// Firefox gets confused what $(this) is - always thinks it's the first tile (because of isotope)
						// 	so we manually adjust it's position
						if ($.browser.mozilla) {
							$('.workPreview').css('position', 'fixed');
							if (cursorInRightHalf) {
									position.left = e.clientX - 490;
							}
							else {
									position.left = e.clientX + 40;
							}

							// Shift panel vertically if close to the edge of the screen
							if ($(window).height() - e.clientY < 400) {
									position.top = e.clientY - 380;    // too close to the bottom
							}
							else if (e.clientY < 300) {
									// too close to the top
							}
							else {
									position.top = e.clientY - 200;    // right in the center
									//console.log(position.top);
							}
						}

            var src = $(this).find('img').attr('src');

            $('.workPreview[rel=' + $(this).attr('rel') + ']').find('img').attr('src', '/images/work/popups' + src.slice(src.lastIndexOf('/')));
            $('.workPreview[rel=' + $(this).attr('rel') + ']').css(position).fadeIn(300);
        },
        function () {
            $('.workPreview').fadeOut(150);
        });

        // Client dropdown select
        $('#clientDropdown').live('change', function () {
            $('.workTypes a.selected').removeClass('selected');
            if ($(this).val() == '*') {
                $('.workShowcase').isotope({ filter: '' });
                //window.location.hash = '#' + $('#clientDropdown').val();  // usability benefits are disputable
            }
            else {
                $('.workShowcase').isotope({ filter: '.' + $('#clientDropdown').val() });
            }
            WorkShowcase.checkForNoMatches();
        });

        // Quick filter link click
        $('.workTypes a').live('click', function (e) {
            e.preventDefault();

            $('#clientDropdown').val('All Clients');

            if ($(this).hasClass('selected')) {
                $('.workTypes a').removeClass('selected');
                $('.workShowcase').isotope({ filter: '' });
                return;
            }

            $('.workTypes a').removeClass('selected');

            $(this).addClass('selected');

            if ($(this).html() == 'All') {
                $('.workShowcase').isotope({ filter: '' });
            }
            else {
                $('.workShowcase').isotope({ filter: '.' + $('.workTypes a.selected').html() });
                //window.location.hash = '#' + $('.workTypes a.selected').html();  // usability benefits are disputable
            }
            WorkShowcase.checkForNoMatches();
        });

        // Prevent clicks on items which have no case study to link to
        $('.workShowcase .noCaseStudy').live('click', function (e) {
            e.preventDefault();
            // Nowhere to go!
        });

        // If the URL ends with a filter, click the appropriate filter
        //  once we have waited 400ms to allow the isotope to construct
        if ($('.workTypes a').length) {
            $('.workShowcase').waitForImages(function () {

                var hash = window.location.hash.substr(1);
                if (window.location.hash && $('.workTypes a:contains(' + hash + ')').length) {
                    $('.workTypes a:contains(' + hash + ')').click();
                    WorkShowcase.checkForNoMatches();
                }
                else if (window.location.hash && $('#clientDropdown option[value=' + hash + ']').length) {
                    //alert('ffs');
                    $('#clientDropdown').val(hash);
                    $('#clientDropdown').trigger('change');
                    WorkShowcase.checkForNoMatches();
                }
                else {
                    $('.workShowcase').isotope({ filter: '' });
                }

            });
        }
    },

    // If no tiles are visible, display apology message
    checkForNoMatches: function () {
        if ($('.isotope-hidden').length == $('.workShowcaseItem').length) {
            $('.noMatches').fadeIn(1000);
        }
        else {
            $('.noMatches').hide();
        }
    }

};

function attachTooltips(xOffset, yOffset) {
    if (typeof xOffset == 'undefined') {
        xOffset = 0;
    }
    if (typeof yOffset == 'undefined') {
        yOffset = -30;
    }
    $(".tooltip").live('mouseenter', function (e) {
        this.t = this.title;
        this.title = "";
        if ($(this).attr('rel') && $('#' + $(this).attr('rel')).length) {
            this.t = $('#' + $(this).attr('rel')).html();
        }
        $("body").append('<div id="tooltip"><img src="/images/arrow-grey-u.gif" class="arrow">' + this.t + "</div>");
        var cursorInRightHalf = ((($(window).width() / 2) - e.clientX - 4) < 0);
        if (cursorInRightHalf) {
            $('#tooltip .arrow').addClass('right');
            xOffset = -$('#tooltip').width() - 40;
        }
        else {
            $('#tooltip .arrow').removeClass('right');
        }
        $("#tooltip")
			.css("top", (e.pageY - yOffset) + "px")
			.css("left", (e.pageX + xOffset) + "px")
			.fadeIn("fast");
    });
    $(".tooltip").live('mouseleave', function (e) {
        if ($(this).attr('rel') && $('#' + $(this).attr('rel')).length) {
            this.title = '';
        }
        else {
            this.title = this.t;
        }
        xOffset = 0;
        yOffset = -30;

        $("#tooltip").remove();
    });
    $(".tooltip").live('mousemove', function (e) {
        $("#tooltip")
			.css("top", (e.pageY - yOffset) + "px")
			.css("left", (e.pageX + xOffset) + "px");
    });
}


/**
* hoverIntent r6 // 2011.02.26 // jQuery 1.5.1+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne brian(at)cherne(dot)net
*/
(function ($) { $.fn.hoverIntent = function (f, g) { var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; cfg = $.extend(cfg, g ? { over: f, out: g} : f); var cX, cY, pX, pY; var track = function (ev) { cX = ev.pageX; cY = ev.pageY }; var compare = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); if ((Math.abs(pX - cX) + Math.abs(pY - cY)) < cfg.sensitivity) { $(ob).unbind("mousemove", track); ob.hoverIntent_s = 1; return cfg.over.apply(ob, [ev]) } else { pX = cX; pY = cY; ob.hoverIntent_t = setTimeout(function () { compare(ev, ob) }, cfg.interval) } }; var delay = function (ev, ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob, [ev]) }; var handleHover = function (e) { var ev = jQuery.extend({}, e); var ob = this; if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t) } if (e.type == "mouseenter") { pX = ev.pageX; pY = ev.pageY; $(ob).bind("mousemove", track); if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout(function () { compare(ev, ob) }, cfg.interval) } } else { $(ob).unbind("mousemove", track); if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout(function () { delay(ev, ob) }, cfg.timeout) } } }; return this.bind('mouseenter', handleHover).bind('mouseleave', handleHover) } })(jQuery);


/**
* Isotope v1.4.110906
* 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) { b.elemCount++; 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() }), this.element.delegate("." + this.options.hiddenClass, "click", function () { return !1 }) }, _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) !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); 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").undelegate("." + this.options.hiddenClass, "click").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) { function h() { --e <= 0 && this.src !== f && (setTimeout(g), d.unbind("load error", h)) } function g() { a.call(b, d) } var b = this, d = b.find("img").add(b.filter("img")), e = d.length, f = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="; e || g(), d.bind("load error", h).each(function () { if (this.complete || this.complete === c) { var a = this.src; this.src = f, this.src = a } }); return b }; 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);


/**
* jQuery lightBox plugin
* This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
* and adapted to me for use like a plugin from jQuery.
* @name jquery-lightbox-0.5.js
* @author Leandro Vieira Pinho - http://leandrovieira.com
* @version 0.5
* @date April 11, 2008
* @category jQuery plugin
* @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
* @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
* @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
*/
eval(function (p, a, c, k, e, r) { e = function (c) { return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function (e) { return r[e] } ]; e = function () { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p } ('(6($){$.2N.3g=6(4){4=23.2H({2B:\'#34\',2g:0.8,1d:F,1M:\'18/5-33-Y.16\',1v:\'18/5-1u-2Q.16\',1E:\'18/5-1u-2L.16\',1W:\'18/5-1u-2I.16\',19:\'18/5-2F.16\',1f:10,2A:3d,2s:\'1j\',2o:\'32\',2j:\'c\',2f:\'p\',2d:\'n\',h:[],9:0},4);f I=N;6 20(){1X(N,I);u F}6 1X(1e,I){$(\'1U, 1S, 1R\').l({\'1Q\':\'2E\'});1O();4.h.B=0;4.9=0;7(I.B==1){4.h.1J(v 1m(1e.17(\'J\'),1e.17(\'2v\')))}j{36(f i=0;i<I.B;i++){4.h.1J(v 1m(I[i].17(\'J\'),I[i].17(\'2v\')))}}2n(4.h[4.9][0]!=1e.17(\'J\')){4.9++}D()}6 1O(){$(\'m\').31(\'<e g="q-13"></e><e g="q-5"><e g="5-s-b-w"><e g="5-s-b"><1w g="5-b"><e 2V="" g="5-k"><a J="#" g="5-k-V"></a><a J="#" g="5-k-X"></a></e><e g="5-Y"><a J="#" g="5-Y-29"><1w W="\'+4.1M+\'"></a></e></e></e><e g="5-s-b-T-w"><e g="5-s-b-T"><e g="5-b-A"><1i g="5-b-A-1t"></1i><1i g="5-b-A-1g"></1i></e><e g="5-1s"><a J="#" g="5-1s-22"><1w W="\'+4.1W+\'"></a></e></e></e></e>\');f z=1D();$(\'#q-13\').l({2K:4.2B,2J:4.2g,S:z[0],P:z[1]}).1V();f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]}).E();$(\'#q-13,#q-5\').C(6(){1a()});$(\'#5-Y-29,#5-1s-22\').C(6(){1a();u F});$(G).2G(6(){f z=1D();$(\'#q-13\').l({S:z[0],P:z[1]});f R=1p();$(\'#q-5\').l({1T:R[1]+(z[3]/10),1c:R[0]})})}6 D(){$(\'#5-Y\').E();7(4.1d){$(\'#5-b,#5-s-b-T-w,#5-b-A-1g\').1b()}j{$(\'#5-b,#5-k,#5-k-V,#5-k-X,#5-s-b-T-w,#5-b-A-1g\').1b()}f Q=v 1j();Q.1P=6(){$(\'#5-b\').2D(\'W\',4.h[4.9][0]);1N(Q.S,Q.P);Q.1P=6(){}};Q.W=4.h[4.9][0]};6 1N(1o,1r){f 1L=$(\'#5-s-b-w\').S();f 1K=$(\'#5-s-b-w\').P();f 1n=(1o+(4.1f*2));f 1y=(1r+(4.1f*2));f 1I=1L-1n;f 2z=1K-1y;$(\'#5-s-b-w\').3f({S:1n,P:1y},4.2A,6(){2y()});7((1I==0)&&(2z==0)){7($.3e.3c){1H(3b)}j{1H(3a)}}$(\'#5-s-b-T-w\').l({S:1o});$(\'#5-k-V,#5-k-X\').l({P:1r+(4.1f*2)})};6 2y(){$(\'#5-Y\').1b();$(\'#5-b\').1V(6(){2u();2t()});2r()};6 2u(){$(\'#5-s-b-T-w\').38(\'35\');$(\'#5-b-A-1t\').1b();7(4.h[4.9][1]){$(\'#5-b-A-1t\').2p(4.h[4.9][1]).E()}7(4.h.B>1){$(\'#5-b-A-1g\').2p(4.2s+\' \'+(4.9+1)+\' \'+4.2o+\' \'+4.h.B).E()}}6 2t(){$(\'#5-k\').E();$(\'#5-k-V,#5-k-X\').l({\'K\':\'1C M(\'+4.19+\') L-O\'});7(4.9!=0){7(4.1d){$(\'#5-k-V\').l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9-1;D();u F})}j{$(\'#5-k-V\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1v+\') 1c 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9-1;D();u F})}}7(4.9!=(4.h.B-1)){7(4.1d){$(\'#5-k-X\').l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'}).11().1k(\'C\',6(){4.9=4.9+1;D();u F})}j{$(\'#5-k-X\').11().2m(6(){$(N).l({\'K\':\'M(\'+4.1E+\') 2l 15% L-O\'})},6(){$(N).l({\'K\':\'1C M(\'+4.19+\') L-O\'})}).E().1k(\'C\',6(){4.9=4.9+1;D();u F})}}2k()}6 2k(){$(d).30(6(12){2i(12)})}6 1G(){$(d).11()}6 2i(12){7(12==2h){U=2Z.2e;1x=27}j{U=12.2e;1x=12.2Y}14=2X.2W(U).2U();7((14==4.2j)||(14==\'x\')||(U==1x)){1a()}7((14==4.2f)||(U==37)){7(4.9!=0){4.9=4.9-1;D();1G()}}7((14==4.2d)||(U==39)){7(4.9!=(4.h.B-1)){4.9=4.9+1;D();1G()}}}6 2r(){7((4.h.B-1)>4.9){2c=v 1j();2c.W=4.h[4.9+1][0]}7(4.9>0){2b=v 1j();2b.W=4.h[4.9-1][0]}}6 1a(){$(\'#q-5\').2a();$(\'#q-13\').2T(6(){$(\'#q-13\').2a()});$(\'1U, 1S, 1R\').l({\'1Q\':\'2S\'})}6 1D(){f o,r;7(G.1h&&G.28){o=G.26+G.2R;r=G.1h+G.28}j 7(d.m.25>d.m.24){o=d.m.2P;r=d.m.25}j{o=d.m.2O;r=d.m.24}f y,H;7(Z.1h){7(d.t.1l){y=d.t.1l}j{y=Z.26}H=Z.1h}j 7(d.t&&d.t.1A){y=d.t.1l;H=d.t.1A}j 7(d.m){y=d.m.1l;H=d.m.1A}7(r<H){1z=H}j{1z=r}7(o<y){1B=o}j{1B=y}21=v 1m(1B,1z,y,H);u 21};6 1p(){f o,r;7(Z.1Z){r=Z.1Z;o=Z.2M}j 7(d.t&&d.t.1F){r=d.t.1F;o=d.t.1Y}j 7(d.m){r=d.m.1F;o=d.m.1Y}2q=v 1m(o,r);u 2q};6 1H(2C){f 2x=v 2w();1q=2h;3h{f 1q=v 2w()}2n(1q-2x<2C)};u N.11(\'C\').C(20)}})(23);', 62, 204, '||||settings|lightbox|function|if||activeImage||image||document|div|var|id|imageArray||else|nav|css|body||xScroll||jquery|yScroll|container|documentElement|return|new|box||windowWidth|arrPageSizes|details|length|click|_set_image_to_view|show|false|window|windowHeight|jQueryMatchedObj|href|background|no|url|this|repeat|height|objImagePreloader|arrPageScroll|width|data|keycode|btnPrev|src|btnNext|loading|self||unbind|objEvent|overlay|key||gif|getAttribute|images|imageBlank|_finish|hide|left|fixedNavigation|objClicked|containerBorderSize|currentNumber|innerHeight|span|Image|bind|clientWidth|Array|intWidth|intImageWidth|___getPageScroll|curDate|intImageHeight|secNav|caption|btn|imageBtnPrev|img|escapeKey|intHeight|pageHeight|clientHeight|pageWidth|transparent|___getPageSize|imageBtnNext|scrollTop|_disable_keyboard_navigation|___pause|intDiffW|push|intCurrentHeight|intCurrentWidth|imageLoading|_resize_container_image_box|_set_interface|onload|visibility|select|object|top|embed|fadeIn|imageBtnClose|_start|scrollLeft|pageYOffset|_initialize|arrayPageSize|btnClose|jQuery|offsetHeight|scrollHeight|innerWidth||scrollMaxY|link|remove|objPrev|objNext|keyToNext|keyCode|keyToPrev|overlayOpacity|null|_keyboard_action|keyToClose|_enable_keyboard_navigation|right|hover|while|txtOf|html|arrayPageScroll|_preload_neighbor_images|txtImage|_set_navigation|_show_image_data|title|Date|date|_show_image|intDiffH|containerResizeSpeed|overlayBgColor|ms|attr|hidden|blank|resize|extend|close|opacity|backgroundColor|next|pageXOffset|fn|offsetWidth|scrollWidth|prev|scrollMaxX|visible|fadeOut|toLowerCase|style|fromCharCode|String|DOM_VK_ESCAPE|event|keydown|append|of|ico|000|fast|for||slideDown||100|250|msie|400|browser|animate|lightBox|do'.split('|'), 0, {}))


/*
* waitForImages 1.3.2
* -----------------
* Provides a callback when all images have loaded in your given selector.
* http://www.alexanderdickson.com/
*
*
* Copyright (c) 2011 Alex Dickson
* Licensed under the MIT licenses.
* See website for more info.
*
*/

; (function ($) {

    // CSS properties which contain references to images. 
    $.waitForImages = {
        hasImageProperties: [
        'backgroundImage',
        'listStyleImage',
        'borderImage',
        'borderCornerImage'
        ]
    };

    // Custom selector to find `img` elements that have a valid `src` attribute and have not already loaded.
    $.expr[':'].uncached = function (obj) {
        return $(obj).is('img[src!=""]') && !obj.complete;
    };

    $.fn.waitForImages = function (finishedCallback, eachCallback, waitForAll) {

        // Handle options object.
        if ($.isPlainObject(arguments[0])) {
            eachCallback = finishedCallback.each;
            waitForAll = finishedCallback.waitForAll;
            finishedCallback = finishedCallback.finished;
        }

        // Handle missing callbacks.
        finishedCallback = finishedCallback || $.noop;
        eachCallback = eachCallback || $.noop;

        // Convert waitForAll to Boolean
        waitForAll = !!waitForAll;

        // Ensure callbacks are functions.
        if (!$.isFunction(finishedCallback) || !$.isFunction(eachCallback)) {
            throw new TypeError('An invalid callback was supplied.');
        };

        return this.each(function () {
            // Build a list of all imgs, dependent on what images will be considered.
            var obj = $(this),
                allImgs = [];

            if (waitForAll) {
                // CSS properties which may contain an image.
                var hasImgProperties = $.waitForImages.hasImageProperties || [],
                    matchUrl = /url\((['"]?)(.*?)\1\)/g;

                // Get all elements, as any one of them could have a background image.
                obj.find('*').each(function () {
                    var element = $(this);

                    // If an `img` element, add it. But keep iterating in case it has a background image too.
                    if (element.is('img:uncached')) {
                        allImgs.push({
                            src: element.attr('src'),
                            element: element[0]
                        });
                    }

                    $.each(hasImgProperties, function (i, property) {
                        var propertyValue = element.css(property);
                        // If it doesn't contain this property, skip.
                        if (!propertyValue) {
                            return true;
                        }

                        // Get all url() of this element.
                        var match;
                        while (match = matchUrl.exec(propertyValue)) {
                            allImgs.push({
                                src: match[2],
                                element: element[0]
                            });
                        };
                    });
                });
            } else {
                // For images only, the task is simpler.
                obj
                 .find('img:uncached')
                 .each(function () {
                     allImgs.push({
                         src: this.src,
                         element: this
                     });
                 });
            };

            var allImgsLength = allImgs.length,
                allImgsLoaded = 0;

            // If no images found, don't bother.
            if (allImgsLength == 0) {
                finishedCallback.call(obj[0]);
            };

            $.each(allImgs, function (i, img) {

                var image = new Image;

                // Handle the image loading and error with the same callback.
                $(image).bind('load error', function (event) {
                    allImgsLoaded++;

                    // If an error occurred with loading the image, set the third argument accordingly.
                    eachCallback.call(img.element, allImgsLoaded, allImgsLength, event.type == 'load');

                    if (allImgsLoaded == allImgsLength) {
                        finishedCallback.call(obj[0]);
                        return false;
                    };

                });

                image.src = img.src;
            });
        });
    };
})(jQuery);
