// JavaScript Document
var $j = jQuery.noConflict();

var path = "/grk/index.php/";

//链接失败
function error_contect()
{
	alert("contect error");
}

function showHideDiv(objStr){
	var obj = $(objStr);
	if(obj.style.display == "none"){
		obj.style.display = "";
	}else{
		obj.style.display = "none";
	}
}

function showHideDiv_navOn(objStr, k){
	var obj = $(objStr);
	var nav = $("n" + k);
	if(obj.style.display == "none"){
		obj.style.display = "";
		nav.className = "on";
	}else{
		obj.style.display = "none";
		nav.className = "";
	}
}

function gotoTop(){
	scroll(0,0);
}


function addBookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}

function showkind(){
	var ser_kind = $("ser_kind");
	
	deleteOption();
	switch (ser_kind.selectedIndex)
	{
		case 1:
			addSel("标题", "title");
			addSel("作者", "author");
			addSel("内容", "content");
			break;
		case 2:
			addSel("标题", "title");
			addSel("内容", "content");
			break;
		case 3:
			addSel("作者", "visitorName");
			addSel("内容", "content");
			addSel("回复", "reply");
			break;
		default:
			addSel("Range", "");
			return null;
			break;
	}
}
function addSel(text, value){
	var opt;
	opt = document.createElement("option");
	opt.value = value;
	opt.text = text;
	$("ser_range").options.add(opt);
}
function  deleteOption(type){
	var objSelect = $("ser_range");
	objSelect.options.length = 0;
	/*var n = objSelect.options.length;
	for(var i = 0; i < n; i++){
		objSelect.options.remove(0);
	}*/
}

function doSubmit(){
	var serRangeValue = $j.trim($("ser_range").value);
	var serKeyValue = $j.trim($("ser_key").value);
	if(serKeyValue == ""){
		alert ("请输入关键字！");
		return null;
		//serKeyValue = "请输入关键字";
	}
	serKeyValue = serKeyValue.replace(/\s+/g,"+");
	serKeyValue = serKeyValue.replace(/\++/g,"+");
	
	var url;
	switch($("ser_kind").selectedIndex)
	{
		case 1:
			location.href = path + "news/main/search/" + serRangeValue + "/" + serKeyValue;
			break;
		case 2:
			location.href = path + "download/main/search/" + serRangeValue + "/" + serKeyValue;
			break;
		case 3:
			location.href = path + "gbook/main/search/" + serRangeValue + "/" + serKeyValue;
			break;
		default:
			alert ("请选择类别！");
			return null;
			break;
	}
}



var $ = function(id){
	return document.getElementById(id);
}
