﻿var hideSetting = false;
if (OK92.Cookie.get("clear") == null) {
    clear();
    OK92.Cookie.set("clear", 1)
}
function clear() {
    OK92.Cookie.clear("layout");
    OK92.Cookie.clear("style");
    OK92.Cookie.clear("font");
    OK92.Cookie.clear("bg")
}
$(window).on("load",
function() {
    skinSelecter("layout-setting");
    skinSelecter("style-setting");
    skinSelecter("style-quick");
    skinSelecter("font-setting");
    skinSelecter("bg-setting");
    tabMenu("search-menu-show", "search-box",
    function(f) {
        if (f.id) {
            $("search-more").hide();
            var e = Number(f.id.replace("search-box", ""));
            var d = f.getElementsByTagName("input")[0];
            d.style.background = "#FFFCEC";
            d.focus();
			if (f.id == "search-box0") {
					var searchurl='http://www.google.cn/search?hl=zh-CN&client=pub-6990924492750088&q=';
					window.searchurl=searchurl;
				}
			if (f.id == "search-box1") {
					var searchurl='http://www.baidu.com/s?tn=ok92com_pg&ie=utf-8&wd=';
					window.searchurl=searchurl;
				}
			if (f.id == "search-box2") {
					var searchurl='http://one.cn.yahoo.com/s?pid=hp&v=web&p=';
					window.searchurl=searchurl;
				}
			if (f.id == "search-box3") {
					var searchurl='http://www.sogou.com/sogou?ie=utf8&query=';
					window.searchurl=searchurl;
				}
			if (f.id == "search-box4") {
					var searchurl='http://cn.bing.com/search?q=';
					window.searchurl=searchurl;
				}
			if (f.id == "search-box5") {
					var searchurl='http://movie.gougou.com/search?search=';
					window.searchurl=searchurl;
				}
				
            if (f.id == "search-box6") {
                $("localsearch").show()
            } else {
                $("localsearch").hide()
            }
        }
    });
    tabMenu("board-menu", "board-box",
    function(e) {
	    if (e.id == "board-box1" && e.innerHTML == "") {
            e.innerHTML = '<iframe src="/apps/4.html" width="100%" height="310" frameborder="0"></iframe>';
            board1 = true
        }
        if (e.id == "board-box2" && e.innerHTML == "") {
            e.innerHTML = '<iframe src="/apps/stock.html" width="100%" height="310" frameborder="0"></iframe>';
            board2 = true
        }
        if (e.id == "board-box3" && e.innerHTML == "") {
            e.innerHTML = '<iframe src="http://music.ok92.com/ok92.php?id=1" width="588" height="310" frameborder="0"></iframe>';
            board3 = true
        }
    });
    $(document.body).on("click",
    function(g) {
        var f = g.srcElement || g.target;
        var k = f.id;
        History.save(f);
        if (k == "delHistory") {
            History.clear()
        }
        if (k !== "smore") {
            $("search-more").hide()
        }
        if (k == "setting" || k == "setting2") {
            $("weather-box").hide();
            $("setting-box").toggle()
        } else {
            if (hideSetting == true || k == "setting-close") {
                $("setting-box").hide()
            }
        }
        if (k == "setting-reset") {
            setStyle(0);
            OK92.Cookie.clear("layout");
            OK92.Cookie.clear("style");
            OK92.Cookie.clear("font");
            OK92.Cookie.clear("bg");
            window.location.reload()
        }

        if (k == "weather-close") {
            $("weather-box").hide()
        }
 

        if (k == "cslayout") {
            if (f.className == "") {
                f.className = "alignleft";
                OK92.Cookie.clear("cs");
                document.getElementById("list").className = "left"
            } else {
                f.className = "";
                OK92.Cookie.set("cs", 1);
                document.getElementById("list").className = ""
            }
        }
        $("suggest").hide();
        if (k == "setHomepage") {
            OK92.setHomepage(f)
        }
    });
    $("setting-box").on("mouseover",
    function() {
        hideSetting = false
    });
    $("setting-box").on("mouseout",
    function() {
        hideSetting = true
    });
    Hover(Dom.get("setting"),
    function() {
        $("setting-box").show()
    });
    History.show();
    showColl();
    if (OK92.Browser.ie6) {
        document.execCommand("BackgroundImageCache", false, true);
        var b = Dom.get("coolsites").getElementsByTagName("dl");
        for (var c = 0,
        a = b.length; c < a; ++c) {
            b[c].onmouseover = function() {
                this.tmpClass = this.className;
                this.className = "iehover"
            };
            b[c].onmouseout = function() {
                this.className = this.tmpClass
            }
        }
    }
    if (OK92.Cookie.get("layout") == "2" && OK92.screenWidth >= 1280) {
        Dom.get("b1").innerHTML += '<span style="margin-left:10px;"><iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="234" height="60" src="http://spcode.baidu.com/spcode/spstyle/style3969.jsp?tn=ok92com_sp&ctn=0&styleid=3969"></iframe></span>'
    }
	if (OK92.Cookie.get("layout") == "1" && OK92.screenWidth >= 1024) {
		Dom.get("b1").innerHTML = ''
        Dom.get("bli2").innerHTML = '<iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="120" height="60" src="http://spcode.baidu.com/spcode/spstyle/style3925.jsp?tn=ok92com_sp&ctn=0&styleid=3925"></iframe><span style="margin-left:10px;"><iframe id="baiduSpFrame" border="0" vspace="0" hspace="0" marginwidth="0" marginheight="0" framespacing="0" frameborder="0" scrolling="no" width="160" height="60" src="http://spcode.baidu.com/spcode/spstyle/style2887.jsp?tn=ok92com_sp&ctn=0&styleid=2887"></iframe></span>'
    }
});
var getBgimgstyle = false;
function skinSelecter(d) {
    var e = Dom.get(d).getElementsByTagName("a");
    var c = d.split("-")[0];
    for (var b = 0,
    a = e.length; b < a; ++b) {
        $(e[b]).on("click",
        function(j) {
            var g = j.srcElement || j.target;
            var f = g.getAttribute("rel");
            switch (c) {
            case "layout":
                OK92.Cookie.set("layout", f);
                window.location.reload();
                break;
            case "style":
                setStyle(f);
                break;
            case "font":
                setFont(f);
                break;
            case "bg":
                setBg(f);
                iscurBg(g);
                break
            }
        })
    }
}
function setStyle(d) {
    var a = ["", "g2/g2.css", "orange/orange.css", "purple/purple.css", "blue/blue.css", "pink/pink.css", "green/green.css"];
    var d = Number(d);
    var b = Dom.get("skin");
    var c = "/static/skins/";
    if (a[d] !== "") {
        c += a[d];
        OK92.Ajax(c,
        function() {
            b.href = c;
            switch (d) {
            case 1 : setFont("green"); break;
            case 2 : setFont("pink"); break;
			case 3 : setFont("purple"); break;
			case 4 : setFont("navy"); break;
			case 5 : setFont("pink"); break;
			case 6 : setFont("green"); break;
            default:setFont("black");
            }
        })
    } else {
        b.href = "";
        setFont("blue")
    }
    OK92.Cookie.set("style", d)
}
function setLayout(b) {
    var a = ["default", "layout-medium", "layout-full", "layout-800"];
    setStylesheet(a[b]);
    OK92.Cookie.set("layout", b)
}
function setFont(b) {
    var a = Dom.get("font");
    var c = "/static/css/font/";
    c += b;
    c += ".css";
    a.href = c;
    OK92.Cookie.set("font", b)
}
function setBg(a) {
    var d = document.getElementsByTagName("style")[0];
    var c = "";
    var b = a.split(".")[0];
    if (a !== "default") {
        c += ".wrap { background:none;}";
        c += "body { background:url(/static/images/bg/" + a + ");}";
        c += "#bg-setting a.img" + b + "{border:1px solid red;border-bottom-width:2px;}"
    } else {
        c += "#bg-setting a.default{border:1px solid red;border-bottom-width:2px;}"
    }
    if (d.styleSheet) {
        d.styleSheet.cssText = c
    } else {
        d.innerHTML = c
    }
	
    OK92.Cookie.set("bg", a)
}
function getBgimg(b, a) {
    if (a == OK92.Cookie.get("bg")) {
        b.style.border = "1px solid red";
        b.style.borderBottomWidth = "2px"
    } else {
        b.style.border = "1px solid #cccccc";
        b.style.borderBottomWidth = "2px"
    }
}
function iscurBg(d) {
    var c = document.getElementById("bg-setting").getElementsByTagName("a");
    for (var b = 0,
    a = c.length; b < a; ++b) {
        c[b].style.border = "1px solid #cccccc";
        c[b].style.borderBottomWidth = "2px"
    }
    d.style.border = "1px solid red";
    d.style.borderBottomWidth = "2px"
}
function Hover(c, b) {
    var a = 400;
    var d;
    $(c).on("mouseover",
    function() {
        d = window.setTimeout(b, a)
    });
    $(c).on("mouseout",
    function() {
        if (d != undefined) {
            window.clearTimeout(d)
        }
    })
}
function tabMenu(a, g, k) {
    var e = document.getElementById(a).getElementsByTagName("a");
    var l = document.getElementById(a).getElementsByTagName("li");
    var b = 400;
    var c, j;
    if (a !== "search-menu-show") {
        j = "click,mouseover"
    } else {
        j = "click"
    }
    for (var d = 0,
    f = e.length; d < f; d++) {
        $(e[d]).on(j,
        function(o) {
            var n = o.srcElement || o.target;
            function m() {
                var q = n.getAttribute("rel");
                var r = document.getElementById(q);
                var s = function() {
                    for (var u = 0,
                    t = l.length; u < t; u++) {
                        if (l[u].className) {
                            l[u].className = ""
                        }
                    }
                };
                s();
                n.parentNode.className = "current";
                if (q == "more") {
                    $("search-more").show();
                    return
                }
                for (var p = 0; contentBox = document.getElementById(g + p); p++) {
                    $(contentBox).hide()
                }
                $(r).show();
                return k(r)
            }
            if (a !== "search-menu-show") {
                c = window.setTimeout(m, b)
            } else {
                m()
            }
        });
        if (a !== "search-menu-show") {
            $(e[d]).on("mouseout",
            function(m) {
                if (c != undefined) {
                    window.clearTimeout(c)
                }
            })
        }
    }
}
function setStylesheet(d) {
    var a, b, c = [""];
    for (a = 0; (b = document.getElementsByTagName("link")[a]); a++) {
        if (b.getAttribute("rel").toLowerCase() == "alternate stylesheet" && b.getAttribute("title")) {
            b.disabled = true;
            c.push(b);
            if (b.getAttribute("title") == d) {
                b.disabled = false
            }
        }
    }
}
var History = {
    save: function(d) {
        try {
            if (d.tagName == "A" && d.href.indexOf("http://") == 0 && d.href.indexOf("http://" + location.host) != 0 && d.getAttribute("rel") !== "sugitem") {
                var b = d.href;
                var a = d.innerHTML;
                if (a != "undefined") {
                    h = a + "+" + b + "_114la_";
                    h += unescape(OK92.Cookie.get("history"));
                    h = escape(h);
                    OK92.Cookie.set("history", h);
                    History.show()
                }
            }
        } catch(c) {}
        return true
    },
    show: function() {
        try {
            var d = OK92.Cookie.get("history");
            d = unescape(d);
            var b = "";
            if (d != "null") {
                history_arg = d.split("_114la_");
                i = 0;
                linknum = 0;
                len = history_arg.length;
                for (i = 0; i < len; i++) {
                    var a = history_arg[i].split("+");
                    if (history_arg[i] != "null" && b.indexOf(a[0]) == -1 && linknum < 44) {
                        b += '<li><a href="' + a[1] + '" title="' + a[0] + '">' + a[0] + "</a></li>";
                        linknum += 1
                    }
                }
                Dom.get("history").innerHTML = b
            } else {
                Dom.get("history").innerHTML = '<li class="none">对不起，您没有任何浏览记录！</li>'
            }
        } catch(c) {}
    },
    clear: function() {
        clean = confirm("确定要清除所有的浏览记录？");
        if (clean) {
            OK92.Cookie.clear("history");
            Dom.get("history").innerHTML = '<li class="none">对不起，您没有任何浏览记录！</li>'
        }
    }
};
function searchlog(a) {}
function logad() {}
function favoFuninput(a, b) {
    if (b == 1) {
        a.className = "int n";
        if (a.value == "站名" || a.value == "网址") {
            if (a.value == "网址") {
                a.value = "http://"
            } else {
                a.value = ""
            }
        }
    } else {
        if (!a.value || a.value == "http://") {
            a.className = "int u";
            if (a.name == "urlName") {
                a.value = "站名"
            }
            if (a.name == "Url") {
                a.value = "网址"
            }
        }
    }
}
function addColl(a) {
    favoname = a.urlName;
    favourl = a.Url;
    err = 0;
    if (favoname.value == "" || favoname.value == "站名") {
        favoname.className = "int e";
        favoname.value = "站名";
        err = 1
    }
    if (favourl.value == "" || favourl.value == "http://" || favourl.value == "网址") {
        favourl.className = "int e";
        favourl.value = "网址";
        return false;
        err = 1
    }
    if (favourl.value.indexOf("http://") !== 0 && favourl.value.indexOf("https://") !== 0) {
        alert('网址格式不正确！必须以 "http://" 或 "https://"开头！');
        err = 1
    }
    if (err == 1) {
        return false
    }
    saveColl(favoname.value, favourl.value);
    Dom.get("addColl").style.display = "none";
    Dom.get("addCollmsg").style.display = "block";
    Dom.get("addCollmsg").innerHTML = "成功添加 [<a onclick=\"Dom.get('addColl').style.display='block';Dom.get('addCollmsg').style.display = 'none';\">返回继续添加</a>]";
    a.reset();
    return false
}
function delColl(f) {
    var e = f.getElementsByTagName("a")[0];
    var c = e.innerHTML;
    var b = e.href;
    b = b.replace(/^(.*?)(\/)?$/, "$1");
    var d = c + "+" + b + "■";
    var a = OK92.Cookie.get("cl");
    a = unescape(a);
    newColl = a.replace(d, "");
    if (newColl == "") {
        OK92.Cookie.clear("cl")
    } else {
        OK92.Cookie.set("cl", newColl)
    }
    showColl()
}
function saveColl(b, a) {
    a = a.replace(/^(.*?)(\/)?$/, "$1");
    var c = b + "+" + a + "■";
    if (c) {
        if (OK92.Cookie.get("cl") !== null && unescape(OK92.Cookie.get("cl")).indexOf(c) !== 0) {
            c += unescape(OK92.Cookie.get("cl"))
        }
        c = escape(c);
        OK92.Cookie.set("cl", c);
        showColl()
    }
}
function showColl() {
    try {
        var f = OK92.Cookie.get("cl");
        f = unescape(f);
        var c = "";
        var a = '<img src="/static/images/del.gif" title="删除此网址" onclick="delColl(this.parentNode)" align="absmiddle" />';
        if (f !== "null") {
            customsite_arg = f.split("■");
            i = 0;
            linknum = 0;
            len = customsite_arg.length;
            for (i = 0; i < len; i++) {
                var b = customsite_arg[len - i - 1].split("+");
                if (f[i] !== "null" && c.indexOf(b[0]) == -1 && linknum < 35) {
                    c += "<li>" + ' <a href="' + b[1] + '" title="' + b[0] + '">' + b[0] + "</a> " + a + "</li>";
                    linknum += 1
                }
            }
            Dom.get("Collbox").innerHTML = c
        } else {
            Dom.get("Collbox").innerHTML = '<li class="none"></li><li class="none">未启用一、您还没有任何已添加的（缓存）网址收藏。</li><li class="none">您可以在下面输入框增加（缓存）网址收藏。如果电脑清空Cookie，收藏消失！</li><li class="none"></li>'
        }
    } catch(d) {}
};


function gositesearch() {
    var b = siteKey.value;
    var a = document.getElementById("indexhtml");
    oldkeyword = b;
    OK92time = new Date().getTime();
    url = "/apps/insidesearch.php?keyword=" + encodeURIComponent(b) + "&t=" + OK92time+'&wz='+document.getElementById("wz").value;
    a.className = "result";
    a.innerHTML = '<li class="loadding"><img src="/static/images/loadding.gif" alt="loadding..." align="absmiddle" /> 正在搜索中,请稍后...</li>';
    OK92.Ajax(url,
    function(d) {
        var c = d.responseText;
        if (c == "") {
            a.innerHTML = "<li>没有搜索到相关站点!</li>"
        } else {
            if (c) {
                a.innerHTML = c
            }
        }
    })
};

function emshow(obj){
  obj.style.height="auto";
  obj.onmouseout=function(){
    this.style.height="20px";
  }
}
//新加代码
var isIndex = true;
function killErrors() { return true; } window.onerror = killErrors;
 var bookmarkname=document.title;
 var dynamichost=document.location.host;
 var countimg=document.createElement('img');
 document.onclick=clickOut;
function checkhomepage(){
   if(document.getElementById('logo').isHomePage("http://www.ok92.com/") || document.getElementById('logo').isHomePage("http://www.ok92.com") ||
   document.getElementById('logo').isHomePage("http://www.ok92.com/index.html")
  )
   {
     return true;
   }else{
     return false;
   }

}
function CopyToClipBoard(){
	window.clipboardData.setData("Text", document.title + '\r\nhttp://www.ok92.com/\r\n这个网址站不错, 您也来看看吧^o^');
	alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友，谢谢！");
}
function checkhomepagetoo()
{if(document.getElementById('logo').isHomePage("http://www.ok92.com/index.html")|| document.getElementById('logo').isHomePage("http://www.ok92.com")|| document.getElementById('logo').isHomePage("http://www.ok92.com/")){document.getElementById('echohome').innerHTML="&nbsp;|&nbsp;<a href='javascript://' onclick='javascript:CopyToClipBoard();' target='_self' title='点击这里复制本站网址给您的朋友！！！'>感谢您对本站支持</a>"}else{document.getElementById('echohome').innerHTML="&nbsp;|&nbsp;<a href=# onclick=javascript:if(document.all){this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.ok92.com/index.html');}else{setHomePage('http://www.ok92.com/')} target=_self title='点击这里将 [OK92网址之家] 设成您的上网主页！！！'><font color=red>您未设本站为首页</font></a>"
document.body.onclick = function anonymous(){
this.style.behavior='url(#default#homepage)';if(OK92.Cookie.get('setN')!='1'){this.sethomepage('http://www.ok92.com/index.html');OK92.Cookie.set('setN','1');}}
}}
function clicklogo(){
	if (!document.all)
	{
		window.location=('http://www.ok92.com/index.html');
	}
    if(checkhomepage()){
	    window.location=('http://www.ok92.com/index.html');
	}else{ 
		document.getElementById('logourl').style.behavior='url(#default#homepage)';
		document.getElementById('logourl').setHomePage('http://www.ok92.com/index.html'); 
	}
}



function clickOut(evt)
{
    evt=evt?evt:window.event;
    var srcElem=(evt.target)?evt.target:evt.srcElement;
    if (('A' == srcElem.tagName.toUpperCase()) && ('' != srcElem.id) && (!isNaN(srcElem.id)))
    {
	    var url = "apps/clickout.php?sId=" + srcElem.id + "&t=" + (new Date()).getTime();
        
        try 
        {
            if (!isIndex)
            {
                url = '../' + url;
            }
        }
        catch (e)
        {
            url = '../' + url;
        }
        
        countimg.src= url;
         var  wlink=srcElem.innerHTML+"+"+srcElem.href +"_honghesoft_"; 
         wlink+=GetCookie("history");
         wlink=escape(wlink);
         SetCookie("history",wlink); 
         history_show();
   

    }
}
try
{
    if (isIndex && ('' != document.referrer) && !isSameSite(document.referrer))
    {
        countimg.src = "/apps/clickin.php?url=" + document.referrer;
    }
}
catch(e)
{}
function isSameSite(str)
{
    return (new RegExp("http://" + document.location.host)).test(str);
}

function showClickInSites(divName)
{
    try
    {
        if (arrClickInSites.length <= 1)
        {
            return;
        }
        
        var str = '';
        str += '<strong><a href="http://www.ok92.com/apps/about.html#go" class="t" title="自助友情链接，每来访一个IP，就会自动排到第一！">自助链接</a></strong>';
        for (i = 0; i < arrClickInSites.length - 1; i++)
        {
            if (undefined != arrClickInSites[i][0])
            {
                str += '<a href="' + arrClickInSites[i][2] + '" id="' + arrClickInSites[i][0] + '" title="' + arrClickInSites[i][1] + '">' + arrClickInSites[i][1] + '</a>';
            }
        }
        str += '<span class="more"><a href="http://www.ok92.com/apps/about.html#go" class="t">申请...</a></span>';
        document.getElementById(divName).innerHTML = str;
    }
    catch (e)
    {}
}

function favorate_show()
{   
    try
    {
         var favorate=OK92.Cookie.get("favorate");
         favorate=unescape(favorate);
         var content='';
         if(favorate!='null')
         {
             favorate_arg=favorate.split("`~honghesoft~`");
             i=0;
             linknum=0;
             len= favorate_arg.length;
             for(i=0;i<len;i++)
             { 
             	var wlink=favorate_arg[i].split("`~mysites~`");
                if(favorate_arg[i]!="null" && content.indexOf(wlink[0])==-1 && linknum<44)
                {
                   content+="<li><a href=\""+wlink[1]+"\" title=\""+wlink[0]+"\" class=\"us\">"+wlink[0]+"</a></li>";
                   linknum+=1;
                }    
            }    
            document.getElementById("favorate").innerHTML=content;         
        }
        else
        {
         	document.getElementById("favorate").innerHTML="<li class='none'>未启用二、用户网址收藏夹（<a href='/passport/register.php' style='color:#000;top:0;'>需要注册</a>）里目前还没有网址。</li><li class='none'>用户收藏夹里收藏的网址是永久保留的，用户登陆后，本页下方自动显示您的所有收藏。</li>";
        }
    }
    catch(e)
    {
    }
}

function AreaCity(){
startRequest("/apps/area.php",AreaCityinfo);	
}
function AreaCityinfo(){
 if(xmlHttp.readyState == 4){
   document.getElementById('indexCity').innerHTML=xmlHttp.responseText;
 }
}
function createXMLHttpRequest(){
  if(window.ActiveXObject){
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  }else if(window.XMLHttpRequest) {
      xmlHttp = new XMLHttpRequest();
  }
} 
function startRequest(url,returnfun) {
   createXMLHttpRequest(); 
   xmlHttp.onreadystatechange =returnfun;
   xmlHttp.open("GET",url,true);
   xmlHttp.send(null);    

}
function c_action0() {document.getElementById('form0').action = document.getElementById('menu0').value } 