﻿$(document).ready(function() {
	$('#nav li').each(function() {
		$(this).find('ul').prev().attr('class', 'stub').parent().bind('mouseover', function() {
			var o = $(this);
			if(o.attr('action')) clearTimeout(o.attr('action'));
			o.attr('action', setTimeout(function() { $(o).find('ul:first').css('visibility', 'visible'); }, 400));
		}).bind('mouseout', function() {
			var o = $(this);
			if(o.attr('action')) clearTimeout(o.attr('action'));
			o.attr('action', setTimeout(function() { $(o).find('ul:first').css('visibility', 'hidden'); }, 400));
		});
	});
	
	// For the site search field
    $('#q').bind('focus', function() { if(this.value == 'Search the site') this.value = ''; });
    $('#q').bind('blur', function() { if (this.value == '') this.value = 'Search the site'; });

    // For the newsletter field
    $('#NewsletterEmail').bind('focus', function() { if (this.value == 'Your email address') this.value = ''; });
    $('#NewsletterEmail').bind('blur', function() { if (this.value == '') this.value = 'Your email address'; });
});