(function( global ) {

	var doc = global.document,
	hasQuerySelect = !!doc.querySelector;

	function supportsSelector( selector ) {

		var body = doc.body,
					ret, div, style;

		// If the browser has support, take the faster path
		if ( hasQuerySelect ) {

			try {
				// Invalid selectors will throw exceptions
				doc.querySelector( selector );
				ret = true;
			} catch( e ) {
				ret = false;
			}

			// Return early from fast path
			return ret;
		}

		// Back up plan for older browser that do not support qS
		body.appendChild(
			(
				( div = document.createElement( "div" ) ),
				( div.innerHTML = [ "&shy;<style>", selector, "{}</style>" ].join("") ),
				div
			)
		);

		style = div.children[ 0 ];

		// IE8 has an easy out, the rule list will be empty
		if ( style.styleSheet && !style.styleSheet.rules.length ) {
			ret = false;
		} else {
			// IE6,7 will create pseudo selectors named ":unknown"
			// Some cases will be uppercase, others will not
			// IE6,7,8 will all create correct rules for selectors deemed valid

			ret = !/unknown/.test( style.styleSheet.rules[0].selectorText.toLowerCase() );
		}

		body.removeChild( div );

		return ret;
	}

	global.supportsSelector = supportsSelector;

})( this );

function supports_input_placeholder() {
  var i = document.createElement('input');
  return 'placeholder' in i;
}

jQuery(function($) {

	if ( !supportsSelector(":last-child") ) {
 		$("header nav li:last-child, #brands li:last-child").addClass("last-child");
	}

	if ( !supportsSelector(":nth-child(4n+1)") ) {
 		$("#friends li:nth-child(4n+1)").addClass("nth-4n1");
	}
	
	if ( !supportsSelector(":nth-child(1)") ) {
 		$(".about #team ul li:nth-child(1)").addClass("nth-1");
	}
	
	if ( !supportsSelector(":nth-child(2)") ) {
 		$(".about #team ul li:nth-child(2)").addClass("nth-2");
	}
	
	if ( !supportsSelector(":nth-child(5)") ) {
 		$("#brands li:nth-child(5)").addClass("nth-5");
	}
	
	if ( !supportsSelector(":nth-child(6)") ) {
 		$("#brands li:nth-child(6)").addClass("nth-6");
	}
	
	if ( !supportsSelector(":nth-child(2n)") ) {
 		$(".about #team ul li:nth-child(2n)").addClass("nth-2n");
	}
	
	if ( !supportsSelector(":not([class])") ) {
 		$(".slider .container > li:not([class])").addClass("not");
	}
	
	if ( !supportsSelector(":nth-child(2n+1)") ) {
 		$(".about #team ul li:nth-child(2n+1), .slider .container > li:nth-child(2n+1)").addClass("nth-2n1");
	}
	
	

	$(".panel .new-search").click(function(e) {
		$(this).parent().prev(".search").show();
		e.preventDefault();
	});
	
	$(".log-notes a").click(function(e) {
		$(this).parent().next("table").toggle();
		$(this).toggleClass("open");
		e.preventDefault();
	});
});
