(function(){
    getSideHover();
	$("#sidemenu > li").click(function(){
	        $("#sidemenu > li").each(function(){$(this).removeClass("hover");});
			$(this).addClass("hover");
		})
	$("#mainMenu > li").each(function(i){
		$(this).addClass("nav"+i);
	})

	getNow();
	
	$("#mainMenu > li").hover(
		  function(){
		      $("#mainMenu > li").each(function(){
		            $(this).removeClass("hover");
		      })
			  $(this).addClass("hover");
			  //$(this).find("ul").show();
			  $(".importantNews").children().hide();
		   },
		  function(){$(this).removeClass("hover");}
	  )
	$("#mainMenu").mouseleave(function(){
	    getNow();
	})
	$.fn.picshow = function(o){
		var o = $.extend({
			 pause:5000,
			 fspd:100,
			 auto:true
		}, o||{});
		return this.each(function(){
			var $cont = $(".ps-cont > a", this), $title = $(".ps-title > h3", this), $nav = $(".ps-nav > a", this),
			len = $cont.length;
			var interval = null, index = 0, isOver = true;
			if(o.auto){$cont.hover(function(){clearInterval(interval);}, auto);}
			if(o.auto){
				$nav.each(function(i){
					$(this).hover(function(){
						clearInterval(interval);
						roll(i);
					}, auto);
				});
			}else{
				$nav.each(function(i){
					$(this).hover(function(){roll(i);});
				});
			}
			
			function auto(){
				clearInterval(interval);
				interval = setInterval(function(){ roll(index==(len-1) ? 0 : index+1);}, o.pause);
			}
			function roll(i){
				if(isOver){
					isOver = false;
					$cont.hide();
					$cont.eq(i).fadeIn(o.fspd, function(){ isOver = true; });
					$nav.removeClass("hover");
					$nav.eq(i).addClass("hover");
					$title.hide();
					$title.eq(i).show()
					index = i;
				}
			}
			//init
			$cont.eq(index).show();
			$nav.eq(index).addClass("hover");
			if(o.auto){auto();}
		});
	}
	$.fn.tabs = function(o){
		var o = $.extend({meth:"hover"}, o||{})
		return this.each(function(){
			var $menu = $(this).children(".tab-menu").children("li"), $cont = $(this).children(".tab-cont").children(".cont");
			$menu.each(function(i){
				if(o.meth == "click"){
					$(this).click(function(){ toggle(i) });				
				}else if(o.meth == "hover"){
					$(this).hover(function(){ toggle(i) });
				}
			});
			function toggle(i){
				$menu.removeClass("hover");
				$menu.eq(i).addClass("hover");
				$cont.removeClass("hover");
				$cont.eq(i).addClass("hover");
			}
		});
	}
})(jQuery);

    function getNow(){
	    var pathname = document.location.pathname;
	    var module="";
	    if(pathname!=""){
	        module = pathname.split('/')[1];
	    }
	    $("#mainMenu > li").each(function(i){
	        var nowpath = $(this).find("a").attr("href");
	        if(nowpath!=""){
	            if(module==nowpath.split('/')[1]){
	                $(this).addClass("now");
	                $(this).addClass("hover");
			        $(this).find("ul").show();
			        $(".importantNews").children().hide();
	            }
	        }
		   
	    })
    }
    function getSideHover(){
        var pathname = document.location.pathname;
        $("#sidemenu > li > ul > li").each(function(){
            var nowpath = $(this).find("a").attr("href");
	        if(nowpath==pathname){	            
                    $(this).parents("li").addClass("hover");
            }
        })
    }

