﻿    
 //折叠、目录树   
 //type值为"normal"时默认触发事件的对象为".toggle"
 //type值为"advance"时定义触发事件的对象为".clickhere" 
 //time:动画执行时间
 //multi:是否同时展开多个窗口,设值为"single"时只能显示当前折叠层
    function toggleEvent(ruleName,type,time,multi)   
    {
        var type=type;
        var time=Number(time);
        
        function display() 
        {
            if(multi!="" && multi=="single")
            {
                $(ruleName).find(".toggle").not(this).next().hide(time);
            }
            switch (type)
            {
              case "normal":
              $(this).next().toggle(time);
              break;
              
              case "advance":
              $(this).parents(".toggle").next().toggle(time);
              break;
            }
        }
        
            switch (type)
            {
              case "normal":
              $(ruleName).find(".toggle").click(display);
              break;
              
              case "advance":
              $(ruleName).find(".clickhere").click(display);
              break;
            }
               
        
        $(ruleName).find(".toggle").next().hide();
    }
    

 //表格隔行变色
    function changeLineColor(ruleName) 
    {
        $(ruleName).find("tr").not("tr:first").mouseover(
            function()
            {
                $(this).css("backgroundColor","#eee");
            }
        ); 
           
        $(ruleName).find("tr").not("tr:first").mouseout(
            function()
            {
                $(this).css("backgroundColor","#fff");
            }
        );    
        $(ruleName).find("tr").not("tr:first").css("backgroundColor","#fff");
    }
    
function openMenu()
{
    var currentUrl=document.location.href;
    var openObjName=currentUrl.split("siteName=")[1];
    var obj=$("input[subdomain="+openObjName+"]");
    if(openObjName)
    {
        $("input[subdomain="+openObjName+"]").parents(".toggle").next().show();
    }
    else 
    return false;
}




    
 //页面加载函数   
	$(document).ready(function() {
		 toggleEvent("#menu","normal","200");
		 toggleEvent("#topSortClass","normal","200");
		 toggleEvent("#ad_sideleft","normal","300","single");
		 toggleEvent("#mailBox","advance","0","single");
		 changeLineColor(".userlist");
	     openMenu();
	});
