// Apply Cufon
Cufon.replace('#content_body h2, #column_one h3, #column_right h3, #div_home_grid h3, #div_home_top_right h3, #social_foot_MO_text');

$(document).ready(function() {
	// Attach behavior to input.clear_val fields
	$("#top_search_field").focus(function() {
		if (this.value == this.defaultValue) this.value = "";
		$(this).animate({width:135},300);
	}).blur(function() {
		if (!this.value.length) this.value = this.defaultValue;
		$(this).animate({width:102},300);
	});
	
	$('.social_foot_MO').hover(
		function() { $('#social_foot_MO_text').show(); },
		function() { $('#social_foot_MO_text').hide(); }
	);
	
	$('#column_one form.autoSubmit').each(function()
	{
		$('input[type="submit"]', this).hide();
		$('select', this).each(function(){ $(this).bind('change',function(){ if (this.value != 'NULL') $(this).parents('form').submit(); }); });
	});
	
	// Auto-stripe alternate rows in tables
	$('table').each(function()
	{
		$('tr:nth-child(even)',this).addClass('even');
	});

	// Attach behavior for expandable menu
	$('#expand_bttn').click(function() {
		if ( $(this).attr('rel') == 'open' ) {
			$(this).attr('rel','closed').removeClass('menu_open');
			$('#header').animate({height:'157px'}, 500);
			$('#header_submenu').fadeOut();
			$('#main_expand_h2, #main_expand_break, #main_expand_header_image').fadeIn();
			$('#header_submenu_container').css('margin','0 0 2px');
		} else {
			$(this).attr('rel','open').addClass('menu_open');
			$('#header').animate({height:'228px'}, 500);
			$('#header_submenu').fadeIn();
			$('#main_expand_h2, #main_expand_break, #main_expand_header_image').fadeOut();
			$('#header_submenu_container').css('margin','0 0 75px');
		}
	});
});


