(function(a){a.fn.quicksand=function(f,b){var e={duration:750,easing:"swing",attribute:"data-id",adjustHeight:"auto",useScaling:true,enhancement:function(g){},selector:"> *"};a.extend(e,b);if(a.browser.msie||(typeof(a.fn.scale)=="undefined")){e.useScaling=false}var c;if(typeof(arguments[1])=="function"){var c=arguments[1]}else{if(typeof(arguments[2]=="function")){var c=arguments[2]}}return this.each(function(q){var k;var s=[];var h=a(f).clone();var g=a(this);var l=a(this).css("height");var j;var x=false;var o=a(g).offset();var n=[];var t=a(this).find(e.selector);if(a.browser.msie&&a.browser.version.substr(0,1)<7){g.html("").append(h);return}var r=0;var m=function(){if(!r){g.html(u.html());if(typeof c=="function"){c.call(this)}if(x){g.css("height",j)}e.enhancement(g);r=1}};var v=g.offsetParent();var w=v.offset();if(v.css("position")=="relative"){if(v.get(0).nodeName.toLowerCase()=="body"){}else{w.top+=parseFloat(v.css("border-top-width"));w.left+=parseFloat(v.css("border-left-width"))}}else{w.top-=parseFloat(v.css("border-top-width"));w.left-=parseFloat(v.css("border-left-width"));w.top-=parseFloat(v.css("margin-top"));w.left-=parseFloat(v.css("margin-left"))}g.css("height",a(this).height());t.each(function(y){n[y]=a(this).offset()});a(this).stop();t.each(function(y){a(this).stop();var z=a(this).get(0);z.style.position="absolute";z.style.margin="0";z.style.top=(n[y].top-parseFloat(z.style.marginTop)-w.top)+"px";z.style.left=(n[y].left-parseFloat(z.style.marginLeft)-w.left)+"px"});var u=a(g).clone();var p=u.get(0);p.innerHTML="";p.setAttribute("id","");p.style.height="auto";p.style.width=g.width()+"px";u.append(h);u.insertBefore(g);u.css("opacity",0);p.style.zIndex=-1;p.style.margin="0";p.style.position="absolute";p.style.top=o.top-w.top+"px";p.style.left=o.left-w.left+"px";if(e.adjustHeight==="dynamic"){g.animate({height:u.height()},e.duration,e.easing)}else{if(e.adjustHeight==="auto"){j=u.height();if(parseFloat(l)<parseFloat(j)){g.css("height",j)}else{x=true}}}t.each(function(y){var z=[];if(typeof(e.attribute)=="function"){k=e.attribute(a(this));h.each(function(){if(e.attribute(this)==k){z=a(this);return false}})}else{z=h.filter("["+e.attribute+"="+a(this).attr(e.attribute)+"]")}if(z.length){if(!e.useScaling){s.push({element:a(this),animation:{top:z.offset().top-w.top,left:z.offset().left-w.left,opacity:1}})}else{s.push({element:a(this),animation:{top:z.offset().top-w.top,left:z.offset().left-w.left,opacity:1,scale:"1.0"}})}}else{if(!e.useScaling){s.push({element:a(this),animation:{opacity:"0.0"}})}else{s.push({element:a(this),animation:{opacity:"0.0",scale:"0.0"}})}}});h.each(function(A){var z=[];var C=[];if(typeof(e.attribute)=="function"){k=e.attribute(a(this));t.each(function(){if(e.attribute(this)==k){z=a(this);return false}});h.each(function(){if(e.attribute(this)==k){C=a(this);return false}})}else{z=t.filter("["+e.attribute+"="+a(this).attr(e.attribute)+"]");C=h.filter("["+e.attribute+"="+a(this).attr(e.attribute)+"]")}var B;if(z.length===0){if(!e.useScaling){B={opacity:"1.0"}}else{B={opacity:"1.0",scale:"1.0"}}d=C.clone();var y=d.get(0);y.style.position="absolute";y.style.margin="0";y.style.top=C.offset().top-w.top+"px";y.style.left=C.offset().left-w.left+"px";d.css("opacity",0);if(e.useScaling){d.css("transform","scale(0.0)")}d.appendTo(g);s.push({element:a(d),animation:B})}});u.remove();e.enhancement(g);for(q=0;q<s.length;q++){s[q].element.animate(s[q].animation,e.duration,e.easing,m)}})}})(jQuery);
