$(document).ready(function(){

//adds a class to child ul parent list items to allow styling
$('ul.sub-menu').parent().addClass('parent');
$('.footer-social-list a').css({'opacity':'0.75'});
$('.footer-social-list a').hover(function(){
	$(this).stop().fadeTo(500,1);
	}, function(){
		$(this).stop().fadeTo(500,0.75);
		});
		
$('.tweety-follow').hover(function(){
	$(this).stop().animate({
			top: '3px'
		});
	}, function(){
			$(this).stop().animate({
				top: '0px'
			});
		});
		
$('.bday-form input').each(function() {
    var default_value = this.value;
    $(this).focus(function() {
        if(this.value == default_value) {
            this.value = '';
        }
    });
    $(this).blur(function() {
        if(this.value == '') {
            this.value = default_value;
        }
    });
});// Main navigation flyout menus
	var timeout = 500;
	var closetimer = 0;
	var flyoutmenuitem = 0;
	// create the flyout functionality
	function flyout_open(){  
		var $this = $(this);
		flyout_canceltimer();
		flyout_close();
		flyoutmenuitem = $this.find(' > ul').css('display','block').animate({
			top: '50px',
			},300);
		
		
		// adds a class to the parent list item which adds styling normally handled by li:hover but requires timeout
		if ( $this.children().hasClass('sub-menu') ) {
			$this.addClass('selected');
		}
	}
		
	// create the flyout close/hide functionality
	function flyout_close(){
		var $this = $('.main-nav > li');
		// removes the added list item style class
		if (flyoutmenuitem) {
			// now hide the flyout
			flyoutmenuitem.css({'display':'none','top':'40px'});
			$this.removeClass('selected');
			}
		}
		
	// the flyout should delay before it closes/hides
	function flyout_timer(){
		closetimer = window.setTimeout(flyout_close, timeout);
	}
	
	// we cancel the flyout timer if we hover on a sibling
	function flyout_canceltimer() {
		if(closetimer) {
			window.clearTimeout(closetimer);
			closetimer = null;
		}
	}
			
	//executes the flyout open, close and timer functions
	$('.main-nav > li').hoverIntent(flyout_open, flyout_timer);
	
	//if we click on something else, it should also close, without delay				
	document.onclick = flyout_close;

});

