/*
 * Socialite v1.0
 * http://socialitejs.com
 * Copyright (c) 2011 David Bushell
 * Dual-licensed under the BSD or MIT licenses: http://socialitejs.com/license.txt
 */
window.Socialite=function(){var a={},b={},c={},d={},e={},f={},g={},h=window.document,i=window.setTimeout,j=encodeURIComponent,k=typeof h.getElementsByClassName==="function";b.appendScript=function(a,c,g){if(typeof a!=="string"||d[a]||e[a]===undefined){return false}var i=d[a]=h.createElement("script");i.async=true;i.src=i.data=e[a];i.onload=i.onreadystatechange=function(){if(b.hasLoaded(a)){return}var c=i.readyState;if(!c||c==="loaded"||c==="complete"){f[a]=true;i.onload=i.onreadystatechange=null;if(g!==undefined){if(typeof g==="function"){g()}}else{b.activateCache(a)}}};if(c){i.id=c}h.body.appendChild(i);return true};b.hasLoaded=function(a){return typeof a!=="string"?false:f[a]===true};b.removeScript=function(a){if(!b.hasLoaded(a)){return false}h.body.removeChild(d[a]);d[a]=f[a]=false;return true};b.createIframe=function(a,c){var d=h.createElement("iframe");d.style.cssText="overflow: hidden; border: none;";d.setAttribute("allowtransparency","true");d.setAttribute("frameborder","0");d.setAttribute("scrolling","no");d.setAttribute("src",a);if(c!==undefined){if(k){d.onload=d.onreadystatechange=function(){d.onload=d.onreadystatechange=null;b.activateInstance(c)}}else{i(function(){b.activateInstance(c)},10)}}return d};b.activateInstance=function(a){if(a.loaded){return}a.loaded=true;a.container.className+=" socialite-loaded"};b.activateCache=function(a){if(g[a]!==undefined){var c=g[a].length;for(var d=0;d<c;d++){b.activateInstance(g[a][d])}}};b.copyDataAttributes=function(a,b){var c,d=a.attributes;for(c=0;c<d.length;c++){if(d[c].name.indexOf("data-")===0&&d[c].value.length){b.setAttribute(d[c].name,d[c].value)}}};b.getDataAttributes=function(a,b,c){var d,e="",f={},g=a.attributes;for(d=0;d<g.length;d++){if(g[d].name.indexOf("data-")===0&&g[d].value.length){var h=g[d].name;var i=g[d].value;if(b===true){h=h.substring(5)}if(c===true){f[h]=i}else{e+=j(h)+"="+j(i)+"&"}}}return c?f:e};b.getElements=function(a,b){if(k){return a.getElementsByClassName(b)}var c=0,d=[],e=a.getElementsByTagName("*"),f=e.length;for(c=0;c<f;c++){var g=" "+e[c].className+" ";if(g.indexOf(" "+b+" ")!==-1){d.push(e[c])}}return d};a.activate=function(b,c){a.load(null,b,c)};a.load=function(d,e,f){d=typeof d==="object"&&d!==null&&d.nodeType===1?d:h;if(e===undefined||e===null){var i=b.getElements(d,"socialite"),j=i,k=i.length;if(!k){return}if(typeof j.item!==undefined){j=[];for(var l=0;l<k;l++){j[l]=i[l]}}a.load(d,j,f);return}if(typeof e==="object"&&e.length){for(var m=0;m<e.length;m++){a.load(d,e[m],f)}return}if(typeof e!=="object"||e.nodeType!==1){return}if(typeof f!=="string"||c[f]===undefined){f=null;var n=e.className.split(" ");for(var o=0;o<n.length;o++){if(c[n[o]]!==undefined){f=n[o];break}}if(typeof f!=="string"){return}}if(typeof c[f]==="string"){f=c[f]}if(typeof c[f]!=="function"){return}var p=h.createElement("div"),q=h.createElement("div");p.className="socialised "+f;q.className="socialite-button";var r=e.parentNode;if(r===null){r=d===h?h.body:d;r.appendChild(p)}else{r.insertBefore(p,e)}p.appendChild(q);q.appendChild(e);e.className=e.className.replace(/\bsocialite\b/,"");if(g[f]===undefined){g[f]=[]}var s={elem:e,button:q,container:p,parent:r,loaded:false};g[f].push(s);c[f](s,b)};a.extend=function(a,b,d){if(typeof a!=="string"||typeof b!=="function"){return false}a=a.indexOf(" ")>0?a.split(" "):[a];if(c[a[0]]!==undefined){return false}for(var f=1;f<a.length;f++){c[a[f]]=a[0]}if(d!==undefined&&typeof d==="string"){e[a[0]]=d}c[a[0]]=b;return true};return a}();(function(){var a=window.Socialite;a.extend("twitter tweet",function(a,b){var c=" "+a.elem.className+" ";if(c.indexOf(" tweet ")!==-1){a.elem.className="twitter-tweet"}else{var d=document.createElement("a"),e=a.elem.getAttribute("data-type"),f=["share","follow","hashtag","mention"],g=0;for(var h=1;h<4;h++){if(e===f[h]||c.indexOf(" "+f[h]+" ")!==-1){g=h}}d.className="twitter-"+f[g]+"-button";if(a.elem.getAttribute("href")!==undefined){d.setAttribute("href",a.elem.href)}b.copyDataAttributes(a.elem,d);a.button.replaceChild(d,a.elem)}var i=window.twttr;if(typeof i==="object"&&typeof i.widgets==="object"&&typeof i.widgets.load==="function"){i.widgets.load();b.activateInstance(a)}else{if(b.hasLoaded("twitter")){b.removeScript("twitter")}if(b.appendScript("twitter","twitter-wjs",false)){window.twttr={_e:[function(){b.activateCache("twitter")}]}}}},"//platform.twitter.com/widgets.js");a.extend("googleplus",function(a,b){var c=document.createElement("div");c.className="g-plusone";b.copyDataAttributes(a.elem,c);a.button.replaceChild(c,a.elem);if(typeof window.gapi==="object"&&typeof window.gapi.plusone==="object"&&typeof gapi.plusone.render==="function"){window.gapi.plusone.render(a.button,b.getDataAttributes(c,true,true));b.activateInstance(a)}else{if(!b.hasLoaded("googleplus")){b.appendScript("googleplus")}}},"//apis.google.com/js/plusone.js")})();

$(document).ready(function()
{
	setTimeout(function() {
		Socialite.load();
	}, 100);
	
	if (typeof SyntaxHighlighter == 'object') {
		$("#main.posts").fitVids();
		SyntaxHighlighter.all();
	}

	if (document.getElementById('contactform')) {
		$('#contactform-enquiry', '#contactform').autoResize();
	}
	
});

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9497100-1']);
_gaq.push(['_setDomainName', 'dbushell.com']);
_gaq.push(['_trackPageview']);

(function() {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

/*
 * jQuery.fn.autoResize 1.14
 * --
 * https://github.com/jamespadolsey/jQuery.fn.autoResize
 * --
 * This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://sam.zoy.org/wtfpl/COPYING for more details. */ 
(function(a){function e(b,c){if(b.data("AutoResizer")){b.data("AutoResizer").destroy()}c=this.config=a.extend({},d.defaults,c);this.el=b;this.nodeName=b[0].nodeName.toLowerCase();this.originalHeight=b.height();this.previousScrollTop=null;this.value=b.val();if(c.maxWidth==="original")c.maxWidth=b.width();if(c.minWidth==="original")c.minWidth=b.width();if(c.maxHeight==="original")c.maxHeight=b.height();if(c.minHeight==="original")c.minHeight=b.height();if(this.nodeName==="textarea"){b.css({resize:"none",overflowY:"hidden"})}b.data("AutoResizer",this);c.animate.complete=function(a){return function(){c.onAfterResize.call(b);return a.apply(this,arguments)}}(c.animate.complete);this.bind()}function d(b){this.filter(d.resizableFilterSelector).each(function(){new e(a(this),b)});return this}var b="ar"+ +(new Date),c=d.defaults={onResize:function(){},onBeforeResize:function(){return 123},onAfterResize:function(){return 555},animate:{duration:200,complete:function(){}},extraSpace:50,minHeight:"original",maxHeight:500,minWidth:"original",maxWidth:500};d.cloneCSSProperties=["lineHeight","textDecoration","letterSpacing","fontSize","fontFamily","fontStyle","fontWeight","textTransform","textAlign","direction","wordSpacing","fontSizeAdjust","paddingTop","paddingLeft","paddingBottom","paddingRight","width"];d.cloneCSSValues={position:"absolute",top:-9999,left:-9999,opacity:0,overflow:"hidden"};d.resizableFilterSelector=["textarea:not(textarea."+b+")","input:not(input[type])","input[type=text]","input[type=password]","input[type=email]","input[type=url]"].join(",");d.AutoResizer=e;a.fn.autoResize=d;e.prototype={bind:function(){var b=a.proxy(function(){this.check();return true},this);this.unbind();this.el.bind("keyup.autoResize",b).bind("change.autoResize",b).bind("paste.autoResize",function(){setTimeout(function(){b()},0)});if(!this.el.is(":hidden")){this.check(null,true)}},unbind:function(){this.el.unbind(".autoResize")},createClone:function(){var c=this.el,e=this.nodeName==="textarea"?c.clone():a("<span/>");this.clone=e;a.each(d.cloneCSSProperties,function(a,b){e[0].style[b]=c.css(b)});e.removeAttr("name").removeAttr("id").addClass(b).attr("tabIndex",-1).css(d.cloneCSSValues);if(this.nodeName==="textarea"){e.height("auto")}else{e.width("auto").css({whiteSpace:"nowrap"})}},check:function(a,b){if(!this.clone){this.createClone();this.injectClone()}var c=this.config,d=this.clone,e=this.el,f=e.val();if(f===this.prevValue){return true}this.prevValue=f;if(this.nodeName==="input"){d.text(f);var g=d.width(),h=g+c.extraSpace>=c.minWidth?g+c.extraSpace:c.minWidth,i=e.width();h=Math.min(h,c.maxWidth);if(h<i&&h>=c.minWidth||h>=c.minWidth&&h<=c.maxWidth){c.onBeforeResize.call(e);c.onResize.call(e);e.scrollLeft(0);if(c.animate&&!b){e.stop(1,1).animate({width:h},c.animate)}else{e.width(h);c.onAfterResize.call(e)}}return}d.width(e.width()).height(0).val(f).scrollTop(1e4);var j=d[0].scrollTop;if(this.previousScrollTop===j){return}this.previousScrollTop=j;if(j+c.extraSpace>=c.maxHeight){e.css("overflowY","");j=c.maxHeight;b=true}else if(j<=c.minHeight){j=c.minHeight}else{e.css("overflowY","hidden");j+=c.extraSpace}c.onBeforeResize.call(e);c.onResize.call(e);if(c.animate&&!b){e.stop(1,1).animate({height:j},c.animate)}else{e.height(j);c.onAfterResize.call(e)}},destroy:function(){this.unbind();this.el.removeData("AutoResizer");this.clone.remove();delete this.el;delete this.clone},injectClone:function(){(d.cloneContainer||(d.cloneContainer=a("<arclones/>").appendTo("body"))).append(this.clone)}}})(jQuery);

(function($) {

	/**
	 * Spoofs placeholders in browsers that don't support them (eg Firefox 3)
	 * 
	 * Copyright 2011 Dan Bentley
	 * Licensed under the Apache License 2.0
	 *
	 * Author: Dan Bentley [github.com/danbentley]
	 */

	// Return if native support is available.
	if ("placeholder" in document.createElement("input")) return;

	$(document).ready(function()
	{	
		$(':input[placeholder]').not(':password').each(function() {
			setupPlaceholder($(this));
		});

		$(':password[placeholder]').each(function() {
			setupPasswords($(this));
		});

		$('form').submit(function(e) {
			clearPlaceholdersBeforeSubmit($(this));
		});
	});

	function setupPlaceholder(input) {

		var placeholderText = input.attr('placeholder');

		setPlaceholderOrFlagChanged(input, placeholderText);
		input.focus(function(e) {
			if (input.data('changed') === true) return;
			if (input.val() === placeholderText) input.val('');
		}).blur(function(e) {
			if (input.val() === '') input.val(placeholderText); 
		}).change(function(e) {
			input.data('changed', input.val() !== '');
		});
	}

	function setPlaceholderOrFlagChanged(input, text) {
		(input.val() === '') ? input.val(text) : input.data('changed', true);
	}

	function setupPasswords(input) {
		var passwordPlaceholder = createPasswordPlaceholder(input);
		input.after(passwordPlaceholder);

		(input.val() === '') ? input.hide() : passwordPlaceholder.hide();

		$(input).blur(function(e) {
			if (input.val() !== '') return;
			input.hide();
			passwordPlaceholder.show();
		});

		$(passwordPlaceholder).focus(function(e) {
			input.show().focus();
			passwordPlaceholder.hide();
		});
	}

	function createPasswordPlaceholder(input) {
		return $('<input>').attr({
			placeholder: input.attr('placeholder'),
			value: input.attr('placeholder'),
			id: input.attr('id'),
			readonly: true
		}).addClass(input.attr('class'));
	}

	function clearPlaceholdersBeforeSubmit(form) {
		form.find(':input[placeholder]').each(function() {
			if ($(this).data('changed') === true) return;
			if ($(this).val() === $(this).attr('placeholder')) $(this).val('');
		});
	}
})(jQuery);

/*
 * respond.js - A small and fast polyfill for min/max-width CSS3 Media Queries
 * Copyright 2011, Scott Jehl, scottjehl.com
 * Dual licensed under the MIT or GPL Version 2 licenses. 
 * Usage: Check out the readme file or github.com/scottjehl/respond
*/
(function(e,h){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=h;if(h){return}var u=e.document,r=u.documentElement,i=[],k=[],p=[],o={},g=30,f=u.getElementsByTagName("head")[0]||r,b=f.getElementsByTagName("link"),d=[],a=function(){var B=b,w=B.length;for(var z=0;z<w;z++){var y=B[z],x=y.href,A=y.media,v=y.rel&&y.rel.toLowerCase()==="stylesheet";if(!!x&&v&&!o[x]){if(!/^([a-zA-Z]+?:(\/\/)?(www\.)?)/.test(x)||x.replace(RegExp.$1,"").split("/")[0]===e.location.host){d.push({href:x,media:A})}else{o[x]=true}}}t()},t=function(){if(d.length){var v=d.shift();n(v.href,function(w){m(w,v.href,v.media);o[v.href]=true;t()})}},m=function(G,v,x){var E=G.match(/@media ([^\{]+)\{((?!@media)[\s\S])*(?=\}[\s]*\/\*\/mediaquery\*\/)/gmi),H=E&&E.length||0,v=v.substring(0,v.lastIndexOf("/")),w=function(I){return I.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+v+"$2$3")},y=!H&&x;if(v.length){v+="/"}if(y){H=1}for(var B=0;B<H;B++){var C;if(y){C=x;k.push(w(G))}else{C=E[B].match(/@media ([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1;k.push(RegExp.$2&&w(RegExp.$2))}var z=C.split(","),F=z.length;for(var A=0;A<F;A++){var D=z[A];i.push({media:D.match(/(only\s+)?([a-zA-Z]+)(\sand)?/)&&RegExp.$2,rules:k.length-1,minw:D.match(/\(min\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1),maxw:D.match(/\(max\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1)})}}j()},l,q,j=function(E){var v="clientWidth",x=r[v],D=u.compatMode==="CSS1Compat"&&x||u.body[v]||x,z={},C=u.createDocumentFragment(),B=b[b.length-1],w=(new Date()).getTime();if(E&&l&&w-l<g){clearTimeout(q);q=setTimeout(j,g);return}else{l=w}for(var y in i){var F=i[y];if(!F.minw&&!F.maxw||(!F.minw||F.minw&&D>=F.minw)&&(!F.maxw||F.maxw&&D<=F.maxw)){if(!z[F.media]){z[F.media]=[]}z[F.media].push(k[F.rules])}}for(var y in p){if(p[y]&&p[y].parentNode===f){f.removeChild(p[y])}}for(var y in z){var G=u.createElement("style"),A=z[y].join("\n");G.type="text/css";G.media=y;if(G.styleSheet){G.styleSheet.cssText=A}else{G.appendChild(u.createTextNode(A))}C.appendChild(G);p.push(G)}f.insertBefore(C,B.nextSibling)},n=function(v,x){var w=c();if(!w){return}w.open("GET",v,true);w.onreadystatechange=function(){if(w.readyState!=4||w.status!=200&&w.status!=304){return}x(w.responseText)};if(w.readyState==4){return}w.send()},c=(function(){var v=false,w=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new XMLHttpRequest()}],y=w.length;while(y--){try{v=w[y]()}catch(x){continue}break}return function(){return v}})();a();respond.update=a;function s(){j(true)}if(e.addEventListener){e.addEventListener("resize",s,false)}else{if(e.attachEvent){e.attachEvent("onresize",s)}}})(this,(function(f){if(f.matchMedia){return true}var e,i=document,c=i.documentElement,g=c.firstElementChild||c.firstChild,h=!i.body,d=i.body||i.createElement("body"),b=i.createElement("div"),a="only all";b.id="mq-test-1";b.style.cssText="position:absolute;top:-99em";d.appendChild(b);b.innerHTML='_<style media="'+a+'"> #mq-test-1 { width: 9px; }</style>';if(h){c.insertBefore(d,g)}b.removeChild(b.firstChild);e=b.offsetWidth==9;if(h){c.removeChild(d)}else{d.removeChild(b)}return e})(this));

