// JavaScript Document
function $(id){return document.getElementById(id);}
function trim(str){
	if(typeof(str) == "string"){
		str = str.replace(/(^\s*)|(\s*$)/g, ""); 
	}
	return str;
}
/* 用于查询框的提示信息 */
var hintMessages = [
"请输入书名或作者进行查询！",
"请输入拍卖主题、拍主昵称、作者查询",
"请输入帖子主题、内容查询"
];

function initSearchHintMessage(name)
{
	var hintColor = "#D8D8D8";
	var items = document.getElementsByName(name);
	for(var i=0; i < hintMessages.length; i++){
		initQueryBoxHint(items[i], hintMessages[i], hintColor);
	}
}

function initQueryBoxHint(curItem, hint, color)
{
	if(curItem.value == ""){
		curItem.style.color = color;
		curItem.value = hint;
	}
	
	curItem.onfocus = function(){
		if(this.value == hint){
			this.style.color = "";
			this.value = "";
		}
	}
	
	curItem.onblur = function(){
		if(this.value == "" || this.value == hint){
			changeQueryValue("");
			this.style.color = color;
			this.value = hint;
		}else{
			this.style.color = "";
		}
	}
}
	
function clearSearchHint(name)
{
	var items = document.getElementsByName(name);
	for(var i=0; i < items.length; i++){
		if(items[i].value == hintMessages[i]){
			items[i].value = "";
		}
	}
}

function resetSearchHint(name, value)
{
	var items = document.getElementsByName(name);
	for(var i=0; i < items.length; i++){
		if(items[i].className != "notset" && items[i].type != "hidden"){
			items[i].value = value;
			items[i].style.color = "";
		}
	}
	initSearchHintMessage(name);
}


//设置排序图标
function initSortPanel(type)
{
	$('priceSort').className="priceGray";
	$('priceSort').href="javascript:setSort(1)";
	$('priceSort').title="点击后按价格从低到高排序";
	
	$('pubDateSort').className="pubDateGray";
	$('pubDateSort').href="javascript:setSort(4)";
	$('pubDateSort').title="点击后按出版日期从近到远排序";
	
	$('addTimeSort').className="addTimeGray";
	$('addTimeSort').href="javascript:setSort(6)";
	$('addTimeSort').title="点击后按上书时间从近到远排序";
	
	if(type==1){
		$('priceSort').className="priceAsc";
		$('priceSort').href="javascript:setSort(2)";
		$('priceSort').title="点击后按价格从高到低排序";
	}
	if(type==2){
		$('priceSort').className="priceDesc";
		$('priceSort').href="javascript:setSort(1)";
	}
	if(type==3){
		$('pubDateSort').className="pubDateAsc";
		$('pubDateSort').href="javascript:setSort(4)";
	}
	if(type==4){
		$('pubDateSort').className="pubDateDesc";
		$('pubDateSort').href="javascript:setSort(3)";
		$('pubDateSort').title="点击后按出版日期从远到近排序";
	}
	if(type==5){
		$('addTimeSort').className="addTimeAsc";
		$('addTimeSort').href="javascript:setSort(6)";
	}
	if(type==6){
		$('addTimeSort').className="addTimeDesc";
		$('addTimeSort').href="javascript:setSort(5)";
		$('addTimeSort').title="点击后按上书时间从远到近排序";
	}
}
