﻿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 () {
    $("#TopMenu img").each(function (i, e) {
        var src = $(e).attr("src").replace("/Menu_", "/Over_");
        $("<img />").attr("src", src);
    });
    $("#TopMenu li").hover(function () {
        $("> ul", this).show().find("li").css("opacity",0).fadeTo("slow",0.4);
        if ($(this).hasClass("current")) {
            return;
        }
        var img = $(" > a img", this);
        img.attr("src", img.attr("src").replace("/Menu_", "/Over_"));
    }, function () {
        $("> ul", this).find("li").fadeOut("slow");
        if ($(this).hasClass("current")) {
            return;
        }
        var img = $(" > a img", this);
        img.attr("src", img.attr("src").replace("/Over_", "/Menu_"));
    });
});

$(function () {
    if ($("#SubMenu").length == 0) {
        return;
    }
    $("#SubMenu a img").each(function (i, e) {
        var src = $(e).attr("src").replace("/Menu_", "/Over_");
        $("<img />").attr("src", src);
    });
    $("#SubMenu a").hover(function () {
        var img = $("img", this);
        img.attr("src", img.attr("src").replace("/Menu_", "/Over_"));
    }, function () {
        var img = $("img", this);
        img.attr("src", img.attr("src").replace("/Over_", "/Menu_"));
    });
});

$(function () {
    SlidePhoto("#PageContent .iBanner img");
    SlidePhoto("#NewsPic img");
    if ($("#proList img").length > 0) {
        if ($("#proList .current").length > 0) {
            return;
        }
        $("#proList img:first").addClass("current");
    }
});


function SlidePhoto(o) {
    if ($(o).length < 2) {
        return;
    }
    setInterval(function () {
        var next = $(o + ":visible").hide().next();
        if (next.length == 0) {
            next = $(o + ":first");
        }
        next.fadeIn(1000);
    }, 4000);
}

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;
}
