﻿(function () {
    if (window.Enuo == undefined)
        window.Enuo = {};

    window.Enuo.SetMainMenu = function (text) {
        $("#Menu .xmenubox_item h2 a").each(function () {
            var thist = $.trim($(this).text());
            if (thist == text)
                $(this).parent().parent().addClass("se");
        });
    }

    window.Enuo.ShowRecommend = function (stype, title, incontent, productUrl, img, username) {
        var pin = "";
        var url = "";
        var content = "我喜欢 @服装学习 ";
        if (username)
            content += "网友 @" + username + " ";
        content += "的这个分享:" + $.trim(incontent); // +" \r\n http://www.eforstudy.com";
        if (stype == "v.qq") {
            url = "http://v.t.qq.com/share/share.php?source=1000002&site=http://www.enuocms.com";
            url = url + "&title=" + content + "&pic=" + img + "&url=" + productUrl + pin;
        }
        if (stype == "sina") {
            url = "http://v.t.sina.com.cn/share/share.php?";
            url = url + "title=" + content + "&pic=" + img + "&url=" + productUrl + pin;
        }
        if (stype == "qzone") {
            url = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?";
            url = url + "title=" + content + "&pic=" + img + "&url=" + productUrl + pin;
        }
        if (stype == "renren") {
            url = "http://share.renren.com/share/buttonshare/post/1004?";
            url = url + "title=" + title + "&content=" + content + "&pic=" + img + "&url=" + productUrl + pin;
        }
        if (stype == "kaixing") {
            url = "http://www.kaixin001.com/repaste/share.php?";
            url = url + "rtitle=" + title + "&rcontent=" + content + "&rurl=" + productUrl + pin;
        }
        if (stype == "douban") {
            url = "http://www.douban.com/recommend/?";
            url = url + "title=" + title + "&comment=" + content + "&url=" + productUrl + pin;
        }
        if (stype == "MSN") {
            url = "http://profile.live.com/P.mvc#!/badge?";
            url = url + "url=" + productUrl + pin + "&title=" + title + "&description=" + content + "&screenshot=" + img;
        }

        if (url != "")
            window.open(encodeURI(url), "", "height=500, width=600");
    }

    $(function () {
        $("#btnAppSearch").click(function () {
            var classid = $("#setAppSearchClass").val();
            var key = $("#keyAppSearchKey").val();
            if (classid == "20083839837593") {
                window.location.href = "/Photo/Search?c=" + encodeURI(classid) + "&k=" + encodeURI(key);
            }
            else {
                window.location.href = "/Article/Search?c=" + encodeURI(classid) + "&k=" + encodeURI(key);
            }
        });

        $("select").sSelect();
    });
})();



//添加收藏
function fnAddFavorite(title, url) {
    if (document.all) {
        window.external.addFavorite(url, title);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(title, url, "");
    }
}

//添加首页
function fnSetHomepage(url) {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(url);

    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");
            }
        }
        if (!confirm("您确定设置" + url + "为首页吗？"))
            return;
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', url);
        alert("您已成功设置为" + url + "首页");
    }
}
