// add prompt text to text input 
$.fn.addInputPromptText = function(o){
	o = $.extend({
		text: '请输入值',
		color: 'gray'
	}, o);
	var promptText = o.text.trim();
	this.each(function(){
		this.inputPromptText = promptText;// save as the dom element's attribute, can be used for data validation
		var ipt = $(this);
		var text = ipt.val().trim();
		var oldColor = ipt.css('color');
		if( ! text ){
			ipt.val(promptText).css('color', o.color);
		}
		ipt.click(function(){
			if( ipt.val().trim()==promptText){
				ipt.val('').css('color', oldColor);
			}
		}).blur(function(){
			if( ipt.val().trim() == '' ){
				ipt.val(promptText).css('color', o.color);
			}
		});
	});
};
// remove the prompt text added by $.fn.addInputPromptText
$.fn.fixInputPromptText = function(){
	this.each(function(){
		if( this.inputPromptText )
		{
			var $this = $(this);
			if( this.inputPromptText == $this.val().trim() )
				$this.val('');
		}
	});
}



function refresh_authcode()
{
	$('#authcode').attr('src', '/post/auth_code.php?nocache=' + (+new Date()) )
	
}
function post_form_add_tag(btn)
{
	$('#id_tag').val(btn.value);
}
function post_form_show_user_tag(btn)
{
	var tr = $('#id_tr_user_tag');
	if( btn.checked )
	{
		tr.show();
	}
	else
	{
		tr.find(':input').val('').end().hide();
	}
}
function submit_search()
{
	var $text = $('#id_header_query');
	$text.fixInputPromptText();
	var val = $text.val();
	if( val )
	{
		$('#search_form').submit();
	}
	else
	{
		alert('请先输入查询条件');
	}
	return false;
}

