﻿function addFav() {
    if (document.all) {
        window.external.addFavorite(location.href, document.title);
    }
    else if (window.sidebar) {
        window.sidebar.addPanel(document.title, location.href, "");
    }
}
function setHomepage() {
    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(location.href);
    }
    else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert(e);
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage', location.href);
    }
}
function downRelation(gid, brandid, brandenname) {
    var loadingImg = "<img src=\"/Images/loading.gif\" width=\"28\" height=\"28\" alt=\"Loading\" />";

    $("#modellist").html(loadingImg);

    $.post("/relation.html", {
        id: gid,
        bid: brandid,
        benname: brandenname
    }, function(data) {
        $("#modellist").html(data);
    });
}

function change(index) {
    if (typeof (isround) != 'undefined') clearTimeout(isround);

    var imgs = $("#imgs li");
    var tips = $("#tips dd");

    for (var i = 0; i < tips.length; i++) {
        $("#imgs li:eq(" + i + ")").hide();
        $("#tips dd:eq(" + i + ")").removeClass("curr");
    }
    $("#imgs li:eq(" + index + ")").show();
    $("#tips dd:eq(" + index + ")").addClass("curr");

    if ((next = index + 1) == $("#tips dd").length) next = 0;
    isround = setTimeout('change(' + next + ')', 3000);
}
$(document).ready(function() {
    change(0);
});
