$(document).ready(function() {
	
	/* Submenu
	---------------------------------------------- */
	$('#categories dd ul').each(function() {
		$(this).hide();
		$(this).parent().find('a:first').addClass('submenu');
		$(this).find('li ul').each(function() {
			$(this).hide();
		}
		);
	});
	$('#categories dd ul li').hover(
		function() {
			$(this).find('ul').show();
		},
		function() {
			$(this).find('ul').hide();
		}
	);
	$('#categories dd').hover(
		function() {
			$(this).find('ul').show();
			$(this).css('z-index', '90');
			$(this).find('a:first').css('text-decoration', 'underline');
			$(this).find('ul li ul').each(function() {
				$(this).hide();
			});
		},
		function() {
			$(this).find('ul').hide();
			$(this).css('z-index', '10');
			$(this).find('a:first').css('text-decoration', 'none');
		}
	);
	
	/* Box helper
	---------------------------------------------- */
	$('.box').each(function(i) {
		if(!$(this).find('div').hasClass('t'))
			$(this).prepend('<div class="c t"><div class="c"></div></div>');
		if(!$(this).find('div').hasClass('b'))
			$(this).append('<div class="c b"><div class="c"></div></div>');
	}); 
	
	/* Clearing inputs
	---------------------------------------------- */
	var CLASS = '.clear-me';	
	 
	$(CLASS).each(function() {
	
		var VALUE = $(this).attr('value');
			
		$(this).focus(function() {
		 	if ($(this).attr('value') == VALUE)
				$(this).attr('value', '');
		});
		
		$(this).blur(function() {
		 	if ($(this).attr('value') == '')
				$(this).attr('value', VALUE);
		});
	});
	
});
