﻿
function $(id) {
	return document.getElementById(id);	
}
function MM_jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
  setCookie("360WEBINDEXCK", selObj.options[selObj.selectedIndex].value);
}

function googleHint(key){
  if($('gsuggest'))$('gsuggest').parentNode.removeChild($('gsuggest'));
  var sg=document.body.appendChild(document.createElement('script'));
  sg.language='javascript';
  sg.id='gsuggest';
  sg.charset='gb2312';
  sg.src='http://www.google.com.hk/complete/search?hl=zh-CN&client=pub-0204114945524753&js=true&q=' + encodeURIComponent(key);
}

function myhint(event){
   var keyword=$('q');
   var h=$('suggests');
   if(!keyword.value || !keyword.value.length || event.keyCode==27 || event.keyCode==13){
       h.style.display='none';
       return;
   }
   if(event.keyCode==38 || event.keyCode==40){
     if(h.style.display=='none') return;
       if(event.keyCode==38){
         if(h._i==-1)h._i=h.firstChild.rows.length-1;
         else{h._i--;} 
      }else{h._i++;} 
    for(var i=0;i<h.firstChild.rows.length;i++)h.firstChild.rows[i].style.background="#FFF";
      if(h._i >= 0 && h._i < h.firstChild.rows.length)with(h.firstChild.rows[h._i]){
        style.background="#E6E6E6";
        keyword.value=cells[0].attributes['_h'].value;
      }else{
        keyword.value=h._kw;
        h._i=-1;
      } 
}else{
      h._i=-1;
      h._kw=keyword.value;
      googleHint(keyword.value);
      with(h.style){width=keyword.offsetWidth - 2;}
    } 
}

window.google={};
window.google.ac={};
window.google.ac.h=function(a){
 
    if(!a || a.length!=2 ) return;
    if(a[0] != $('q').value) return;
    var ihtml='';
 var c = a[1];
    for(var j = 0; j < c.length; j ++) {
        ihtml += '<tr style="cursor:hand" onmousedown="$(\'q\').value=\'' +c[j][0] +'\';javascript:searchSubmit(this);" onmouseover="javascript:this.style.background=\'#E6E6E6\'" onmouseout="javascript:this.style.background=\'#FFF\';"><td style="color:#000;font-size:12px;" align="left" _h="'+c[j][0] +'">' +c[j][0] +'</td><td style="color:#090" align="right" style="font-size:11.5px;">约' +c[j][1] +'</td></tr>';
    }
    $('suggests').innerHTML='<table width="100%" border="0" cellpadding="0" cellspacing="0">' + ihtml + '</table>';
    setDisplay('suggests', 1);
};

function searchSubmit(index){
     formInfo = index.parentNode.parentNode.parentNode.parentNode; 
     if(formInfo.tagName == "FORM") {
if($("backUrl")) {$("backUrl").value="http%3A//search.dangdang.com/search.aspx%3Fkey%3D"+$("q").value;}
formInfo.submit();
}
}
function getObj(id){return document.getElementById(id);}
function Menu(index){var num= getObj("conBox").getElementsByTagName("div");for(var i=1;i<=num.length;i++){if(getObj("con"+i)&&getObj("m"+i)){getObj("con"+i).style.display = "none";getObj("m"+i).className = "";}}if(getObj("con"+index)&&getObj("m"+index)){if(index==2&&getObj("ifrm"+index)){getObj("ifrm2").src='http://finance.sina.com.cn/promotion/20081119/001.shtml';}if(index==3&&getObj("ifrm"+index)){getObj("ifrm3").src='http://d.hao.360.cn/city/province_index.html';}if(index==4&&getObj("ifrm"+index)){getObj("ifrm4").src='http://d.hao.360.cn/listMyBookMark.php';}if(index==5&&getObj("ifrm"+index)){getObj("ifrm5").src='http://hao.360.cn/unclosedlist2.html';}getObj("con"+index).style.display ="block";getObj("m"+index).className = "at";}}
function getCookie(name){var arr; var reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");if(arr=document.cookie.match(reg)){return unescape(arr[2]);}else{return null;}}
function setCookie(name,value){var expire = arguments[2] ? arguments[2] : 365*24*60*60*1000;var exp = new Date();exp.setTime(exp.getTime() + expire);document.cookie = name + "="+ escape (value) + ";path=/;expires=" + exp.toGMTString();}
function setDisplay(i, d){getObj(i).style.display= d ? "block" : "none";}
/** search tab start **/
function getSearchTabCookieName(){return 'schtab';}
function setSearchTab(value){expire = 1000*3600*24*30;setCookie(getSearchTabCookieName(), value, expire);}
function getSearchTabByIndex(){var index = arguments[0] ? arguments[0] : 0;var schtab = getCookie(getSearchTabCookieName());if( ( schtab==null || schtab=='' ) ){if(arguments[1]){return arguments[1];}else{return 0;}}schtabs = schtab.split(',');return schtabs[index];}
/** search tab end **/
var indexUrl = getCookie("360WEBINDEXCK");
if(indexUrl != null){if(indexUrl != window.location  && indexUrl.match(/^http:\/\/hao\.360\.cn\//i)){window.location.href = indexUrl;}}
function getPWCookieName() { return "360WEBPW";}
if(getCookie(getPWCookieName()) == 1){getObj("widthS").href="css/ws_y.css";}
function getRight(){if(getCookie(getPWCookieName()) == 1){getObj("setPageMenu").style.marginRight = screen.availWidth > 1020&&screen.availWidth < 1124? "136px" : "";getObj("set").style.right = screen.availWidth > 1020&&screen.availWidth < 1124? "136px" : "";}}

window.onload=function(){
getRight();
}
/** search tab start **/

function highlightSearchTab()
{
    displayTab(1, 0);
}

/** search tab end **/

var j
function init(){
		var liS=$("selectId").getElementsByTagName("input");
		j=liS.length;
		for(var i=0;i<j;i++){
			liS[i].lisNum = i;
			liS[i].onclick=function(){displayTab(this.lisNum,0);}
		}
}

var searchs = [];
searchs[0] = [];
searchs[0][0] = new Array("网页","http://www.baidu.com/s", "wd","百度",-1,"http://www.baidu.com/?tn=luowo_pg","tn:luowo_pg;ie:gb2312");
searchs[0][1] = new Array("新闻","http://news.baidu.com/ns", "word","百度",-1,"http://news.baidu.com/");
searchs[0][2] = new Array("贴吧","http://tieba.baidu.com/f", "kw","百度",-1,"http://tieba.baidu.com/?tn=luowo_pg", "tn:luowo_pg;ie:gb2312");
searchs[0][3] = new Array("知道","http://zhidao.baidu.com/q", "word","百度", -1,"http://zhidao.baidu.com/q?tn=ikaslist","ct:17;pt:360se_ik;tn:ikaslist");
searchs[0][4] = new Array("MP3","http://mp3.baidu.com/m", "word","百度",-1,"http://mp3.baidu.com/?tn=luowo_pg","f:ms;ct:134217728;tn:luowo_pg;ie:gb2312");
searchs[0][5] = new Array("图片","http://image.baidu.com/i", "word","百度",-1,"http://image.baidu.com/?tn=luowo_pg","cl:2;lm:-1;ct:201326592;tn:luowo_pg;ie:gb2312");
searchs[0][6] = new Array("视频","http://video.baidu.com/v", "word","百度",-1,"http://video.baidu.com/?tn=luowo_pg","tn:luowo_pg;ie:gb2312");
searchs[1] = [];
searchs[1][0] = new Array("网页","http://www.google.com.hk/search", "q","谷歌", -29, "http://www.google.com.hk/webhp?client=pub-0204114945524753", "client:pub-0204114945524753;channel:9071392184;h1:zh-CN;prog:aff;source:sdo_sb;sdo_rt:ChBLFbMiAAdswgpvSgtlHxEVEg5fX1JMX0RFRkFVTFRfXxoIG4_JNxjkKCsoAVisw6n-lPGm63A");
searchs[1][1] = new Array("图片","http://images.google.com.hk/images", "q","谷歌", -29,"http://images.google.com.hk/imghp?client=pub-0204114945524753", "client:pub-0204114945524753;channel:9071392184;h1:zh-CN;prog:aff;source:sdo_sb;sdo_rt:ChBLFbMiAAdswgpvSgtlHxEVEg5fX1JMX0RFRkFVTFRfXxoIG4_JNxjkKCsoAVisw6n-lPGm63A");
searchs[1][2] = new Array("视频","http://video.google.cn/videosearch", "q","谷歌", -29,"http://video.google.cn/?client=pub-0204114945524753", "client:pub-0204114945524753;channel:9071392184;h1:zh-CN;prog:aff;source:sdo_sb;sdo_rt:ChBLFbMiAAdswgpvSgtlHxEVEg5fX1JMX0RFRkFVTFRfXxoIG4_JNxjkKCsoAVisw6n-lPGm63A");
searchs[1][3] = new Array("地图","http://ditu.google.cn/maps", "q","谷歌", -29,"http://ditu.google.cn/?client=pub-0204114945524753", "client:pub-0204114945524753;channel:9071392184;h1:zh-CN;prog:aff;source:sdo_sb;sdo_rt:ChBLFbMiAAdswgpvSgtlHxEVEg5fX1JMX0RFRkFVTFRfXxoIG4_JNxjkKCsoAVisw6n-lPGm63A");
searchs[1][4] = new Array("资讯","http://news.google.com.hk/news/search", "q","谷歌", -29,"http://news.google.com.hk/?client=pub-0204114945524753", "client:pub-0204114945524753;hl:zh-CN;ie:gb2312;channel:9071392184");
searchs[1][5] =  new Array("音乐","http://www.google.cn/music/search", "q","谷歌", -29,"http://www.google.cn/music/?client=pub-0204114945524753", "client:pub-0204114945524753;hl:zh-CN;ie:gb2312;oe:gb2312")



function  displayTab(sNum, tNum){
	$("hidpar").innerHTML = '';
	$("searchForm").action = searchs[sNum][tNum][1];
	$("q").name = searchs[sNum][tNum][2];
           $("searchBtn").value = searchs[sNum][tNum][3]+"搜索";
	if($("seBox").style.backgroundPositionY) 
		$("seBox").style.backgroundPositionY = searchs[sNum][tNum][4]+"px";
	else {$("seBox").style.backgroundPosition = "0 "+searchs[sNum][tNum][4]+"px";}
	tabLen = searchs[sNum].length;tabStr = '';
	var selectWeb = document.getElementsByName("searchRadio");
	for(var i=0; i<selectWeb.length; i++)
	{
		if(i == sNum) selectWeb[i].checked=true;
		else selectWeb[i].checked=false;
	}
	for(var i=0; i< tabLen; i++)
	{
		if(i == tNum){tabStr = tabStr + "<b  class='bStyle'>"+searchs[sNum][i][0]+"</b>";}
		else{tabStr = tabStr + "<b onclick='displayTab("+sNum+","+i+")'>"+searchs[sNum][i][0]+"</b>";}
		if(i < tabLen-1) tabStr = tabStr + "|";
	}
	$("searchTab").innerHTML = tabStr;
	$("setUrl").href = searchs[sNum][tNum][5];
	if(searchs[sNum][tNum][6] != null)
	{
		paramArrs = searchs[sNum][tNum][6].split(";");
		for(var i=0; i< paramArrs.length; i++)
		{
			pvalue = paramArrs[i].split(":");
			pel = document.createElement("INPUT");
			pel.type = "hidden";
			pel.name = pvalue[0];
			pel.id = pvalue[0];
			pel.value = pvalue[1];
			$("hidpar").appendChild(pel);
		}
	}
           if(sNum > 1){sNum = 1;tNum = 0;}
           setSearchTab(sNum+','+tNum);
}	

//var _s=window.hao360cn;

function setPage(){
		if($("set").style.display=="none"){
			$("set").style.display="";
			}else{
				$("set").style.display="none";
				}
		}

function col(){
	$("setBt").className="setBtn";
	$("set").style.display="none";
}