$(document).ready(function() {
	
	// Expand and Collapse LongReplies
	$('.longReplyMenu .button-small').click(function(){
		var parentwrap = $(this).parents('.longReply');
		if($(this).html() == 'Collapse'){
			$(parentwrap).children('.lr').slideUp();
			$(parentwrap).children('.sr').slideDown();
			$(this).html('Expand');
		} else {
			$(parentwrap).children('.sr').slideUp();
			$(parentwrap).children('.lr').slideDown();
			$(this).html('Collapse');
		}
	});


	// Add error class to fieldwrapper with an error.
	$('.invalid-error').each(function(){
		$(this).parent('.fieldwrap').addClass('error');
	});
	
	// Make input wrappers white on focus.
	$('.fieldwrap input').live('focusin focusout', function(event){
		if (event.type == 'focusout') {
			$('.active').removeClass('active');
		} else {
			$(this).parent('.fieldwrap').addClass('active');
		}
	});
	
	// Make browserbox wrapper white on hover.
	$('a.extlink').hover(function(){
		$(this).parent('.browserbox').addClass('active');
	}, function(){
		$('.browserbox').removeClass('active');
	});

});
