/**************************************************************
 * Filename: site.js
 * Description: Primary javascript file for EDC Wayne County 
 *              Web site.
 * Author: Shaun Lieberman
 * Company: Huffine Design, Inc.
 * Created: 7/15/2009
 **************************************************************/
 
 function init() {
	
	// Set up menu stuff
	$('ul.subnav', '#nav').css('display', 'none');
	$('#nav li').hover(
		function(e) {
			$('ul.subnav', this).fadeIn('fast');
		},
		function(e) {
			$('ul.subnav', this).fadeOut('fast');
		}
	);
	
	// Show broken links
	$('a[href=""]').hover(
		function(e) {
			$(this).css('text-decoration', 'line-through');
		},
		function(e) {
			$(this).css('text-decoration', '');
		}
	);
	
	// Set up smooth scrollers
	$('a.smooth-scroll, .smooth-scroll a').click(function(){
		var href = $(this).attr('href');
		if (href.substr(0, 1) != '#') {
			return true;
		}
		
		$('html, body').animate({
			scrollTop: $(href).offset().top
		}, 750);
		return false;
	});
	
	
	// Set up the search box
	$('#search-form #submit-input').hide();
	$('#search-form #query-input')
		.css({paddingRight: '5px', width: '190px', textAlign: 'right', color: '#aaa'})
		.attr('value', 'search')
		.focus(function(){
			if ($(this).attr('value') == 'search' && $(this).css('text-align') == 'right' ) {
				$(this).attr('value', '').css({textAlign: 'left', color: ''});
			}
		})
		.blur(function(){
			if ($(this).attr('value') == '') {
				$(this).attr('value', 'search').css({textAlign: 'right', color: '#aaa'});
			}
		})
}

$(document).ready(init);