﻿/*!
* Phoenix.Tags
* 功能说明：常用的Tags
* 作者：李金安
* 版本：1.0
*/
(function ($) {
    $.fn.Tags = function (opts) {
        var defaults = {
            on: "cont-tit-center01",  // 激活的样式
            off: "", // 默认的样式
            def: 0  //第一次加载时显示哪一个标签
        }
        var ps = $.extend({}, defaults, opts);
        var cur_taget_id = null;
        var cur_tag_obj = null;
        if (this.length > 0) {
            var defObj = this.eq(ps.def);
            defObj.removeClass(ps.off);
            defObj.addClass(ps.on);
            cur_taget_id = $(this).attr("rel");
            cur_tag_obj = this;
            if (cur_taget_id) $(cur_taget_id).show();
        }
        return this.each(function () {
            var me = this;
            $(me).bind('mouseover', { e: me }, function (s) {
                var e = s || window.event;
                var tar = e.relatedTarget || e.toElement;
                if (cur_taget_id != null) {
                    $(cur_taget_id).hide();
                    $(cur_tag_obj).find("a").removeClass(ps.on);
                    $(cur_tag_obj).find("a").addClass(ps.off);
                }
                cur_taget_id = $(this).attr("rel");
                cur_tag_obj = this;
                $(cur_taget_id).show();
                $(this).removeClass(ps.off);
                $(this).addClass(ps.on);
            });
        });
    };
})(jQuery);
