function openwin(xurl) {window.open(xurl,'xh','left='+(screen.width-560)/2+',height=420,width=560,status=no,toolbar=no,menubar=no,resizable=yes')}
var tmt='',tm2t='',nnx=''
function sm(){a='tm';nnx=a;st=eval(nnx+"t");o=$(a);o.style.display="block";document.onmousemove=cp
add=(GetCookie('skinp')==2)?269:194
os('tm').left=(getPos($('n3'))).x+add+'px'
}
function cp(event)
{evt=window.event?window.event:event;var pointer=function(event){return{x:event.pageX||(event.clientX+
(document.documentElement.scrollLeft||document.body.scrollLeft)),y:event.pageY||(event.clientY+
(document.documentElement.scrollTop||document.body.scrollTop))}}(evt);l=o.offsetLeft-30;t=o.offsetTop-30;r=l+o.offsetWidth+40;b=o.offsetTop+o.offsetHeight+30;py=pointer.y;px=pointer.x;if((py>t&&py<b)&&(px>l&&px<r)){}
else{st=eval(nnx+"t");st=setTimeout(function(){o.style.display="none"},100);document.onmousemove=function(){}}}

//pageset
var ifload=0,comnum=0,mailifload=0;
function setPage(){
comnum=0
var a='gxsz',b='none'
if( os('set').display=='none' ) a='gxsz_hot',b=''
$('settd').className=a
os('set').display=b
if(!ifload){$('ifset').src='set.htm?'+cssver;ifload=1}
pagepos()
}
function pagepos()
{
pos=getPos($('settd'));
//alert(pos.x);
var offset=216;
if(browser.msie && browser.version=='7.0')var offset=217;
$('set').style.left=(pos.x-offset)+'px'
if($('skin').readyState !='complete' && comnum<5) setTimeout("pagepos()",100)
comnum++
}
//load page
function mailpagepos()
{
pos=getPos($('mailhead'));
var offset=0;
if(browser.msie && browser.version=='7.0')var offset=1;
var ms = $('mailBody').style;
ms.left=(pos.x-offset)+'px';
ms.top=(pos.y+25)+'px';
if($('skin').readyState !='complete' && mailcomnum<5) setTimeout("mailpagepos()",200)
mailcomnum++
}

link_color()	//字体色
function link_color()
{
var color = GetCookie('lcolor')
if(color && color.substr(0,1)=='#' && color!='#000000'){
var a=['A','FONT','LI']
for(b in a){
var tclass = document.getElementsByTagName(a[b]);
for (var i = 0; i < tclass.length; i++) { if(tclass[i].className=='') tclass[i].style.color=color}
}}}
//皮肤
function skin(a)
{
vp=GetCookie('skinp')
s=vp==2?'big_':''
$('skin').href='css/'+s+'css'+a+'.css?'+cssver
SetCookie('skinc',a,94608000,'/',top_domain())
if(ifload) frame('ifset').$('skin').href='css/set'+a+'.css?'+cssver
}

//导航
var cch=function(i){return function(){cc(i)}}

for(i=1;i<9;i++)regE($('tr'+i),'onclick',cch(i))
var curCc=1
var cclist=['','','sycx.html','music/','http://www.ttcj.cc/i/go2000.php','star/astro.asp','note/','user/my.asp','lsjl.html']
function cc(a)
{
if(a==curCc) return
if(a==1){
	os('nav1').display=''
	os('nav2').display='none'
	os('lxgq').display='none'
}
else{
if( a==3 ){
	os('lxgq').display=''
	os('nav1').display='none'
	os('nav2').display='none'
	if($('lxgq').src!=cclist[a])$('lxgq').src=cclist[a]
}
else{
	os('nav1').display='none'
	os('nav2').display=''
	os('lxgq').display='none'
	$('nav2').src=cclist[a]
}
}
$('tr'+a).className='nav_css1'
$('tr'+curCc).className='nav_css2'
curCc=a
}
document.onclick = function(e){
os('suggest').display='none'
try{
if(!mailshowed){os('mailBody').display='none';}
}
catch(e){}
mailshowed = false;
e = window.event || e
sE = e.srcElement || e.target
if( sE.tagName !='P' )os('wth_f').display='none'
if( sE.tagName != "IMG"){os('set').display='none';$('settd').className='szym_bg'}
if( sE.tagName == "A" && sE.className!='ssbutton' )	his(sE.innerHTML,sE.href)
}


//搜索提示
//var isIE=document.all?true:false;
function googleHint(key)
{
	if (document.readyState=="complete"){
		if($('gsuggest'))
			var sg=$('gsuggest');		
			//$('gsuggest').removeNode(true);
		else
			var sg=document.body.appendChild(document.createElement('script'));
		sg.language='javascript';
		sg.id='gsuggest';
		if(currTab=='buy'){
			sg.charset='utf-8';
			sg.src='http://suggest.taobao.com/sug?code=utf-8&callback=TB.Suggest.callback&q='+encodeURIComponent(key)+'&t='+Math.random();
		}
		else{
			sg.charset='gb2312';
			sg.src='http://suggestion.baidu.com/su?wd='+encodeURIComponent(key)+'&p=3&t='+Math.random();
		}
	}
}
var searchurl = ssa['web']['link'];
showobj = $('q');
function bdhint(event){myhint(event,$('q1'));searchurl=ssa[currTab]['link']}
regE($('q1'),'onkeyup',bdhint)
function UrlEncode(str){
var ret="";
var strSpecial="!\"#$%&'()*+,/:;<=>?[]^`{|}~%";
for(var i=0;i<str.length;i++){
var chr = str.charAt(i);
//var c=str2asc(chr);
var c=chr;
if(parseInt("0x"+c) > 0x7f){
    ret+="%"+c.slice(0,2)+"%"+c.slice(-2);
}else{if(chr==" "){
    ret+="+";
}else if(strSpecial.indexOf(chr)!=-1){
    ret+="%"+c.toString(16);
}else{ret+=chr;
}}}return ret;
}

var sg_tb = $('suggest');
function sg_trover(ob,iv)
{
	var h = sg_tb;
	if(h._oldhi!='')h.firstChild.rows[h._oldhi].className = "trout";
	ob.className='trover';
	sg_tb._i=iv;
	h._oldhi=iv;
}
function myhint(event,obj)
{
showobj=obj;
//if(!isIE)  return;
var keyword=showobj;
var h=$('suggest');
h._oldhi='';
if(!keyword.value || !keyword.value.length || event.keyCode==27 || event.keyCode==13){h.style.display='none';return}
if(event.keyCode==38 || event.keyCode==40){
h._maxi=h.firstChild.rows.length-1;
if(h.style.display=='none') return;
if(event.keyCode==38){
  if(h._i==-1)
	{
	  h._i=h._maxi;
	}
  else{
	  h._i--;
  } 
}
else{
	h._i++;
}
if(h._oldhi!='')h.firstChild.rows[h._oldhi].className = "trout";
h._oldhi=h._i;
if(h._i==-1 || h._i>h._maxi)h._oldhi='';
for(var i=0;i<h.firstChild.rows.length;i++)h.firstChild.rows[i].className="trout";
if(h._i >= 0 && h._i < h.firstChild.rows.length)with(h.firstChild.rows[h._i]){
  className="trover";
  tmp=cells[0].innerHTML.split("blank>");
	keyword.value=tmp[1].replace("</A>",'');
}else{
  keyword.value=h._kw;
  h._i=-1;
} 
 }else{
h._i=-1;
h._kw=keyword.value;
googleHint(keyword.value);
var pos=getPos(keyword);
h.style.left=pos.x;
h.style.top=pos.y-1+keyword.offsetHeight;
h.style.width=keyword.offsetWidth - 1;
}}

//百度预搜索
window.baidu={};
window.baidu.sug=function(dd)
{
b=dd['q'];
c=dd['s'];
if(!c || c.length<3) return;
//if(b != showobj.value) return;
var ihtml='';
if (document.readyState=="complete"){
var currline = 0;
for(var j=0;j<c.length;j+=1){
var acWord = c[j];
url=searchurl+UrlEncode(acWord);
ihtml+='<tr onmouseover="sg_trover(this,'+currline+');" onmouseout="this.className=\'trout\';">';
ihtml+='<td>';
if(currTab=='mp3')url = url.replace( "gb2312" , "");
ihtml+='<a href="'+url+'" target="_blank" onclick="$(\'suggest\').style.display=\'none\';">' +acWord +'</a>';
ihtml+='</td></tr>';
currline++;
}
$('suggest').innerHTML='<table width="100%" class="suggestTable">'+ihtml+'</table>';
$('suggest').style.display="block";
}else{
//setTimeout("myhint(event)", 2000);
}
}

//taobao
TB={};
TB.Suggest={};
TB.Suggest.callback=function(dd){
	c=dd['result'];
	if(!c || c.length<3) return;
	var ihtml='';
	if (document.readyState=="complete"){
	var currline = 0;
	for(var j=0;j<c.length;j+=1){
	var acWord = c[j][0];
	url=searchurl+UrlEncode(acWord);
	ihtml+='<tr onmouseover="sg_trover(this,'+currline+');" onmouseout="this.className=\'trout\';">';
	ihtml+='<td>';
	if(currTab=='mp3')url = url.replace( "gb2312" , "");
	ihtml+='<a href="'+url+'" target="_blank" onclick="$(\'suggest\').style.display=\'none\';">' +acWord +'</a>';
	ihtml+='</td></tr>';
	currline++;
	}
	$('suggest').innerHTML='<table width="100%" class="suggestTable">'+ihtml+'</table>';
	$('suggest').style.display="block";
	}else{
	//setTimeout("myhint(event)", 2000);
	}
}

//天气
var cityid=GetCookie('cityid');
if(isNaN(cityid) || cityid==null || (new String(cityid)).length<5 )
loadJS('http://www.btcha.com/tianqi/getcity.php');
else
wtsrc(cityid)

function loadJS(file){
var html_doc = document.getElementsByTagName('head')[0]
js = document.createElement('script')
js.setAttribute('type', 'text/javascript')
js.setAttribute('src', file)
html_doc.appendChild(js)
js.onreadystatechange = function () {if(js.readyState == 'complete' || js.readyState =="loaded"){goif()}}
js.onload = function (){goif()}
return false
}

function goif(){
if(cityid!=null && (new String(cityid)).length==5){
SetCookie('cityid',cityid,5184000,'/',top_domain());wtsrc(cityid)}
else wtsrc(13000)
}
function wtsrc(id){
	//id="26018";
	$('wtd').innerHTML='<iframe id="wt" src="/weather/code/id.htm?type=1&id=&fcolor=ffffff&imgurl=images/ico/i1" width="100%" marginwidth="0" height="100%" marginheight="0" scrolling="no" allowtransparency="true" frameborder="0"></iframe>';
}


//laugh
function ajaxxh()
{
	myurl = '/xhjs/'+(parseInt(Math.random()*(71-1))+1)+'.js';
	var oldS=document.getElementById('joke_js');
	if(oldS) oldS.parentNode.removeChild(oldS);
	var t=document.createElement('script');
	t.src= myurl ;
	t.type='text/javascript';
	t.id="joke_js";
	document.getElementsByTagName('head')[0].appendChild(t);
}

document.onclick = function(e){
os('suggest').display='none'
try{
if(!mailshowed){os('mailBody').display='none';}
}
catch(e){}
mailshowed = false;
e = window.event || e
sE = e.srcElement || e.target
if( sE.tagName !='P' )os('wth_f').display='none'
if( sE.id != "seta"){os('set').display='none';$('settd').className='gxsz'}
if( sE.tagName == "A" && sE.className!='ssbutton' )	his(sE.innerHTML,sE.href)
}

window.onload=function()
{
if(!isIE)document.readyState="complete";
ajaxxh() ;
loadUserMail();
$('q1').focus();
}

