/***********************
 * clear input's value *
 *********************/
function clearValue(element) {
	(function($) {
		try {
			var el = $(element);
			var color = el.css('color');
			var val;
			el.hover(function() {
				$(this).css('color', '#666');
			}, function() {
				if ($(this).val() != val && $(this).val() !== '') $(this).css('color', color);
			}).focusin(function() {
				val = $(this).val();
				if ($(this).val() == val) {
					$(this).val('');
					$(this).css('color', color);
				}
			}).focusout(function() {
				if ($(this).val() === '') $(this).val(val);
			});
		} catch (error) {
			if (typeof console == 'object') console.log(error.name + ': ' + error.message);
		}
	})(this.jQuery);
}
/******************
 * fake pull down *
 ******************/
function pullDown(element) {
	(function($) {
		try {
			var el = $(element);
			var list = el.find('p').next('ul');
			var btn = el.find('p a');
			btn.click(function() {
				list.height('auto');
				el.siblings().find('ul').fadeOut('fast');
				if (list.is(':visible')) {
					list.fadeOut('fast');
				} else {
					list.slideDown('fast');
				}
				return false;
			});
		} catch (error) {
			if (typeof console == 'object') console.log(error.name + ': ' + error.message);
		}
	})(this.jQuery);
}
/******************
 * document ready *
 *****************/
jQuery(document).ready(function($) {
	clearValue('#searchTerm');
	clearValue('#user');
	clearValue('#pass');
	pullDown('#objDbSelCategory1');
	pullDown('#objDbSelCategory2');
	pullDown('#objDbSelCategory3');
	pullDown('#objDbSelShowCount');
});

