$(document).ready(function() {

	/*
		IE6 specific
		Adds a class focus to elements on which fix is applied when focused
	*/

	function focusfix(selector, className) {
		$(selector).focus(function() {
			$(this).addClass(className);
		});
		// Removes class when focus is lost
		$(selector).blur(function() {
			$(this).removeClass(className);
		});
	}

	focusfix('input.input-text', 'focus');
	focusfix('input.inputPassword', 'focus');
	focusfix('textarea', 'focus');
	focusfix('input.input-text', 'focus');
	focusfix('input.input-password', 'focus');

	/*
		watch all inputs for text entry
		Once text is entered, keep focus class "on"
	*/

	$('input').change(function() {
		if ($('input.input-text').attr('value').length > 0) {
			$('input.input-text').addClass('keepFocus');
		} else {
			$('input.input-text').removeClass('keepFocus');
		}
	});

	/*
		Missing selector support
	*/

	// Datagrid striping
	$('table tr:nth-child(2n)').addClass('even');
	$('table tr:nth-child(2n+1)').addClass('odd');

	// Infogrid last class
	$('.infoGrid tbody tr:last-child').addClass('lastChild');
	$('#home #secondaryContent p:first-child').addClass('firstChild')

	/*
		Replace hr-s with stylish rulers
	*/
	$('hr').replaceWith('<div class="hr">&nbsp;</div>')

	// Remove border from linked images
	$("a > img").parent().css('border', 'none');

});
