﻿// JScript 文件

//获取对象
function $(id)
{
    var obj;
    obj=(document.getElementById?document.getElementById(id):document.all?document.all[id]:document.layers[id]);
    return obj
}
//****************************************************************
//获取cookie
function getCookie(sName)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
	    // a name/value pair (a crumb) is separated by an equal sign
	    var aCrumb = aCookie[i].split("=");
	    if (sName == aCrumb[0])
	    {
	        return unescape(aCrumb[1]);
	    }
	}
	// a cookie with the requested name does not exist
	return "";
}
//****************************************************************
//设置cookie
function setCookies(name,value)
{
	var Then = new Date(); 
	Then.setTime(Then.getTime() + 60*1000*60*24*365 ); ///一年
	document.cookie = name+"="+value+";expires="+ Then.toGMTString();
}
//****************************************************************
//在载入时自动根据内页高度调整框架高度  
function dyniframesize(iframeId)
{
    var mainframe=(document.getElementById?document.getElementById(iframeId):document.all?document.all[iframeId]:document.layers[iframeId]);
    if (mainframe && !window.opera)
    { 
        //begin resizing iframe 
        mainframe.style.display="block" ;

        if (mainframe.contentDocument && mainframe.contentDocument.body.offsetHeight)
            { 
                //ns6 syntax 
                mainframe.height = mainframe.contentDocument.body.offsetHeight; 
            } 
        else if (mainframe.Document && mainframe.Document.body.scrollHeight)
            { 
                //ie5+ syntax 
                mainframe.height = mainframe.Document.body.scrollHeight; 
            } 
    }
}
//****************************************************************
//更改选中项样式
function changeStyle(category)
{
    var i=1;
    while($("C"+i))
    {
        if(i==category)
           $("C"+i).className="a_category2";
        else
            $("C"+i).className="a_category";
        i++;
    }
}
//****************************************************************
//更改分类
function changeCategory(id)
{
    //更改搜索引擎
    switch(id)
    {
        case "2"://网页
        case "12"://博客
            changeSearch("9");
            break;
        case "11"://软件
        case "7": //影视下载          
            changeSearch("4");                      
            break;
        case "6": 
            //在线视频 小类导航代码
            changeSearch("3");                      
            break;
        case "10"://地图
            changeSearch("2");                      
            break;            
        case "3"://新闻
        case "4"://图片
        case "5"://音乐
        case "9"://知识问答
        case "13"://词典
            changeSearch("1");
            break;
        case "0":
            changeSearch("0");
            break; 
        case "8"://购物       
        default:
            changeSearch("6");
            break;
    }
    if(id=="0")
        id=getCookie("Category");
    else
        setCookies("Category",id);
        
    changeStyle(id);//修改选中项样式
    
    //小类导航显示
    var showid=1;
    for(var i=13;i>1;i--)
    {
        if(id==i)
        {
            if($("TypeDiv"+i))
            {
                $("TypeDiv"+i).className="show";
                showid=id;
                //alert("TypeDiv"+i+"show");
            }
            else
            {
                if($("TypeDiv1").className!="show")
                {
                    $("TypeDiv1").className="show";
                    //alert("TypeDiv1 show");
                }
            }
        }
        else
        {
            if($("TypeDiv"+i))
            {
                if($("TypeDiv"+i).className=="show")
                {
                    $("TypeDiv"+i).className="hidden";
                    //alert("TypeDiv"+i+"hidden");
                }
            }
        }
    }
    if(showid==1)
    {
        if($("TypeDiv1").className!="show")
           $("TypeDiv1").className="show" 
    }
    else if($("TypeDiv1").className=="show")
    {
        $("TypeDiv1").className="hidden";
    }
}
//****************************************************************
//更改搜索引擎
function changeSearch(id)
{
    //获取cookie中的分类
    if(id=="0")
        id=getCookie("Type");
    
    var newFram;
    
    switch(id)
    {    
        case "1":
            //搜索引擎代码 百度
            newFram="<img src='http://www.baidu.com/img/baidu_logo.gif' width='270' height='129'>";
            newFram+="<iframe id='baiduframe' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='750' height='75' ";
            newFram+="  src='http://unstat.baidu.com/bdun.bsc?tn=daimin_pg&cv=0&cid=1166596&csid=282&bgcr=ffffff&ftcr=000000&urlcr=0000ff&tbsz=265&sropls=1,2,3,4,5,6,7,9,10,99&insiteurl=www.sousuoba.net%3Bwww.sousuoba.net.cn&defid=2&kwgp=0'>";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","1");
            break;
        case "2": 
            //搜索引擎代码  Google        
            newFram="<iframe id='Iframe1' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='750' height='280' ";
            newFram+="  src='/web/search/google.htm' onload=\"dyniframesize('Iframe1');\">";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","2");           
            break;
        case "3":
            //优酷
            newFram="<iframe id='Iframe1' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='750' height='200' ";
            newFram+="  src='/web/search/youku.htm' onload=\"dyniframesize('Iframe1');\">";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","3");
            break;
        case "4":
            //狗狗
            newFram="<iframe id='Iframe1' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='750' height='200' ";
            newFram+="  src='/web/search/gougou.htm' onload=\"dyniframesize('Iframe1');\">";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","4");
            break;
        case "5":
            //华军软件
            newFram="<iframe id='Iframe1' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='750' height='200' ";
            newFram+="  src='/web/search/huajun.htm' onload=\"dyniframesize('Iframe1');\">";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","5");
            break;
        case "7":
            //搜索引擎代码 搜狗
            newFram="<iframe id='Iframe1' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='700' height='220' ";
            newFram+="  src='/web/search/sogou.htm'>";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","7");
            break;
        case "8":
            //购物 百度有啊
            newFram="<iframe id='Iframe1' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='900' height='135' ";
            newFram+="  src='/web/search/youa.baidu.htm'>";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","8");
            break;
        case "9":
            //搜索 搜搜
            newFram="<iframe id='Iframe1' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='600' height='230' ";
            newFram+="  src='/web/search/soso.htm'>";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","9");
            break;
        case "10":
            //购物 拍拍
            newFram="<iframe id='Iframe1' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='900' height='130' ";
            newFram+="  src='/web/search/paipai.htm'>";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","10");
            break;
        default:
            //淘宝
            newFram="<iframe id='Iframe1' marginwidth='0' marginheight='0' scrolling='no'";
            newFram+="  framespacing='0' vspace='0' hspace='0' frameborder='0' width='960' height='200' ";
            newFram+="  src='/web/search/taobao.htm' onload=\"dyniframesize('Iframe1');\">";
            newFram+="</iframe>";
            $("mainDiv").innerHTML=newFram;
            //设置cookies
            setCookies("Type","6");
            break;
    }
}
//****************************************************************