(function($){
	
/*	
	//	Index layout
	var layout = new Array(
		"pro/400/",
		"lab/attp/",
		"pro/3t/",
		"lab/the-flames/",
		"pro/bx/",
		"lab/labor/",
		"pro/yimyam/",
		"pro/indoors/"
	);

	function more() {
		$.ajax({
		  url: "inc/"+layout.pop()+"index.html",
		  dataType: "html",
		  success: function(html){
		    $("#a").append(html);
		  }
		});
	}


	m = $( "#more" ),
	o = { offset: '100%' };
	$.waypoints.settings.scrollThrottle = 30;
	m.waypoint(function(e,d){
		m.waypoint('remove');
		console.log( d );
		if( layout.length>0 ) {
			more();
			m.waypoint(o);
		}
	},o);
*/
	
/*
	$( document ).bind( "scroll", function() {
		console.log( $( "body" ).scrollTop() )
 		if ( $( "body" ).offsetHeight + $( "body" ).scrollTop() >= $( "body" ).scrollHeight) {
			if( layout.length > 0 ) {
				more();
			}
		}
	});
*/
	
	
	
	
	$( "header" ).bind( "click", function(){ $( "body" ).animate({ scrollTop: 0 }, 600 ); });
	
	
	
	
	//  Separate Internal and External Links
	//	Nicked from stewd.io
	$( "a[href^='http://']" )
  	.not( "a[href^='http://www.sebastianberns.com']" )
  	.not( "a[href^='http://sebastianberns.com']" )
  	.attr( "target", "_blank" );
	
	
	
	
	//	Gallery click-through
	$( ".staple" ).live("click",function(e){ if ( e.target.tagName != "a" ) carousel(e); });
	function carousel(e) {
		var o = $( e.target ).parents( ".staple" ).children();
		var t = new Array();
		o.each(function(i){
			var a = $( this ).attr( "class" );
			var b = i==0 ? o.filter( ":last" ).attr( "class" ) : t.pop();
			$( this ).removeClass().addClass( b );
			t.push( a );
		});
	}
	
	
	
})(jQuery);
