        var Site = {
        	init: function () {
        		if (window.location.pathname.length > 1) {
        			window.location = "http://" + window.location.host + "#" + window.location.pathname;
        			return;
        		}
        		Site.onLoad();
        		Site.addThis();
        	},
        	onLoad: function () {
        		if ($(".carousel").length) $(".carousel").carousel({
        			wrap: true,
        			vertical: false,
        			controls: true
        		});
        		if ($("#featured-container").length) $("#featured-container").carousel({
        			numbersObj: "#controls",
        			auto: 8,
        			vertical: true,
        			numbers: true,
        			easing: "easeOutQuad"
        		});
        		Site.overwriteLinks();
        		Site.onAddThis();
        	},
        	overwriteLinks: function () {
        		$("a:not([href=\"#\"]):not([href*=\"http:\"]):not([href*=\"mailto:\"]), a[href^=\"http://" + document.location.host + "\"]").address(function () {
        			return $(this).attr('href').replace("http://" + document.location.host, '').replace(window.location.pathname, '').replace("#", '');
        		});
        		$("a[href^=\"http://\"]:not(a[href^=\"http://" + document.location.host + "\"]):not(a[href^=\"http://www." + document.location.host + "\"])").attr("target", "_blank");
        	},
        	oldAddress: "",
        	onChange: function (e) {
		    
        		var page;
        		switch (e.pathNames[0]) {
        		case undefined:
        			page = "";
        			if ($("#container").attr("class") == "home") return;
        			Site.loadSite(page, e.pathNames[1]);
        			break;
        		default:
        			page = e.pathNames[0];
        			if (page == $("#container").attr("class") && typeof (e.pathNames[1]) == "undefined") return;
        			Site.loadSite(page, e.pathNames[1]);
        		}
        	},
        	loadSite: function (page, id) {
		  
        		var url = "/index.php",
        			_page = page,
        			dataObj = {
        				page: page,
        				ajax: 1,
        				id: id
        			};
        		if (page == "") page = "home";
        		$.ajax({
        			url: url,
        			global: false,
        			type: "GET",
        			data: dataObj,
        			dataType: "html",
        			async: false,
        			success: function (data) {
        				$("header").find(".selected").removeClass("selected");
        				$("header").find("a[href^='/" + page + "']").parent().addClass("selected");
        				$("#container").addClass("hideit");
        				setTimeout(function () {
						if ($(".carousel").length) $(".carousel").carousel("destroy");
						if ($("#featured-container").length) $("#featured-container").carousel("destroy");
        					$("#container").html(innerShiv($("div", data).html(), false)).removeAttr("class").addClass(page);
        					$("html,body").animate({
        						scrollTop: 0
        					}, 600);
        					Site.onLoad();
        				}, 500);
        				document.title = $("h1", data).html() + " - Adam Widmanski";
        			}
        		});
        	},
        	addThis: function () {
        		var cache = jQuery.ajaxSettings.cache;
        		jQuery.ajaxSettings.cache = true;
        		jQuery.getScript('https://s7.addthis.com/js/250/addthis_widget.js?domready=1', Site.onAddThis);
        		jQuery.ajaxSettings.cache = cache;
        	},
        	onAddThis: function () {
        		if (window.addthis !== undefined) {
        			var addthis_config = {
        				ui_language: "en"
        			},
        				doc = document.location.href;
        			doc = doc.replace("/#/", "/");
        			$("#share").html("").append('<a class=\"addthis_button_facebook\" id=\"fbk\"></a><a class=\"addthis_button_twitter\" id=\"twt\"></a>');
        			addthis.toolbox("#share", addthis_config, {
        				url: doc
        			});
        			$("#share").find("span").remove();
        		}
        	}
        };
	
	
$(document).ready(Site.init);
$.address.change(Site.onChange);

(function($){var m={init:function(a){var $t=$(this),c=a||{},d=$t.children().length,g={a:false||c.vertical,b:0||c.auto,c:false||c.numbers,d:false||c.controls,e:false||c.wrap,f:800||c.speed,g:""||c.numbersObj,h:"swing"||c.easing},f={g:g,h:0,j:null,s:[$t.width(),$t.height()]};$t.data('carousel',f),m.wrap.apply($t);f.i=$t.parent();f.h=$t.parent().parent();if(g.d==true&&d>1){$(f.h).prepend("<a class=\"next\" href=\"#\"></a>").prepend("<a class=\"prev\" href=\"#\"></a>");$(f.h).children().filter("a").bind("click",function(e){m.onClick.apply($t,[e])})}if(g.c==true&&d>1){if(!$(g.g).length)return;var n=0,l=$t.children().length;for(n=0;n<l;n++){$(g.g).append('<li><a href="#">'+(n+1)+'</a></li>')}$(g.g).find("li").unbind("click").bind("click",function(e){m.numberOnClick.apply($t,[e])}).parent().find("li:eq("+f.h+")").addClass("selected")}m.play.apply($t);$(window).bind("resize.carousel",function(){m.onResize.apply($t)});$t.hover(function(){m.pause.apply($t)},function(){m.play.apply($t)});$t.data('carousel',f);m.slide.apply($t,[0,0])},wrap:function(){var $t=$(this),f=$t.data('carousel');if(!f.g.e)return;$t.wrap('<div class="carousel-container" />').wrap('<div class="carousel-wrapper" />')},onClick:function(e){e.preventDefault();e.stopPropagation();var $t=$(this),c=$(e.currentTarget).attr("class"),k=-1,q;m.pause.apply($t);if(c=="next")k=1;m.slide.apply($t,[k]);m.play.apply($t)},numberOnClick:function(e){var $t=$(this);m.pause.apply($t);e.stopPropagation();e.preventDefault();var i=$(e.currentTarget).index();m.slide.apply($t,[0,i])},onResize:function(){var $t=$(this),f=$t.data('carousel'),t=f.g,c=$t.children().length,o,d;if(t.a==false){o=$t.children().filter(":first-child").outerWidth(true);d="width"}else{o=$t.children().filter(":first-child").outerHeight(true);d="height"}$t.css(d,(o*c)+"px");m.pause.apply($t);$t.stop(true,true).animate({marginLeft:0,marginTop:0},t.f);f.current=0;if(f.g.c==true)$(f.g.g).find("li").removeClass("selected").filter(":first-child").addClass("selected");$t.data('carousel',f);m.play.apply($t)},play:function(){var $t=$(this),f=$t.data('carousel');clearInterval(f.j);if(f.g.b>0)f.j=setInterval(function(){m.slide.apply($t,[1])},f.g.b*1000);$t.data('carousel',f)},pause:function(){var $t=$(this),f=$t.data('carousel');clearInterval(f.j);$t.data('carousel',f)},slide:function(k,t){var $t=$(this),f=$t.data('carousel'),g=f.g,h=f.h,d=$t.children().length,o,w,p,r,l,q=Array(0,0);if(g.a==false){o=$t.children().filter(":first-child").outerWidth(true);w=$t.parent().width();l="width";r=0}else{o=$t.children().filter(":first-child").outerHeight(true);w=$t.parent().height();l="height";r=1}p=Math.round(w/o);if(k!=0){h+=k*p}else{h=t}if(h>=d)h=0;if(h>=d-p+1)h=d-p;if(h<-p+1)h=d-p;if(h<0)h=0;q[r]=-h*o;$t.css(l,(o*d)+"px").animate({marginLeft:q[0]+"px",marginTop:q[1]+"px"},g.f,g.h);if(g.c==true)$(g.g).find("li").removeClass("selected").filter(":eq("+h+")").addClass("selected");f.h=h;$t.data('carousel',f)},destroy:function(){var $t=$(this),f=$t.data('carousel');m.pause.apply($t);if(f.g.c)$(f.g.g).html("");if(f.g.d)$(f.container).find(".next, .prev").remove();if(f.g.e)$t.unwrap().unwrap();$t.stop(true,true).css({marginLeft:0,marginTop:0,width:f.s[0]+"px",height:f.s[1]+"px"});$(window).unbind('.carousel');$t.removeData('carousel')}};$.fn.carousel=function(n){if(m[n]){return m[n].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof n==='object'||!n){return m.init.apply(this,arguments)}else{$.error('Method '+n+' does not exist')}}})(jQuery);
$.extend($.easing,{easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b}});

window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.appendChild(g);return function(h){g.innerHTML='&shy;<style media="'+h+'"> #mq-test-1 { width: 42px; }</style>';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document);
/*! Respond.js v1.1.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */
(function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var w=e.document,s=w.documentElement,i=[],k=[],q=[],o={},h=30,f=w.getElementsByTagName("head")[0]||s,g=w.getElementsByTagName("base")[0],b=f.getElementsByTagName("link"),d=[],a=function(){var D=b,y=D.length,B=0,A,z,C,x;for(;B<y;B++){A=D[B],z=A.href,C=A.media,x=A.rel&&A.rel.toLowerCase()==="stylesheet";if(!!z&&x&&!o[z]){if(A.styleSheet&&A.styleSheet.rawCssText){m(A.styleSheet.rawCssText,z,C);o[z]=true}else{if((!/^([a-zA-Z:]*\/\/)/.test(z)&&!g)||z.replace(RegExp.$1,"").split("/")[0]===e.location.host){d.push({href:z,media:C})}}}}u()},u=function(){if(d.length){var x=d.shift();n(x.href,function(y){m(y,x.href,x.media);o[x.href]=true;u()})}},m=function(I,x,z){var G=I.match(/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi),J=G&&G.length||0,x=x.substring(0,x.lastIndexOf("/")),y=function(K){return K.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+x+"$2$3")},A=!J&&z,D=0,C,E,F,B,H;if(x.length){x+="/"}if(A){J=1}for(;D<J;D++){C=0;if(A){E=z;k.push(y(I))}else{E=G[D].match(/@media *([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1;k.push(RegExp.$2&&y(RegExp.$2))}B=E.split(",");H=B.length;for(;C<H;C++){F=B[C];i.push({media:F.split("(")[0].match(/(only\s+)?([a-zA-Z]+)\s?/)&&RegExp.$2||"all",rules:k.length-1,hasquery:F.indexOf("(")>-1,minw:F.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:F.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}j()},l,r,v=function(){var z,A=w.createElement("div"),x=w.body,y=false;A.style.cssText="position:absolute;font-size:1em;width:1em";if(!x){x=y=w.createElement("body")}x.appendChild(A);s.insertBefore(x,s.firstChild);z=A.offsetWidth;if(y){s.removeChild(x)}else{x.removeChild(A)}z=p=parseFloat(z);return z},p,j=function(I){var x="clientWidth",B=s[x],H=w.compatMode==="CSS1Compat"&&B||w.body[x]||B,D={},G=b[b.length-1],z=(new Date()).getTime();if(I&&l&&z-l<h){clearTimeout(r);r=setTimeout(j,h);return}else{l=z}for(var E in i){var K=i[E],C=K.minw,J=K.maxw,A=C===null,L=J===null,y="em";if(!!C){C=parseFloat(C)*(C.indexOf(y)>-1?(p||v()):1)}if(!!J){J=parseFloat(J)*(J.indexOf(y)>-1?(p||v()):1)}if(!K.hasquery||(!A||!L)&&(A||H>=C)&&(L||H<=J)){if(!D[K.media]){D[K.media]=[]}D[K.media].push(k[K.rules])}}for(var E in q){if(q[E]&&q[E].parentNode===f){f.removeChild(q[E])}}for(var E in D){var M=w.createElement("style"),F=D[E].join("\n");M.type="text/css";M.media=E;f.insertBefore(M,G.nextSibling);if(M.styleSheet){M.styleSheet.cssText=F}else{M.appendChild(w.createTextNode(F))}q.push(M)}},n=function(x,z){var y=c();if(!y){return}y.open("GET",x,true);y.onreadystatechange=function(){if(y.readyState!=4||y.status!=200&&y.status!=304){return}z(y.responseText)};if(y.readyState==4){return}y.send(null)},c=(function(){var x=false;try{x=new XMLHttpRequest()}catch(y){x=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return x}})();a();respond.update=a;function t(){j(true)}if(e.addEventListener){e.addEventListener("resize",t,false)}else{if(e.attachEvent){e.attachEvent("onresize",t)}}})(this);
