$(function() {
	
	$('.validate-form').each(function() {
		return $(this).validate();
	});
	
	$('.validate-form input:text,.validate-form textarea').each(function() {
		$(this).attr('default_val', $(this).val());
	});
	
	$('.validate-form input:text,.validate-form textarea').focus(function() {
		var default_val = $(this).attr('default_val'), val = $(this).val();
		
		if (val == default_val) {
			$(this).val('');
		}
		
		$(this).addClass('focus');
		
	}).blur(function() {
		var default_val = $(this).attr('default_val'), val = $(this).val();
		
		if (val.length == 0) {
			$(this).val(default_val);
		}
		
		$(this).removeClass('focus');
	});
	
	
	$('#recipe-search input[name=q], .recipe-search input[name=q]').focus(function() {
		var v = $(this).val();
		
		if (v == 'e.g chocolate cake') {
			$(this).val('');
		}
	}).blur(function() {
		var v = $(this).val();
		
		if (v == '') {
			$(this).val('e.g chocolate cake');
		}
	});
	
	$('#search-field').focus(function() {
		var v = $(this).val();
		
		if (v == 'Search') {
			$(this).val('');
		}
	}).blur(function() {
		var v = $(this).val();
		
		if (v == '') {
			$(this).val('Search');
		}
	});
	
});
