
jQuery.easing.jswing=jQuery.easing.swing;
jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(p,j,u,t,o){return jQuery.easing[jQuery.easing.def](p,j,u,t,o)},easeInQuad:function(p,j,u,t,o){return t*(j/=o)*j+u},easeOutQuad:function(p,j,u,t,o){return-t*(j/=o)*(j-2)+u},easeInOutQuad:function(p,j,u,t,o){if((j/=o/2)<1)return t/2*j*j+u;return-t/2*(--j*(j-2)-1)+u},easeInCubic:function(p,j,u,t,o){return t*(j/=o)*j*j+u},easeOutCubic:function(p,j,u,t,o){return t*((j=j/o-1)*j*j+1)+u},easeInOutCubic:function(p,j,u,t,o){if((j/=o/2)<1)return t/
2*j*j*j+u;return t/2*((j-=2)*j*j+2)+u},easeInQuart:function(p,j,u,t,o){return t*(j/=o)*j*j*j+u},easeOutQuart:function(p,j,u,t,o){return-t*((j=j/o-1)*j*j*j-1)+u},easeInOutQuart:function(p,j,u,t,o){if((j/=o/2)<1)return t/2*j*j*j*j+u;return-t/2*((j-=2)*j*j*j-2)+u},easeInQuint:function(p,j,u,t,o){return t*(j/=o)*j*j*j*j+u},easeOutQuint:function(p,j,u,t,o){return t*((j=j/o-1)*j*j*j*j+1)+u},easeInOutQuint:function(p,j,u,t,o){if((j/=o/2)<1)return t/2*j*j*j*j*j+u;return t/2*((j-=2)*j*j*j*j+2)+u},easeInSine:function(p,
j,u,t,o){return-t*Math.cos(j/o*(Math.PI/2))+t+u},easeOutSine:function(p,j,u,t,o){return t*Math.sin(j/o*(Math.PI/2))+u},easeInOutSine:function(p,j,u,t,o){return-t/2*(Math.cos(Math.PI*j/o)-1)+u},easeInExpo:function(p,j,u,t,o){return j==0?u:t*Math.pow(2,10*(j/o-1))+u},easeOutExpo:function(p,j,u,t,o){return j==o?u+t:t*(-Math.pow(2,-10*j/o)+1)+u},easeInOutExpo:function(p,j,u,t,o){if(j==0)return u;if(j==o)return u+t;if((j/=o/2)<1)return t/2*Math.pow(2,10*(j-1))+u;return t/2*(-Math.pow(2,-10*--j)+2)+u},
easeInCirc:function(p,j,u,t,o){return-t*(Math.sqrt(1-(j/=o)*j)-1)+u},easeOutCirc:function(p,j,u,t,o){return t*Math.sqrt(1-(j=j/o-1)*j)+u},easeInOutCirc:function(p,j,u,t,o){if((j/=o/2)<1)return-t/2*(Math.sqrt(1-j*j)-1)+u;return t/2*(Math.sqrt(1-(j-=2)*j)+1)+u},easeInElastic:function(p,j,u,t,o){p=1.70158;var z=0,G=t;if(j==0)return u;if((j/=o)==1)return u+t;z||(z=o*0.3);if(G<Math.abs(t)){G=t;p=z/4}else p=z/(2*Math.PI)*Math.asin(t/G);return-(G*Math.pow(2,10*(j-=1))*Math.sin((j*o-p)*2*Math.PI/z))+u},easeOutElastic:function(p,
j,u,t,o){p=1.70158;var z=0,G=t;if(j==0)return u;if((j/=o)==1)return u+t;z||(z=o*0.3);if(G<Math.abs(t)){G=t;p=z/4}else p=z/(2*Math.PI)*Math.asin(t/G);return G*Math.pow(2,-10*j)*Math.sin((j*o-p)*2*Math.PI/z)+t+u},easeInOutElastic:function(p,j,u,t,o){p=1.70158;var z=0,G=t;if(j==0)return u;if((j/=o/2)==2)return u+t;z||(z=o*0.3*1.5);if(G<Math.abs(t)){G=t;p=z/4}else p=z/(2*Math.PI)*Math.asin(t/G);if(j<1)return-0.5*G*Math.pow(2,10*(j-=1))*Math.sin((j*o-p)*2*Math.PI/z)+u;return G*Math.pow(2,-10*(j-=1))*Math.sin((j*
o-p)*2*Math.PI/z)*0.5+t+u},easeInBack:function(p,j,u,t,o,z){if(z==undefined)z=1.70158;return t*(j/=o)*j*((z+1)*j-z)+u},easeOutBack:function(p,j,u,t,o,z){if(z==undefined)z=1.70158;return t*((j=j/o-1)*j*((z+1)*j+z)+1)+u},easeInOutBack:function(p,j,u,t,o,z){if(z==undefined)z=1.70158;if((j/=o/2)<1)return t/2*j*j*(((z*=1.525)+1)*j-z)+u;return t/2*((j-=2)*j*(((z*=1.525)+1)*j+z)+2)+u},easeInBounce:function(p,j,u,t,o){return t-jQuery.easing.easeOutBounce(p,o-j,0,t,o)+u},easeOutBounce:function(p,j,u,t,o){return(j/=
o)<1/2.75?t*7.5625*j*j+u:j<2/2.75?t*(7.5625*(j-=1.5/2.75)*j+0.75)+u:j<2.5/2.75?t*(7.5625*(j-=2.25/2.75)*j+0.9375)+u:t*(7.5625*(j-=2.625/2.75)*j+0.984375)+u},easeInOutBounce:function(p,j,u,t,o){if(j<o/2)return jQuery.easing.easeInBounce(p,j*2,0,t,o)*0.5+u;return jQuery.easing.easeOutBounce(p,j*2-o,0,t,o)*0.5+t*0.5+u}});
(function(p){function j(t){for(var o=["transform","WebkitTransform","MozTransform"],z;z=o.shift();)if(typeof t.style[z]!="undefined")return z;return"transform"}var u=p.fn.css;p.fn.css=function(t){if(typeof p.props.transform=="undefined"&&(t=="transform"||typeof t=="object"&&typeof t.transform!="undefined"))p.props.transform=j(this.get(0));if(t=="transform")t=p.props.transform;return u.apply(this,arguments)}})(jQuery);
(function(p){var j="deg";p.fn.rotate=function(o){var z=p(this).css("transform")||"none";if(typeof o=="undefined"){if(z)if((o=z.match(/rotate\(([^)]+)\)/))&&o[1])return o[1];return 0}if(o=o.toString().match(/^(-?\d+(\.\d+)?)(.+)?$/)){if(o[3])j=o[3];p(this).css("transform",z.replace(/none|rotate\([^)]*\)/,"")+"rotate("+o[1]+j+")")}};p.fn.scale=function(o){var z=p(this).css("transform");if(typeof o=="undefined"){if(z)if((o=z.match(/scale\(([^)]+)\)/))&&o[1])return o[1];return 1}p(this).css("transform",
z.replace(/none|scale\([^)]*\)/,"")+"scale("+o+")")};var u=p.fx.prototype.cur;p.fx.prototype.cur=function(){if(this.prop=="rotate")return parseFloat(p(this.elem).rotate());else if(this.prop=="scale")return parseFloat(p(this.elem).scale());return u.apply(this,arguments)};p.fx.step.rotate=function(o){p(o.elem).rotate(o.now+j)};p.fx.step.scale=function(o){p(o.elem).scale(o.now)};var t=p.fn.animate;p.fn.animate=function(o){if(typeof o.rotate!="undefined"){var z=o.rotate.toString().match(/^(([+-]=)?(-?\d+(\.\d+)?))(.+)?$/);
if(z&&z[5])j=z[5];o.rotate=z[1]}return t.apply(this,arguments)}})(jQuery);
(function(p){p.fn.quicksand=function(j,u,t){var o={duration:750,easing:"swing",attribute:"data-id",adjustHeight:"auto",useScaling:true,enhancement:function(){},selector:"> *"};p.extend(o,u);if(p.browser.msie||typeof p.fn.scale=="undefined")o.useScaling=false;var z;if(typeof u=="function")z=u;else if(typeof(t=="function"))z=t;return this.each(function(G){var U,R=[],S=p(j).clone(),L=p(this);G=p(this).css("height");var Z,ea=false,fa=p(L).offset(),T=[],V=p(this).find(o.selector);if(p.browser.msie&&p.browser.version.substr(0,
1)<7)L.html("").append(S);else{var c=0,oa=function(){if(!c){L.html(N.html());typeof z=="function"&&z.call(this);ea&&L.css("height",Z);o.enhancement(L);c=1}},J=L.offsetParent(),v=J.offset();if(J.css("position")=="relative"){if(J.get(0).nodeName.toLowerCase()!="body"){v.top+=parseFloat(J.css("border-top-width"));v.left+=parseFloat(J.css("border-left-width"))}}else{v.top-=parseFloat(J.css("border-top-width"));v.left-=parseFloat(J.css("border-left-width"));v.top-=parseFloat(J.css("margin-top"));v.left-=
parseFloat(J.css("margin-left"))}L.css("height",p(this).height());V.each(function(K){T[K]=p(this).offset()});p(this).stop();V.each(function(K){p(this).stop();var M=p(this).get(0);M.style.position="absolute";M.style.margin="0";M.style.top=T[K].top-parseFloat(M.style.marginTop)-v.top+"px";M.style.left=T[K].left-parseFloat(M.style.marginLeft)-v.left+"px"});var N=p(L).clone();J=N.get(0);J.innerHTML="";J.setAttribute("id","");J.style.height="auto";J.style.width=L.width()+"px";N.append(S);N.insertBefore(L);
N.css("opacity",0);J.style.zIndex=-1;J.style.margin="0";J.style.position="absolute";J.style.top=fa.top-v.top+"px";J.style.left=fa.left-v.left+"px";if(o.adjustHeight==="dynamic")L.animate({height:N.height()},o.duration,o.easing);else if(o.adjustHeight==="auto"){Z=N.height();if(parseFloat(G)<parseFloat(Z))L.css("height",Z);else ea=true}V.each(function(){var K=[];if(typeof o.attribute=="function"){U=o.attribute(p(this));S.each(function(){if(o.attribute(this)==U){K=p(this);return false}})}else K=S.filter("["+
o.attribute+"="+p(this).attr(o.attribute)+"]");if(K.length)o.useScaling?R.push({element:p(this),animation:{top:K.offset().top-v.top,left:K.offset().left-v.left,opacity:1,scale:"1.0"}}):R.push({element:p(this),animation:{top:K.offset().top-v.top,left:K.offset().left-v.left,opacity:1}});else o.useScaling?R.push({element:p(this),animation:{opacity:"0.0",scale:"0.0"}}):R.push({element:p(this),animation:{opacity:"0.0"}})});S.each(function(){var K=[],M=[];if(typeof o.attribute=="function"){U=o.attribute(p(this));
V.each(function(){if(o.attribute(this)==U){K=p(this);return false}});S.each(function(){if(o.attribute(this)==U){M=p(this);return false}})}else{K=V.filter("["+o.attribute+"="+p(this).attr(o.attribute)+"]");M=S.filter("["+o.attribute+"="+p(this).attr(o.attribute)+"]")}var ka;if(K.length===0){ka=o.useScaling?{opacity:"1.0",scale:"1.0"}:{opacity:"1.0"};d=M.clone();var $=d.get(0);$.style.position="absolute";$.style.margin="0";$.style.top=M.offset().top-v.top+"px";$.style.left=M.offset().left-v.left+"px";
d.css("opacity",0);o.useScaling&&d.css("transform","scale(0.0)");d.appendTo(L);R.push({element:p(d),animation:ka})}});N.remove();o.enhancement(L);for(G=0;G<R.length;G++)R[G].element.animate(R[G].animation,o.duration,o.easing,oa)}})}})(jQuery);


// Custom sorting plugin
(function($) {
  $.fn.sorted = function(customOptions) {
    var options = {
      reversed: false,
      by: function(a) { return a.text(); }
    };
    $.extend(options, customOptions);
    $data = $(this);
    arr = $data.get();
    arr.sort(function(a, b) {
      var valA = options.by($(a));
      var valB = options.by($(b));
      if (options.reversed) {
        return (valA < valB) ? 1 : (valA > valB) ? -1 : 0;				
      } else {		
        return (valA < valB) ? -1 : (valA > valB) ? 1 : 0;	
      }
    });
    return $(arr);
  };
})(jQuery);

// DOMContentLoaded
$(function() {

  // bind radiobuttons in the form
  var $filterType = $('#filter input[name="type"]');
  var $filterSort = $('#filter input[name="sort"]');

  // get the first collection
  var $applications = $('#applications');

  // clone applications to get a second collection
  var $data = $applications.clone();

  // attempt to call Quicksand on every form change
  $filterType.add($filterSort).change(function(e) {
    if ($($filterType+':checked').val() == 'all') {
      var $filteredData = $data.find('li');
    } else {
      var $filteredData = $data.find('li[data-type=' + $($filterType+":checked").val() + ']');
    }

    // if sorted by size
    if ($('#filter input[name="sort"]:checked').val() == "size") {
      var $sortedData = $filteredData.sorted({
        by: function(v) {
          return parseFloat($(v).find('span[data-type=size]').text());
        }
      });
    } else {
      // if sorted by name
      var $sortedData = $filteredData.sorted({
        by: function(v) {
          return $(v).find('strong').text().toLowerCase();
        }
      });
    }   

    // finally, call quicksand
    $applications.quicksand($sortedData, {
      duration: 800,
      easing: 'easeInOutQuad'
    });

  });

});

