﻿function Swf(url, w, h, o) {
    var swf = [];
    var parm = [];
    var attr = [];
    o = jQuery.extend({ allowScriptAccess: "sameDomain", quality: "high", menu: false }, o);
    swf.push('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + w + '" height="' + h + '">');
    swf.push('<param name="movie" value="' + url + '">');
    $.each(o, function (i, e) {
        parm.push("<param name=\"" + i + "\" value=\"" + e + "\">");
        attr.push(i + "=\"" + e + "\"");
    });
    swf.push(parm.join(""));
    swf.push("<embed ");
    swf.push(attr.join(" "));
    swf.push(' src="' + url + '" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + w + '" height="' + h + '"></embed>');
    swf.push('</object>');
    document.write(swf.join(""));
}

function FocusFlash(s, w, h) {
    Swf("/Images/FocusSkinA.swf?xml=" + s, w, h, { wmode: "transparent"});
}

$(function () {
    $("#setHomePage").click(setHomepage);
    $("#addFav").click(addFavorites);
});

$(function () {
    var o = "#Banner img";
    if ($(o).length < 2) {
        return;
    }
    setInterval(function () {
        var next = $(o + ":visible").hide().next();
        if (next.length == 0) {
            next = $(o + ":first");
        }
        next.fadeIn("slow");
    }, 4000);
});

$(function () {
    $("#btnGoSearch").click(function () {
        var t = $("#txtKey");
        if (t.val() == "") {
            alert("请输入要搜索的关键字！");
            return;
        }
        location.href = "/Zh/Media.aspx?Key=" + escape(t.val());
    });
    $("#txtKey").blur(function () {
        if ($(this).val() == "")
            return;
        $("#btnGoSearch").click();
    });
});

function addFavorites() {
    if (document.all) {
        window.external.addFavorite(document.URL + '', document.title + '');
    }
    else if (window.sidebar) {
        window.sidebar.addPanel('' + document.title, document.URL + '', '');
    }
    return false;
}
function setHomepage() {
    var url = document.URL.substring(0, document.URL.indexOf("/", 8));
    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");
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref("browser.startup.homepage", url);
    }
    return false;
}
