(function($, window){
	
	// settings
	window.pnst = {
		animLength: 500,
		More: '<span>↓</span> Keep Reading',
		Less: '<span>↑</span> Put Away',
		DisableKeepReading: false,
		parasToShow: 2,
		clickEventAdded: false,
		contentHeight : false,
		loadEvent: function() {
			//console.log('hell, world');
			
			pnst.entryHide = pnst.entryHide || $('.blog-home .i-1 .entry-content');
			pnst.entryChildren = pnst.entryChildren || pnst.entryHide.find("p");
			
			if ( ! ( pnst.entryChildren.size() > 2 ) )
				return;
			
			pnst.entryHeight = 0;

			// some serious jiggery pokery here because:
			// we might be running this a second time (after fonts loaded)
			if ( pnst.contentHeight ) {
				var entryHideClone = pnst.entryHide.clone().removeAttr("style").css("visibility","hidden","position:absolute"); 
				pnst.entryHide.after(entryHideClone);
				pnst.contentHeight = entryHideClone.height();
				entryHideClone.remove();
			}
			else {
				pnst.contentHeight = pnst.entryHide.height();
			}
			
			for ( var i = 0; i < pnst.parasToShow; i++ ) {
				var th = pnst.entryChildren.eq(i).outerHeight(true);
				//console.log(th);
				pnst.entryHeight += th;
			}
			

			pnst.entryHide.css({height: pnst.entryHeight});
			if ( ! pnst.clickEventAdded ) {
				pnst.clickEventAdded = true;
				pnst.entryHide.after("<div class='reveal'><p>"+ pnst.More +"</p></div>").addClass("shortened");
				$(".reveal > p").click(pnst.clickEvent);
			}
		},
		clickEvent: function() {
			if ($(this).hasClass('hide') ) { // hide it
				$(this).removeClass('hide').html(pnst.More);
				pnst.entryHide.animate({height: pnst.entryHeight}, pnst.animLength);
				$.scrollTo("#primary", pnst.animLength);
			}
			else { // show it
				$(this).addClass('hide').html(pnst.Less);
				pnst.entryHide.animate({height: pnst.contentHeight}, pnst.animLength);
			}
			pnst.entryHide.toggleClass("shortened");
		}
	};

//	$(window).load(pnst.loadEvent);
	
	var html = $("html");
	
	// OS detection
	$.each(['Mac','Win','Linux'], function(i, val){
		if ( navigator.platform.match(val) )
			html.addClass( val.toLowerCase() );
	});

	// Platform Detection
	$.each(['msie','mozilla','webkit'], function(i, val) {
		if ( $.browser[val] )
			html.addClass(val);
	});
	
	// Safari Detection
	if ( $.browser.webkit && navigator.vendor === 'Apple Computer, Inc.' ) {
		html.addClass('safari');
	}
	
})(jQuery, window);



jQuery(document).ready(function($) {
	// we run this to get started, and also call it at load to make sure it gets called after the fonts are completely loaded
//	pnst.loadEvent();
});


/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
(function(C){var A=C.scrollTo=function(F,E,D){C(window).scrollTo(F,E,D);};A.defaults={axis:"xy",duration:parseFloat(C.fn.jquery)>=1.3?0:1};A.window=function(D){return C(window)._scrollable();};C.fn._scrollable=function(){return this.map(function(){var E=this,D=!E.nodeName||C.inArray(E.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!D){return E;}var F=(E.contentWindow||E).document||E.ownerDocument||E;return C.browser.safari||F.compatMode=="BackCompat"?F.body:F.documentElement;});};C.fn.scrollTo=function(F,E,D){if(typeof E=="object"){D=E;E=0;}if(typeof D=="function"){D={onAfter:D};}if(F=="max"){F=9000000000;}D=C.extend({},A.defaults,D);E=E||D.speed||D.duration;D.queue=D.queue&&D.axis.length>1;if(D.queue){E/=2;}D.offset=B(D.offset);D.over=B(D.over);return this._scrollable().each(function(){var L=this,J=C(L),K=F,I,G={},M=J.is("html,body");switch(typeof K){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(K)){K=B(K);break;}K=C(K,this);case"object":if(K.is||K.style){I=(K=C(K)).offset();}}C.each(D.axis.split(""),function(Q,R){var S=R=="x"?"Left":"Top",U=S.toLowerCase(),P="scroll"+S,O=L[P],N=A.max(L,R);if(I){G[P]=I[U]+(M?0:O-J.offset()[U]);if(D.margin){G[P]-=parseInt(K.css("margin"+S),10)||0;G[P]-=parseInt(K.css("border"+S+"Width"),10)||0;}G[P]+=D.offset[U]||0;if(D.over[U]){G[P]+=K[R=="x"?"width":"height"]()*D.over[U];}}else{var T=K[U];G[P]=T.slice&&T.slice(-1)=="%"?parseFloat(T)/100*N:T;}if(/^\d+$/.test(G[P])){G[P]=G[P]<=0?0:Math.min(G[P],N);}if(!Q&&D.queue){if(O!=G[P]){H(D.onAfterFirst);}delete G[P];}});H(D.onAfter);function H(N){J.animate(G,E,D.easing,N&&function(){N.call(this,F,D);});}}).end();};A.max=function(J,I){var H=I=="x"?"Width":"Height",E="scroll"+H;if(!C(J).is("html,body")){return J[E]-C(J)[H.toLowerCase()]();}var G="client"+H,F=J.ownerDocument.documentElement,D=J.ownerDocument.body;return Math.max(F[E],D[E])-Math.min(F[G],D[G]);};function B(D){return typeof D=="object"?D:{top:D,left:D};}})(jQuery);
