String.prototype.LTrim = function(){return LTrim(this);} 
function LTrim(str) 
{ 
var i; 
for(i=0;i<str.length;i++) 
{ 
if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break; 
} 
str=str.substring(i,str.length); 
return str; 
} 

var g_restype = "search";

function setResType(index) {
	//9 BT http://bt.xunlei.com/bt_search?s=qq&id=2
	// 10 找到 http://so1.xunlei.com/found?s=qq
	g_restype = index;
}

function check()
{
  var url;

  var s_key = document.getElementById("searchbox1").value;
  s_key = s_key.LTrim();
  if (s_key == "搜索超过10万部小说内容" || s_key ==""){
	  alert("请输入搜索关键字!") ;
	  document.getElementById("searchbox1").value = "" ;
	  document.getElementById("searchbox1").focus();
	  return false ;
  }
  s_key = s_key;

  if (g_restype == 'video')
  {
		url = "modules/article/search.php?searchtype=articlename&searchkey="+s_key ;
  } else if (g_restype == 'search')  {
		url = "modules/article/search.php?searchtype=articlename&searchkey="+s_key ;
  }
  else{
		url = "modules/article/search.php?searchtype=articlename&searchkey="+s_key ;
  }
  

  if (g_restype == 'game') {
		url = url + "&restype=1" ;
  }
  else if (g_restype == 'soft') {
		url = url + "&restype=2" ;
  }
  else if (g_restype == 'book') {
		url = url + "&restype=3" ;
  }
  else if (g_restype == 'shouji') {
		url = url + "&restype=6" ;
  }
  else if (g_restype == 'web')
  {
	  //url = url + "&id=1" ;
  }
  url = url;
  var d = new Date();
  var windowName = parseInt(d.getHours().toString() + d.getMinutes().toString() + d.getSeconds().toString()/3);
  img = new Image();
  img.src = "http://tracker.movie.xunlei.com/set_movie_stat.php?t=3&id=54&c=pageview&cache="+(Math.floor(Math.random()*999999)+1);
  window.open(url,"so_" + windowName); 

}


function submitToGoogle(channelname) {

 	var s_key = document.getElementById("searchbox1").value; 
	document.gform1.q.value=s_key;
	document.gform1.channel.value=channelname;
	document.gform1.submit();
	return;
}

function getSearchUrl(){
var url;
  var s_type = g_restype;
  var g_lrc = g_suffix = "";
  var s_key = document.getElementById("searchbox1").value;  
  //select();
  
  if( g_restype == 8 ){
	submitToGoogle('websearch');
	return;
  }
  
  if(LTrim(s_key) == "")
  {
     url = " ";
  }
  else
  {   
     s_key = encodeURIComponent(s_key);
     if(g_restype != 7)
	 {
		if(g_restype == 0) url = " ";
		else if(g_restype == 4) url = " ";
		else url = " ";
	 
	    if(g_lrc == "" )
		   url = url + "/search?" + "search=" + s_key + "&suffix=" + g_suffix + "&restype=" + s_type;
		/*
		else
		{
			if(g_lrc == "false" ) url = url + "/search?" + "search=" + s_key + "&lrc=" + g_lrc + "&mtv=1&id=1";
		   	else if(g_lrc == "true" )url = url + "/lrc?" + "search=" + s_key + "&lrc=" + g_lrc + "&id=1";
		}*/
	 }
	else 
	    url = "";
  }
  //reloc_a.href=url;
}