jQuery.fn.extend({
    TrunAd: function (options) {
        var auto = null;
        var obj = jQuery(this);
        counta = jQuery("a", obj).size();
        if (p_num == null || p_num == "") {
            var na = 0;
        } else {
            var na = p_num;
        }
        var settings = { timer: 6000, menu: "#play_text" };
        options = options || {};
        jQuery.extend(settings, options);

        jQuery("a", this).hide();
        jQuery(this).children("a").eq(na).show()
        jQuery(settings.menu + " li").eq(na).css({ "background": "#BA2451", "color": "#FFF", "border": "1px solid #FFF", "margin-top": "0" });

        jQuery(settings.menu + " li").mouseover(function () {
            ia = jQuery(this).attr("value") - 1;
            na = ia;
            //alert(na);
            if (na >= counta) return;
            jQuery("a", obj).filter(":visible").fadeOut(200, function () { jQuery(this).parent().children().eq(na).fadeIn(300); });
            jQuery(this).css({ "background": "#BA2451", "color": "#FFF", "border": "1px solid #FFF", "margin-top": "0" }).siblings().css({ "background": "#d1d1d1", "color": "#010000", "border": "0", "margin-top": "1px" });
            clearInterval(auto);
        }).mouseout(function () {
            //auto = setInterval(showAuto, settings.timer);
        });

        auto = setInterval(showAuto, settings.timer);
        obj.hover(function () { clearInterval(auto) }, function () { auto = setInterval(showAuto, settings.timer); }); //·Åµ½´óÍ¼Í£Ö¹ÇÐ»»
        function showAuto() {
            na = na >= (counta - 1) ? 0 : ++na;
            if (na >= counta) return;
            jQuery("a", obj).filter(":visible").fadeOut(200, function () { jQuery(this).parent().children().eq(na).fadeIn(300); });
            jQuery(settings.menu + " li").eq(na).css({ "background": "#BA2451", "color": "#FFF", "border": "1px solid #FFF", "margin-top": "0" }).siblings().css({ "background": "#d1d1d1", "color": "#010000", "border": "0", "margin-top": "1px" });
        }
    }
});

