// typekit

	try{Typekit.load();}catch(e){}

// analytics

	var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-19861044-3']); _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); })();

// globals

	if ( navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/iPad/i) )
		var ios = true;

	function wipeForm() {
		$('nav')
			.addClass('open')
			.removeClass('active');
		$('[type="search"]').removeAttr('value');
		$('article').removeAttr('style');
		}

$(document)
	.ready(function() {

	$(document)
		.on('click', 'nav > a', function(e) {

			e.preventDefault();
			$('nav').toggleClass('open');

			if (!ios)
				$('[type="search"]').focus();

			})
		.on('click', 'body', function(e) {
			if ( !$(e.target).closest('nav').length )
				$('nav').removeClass('open');
			})
		.on('focus', '[type="search"]', function() {

			$.fn.liveFilter = function (wrapper) {
	
				$('[type="search"]').keyup(function() {

					if ($(this).val().length > 0)
						$('nav').addClass('active');
					else
						$('nav').removeClass('active');

					$('article').hide();
					$('article h2:contains("' + $(this).val() + '"), article time:contains("' + $(this).val() + '")').closest('article').removeAttr('style');

					});
	
				$.expr[':'].contains = function(a,i,m) {
					return $(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
					};
	
				}
	
			$('[role="content"]').liveFilter('article');

			})
		.on('keydown', function(e) {
			if (e.which == '27' && $('[type="search"]').not(':focus')) // esc
				$('nav').removeClass('open');
			})
		.on('keydown', '[type="search"]', function(e) {
			if (e.which == '27') { // esc
				wipeForm();
				return false;
				}
			})
		.on('mousedown', '[type="reset"]', function() {
			wipeForm();
			return false;
			});

	});

$(document).scroll(function() {

    if ( $(document).scrollTop() >= 100 )
		$('body').addClass('scrolled');
	else
		$('body').removeAttr('class');

	});

$(window).load(function () {

	});
