﻿$(document).ready(function() {
	$('#mainnav li').each(function() {
        $(this).bind('mouseover', function() {
            var parent = $(this).parent().parent();
            if(parent.is('li')) parent.find('a:first').addClass('trail');
        });
        
		$(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'); $('#mainnav li a').removeClass('trail'); }, 400));
		});
	});

    // For the site search field at top
    $('#q').bind('focus', function() { if(this.value == 'Search site or enter product code...') this.value = ''; });
    $('#q').bind('blur', function() { if(this.value == '') this.value = 'Search site or enter product code...'; });

    // For the subscribe field at bottom of screen
    $('#NewsletterEmail').bind('focus', function() { if(this.value == 'Please enter your email...') this.value = ''; });
    $('#NewsletterEmail').bind('blur', function() { if(this.value == '') this.value = 'Please enter your email...'; });
});