﻿$(function(){
    // 左导航菜单所定义全局变量
    that = null;
    key_id = $("#p_id").html();
    
    xh = "/mximg_new/game/xh.gif";
    jh = "/mximg_new/game/jh.gif";
    
    $("#pane").find("div").each(function(i){
        if (!($(this).attr('id') == 'slideUl_'+key_id))
        { 
            $(this).animate({opacity:"toggle"},'fast');
        } else {
            that = $(this).prev();
            if ($("img",that).attr("src").search(jh) !== -1)
            {
                $("img",that).attr("src",xh);
            }
        }
    }); 

    $.fn.extend({
        slideUl : function(keyid)
        {
            if (that != null && key_id != keyid)
            {
                if ($("img",that).attr("src") == xh)
                {
                    $("img",that).attr("src",jh);
                }
                $(that).next().slideUp('fast');
            } 

            $(this).next().animate({opacity:"toggle"},300);
            //$(this).toggle(function(){$("img",this).attr("src",xh);},function(){$("img",this).attr("src",jh);});
            
            if ($("img",this).attr("src").search(jh) == -1)
            {
                $("img",this).attr("src",jh);
            } else {
                $("img",this).attr("src",xh);
            }
            
            that = this;
            key_id = keyid;
            return false;
        }
    });
});