/*
 * Elemis Alphine Portfolio Plugin
 * Copyright © 2012 Elemis Themes
 * Version: 1.0 (Jan 2012)
 * Created with Masonry by Jonathan Boyer (http://www.grafikart.fr) and improved by Lee Chestnutt (http://www.designchemical.com)
 * You may not modify and/or redistribute this file.
 * http://elemis.iki-bir.com
 * elemisthemes@gmail.com
 */

function windowH(){if(window.innerHeight)return window.innerHeight;else{return $(window).height()}}function scrollTo(a){var b=$(a).length?$(a).offset().top:$("a[name="+a.substr(1,a.length-1)+"]").offset().top;$("html,body").animate({scrollTop:b-18},1e3);return false}$(document).ready(function(){function e(c){c.addClass("hidden");b.masonry("reload");$(".box.col4 a").removeClass("active");c.removeClass("hidden").stop().slideUp(a,function(){c.remove();b.masonry("reload");$(".box.col4 a:not(.active) span").fadeOut(200)});location.hash="!"}function d(c,d){c.removeClass("hidden").css("top",parseInt(t.css("top"))+t.outerHeight(true));b.masonry("reload");scrollTo(d);c.slideDown(a).fadeIn(400,function(){});$(".box.col1 .slides").slides({preload:false,play:5e3,pause:2500,effect:"fade",crossfade:true,hoverPause:true})}var a=1e3,b=$("#portfolio .items"),c={itemSelector:".box:not(.hidden)",animate:true,animationOptions:{duration:a,queue:false}};b.imagesLoaded(function(){b.masonry(c);if(location.hash){$('a[href="'+location.hash+'"]').trigger("click").children("span").fadeIn(200)}});$("#filtering-nav").on("click","a",function(c){var d=$(this).attr("class");var e="box";var f=".box";if(d!="all"){f="."+d}$(this).parent().addClass("active").siblings().removeClass("active");$(".box.col4 a span").fadeOut(200);$(".box.col4 a").removeClass("active");var g=b.find(f);var h=b.find("div:not("+f+")");g.removeClass("hidden");h.addClass("hidden");$("#portfolio .col1").remove();b.masonry("reload");h.fadeOut(a);g.fadeIn(a);location.hash=d;c.preventDefault()});$("#portfolio").on("click",".box-close",function(a){var b=$("#portfolio .col1");$(".box.col4 a span").fadeOut(200);$(".box.col4 a").removeClass(".active");e(b);a.preventDefault()});$(".items .col4").on("click","a",function(c){var f=$(".items .col4 a.active").parent().index(".items .col4");$(".items .col4 a").removeClass("active");$(".items .col4:eq("+f+") a span").fadeOut(400);var g=$(this);var h=g.parent();var i=h.index(".items .col4");var j=$("#portfolio .col1");var k=$("#portfolio .box:not(:visible)");t=null;if($('#portfolio .col1[rel="'+i+'"]').length){e(j)}else{$(this).toggleClass("active");var l=$('<div class="box col1" rel="'+i+'"><a href="#" class="box-close">Close</a>'+h.find(".container").html()+"</div>");h.nextAll(".box:not(.hidden)").each(function(){if($(this).css("top")!=h.css("top")&&t==null){t=$(this).prevAll(".box:not(.hidden):first")}});if(t==null){t=$("#portfolio .box:visible:last")}t.after(l.css("position","absolute"));j.addClass("hidden");l.addClass("hidden").hide();b.masonry("reload");if(j.length>0){j.removeClass("hidden").stop().slideUp(a,function(){j.remove();d(l,h)})}else{d(l,h)}location.hash=g.attr("href")}return false})});$.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}
