﻿//打开网页库链接 
function s(l,id)
	{
		if(l==null || l=="")
         {
             var win = window.open("/portal/content.jsf?id="+id);					   
			//win.focus(); 
         }
		else if(l.indexOf("ttp")==-1)
	   	{
			var win =	window.open("content.jsf?t=14&id="+id);								   
			//win.focus(); 
		}
		else
		{
			var win = window.open(l);								   
			//win.focus();	
			
		}
	}

var stabid=0;
function setsrch(c){	
for(i=1;i<=6;i++){document.getElementById("stab"+i).className = "";}
c.className = "cur";
stabid=c.id.substr(c.id.length-1,1);
}


//top查询按钮
    function btsearch()
    {
    	var keywords = document.getElementById('inputkeywords').value;
    	//var keytype = document.getElementById('keytype').value; 
		var keytype=stabid;
    	if(keywords.replace(/(^\s*)|(\s*$)/g, "")=="" || keywords=="输入关键词")
    		alert("请输入查询关键词");
    	else
    	{
    		if(keytype=="6")
    		{
    			//self.location = "http://www.baidu.com/s?si=www.tbtmap.cn&rn=10&&cl=3&ie=utf-8&ct=2097152&wd="+keywords 
    			window.top.location ="http://www.google.com/search?ie=utf-8&sitesearch=www.tbtmap.cn&hl=zh_CN&q="+keywords;
    			//self.location = "http://search.cn.yahoo.com/search?ei=utf-8&vs=www.tbtmap.cn&p="+keywords;
    		}
    		else
    		{
    			keywords = encodeURI(keywords);
        		window.top.location = "http://www.tbtmap.cn/portal/common/search2.jsf?k="+keywords+"&t="+keytype;
        	}
        }	
    }
	
    function toUTF8(szInput){ 
 var wch,x,uch="",szRet="";
 for (x=0; x<szInput.length; x++){
  wch=szInput.charCodeAt(x);
  if (!(wch & 0xFF80)){
   szRet += szInput.charAt(x);
  }
  else if (!(wch & 0xF000)){
   uch = "%" + (wch>>6 | 0xC0).toString(16) + 
      "%" + (wch & 0x3F | 0x80).toString(16);
   szRet += uch; 
  }
  else{
   uch = "%" + (wch >> 12 | 0xE0).toString(16) + 
      "%" + (((wch >> 6) & 0x3F) | 0x80).toString(16) +
      "%" + (wch & 0x3F | 0x80).toString(16);
   szRet += uch; 
  }
 }
 return(szRet);
}
 
    //top查询类型选择
	function showsearchbg(i)
	{
		var secToDo = 'search_bg_img' + i;
		var secToDoSrc = '/portal/image/search_bg_img'+ i +'_on.jpg';
		eval("document.all[secToDo].src=secToDoSrc;");
		for(var j=1;j<=6;j++)
		{
			if(j!=i)
			{
				var secNotDo = 'search_bg_img' + j;
				var secNotDoSrc = '/portal/image/search_bg_img'+ j +'.jpg';
				eval("document.all[secNotDo].src=secNotDoSrc;");
			}
		}
		document.getElementById('keytype').value = i;
		
	}

function showoutsearchbg(){
for(var j=1;j<=6;j++){
var secNotDo = 'search_bg_img' + j;
var secNotDoSrc = '/portal/image/search_bg_img'+ j +'.jpg';
eval("document.all[secNotDo].src=secNotDoSrc;");
}
}

//根据URL确定导航的active项
function showHeadActive(URL)
{
	
	if(URL.indexOf("专题样式模板")>0)
	{
			
		//document.getElementById("zhuanti-td").setAttribute("class","active"); 
		document.getElementById("zhuanti-td").className = "active";
		//alert(document.all['zhuanti-td'].getAttribute("class"));	

	}
}

//enter
function showSel()
{
  if(event.keyCode==13) 
  {
  		btsearch();
  }
 }
//iframe_set <iframe id="mainFramee2" src="" width="100%" height="20" name="mainFramee2" marginwidth="0" frameborder="0" height="50px" width="200px" onLoad="TuneHeight('mainFramee2')" scrolling="no" 

function TuneHeight(S) 
{ 
  try
  {
	var frm = document.getElementById(S); 
	var subWeb = document.frames ? document.frames[S].document : frm.contentDocument; 
	if(frm != null && subWeb != null) 
		{ 
			frm.height = subWeb.body.scrollHeight;
		} 
  }
  catch(e){}
} 