﻿
function SetHome(obj, vrl) { try { obj.style.behavior = 'url(#default#homepage)';obj.setHomePage(vrl);} catch (e) {if (window.netscape) {try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");} catch (e) { alert("抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”，点击“加入收藏”后忽略安全提示，即可设置成功。");} var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage', vrl);}}}
function keyDown(e) { var ev = window.event || e; if (ev.keyCode == 13) { login('index_login'); } }
function copyUrl() { var content = ''; window.clipboardData.setData("Text", window.location.href); alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友"); }
function goTop() { $('html,body').animate({ scrollTop: '0px' }, 300); }
function IpMark(ipadd) { var arrip = ipadd.toString().split('.'); return arrip[0] + '.' + arrip[1] + ".*.*"; }
function keyDownSearch(e) { var ev = window.event || e; if (ev.keyCode == 13) { Search(); } }
function AddFavorite(sURL, sTitle) {
    try {

        window.external.addFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
function Search() {
    var s = $("#search-keywords").val();
    if (s == '请输入关键字...' || s == "") return;
    window.location.href = "/s/" + escape(s) + "/p-1";
 }
  /*
        message:要显示的消息
        x,y:显示消息框的坐标,默认为左上角
        delay:延迟多长时间消失，-1为永不消失，单位为毫秒
        */
function msgbox(message,delay, x, y) {
    if (!message) return;
    if (!x) x = 0;
    if (!y) y = 0;
    if (!delay) delay = 3000;
 
    //只允许百分数或数值参数
    x = /\d{1,2}%|100%|left|right/.test(x) ? x : (parseInt(x) || 0) + "px";
    y = /\d{1,2}%|100%|top|bottom/.test(y) ? y : (parseInt(y) || 0) + "px";

    var fdDiv = $('#show_feedBack_message')[0];

    if (!fdDiv) {
        var showMessage = $("<div id='show_feedBack_message' class='feedBack_message' style='z-index:10000;filter:alpha(opacity=100);position:absolute;white-space:nowrap;'></div>");
        $('body').append(showMessage);
        fdDiv = $('#show_feedBack_message')[0];
    }
    $(fdDiv).html(message);

    var docWidth = document.documentElement.scrollWidth > document.documentElement.clientWidth ? document.documentElement.scrollWidth : document.documentElement.clientWidth;
    var docHeight = document.documentElement.scrollHeight > document.documentElement.clientHeight ? document.documentElement.scrollHeight : document.documentElement.clientHeight;
    var popupHeight = $(fdDiv).height();
    var popupWidth = $(fdDiv).width();
    if (x == "0px") {
        
        var bodyScrollSize=getBodyScrollSize();
	    var bodySize=getBodySize();
	    var left=bodyScrollSize.left;
	    var top=bodyScrollSize.top;
        top=(bodySize.height-popupHeight)/2 + top;
		left=(bodySize.width-popupWidth)/2;
      
        $(fdDiv).css({
        "position": "absolute",
            "top": top,
            "left":left
        });  
    }
    else {
        if (/left|right/.test(x)) {
            x = (x == "left") ? "0px" : (docWidth - fdDiv.offsetWidth) + "px";
        }
        if (/top|bottom/.test(y)) {
            y = (y == "top") ? "0px" : (docHeight - fdDiv.offsetHeight) + "px";
        }
        fdDiv.style.left = x;
        fdDiv.style.top = y;
    }
        
   
    $(fdDiv).show();
    if (delay < 0) return;
    $(fdDiv).fadeOut(delay);
}
var getBodySize = function() {
    var bodyCW, bodyCH;
    if (window.innerWidth)
        bodyCW = window.innerWidth;
    else if (document.documentElement && document.documentElement.clientWidth)
        bodyCW = document.documentElement.clientWidth;
    else if (document.body)
        bodyCW = document.body.clientWidth; //author: meizz 

    if (window.innerHeight)
        bodyCH = window.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight)
        bodyCH = document.documentElement.clientHeight;
    else if (document.body)
        bodyCH = document.body.clientHeight;

    return { "width": bodyCW, "height": bodyCH };
}
getBodyScrollSize=function()
{
	var bodySL, bodyST, bodySW, bodySH; 
	if(window.pageXOffset) 
	{
		bodySL=window.pageXOffset; 
		bodySW=window.innerWidth; 
		bodyST=window.pageYOffset; 
		bodySH=window.innerHeight; 
	}
	else if(document.documentElement) 
	{	
		bodySL=document.documentElement.scrollLeft; 
		bodySW=document.documentElement.scrollWidth; //-10
		bodyST=document.documentElement.scrollTop; 
		bodySH=document.documentElement.clientHeight>document.documentElement.scrollHeight?document.documentElement.clientHeight:document.documentElement.scrollHeight;
	}
	else if(document.body) 
	{
		bodySL=document.body.scrollLeft; 
		bodySW=document.body.scrollWidth; 
		bodyST=document.body.scrollTop; 
		bodySH=document.body.clientHeight>document.body.scrollHeight?document.body.clientHeight:document.body.scrollHeight;
	}

	return {"top":bodyST,"left":bodySL,"width":bodySW,"height":bodySH};
}
function newGuid() {
    var guid = "";
    for (var i = 1; i <= 32; i++) {
        var n = Math.floor(Math.random() * 16.0).toString(16);
        guid += n;
        if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
            guid += "-";
    }
    return guid;
}


