﻿$(function () {
    var $container = $('#container');
    $container.isotope({
        itemSelector: '.element'
    });


    $container.infinitescroll({
        navSelector: '#page_nav',    // selector for the paged navigation 
        nextSelector: '#page_nav a',  // selector for the NEXT link (to page 2)
        itemSelector: '.element',     // selector for all items you'll retrieve
        loading: {
            finishedMsg: 'No more pages to load.',
            img: 'http://load.jpg'
        }
    },
    // call Isotope as a callback
        function (newElements) {
            $container.isotope('appended', $(newElements));
           
        }
      );


    var $optionSets = $('#options .option-set'),
          $optionLinks = $optionSets.find('a');

    $optionLinks.click(function () {
        var $this = $(this);
        // don't proceed if already selected
        if ($this.hasClass('selected')) {
            return false;
        }
        var $optionSet = $this.parents('.option-set');
        $optionSet.find('.selected').removeClass('selected');
        $this.addClass('selected');

        // make option object dynamically, i.e. { filter: '.my-filter-class' }
        var options = {},
            key = $optionSet.attr('data-option-key'),
            value = $this.attr('data-option-value');
        // parse 'false' as false boolean
        value = value === 'false' ? false : value;
        options[key] = value;
        if (key === 'layoutMode' && typeof changeLayoutMode === 'function') {
            // changes in layout modes need extra logic
            changeLayoutMode($this, options)
        } else {
            // otherwise, apply new options
            $container.isotope(options);
        }

        return false;
    })


 //   var theWindow = $(window), $bg = $("#bg"), aspectRatio = $bg.width() / $bg.height(); function resizeBg() { if ((theWindow.width() / theWindow.height()) < aspectRatio) { $bg.removeClass().addClass('bgheight'); } else { $bg.removeClass().addClass('bgwidth'); } } theWindow.resize(function () { resizeBg(); }).trigger("resize");



});

